diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-03-30 19:52:41 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-04-05 19:53:27 +0200 |
commit | fb59a42ef977dd91085a602f10c9c82f88d072e5 (patch) | |
tree | e65c7b1e66eb0b07dbe51124e88fb3b918129b6f /libavcodec/assdec.c | |
parent | 1c3c29d07d7e0b7f5bec13cb0214f90e26604aee (diff) | |
download | ffmpeg-fb59a42ef977dd91085a602f10c9c82f88d072e5.tar.gz |
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/assdec.c')
-rw-r--r-- | libavcodec/assdec.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/libavcodec/assdec.c b/libavcodec/assdec.c index 86d3e3e5a8..bf1260a947 100644 --- a/libavcodec/assdec.c +++ b/libavcodec/assdec.c @@ -40,11 +40,9 @@ static av_cold int ass_decode_init(AVCodecContext *avctx) return 0; } -static int ass_decode_frame(AVCodecContext *avctx, void *data, int *got_sub_ptr, - AVPacket *avpkt) +static int ass_decode_frame(AVCodecContext *avctx, AVSubtitle *sub, + int *got_sub_ptr, AVPacket *avpkt) { - AVSubtitle *sub = data; - if (avpkt->size <= 0) return avpkt->size; @@ -70,7 +68,7 @@ const FFCodec ff_ssa_decoder = { .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_ASS, .init = ass_decode_init, - .decode = ass_decode_frame, + .decode_sub = ass_decode_frame, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, }; #endif @@ -82,7 +80,7 @@ const FFCodec ff_ass_decoder = { .p.type = AVMEDIA_TYPE_SUBTITLE, .p.id = AV_CODEC_ID_ASS, .init = ass_decode_init, - .decode = ass_decode_frame, + .decode_sub = ass_decode_frame, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, }; #endif |