[FFmpeg-cvslog] lavf/utils.c: Don't compute start_time from DISCARD packets for video.

Sasi Inguva git at videolan.org
Sat Mar 24 04:13:02 EET 2018


ffmpeg | branch: master | Sasi Inguva <isasi-at-google.com at ffmpeg.org> | Wed Mar 21 13:36:38 2018 -0700| [829aebf95d44c1e850fd31692a273e6c6ab8161a] | committer: Michael Niedermayer

lavf/utils.c: Don't compute start_time from DISCARD packets for video.

Signed-off-by: Sasi Inguva <isasi at isasi.mtv.corp.google.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavformat/utils.c                            |  4 +++-
 tests/fate/mov.mak                             | 10 +++++++++-
 tests/ref/fate/mov-neg-firstpts-discard        |  3 +++
 tests/ref/fate/mov-neg-firstpts-discard-frames | 24 ++++++++++++++++++++++++
 4 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 4d0b56c2a8..f13c8208b1 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1158,7 +1158,9 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index,
     }
 
     if (st->start_time == AV_NOPTS_VALUE) {
-        st->start_time = pts;
+        if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO || !(pkt->flags & AV_PKT_FLAG_DISCARD)) {
+            st->start_time = pts;
+        }
         if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->sample_rate)
             st->start_time += av_rescale_q(st->skip_samples, (AVRational){1, st->codecpar->sample_rate}, st->time_base);
     }
diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
index 64f92e9488..9d7d62a023 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -13,8 +13,10 @@ FATE_MOV = fate-mov-3elist \
            fate-mov-elst-ends-betn-b-and-i \
            fate-mov-frag-overlap \
            fate-mov-bbi-elst-starts-b \
+           fate-mov-neg-firstpts-discard-frames \
 
-FATE_MOV_FFPROBE = fate-mov-aac-2048-priming \
+FATE_MOV_FFPROBE = fate-mov-neg-firstpts-discard \
+                   fate-mov-aac-2048-priming \
                    fate-mov-zombie \
                    fate-mov-init-nonkeyframe \
                    fate-mov-displaymatrix \
@@ -72,6 +74,12 @@ fate-mov-frag-overlap: CMD = framemd5 -i $(TARGET_SAMPLES)/mov/frag_overlap.mp4
 # GOP structure : B B I in presentation order.
 fate-mov-bbi-elst-starts-b: CMD = framemd5 -flags +bitexact -acodec aac_fixed -i $(TARGET_SAMPLES)/h264/twofields_packet.mp4
 
+# Makes sure that the stream start_time is not negative when the first packet is a DISCARD packet with negative timestamp.
+fate-mov-neg-firstpts-discard: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entries stream=start_time -bitexact $(TARGET_SAMPLES)/mov/mov_neg_first_pts_discard.mov
+
+# Makes sure that expected frames are generated for mov_neg_first_pts_discard.mov with -vsync 1
+fate-mov-neg-firstpts-discard-frames: CMD = framemd5 -flags +bitexact -i $(TARGET_SAMPLES)/mov/mov_neg_first_pts_discard.mov -vsync 1
+
 fate-mov-aac-2048-priming: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_packets -print_format compact $(TARGET_SAMPLES)/mov/aac-2048-priming.mov
 
 fate-mov-zombie: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_streams -show_packets -show_frames -bitexact -print_format compact $(TARGET_SAMPLES)/mov/white_zombie_scrunch-part.mov
diff --git a/tests/ref/fate/mov-neg-firstpts-discard b/tests/ref/fate/mov-neg-firstpts-discard
new file mode 100644
index 0000000000..7c982d3ffe
--- /dev/null
+++ b/tests/ref/fate/mov-neg-firstpts-discard
@@ -0,0 +1,3 @@
+[STREAM]
+start_time=N/A
+[/STREAM]
diff --git a/tests/ref/fate/mov-neg-firstpts-discard-frames b/tests/ref/fate/mov-neg-firstpts-discard-frames
new file mode 100644
index 0000000000..81b59b384b
--- /dev/null
+++ b/tests/ref/fate/mov-neg-firstpts-discard-frames
@@ -0,0 +1,24 @@
+#format: frame checksums
+#version: 2
+#hash: MD5
+#tb 0: 1/30
+#media_type 0: video
+#codec_id 0: rawvideo
+#dimensions 0: 320x240
+#sar 0: 1/1
+#stream#, dts,        pts, duration,     size, hash
+0,          0,          0,        1,   115200, 1e55263b359b4c99c3463655a1120f11
+0,          1,          1,        1,   115200, ce33efea81064e7c23deb57dc4c21995
+0,          2,          2,        1,   115200, 42234f25d6191ab13c3676a7937c921b
+0,          3,          3,        1,   115200, eab2ccb227c66cba4c9feb8cdbf28ef8
+0,          4,          4,        1,   115200, c8816e0b151b2c892163e35086918520
+0,          5,          5,        1,   115200, c633f5604c8651165d551ee88fb4cd92
+0,          6,          6,        1,   115200, 5f3f8530d720fef3ac4c937e7f488ea7
+0,          7,          7,        1,   115200, be24a583909ca92008b642f39be02685
+0,          8,          8,        1,   115200, 83872a6e5c3369fe76f684de31bd9a36
+0,          9,          9,        1,   115200, 4629d6eb656883b337e8e0b381f2db8d
+0,         10,         10,        1,   115200, f6bec55bc026440d23a44b948900e785
+0,         11,         11,        1,   115200, 7e12e8113916305c79e5d08354acc9ae
+0,         12,         12,        1,   115200, d315c0093536642d340ea50de3b2bfbb
+0,         13,         13,        1,   115200, 3d12b24aaed72bfada4a1a3e5e02945a
+0,         14,         14,        1,   115200, 070d6b8935c11304d8f9520c4401a130



More information about the ffmpeg-cvslog mailing list