[FFmpeg-devel] [PATCH 08/12] Added standard headers
Traian Coza
traian.coza at gmail.com
Tue May 3 19:13:24 EEST 2022
---
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
More information about the ffmpeg-devel
mailing list