From patchwork Tue May 3 16:13:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Traian Coza X-Patchwork-Id: 35569 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:a885:b0:7f:4be2:bd17 with SMTP id ca5csp496450pzb; Tue, 3 May 2022 09:14:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwODh6R5Pb4ZVEBktYLQdLi5xN/pGAN0BZ2A+2slmqV2ZO2jxnkU9Va7HG04ek9g7qnrfd4 X-Received: by 2002:a17:907:7282:b0:6ef:f412:f7c4 with SMTP id dt2-20020a170907728200b006eff412f7c4mr16123359ejc.258.1651594473604; Tue, 03 May 2022 09:14:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651594473; cv=none; d=google.com; s=arc-20160816; b=PG40acRK/hO/62coAj9tztJMkA18BF6v6gyph+C2A3pC4cgIQoi+Ai3k2NFFDMUxpL 1vaHNdoMs9U1IgTK4ldDmZ7D7BaLhQpUQg2mMuXe0OiZTR0Ir/CH0x+PHjSC37yrX4n9 29MUUAw0T6rd0cKRAiDqapcq1EGf5drnt+Kloo5pMiB+dEiZVhqt3/Jd77R6LgburMna XF/LQh3EAWN2YQcPfb5RJ52OKIKQT54cLmAqg8z/LZUgUuDusTSDh3KF7d3+Yvhn4PDR 9Spw6dcy/CXaQzDWf5s4oSuykWldxo7JrXCiu9wskmgDYMLwIMAVkrP8BidpOPadP4Tv K+sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=9XmzVQplqNppWbt/n7+1dq3mCuVc8PX+IDWYOtSg3wg=; b=Ae+Y5oFH6FtJY82oHAFBxGg9JwGhchEo9ylAzm9gVvCW2QsiEHMeFY5qkAhru6pzXQ WBrH9NTJ3D5nqNOa4jkea4icNIPRS5Bpv2S8xKErlO1wFN+e8sGgbo+0JHz33kuNMjfa aPluX6/plEcpVbCJqZsz+CYgExDdK9LJm4etp5dA/aS3vh5M2XH6oAqawwJfsSbfcDLK FAoiqskEdbXGGps/SBenrB0f6XkJEyvDAFKR0h9TlkX1bHF+vLWt2AmzkMfgJhJ0N6+h X1QcgVs8nhyCJxNL+17gmnB8SHJjIMnS6G9Zm0J0sgHELpwTON9QZ33ZpjqUZ51CSd4T 829w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=iRx3MXaD; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id cw27-20020a056402229b00b00423fb5cb330si11910308edb.187.2022.05.03.09.14.33; Tue, 03 May 2022 09:14:33 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=iRx3MXaD; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 49F6F68B3AD; Tue, 3 May 2022 19:14:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 10E3568B37A for ; Tue, 3 May 2022 19:13:57 +0300 (EEST) Received: by mail-qt1-f173.google.com with SMTP id hf18so13891275qtb.0 for ; Tue, 03 May 2022 09:13:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6fHKcLGUJ923gfkioUAXu+P5r3PLkV2chh8tb8r2CAo=; b=iRx3MXaDzzsnha3dYW8MKfCY9kZRtKRdKBVNp3M1sdY2r2wEC/IZNGXZth3M0Rpa+X TxRBCE+Vtbjxx31o5+fjsL6Y6ln+jvnK1q79YDrkIhqsTAc5K/PumBj7KJAIKBH6U571 vWSqcjoutZLpPz2sWXjj3iFIKjP1H+tdA/9po0Xr6CyEH7qWOLugwABG0oiLEesUlSMV Qj5Oy+xutNJuv26fC4KFU8Dc0N9O6bo7zV0b6fy5v4RO4lUwceDiIO+FCscufgix462b n+Qv4/5Gzn1CRwMZQwq4l53othHlOvV23+RTMjdiKsEM+jSHdq6WF7FJFmqTuJeokJoe 9P5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6fHKcLGUJ923gfkioUAXu+P5r3PLkV2chh8tb8r2CAo=; b=CrQQq7v3lp5twUjy4RPwghEwlG3jWtqEJl2hJmgSaL9yCxCWcbzNGS66CqhevGUA1V sTK9DMF4VeZX4cMeVKRhJAd61OgKL+8+gehQjeW4CwoRpgkf5icwCzLTsU8xWsYn608j dstVbqtXA7lmL3rHoQ1t9c5b3NZc9QzoYKVGXL2lBmVPj5pYw9SB4TX+tnHbvhWehL0W VYIoiTAxpqXEycqvJDXTo7A3ub/ScojCKeDp64b0a0rEmAbW/lo3aaaxM8WhvbjhrUo4 G0lPk7FzudjF6HQYfPjuDPdPEF4rrSz2YoruHb44a5XcpUbeevpWWgu6UxPP7BwDH3Gb x4TA== X-Gm-Message-State: AOAM531C3TQ3C0XRjRM85jQKyLE2muBCXZbXEz66Zn5R4gYMdWP9n+fg 8uOBYSwnsmHi4/NFCHn86mJkzENKJAvt X-Received: by 2002:a05:622a:44d:b0:2f3:b4ea:1bb6 with SMTP id o13-20020a05622a044d00b002f3b4ea1bb6mr323208qtx.480.1651594436383; Tue, 03 May 2022 09:13:56 -0700 (PDT) Received: from thinkpad.. ([66.220.203.136]) by smtp.gmail.com with ESMTPSA id fp35-20020a05622a50a300b002f39b99f67asm5812731qtb.20.2022.05.03.09.13.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 May 2022 09:13:55 -0700 (PDT) From: Traian Coza To: ffmpeg-devel@ffmpeg.org Date: Tue, 3 May 2022 12:13:24 -0400 Message-Id: <20220503161328.842587-9-traian.coza@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220503161328.842587-1-traian.coza@gmail.com> References: <20220503161328.842587-1-traian.coza@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/12] Added standard headers X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Traian Coza Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: g+FhxV/dQPcF --- libavcodec/text_to_bitmap.c | 47 ++++++++++++++++++++++++++++++++++++- libavcodec/text_to_bitmap.h | 25 +++++++++++++++++--- 2 files changed, 68 insertions(+), 4 deletions(-) diff --git a/libavcodec/text_to_bitmap.c b/libavcodec/text_to_bitmap.c index c419e89c20..52d161d7b1 100644 --- a/libavcodec/text_to_bitmap.c +++ b/libavcodec/text_to_bitmap.c @@ -1,4 +1,23 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + /** + * @file * text to bitmap support code. * * This file contains a function to initiate the functionality for a stream, @@ -11,6 +30,9 @@ #include "avcodec.h" #include "ass_split.h" +/** + * Holds the objects used by the rendering function so they don't have to be reinitialized every time + */ struct ASS_Context { ASS_Library *library; ASS_Renderer *renderer; @@ -18,6 +40,17 @@ struct ASS_Context { ASSSplitContext *ass_split_context; }; +/** + * Initiates the ASS_Context structure and adds it to the input stream decoder context. + * Does nothing if ist->dec_ctx->ass_context is already set. + * It needs all these arguments because it searches for a frame size in all the streams + * @param input_streams + * @param output_streams + * @param nb_input_streams + * @param nb_output_streams + * @param ist_i index of input stream for transcoding + * @param ost_i index of output stream for transcoding + */ void init_ass_context( InputStream **input_streams, OutputStream **output_streams, @@ -82,12 +115,17 @@ void init_ass_context( ass_set_shaper(context->renderer, 0); ass_set_fonts(context->renderer, NULL, NULL, 1, NULL, 1); - context->track = ass_read_memory(context->library, (char *)ist->dec_ctx->subtitle_header, ist->dec_ctx->subtitle_header_size, NULL); + context->track = ass_read_memory(context->library, + (char *)ist->dec_ctx->subtitle_header, ist->dec_ctx->subtitle_header_size, NULL); context->ass_split_context = ff_ass_split((char *)ist->dec_ctx->subtitle_header); ist->dec_ctx->ass_context = context; } +/** + * Frees what was allocated in init_ass_context + * @param context + */ void free_ass_context(ASS_Context *context) { ass_library_done(context->library); ass_renderer_done(context->renderer); @@ -104,6 +142,11 @@ void free_ass_context(ASS_Context *context) { #define ALPHA_THRESHOLD 0b10000000 +/** + * Renders the AVSubtitle and sets the bitmap data for each AVSubtitleRect + * @param context + * @param sub + */ void render_avsub_ass(ASS_Context *context, AVSubtitle *sub) { for (int r = 0; r < sub->num_rects; r++) @@ -180,6 +223,7 @@ void render_avsub_ass(ASS_Context *context, AVSubtitle *sub) } } +/* static void print_ass_image(const ASS_Image *image) { int index = 0; @@ -234,3 +278,4 @@ static void print_subtitle(AVSubtitle sub) } printf("\n"); } +*/ \ No newline at end of file diff --git a/libavcodec/text_to_bitmap.h b/libavcodec/text_to_bitmap.h index 0c4689b039..29037150c2 100644 --- a/libavcodec/text_to_bitmap.h +++ b/libavcodec/text_to_bitmap.h @@ -1,9 +1,28 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + /** + * @file * text_to_bitmap header file */ -#ifndef FFMPEG_TEXT_TO_BITMAP_H -#define FFMPEG_TEXT_TO_BITMAP_H +#ifndef AVCODEC_TEXT_TO_BITMAP_H +#define AVCODEC_TEXT_TO_BITMAP_H #include #include "fftools/ffmpeg.h" @@ -21,4 +40,4 @@ void init_ass_context( void render_avsub_ass(ASS_Context *, AVSubtitle *); void free_ass_context(ASS_Context *context); -#endif //FFMPEG_TEXT_TO_BITMAP_H +#endif //AVCODEC_TEXT_TO_BITMAP_H