aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/pgssubdec.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/pgssubdec.c
parent1c3c29d07d7e0b7f5bec13cb0214f90e26604aee (diff)
downloadffmpeg-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/pgssubdec.c')
-rw-r--r--libavcodec/pgssubdec.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c
index 4cd5e237f2..8b5eb5f816 100644
--- a/libavcodec/pgssubdec.c
+++ b/libavcodec/pgssubdec.c
@@ -494,10 +494,9 @@ static int parse_presentation_segment(AVCodecContext *avctx,
* @param buf pointer to the packet to process
* @param buf_size size of packet to process
*/
-static int display_end_segment(AVCodecContext *avctx, void *data,
+static int display_end_segment(AVCodecContext *avctx, AVSubtitle *sub,
const uint8_t *buf, int buf_size)
{
- AVSubtitle *sub = data;
PGSSubContext *ctx = avctx->priv_data;
int64_t pts;
PGSSubPalette *palette;
@@ -590,8 +589,8 @@ static int display_end_segment(AVCodecContext *avctx, void *data,
return 1;
}
-static int decode(AVCodecContext *avctx, void *data, int *got_sub_ptr,
- AVPacket *avpkt)
+static int decode(AVCodecContext *avctx, AVSubtitle *sub,
+ int *got_sub_ptr, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
@@ -639,7 +638,7 @@ static int decode(AVCodecContext *avctx, void *data, int *got_sub_ptr,
ret = parse_object_segment(avctx, buf, segment_length);
break;
case PRESENTATION_SEGMENT:
- ret = parse_presentation_segment(avctx, buf, segment_length, ((AVSubtitle*)(data))->pts);
+ ret = parse_presentation_segment(avctx, buf, segment_length, sub->pts);
break;
case WINDOW_SEGMENT:
/*
@@ -657,7 +656,7 @@ static int decode(AVCodecContext *avctx, void *data, int *got_sub_ptr,
ret = AVERROR_INVALIDDATA;
break;
}
- ret = display_end_segment(avctx, data, buf, segment_length);
+ ret = display_end_segment(avctx, sub, buf, segment_length);
if (ret >= 0)
*got_sub_ptr = ret;
break;
@@ -699,7 +698,7 @@ const FFCodec ff_pgssub_decoder = {
.priv_data_size = sizeof(PGSSubContext),
.init = init_decoder,
.close = close_decoder,
- .decode = decode,
+ .decode_sub = decode,
.p.priv_class = &pgsdec_class,
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
};