[FFmpeg-devel] [PATCH 1/2] Use input AVPavket.pts to set AVSubtitle.pts when the subtitle decoder don't set this field by itself.

Aurelien Jacobs aurel at gnuage.org
Mon Apr 11 23:57:40 CEST 2011


Signed-off-by: Aurelien Jacobs <aurel at gnuage.org>
---
 libavcodec/utils.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index bd5bdfd..6f4c689 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -803,8 +803,12 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
     *got_sub_ptr = 0;
     avcodec_get_subtitle_defaults(sub);
     ret = avctx->codec->decode(avctx, sub, got_sub_ptr, avpkt);
-    if (*got_sub_ptr)
+    if (*got_sub_ptr) {
         avctx->frame_number++;
+        if (sub->pts == AV_NOPTS_VALUE && avpkt->pts != AV_NOPTS_VALUE)
+            sub->pts = ((int64_t)AV_TIME_BASE * avpkt->pts *
+                        avctx->time_base.num) / avctx->time_base.den;
+    }
     return ret;
 }
 
-- 
1.7.4.1



More information about the ffmpeg-devel mailing list