[FFmpeg-cvslog] avcodec/ttmlenc: split header writing into its own function
Jan Ekström
git at videolan.org
Mon Apr 26 16:45:29 EEST 2021
ffmpeg | branch: master | Jan Ekström <jan.ekstrom at 24i.com> | Mon Mar 15 12:41:18 2021 +0200| [b71184faefce38c8a965c7d0e8552e049ae9e150] | committer: Jan Ekström
avcodec/ttmlenc: split header writing into its own function
Signed-off-by: Jan Ekström <jan.ekstrom at 24i.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b71184faefce38c8a965c7d0e8552e049ae9e150
---
libavcodec/ttmlenc.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/libavcodec/ttmlenc.c b/libavcodec/ttmlenc.c
index 3972b4368c..e3c155fdd1 100644
--- a/libavcodec/ttmlenc.c
+++ b/libavcodec/ttmlenc.c
@@ -173,16 +173,8 @@ static av_cold int ttml_encode_close(AVCodecContext *avctx)
return 0;
}
-static av_cold int ttml_encode_init(AVCodecContext *avctx)
+static int ttml_write_header_content(AVCodecContext *avctx)
{
- TTMLContext *s = avctx->priv_data;
-
- s->avctx = avctx;
-
- if (!(s->ass_ctx = ff_ass_split(avctx->subtitle_header))) {
- return AVERROR_INVALIDDATA;
- }
-
if (!(avctx->extradata = av_mallocz(TTMLENC_EXTRADATA_SIGNATURE_SIZE +
1 + AV_INPUT_BUFFER_PADDING_SIZE))) {
return AVERROR(ENOMEM);
@@ -192,8 +184,25 @@ static av_cold int ttml_encode_init(AVCodecContext *avctx)
memcpy(avctx->extradata, TTMLENC_EXTRADATA_SIGNATURE,
TTMLENC_EXTRADATA_SIGNATURE_SIZE);
+ return 0;
+}
+
+static av_cold int ttml_encode_init(AVCodecContext *avctx)
+{
+ TTMLContext *s = avctx->priv_data;
+ int ret = AVERROR_BUG;
+ s->avctx = avctx;
+
av_bprint_init(&s->buffer, 0, AV_BPRINT_SIZE_UNLIMITED);
+ if (!(s->ass_ctx = ff_ass_split(avctx->subtitle_header))) {
+ return AVERROR_INVALIDDATA;
+ }
+
+ if ((ret = ttml_write_header_content(avctx)) < 0) {
+ return ret;
+ }
+
return 0;
}
More information about the ffmpeg-cvslog
mailing list