[FFmpeg-cvslog] avformat/utils: Fix pts_wrap_behavior calculation with negative first_dts

Michael Niedermayer git at videolan.org
Wed Dec 4 02:59:41 CET 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Dec  4 01:49:14 2013 +0100| [dd5f925927d6aaf01716a1a802a428340eeea077] | committer: Michael Niedermayer

avformat/utils: Fix pts_wrap_behavior calculation with negative first_dts

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dd5f925927d6aaf01716a1a802a428340eeea077
---

 libavformat/utils.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 06758bf..8c29f08 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -874,11 +874,12 @@ static int update_wrap_reference(AVFormatContext *s, AVStream *st, int stream_in
         st->pts_wrap_reference == AV_NOPTS_VALUE && st->first_dts != AV_NOPTS_VALUE) {
         int i;
 
+        int64_t ref = st->first_dts & ((1LL<<st->pts_wrap_bits)-1);
         // reference time stamp should be 60 s before first time stamp
-        int64_t pts_wrap_reference = st->first_dts - av_rescale(60, st->time_base.den, st->time_base.num);
+        int64_t pts_wrap_reference = ref - av_rescale(60, st->time_base.den, st->time_base.num);
         // if first time stamp is not more than 1/8 and 60s before the wrap point, subtract rather than add wrap offset
-        int pts_wrap_behavior = (st->first_dts < (1LL<<st->pts_wrap_bits) - (1LL<<st->pts_wrap_bits-3)) ||
-            (st->first_dts < (1LL<<st->pts_wrap_bits) - av_rescale(60, st->time_base.den, st->time_base.num)) ?
+        int pts_wrap_behavior = (ref < (1LL<<st->pts_wrap_bits) - (1LL<<st->pts_wrap_bits-3)) ||
+            (ref < (1LL<<st->pts_wrap_bits) - av_rescale(60, st->time_base.den, st->time_base.num)) ?
             AV_PTS_WRAP_ADD_OFFSET : AV_PTS_WRAP_SUB_OFFSET;
 
         AVProgram *first_program = av_find_program_from_stream(s, NULL, stream_index);



More information about the ffmpeg-cvslog mailing list