From b83dae62884a79b4e673edaeac86923fb9700701 Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Sun, 15 Dec 2019 11:58:52 -0800 Subject: [PATCH] dvdsubdec: use pts of initial packet When the source is DVD, only the initial packet of a subtitle that spans multiple packets will have a pts value. --- libavcodec/dvdsubdec.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c index 9220285877..49007383c3 100644 --- a/libavcodec/dvdsubdec.c +++ b/libavcodec/dvdsubdec.c @@ -43,6 +43,7 @@ typedef struct DVDSubContext int buf_size; int forced_subs_only; uint8_t used_color[256]; + int64_t pts; #ifdef DEBUG int sub_id; #endif @@ -577,10 +578,13 @@ static int dvdsub_decode(AVCodecContext *avctx, int appended = 0; int is_menu; + if (ctx->pts == AV_NOPTS_VALUE && sub->pts != AV_NOPTS_VALUE) + ctx->pts = sub->pts; if (ctx->buf_size) { int ret = append_to_cached_buf(avctx, buf, buf_size); if (ret < 0) { *data_size = 0; + ctx->pts = AV_NOPTS_VALUE; return ret; } buf = ctx->buf; @@ -593,6 +597,7 @@ static int dvdsub_decode(AVCodecContext *avctx, *data_size = 0; int ret = appended ? 0 : append_to_cached_buf(avctx, buf, buf_size); if (ret < 0) { + ctx->pts = AV_NOPTS_VALUE; return ret; } return buf_size; @@ -604,6 +609,7 @@ static int dvdsub_decode(AVCodecContext *avctx, reset_rects(sub); *data_size = 0; + ctx->pts = AV_NOPTS_VALUE; return buf_size; } if (!is_menu && find_smallest_bounding_rectangle(ctx, sub) == 0) @@ -627,6 +633,8 @@ static int dvdsub_decode(AVCodecContext *avctx, ctx->buf_size = 0; *data_size = 1; + sub->pts = ctx->pts; + ctx->pts = AV_NOPTS_VALUE; return buf_size; } @@ -761,6 +769,7 @@ static av_cold int dvdsub_init(AVCodecContext *avctx) av_log(avctx, AV_LOG_DEBUG, " 0x%06"PRIx32, ctx->palette[i]); av_log(avctx, AV_LOG_DEBUG, "\n"); } + ctx->pts = AV_NOPTS_VALUE; return 1; } -- 2.23.0