From fb59a42ef977dd91085a602f10c9c82f88d072e5 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Wed, 30 Mar 2022 19:52:41 +0200 Subject: avcodec/codec_internal: Add FFCodec.decode_sub This increases type-safety by avoiding conversions from/through void*. It also avoids the boilerplate "AVSubtitle *sub = data;" line for subtitle decoders. Its only downside is that it increases sizeof(FFCodec), yet this can be more than offset lateron. Signed-off-by: Andreas Rheinhardt --- libavcodec/textdec.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'libavcodec/textdec.c') diff --git a/libavcodec/textdec.c b/libavcodec/textdec.c index 95450a18f7..48e7e14602 100644 --- a/libavcodec/textdec.c +++ b/libavcodec/textdec.c @@ -45,12 +45,11 @@ static const AVOption options[] = { { NULL } }; -static int text_decode_frame(AVCodecContext *avctx, void *data, +static int text_decode_frame(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt) { int ret = 0; AVBPrint buf; - AVSubtitle *sub = data; const char *ptr = avpkt->data; TextContext *text = avctx->priv_data; @@ -87,7 +86,7 @@ const FFCodec ff_text_decoder = { .priv_data_size = sizeof(TextContext), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_TEXT, - .decode = text_decode_frame, + .decode_sub = text_decode_frame, .init = ff_ass_subtitle_header_default, .p.priv_class = &textsub_decoder_class, .flush = text_flush, @@ -111,7 +110,7 @@ const FFCodec ff_vplayer_decoder = { .priv_data_size = sizeof(TextContext), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_VPLAYER, - .decode = text_decode_frame, + .decode_sub = text_decode_frame, .init = linebreak_init, .p.priv_class = &textsub_decoder_class, .flush = text_flush, @@ -126,7 +125,7 @@ const FFCodec ff_stl_decoder = { .priv_data_size = sizeof(TextContext), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_STL, - .decode = text_decode_frame, + .decode_sub = text_decode_frame, .init = linebreak_init, .p.priv_class = &textsub_decoder_class, .flush = text_flush, @@ -141,7 +140,7 @@ const FFCodec ff_pjs_decoder = { .priv_data_size = sizeof(TextContext), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_PJS, - .decode = text_decode_frame, + .decode_sub = text_decode_frame, .init = linebreak_init, .p.priv_class = &textsub_decoder_class, .flush = text_flush, @@ -156,7 +155,7 @@ const FFCodec ff_subviewer1_decoder = { .priv_data_size = sizeof(TextContext), .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_SUBVIEWER1, - .decode = text_decode_frame, + .decode_sub = text_decode_frame, .init = linebreak_init, .p.priv_class = &textsub_decoder_class, .flush = text_flush, -- cgit v1.2.3