[FFmpeg-cvslog] avformat/utils: increase detected start_time with skip_samples

Marton Balint git at videolan.org
Sun Mar 20 20:34:21 CET 2016


ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Sat Feb 20 22:39:07 2016 +0100| [25f707694cd33f65979320bc0de9273c11bf547c] | committer: Marton Balint

avformat/utils: increase detected start_time with skip_samples

Reviewed-by: Michael Niedermayer <michael at niedermayer.cc>
Signed-off-by: Marton Balint <cus at passwd.hu>

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

 libavformat/utils.c                          |   10 +++-
 tests/ref/fate/gaplessenc-itunes-to-ipod-aac |   68 +++++++++++++-------------
 tests/ref/fate/gaplessinfo-itunes1           |    4 +-
 tests/ref/fate/gaplessinfo-itunes2           |    4 +-
 4 files changed, 46 insertions(+), 40 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 5cff3a7..5409907 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -997,16 +997,22 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index,
         if (is_relative(pktl_it->pkt.dts))
             pktl_it->pkt.dts += shift;
 
-        if (st->start_time == AV_NOPTS_VALUE && pktl_it->pkt.pts != AV_NOPTS_VALUE)
+        if (st->start_time == AV_NOPTS_VALUE && pktl_it->pkt.pts != AV_NOPTS_VALUE) {
             st->start_time = pktl_it->pkt.pts;
+            if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->codec->sample_rate)
+                st->start_time += av_rescale_q(st->skip_samples, (AVRational){1, st->codec->sample_rate}, st->time_base);
+        }
     }
 
     if (has_decode_delay_been_guessed(st)) {
         update_dts_from_pts(s, stream_index, pktl);
     }
 
