From 6d77d9acf7c505bb23948fa4e84b9ea236652772 Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michaelni@gmx.at>
Date: Tue, 8 Jul 2008 14:07:37 +0000
Subject: [PATCH] Set cur_dts to 0 only during creating new streams and not
 every time cur_dts happens to be AV_NOPTS_VALUE.

Originally committed as revision 14118 to svn://svn.ffmpeg.org/ffmpeg/trunk
---
 libavformat/utils.c        | 10 +++++-----
 tests/libav.regression.ref |  2 +-
 tests/seek.regression.ref  |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index affb9125bcf..671595b4afe 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -730,10 +730,6 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
     if(pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->pts > pkt->dts)
         presentation_delayed = 1;
 
-    if(st->cur_dts == AV_NOPTS_VALUE){
-        st->cur_dts = 0; //FIXME maybe set it to 0 during init
-    }
-
 //    av_log(NULL, AV_LOG_DEBUG, "IN delayed:%d pts:%"PRId64", dts:%"PRId64" cur_dts:%"PRId64" st:%d pc:%p\n", presentation_delayed, pkt->pts, pkt->dts, st->cur_dts, pkt->stream_index, pc);
     /* interpolate PTS and DTS if they are not present */
     if(delay==0 || (delay==1 && pc)){
@@ -2263,7 +2259,11 @@ AVStream *av_new_stream(AVFormatContext *s, int id)
     st->id = id;
     st->start_time = AV_NOPTS_VALUE;
     st->duration = AV_NOPTS_VALUE;
-    st->cur_dts = AV_NOPTS_VALUE;
+        /* we set the current DTS to 0 so that formats without any timestamps
+           but durations get some timestamps, formats with some unknown
+           timestamps have their first few packets buffered and the
+           timestamps corrected before they are returned to the user */
+    st->cur_dts = 0;
     st->first_dts = AV_NOPTS_VALUE;
 
     /* default pts setting is MPEG-like */
diff --git a/tests/libav.regression.ref b/tests/libav.regression.ref
index 6c5c23690a0..02f6faee1d8 100644
--- a/tests/libav.regression.ref
+++ b/tests/libav.regression.ref
@@ -11,7 +11,7 @@ bdb7484c68db722f66ba1630cf79844c *./tests/data/b-libav.mpg
 ./tests/data/b-libav.mpg CRC=0x2b71a386
 447b005e527cf495ec13092e788f028d *./tests/data/b-libav.ts
 471692 ./tests/data/b-libav.ts
-./tests/data/b-libav.ts CRC=0xcc4948e1
+./tests/data/b-libav.ts CRC=0xd14320e2
 d6fdeb9f7083cc827f9510c6c4517dc0 *./tests/data/b-libav.swf
 335771 ./tests/data/b-libav.swf
 ./tests/data/b-libav.swf CRC=0xe14e8847
diff --git a/tests/seek.regression.ref b/tests/seek.regression.ref
index 749c559ebeb..c53fb813ade 100644
--- a/tests/seek.regression.ref
+++ b/tests/seek.regression.ref
@@ -3481,7 +3481,7 @@ ret:-1 st:-1 ts:0.460008 flags:0
 ret:-1 st:-1 ts:-0.645825 flags:1
 ----------------
 tests/data/b-libav.ts
-ret: 0 st: 0 dts:0.000000 pts:-102481911520608.625000 pos:-1 size:24921 flags:1
+ret: 0 st: 0 dts:-102481911520608.625000 pts:-102481911520608.625000 pos:-1 size:24921 flags:1
 ret: 0 st:-1 ts:-1.000000 flags:0
 ret: 0 st: 0 dts:0.000000 pts:-102481911520608.625000 pos:-1 size:22036 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
-- 
GitLab