summaryrefslogtreecommitdiff
path: root/libavcodec/textdec.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-03-30 19:52:41 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-04-05 19:53:27 +0200
commitfb59a42ef977dd91085a602f10c9c82f88d072e5 (patch)
treee65c7b1e66eb0b07dbe51124e88fb3b918129b6f /libavcodec/textdec.c
parent1c3c29d07d7e0b7f5bec13cb0214f90e26604aee (diff)
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 <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavcodec/textdec.c')
-rw-r--r--libavcodec/textdec.c13
1 files changed, 6 insertions, 7 deletions
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,