-    if (st->start_time == AV_NOPTS_VALUE)
+    if (st->start_time == AV_NOPTS_VALUE) {
         st->start_time = pts;
+        if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->codec->sample_rate)
+            st->start_time += av_rescale_q(st->skip_samples, (AVRational){1, st->codec->sample_rate}, st->time_base);
+    }
 }
 
 static void update_initial_durations(AVFormatContext *s, AVStream *st,
diff --git a/tests/ref/fate/gaplessenc-itunes-to-ipod-aac b/tests/ref/fate/gaplessenc-itunes-to-ipod-aac
index 1d4262f..564c212 100644
--- a/tests/ref/fate/gaplessenc-itunes-to-ipod-aac
+++ b/tests/ref/fate/gaplessenc-itunes-to-ipod-aac
@@ -1,43 +1,43 @@
 [STREAM]
 index=0
-start_pts=1058
+start_pts=-1024
 duration_ts=104384
 [/STREAM]
 [FORMAT]
-start_time=0.023991
+start_time=-0.023220
 duration=2.367000
 [/FORMAT]
-packet|pts=1058|dts=1058|duration=1024
-packet|pts=2082|dts=2082|duration=1024
-packet|pts=3106|dts=3106|duration=1024
-packet|pts=4130|dts=4130|duration=1024
-packet|pts=5154|dts=5154|duration=1024
-packet|pts=6178|dts=6178|duration=1024
-packet|pts=7202|dts=7202|duration=1024
-packet|pts=8226|dts=8226|duration=1024
-packet|pts=97314|dts=97314|duration=1024
-packet|pts=98338|dts=98338|duration=1024
-packet|pts=99362|dts=99362|duration=1024
-packet|pts=100386|dts=100386|duration=1024
-packet|pts=101410|dts=101410|duration=1024
-packet|pts=102434|dts=102434|duration=1024
-packet|pts=103458|dts=103458|duration=1024
-packet|pts=104482|dts=104482|duration=-98
+packet|pts=-1024|dts=-1024|duration=1024
+packet|pts=0|dts=0|duration=1024
+packet|pts=1024|dts=1024|duration=1024
+packet|pts=2048|dts=2048|duration=1024
+packet|pts=3072|dts=3072|duration=1024
+packet|pts=4096|dts=4096|duration=1024
+packet|pts=5120|dts=5120|duration=1024
+packet|pts=6144|dts=6144|duration=1024
+packet|pts=95232|dts=95232|duration=1024
+packet|pts=96256|dts=96256|duration=1024
+packet|pts=97280|dts=97280|duration=1024
+packet|pts=98304|dts=98304|duration=1024
+packet|pts=99328|dts=99328|duration=1024
+packet|pts=100352|dts=100352|duration=1024
+packet|pts=101376|dts=101376|duration=1024
+packet|pts=102400|dts=102400|duration=1984
 stream|nb_read_packets=102
-frame|pkt_pts=1058|pkt_dts=1058|best_effort_timestamp=1058|pkt_duration=1024|nb_samples=1024
-frame|pkt_pts=2082|pkt_dts=2082|best_effort_timestamp=2082|pkt_duration=1024|nb_samples=1024
-frame|pkt_pts=3106|pkt_dts=3106|best_effort_timestamp=3106|pkt_duration=1024|nb_samples=1024
-frame|pkt_pts=4130|pkt_dts=4130|best_effort_timestamp=4130|pkt_duration=1024|nb_samples=1024
-frame|pkt_pts=5154|pkt_dts=5154|best_effort_timestamp=5154|pkt_duration=1024|nb_samples=1024
-frame|pkt_pts=6178|pkt_dts=6178|best_effort_timestamp=6178|pkt_duration=1024|nb_samples=1024
-frame|pkt_pts=7202|pkt_dts=7202|best_effort_timestamp=7202|pkt_duration=1024|nb_samples=1024
-frame|pkt_pts=8226|pkt_dts=8226|best_effort_timestamp=8226|pkt_duration=1024|nb_samples=1024
-frame|pkt_pts=97314|pkt_dts=97314|best_effort_timestamp=97314|pkt_duration=1024|nb_samples=1024
-frame|pkt_pts=98338|pkt_dts=98338|best_effort_timestamp=98338|pkt_duration=1024|nb_samples=1024
-frame|pkt_pts=99362|pkt_dts=99362|best_effort_timestamp=99362|pkt_duration=1024|nb_samples=1024
-frame|pkt_pts=100386|pkt_dts=100386|best_effort_timestamp=100386|pkt_duration=1024|nb_samples=1024
-frame|pkt_pts=101410|pkt_dts=101410|best_effort_timestamp=101410|pkt_duration=1024|nb_samples=1024
-frame|pkt_pts=102434|pkt_dts=102434|best_effort_timestamp=102434|pkt_duration=1024|nb_samples=1024
-frame|pkt_pts=103458|pkt_dts=103458|best_effort_timestamp=103458|pkt_duration=1024|nb_samples=1024
-frame|pkt_pts=104482|pkt_dts=104482|best_effort_timestamp=104482|pkt_duration=-98|nb_samples=1024
+frame|pkt_pts=-1024|pkt_dts=-1024|best_effort_timestamp=-1024|pkt_duration=1024|nb_samples=1024
+frame|pkt_pts=0|pkt_dts=0|best_effort_timestamp=0|pkt_duration=1024|nb_samples=1024
+frame|pkt_pts=1024|pkt_dts=1024|best_effort_timestamp=1024|pkt_duration=1024|nb_samples=1024
+frame|pkt_pts=2048|pkt_dts=2048|best_effort_timestamp=2048|pkt_duration=1024|nb_samples=1024
+frame|pkt_pts=3072|pkt_dts=3072|best_effort_timestamp=3072|pkt_duration=1024|nb_samples=1024
+frame|pkt_pts=4096|pkt_dts=4096|best_effort_timestamp=4096|pkt_duration=1024|nb_samples=1024
+frame|pkt_pts=5120|pkt_dts=5120|best_effort_timestamp=5120|pkt_duration=1024|nb_samples=1024
+frame|pkt_pts=6144|pkt_dts=6144|best_effort_timestamp=6144|pkt_duration=1024|nb_samples=1024
+frame|pkt_pts=95232|pkt_dts=95232|best_effort_timestamp=95232|pkt_duration=1024|nb_samples=1024
+frame|pkt_pts=96256|pkt_dts=96256|best_effort_timestamp=96256|pkt_duration=1024|nb_samples=1024
+frame|pkt_pts=97280|pkt_dts=97280|best_effort_timestamp=97280|pkt_duration=1024|nb_samples=1024
+frame|pkt_pts=98304|pkt_dts=98304|best_effort_timestamp=98304|pkt_duration=1024|nb_samples=1024
+frame|pkt_pts=99328|pkt_dts=99328|best_effort_timestamp=99328|pkt_duration=1024|nb_samples=1024
+frame|pkt_pts=100352|pkt_dts=100352|best_effort_timestamp=100352|pkt_duration=1024|nb_samples=1024
+frame|pkt_pts=101376|pkt_dts=101376|best_effort_timestamp=101376|pkt_duration=1024|nb_samples=1024
+frame|pkt_pts=102400|pkt_dts=102400|best_effort_timestamp=102400|pkt_duration=1984|nb_samples=1024
 stream|nb_read_frames=102
diff --git a/tests/ref/fate/gaplessinfo-itunes1 b/tests/ref/fate/gaplessinfo-itunes1
index a18879b..717a2a8 100644
--- a/tests/ref/fate/gaplessinfo-itunes1
+++ b/tests/ref/fate/gaplessinfo-itunes1
@@ -1,10 +1,10 @@
 [STREAM]
 index=0
-start_pts=0
+start_pts=2112
 duration_ts=1294336
 [/STREAM]
 [FORMAT]
-start_time=0.000000
+start_time=0.047889
 duration=29.350023
 [/FORMAT]
 packet|pts=0|dts=0|duration=1024
diff --git a/tests/ref/fate/gaplessinfo-itunes2 b/tests/ref/fate/gaplessinfo-itunes2
index c81dddf..be15113 100644
--- a/tests/ref/fate/gaplessinfo-itunes2
+++ b/tests/ref/fate/gaplessinfo-itunes2
@@ -1,10 +1,10 @@
 [STREAM]
 index=0
-start_pts=0
+start_pts=2112
 duration_ts=105472
 [/STREAM]
 [FORMAT]
-start_time=0.000000
+start_time=0.047891
 duration=2.391655
 [/FORMAT]
 packet|pts=0|dts=0|duration=1024



More information about the ffmpeg-cvslog mailing list