From: Traian Coza <traian.coza@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: Traian Coza <traian.coza@gmail.com> Subject: [FFmpeg-devel] [PATCH 08/12] Added standard headers Date: Tue, 3 May 2022 12:13:24 -0400 Message-ID: <20220503161328.842587-9-traian.coza@gmail.com> (raw) In-Reply-To: <20220503161328.842587-1-traian.coza@gmail.com> --- 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 <ass/ass.h> #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 -- 2.34.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-05-03 16:14 UTC|newest] Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-05-03 16:13 [FFmpeg-devel] [PATCH 00/12] I added text to bitmap subtitle conversion functionality! Traian Coza 2022-05-03 16:13 ` [FFmpeg-devel] [PATCH 01/12] Implemented text to bitmap subtitles! Traian Coza 2022-05-03 16:13 ` [FFmpeg-devel] [PATCH 02/12] Render only when necessary Traian Coza 2022-05-03 16:13 ` [FFmpeg-devel] [PATCH 03/12] Retreive width and height from video stream! Traian Coza 2022-05-03 16:13 ` [FFmpeg-devel] [PATCH 04/12] Initialize ass library only once! Traian Coza 2022-05-03 16:13 ` [FFmpeg-devel] [PATCH 05/12] Cleaned up Traian Coza 2022-05-03 16:13 ` [FFmpeg-devel] [PATCH 06/12] Wrote proper headers Traian Coza 2022-05-03 16:13 ` [FFmpeg-devel] [PATCH 07/12] Close libass after using Traian Coza 2022-05-03 16:13 ` Traian Coza [this message] 2022-05-03 16:13 ` [FFmpeg-devel] [PATCH 09/12] Rearranged files, all tests are passing! Traian Coza 2022-05-03 16:13 ` [FFmpeg-devel] [PATCH 10/12] " Traian Coza 2022-05-03 16:13 ` [FFmpeg-devel] [PATCH 11/12] Added logging Traian Coza 2022-05-03 16:13 ` [FFmpeg-devel] [PATCH 12/12] Added more logging Traian Coza 2022-05-03 16:20 ` [FFmpeg-devel] [PATCH 00/12] I added text to bitmap subtitle conversion functionality! Paul B Mahol 2022-05-03 16:51 ` Nicolas George 2022-05-03 17:01 ` Traian Coza 2022-05-03 17:05 ` Leo Izen 2022-05-03 17:09 ` Traian Coza 2022-05-03 16:27 ` Soft Works 2022-05-04 0:16 ` Soft Works
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220503161328.842587-9-traian.coza@gmail.com \ --to=traian.coza@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git