Signed-off-by: Marton Balint <c...@passwd.hu>
---
 libavformat/utils.c               | 10 ++++--
 tests/ref/fate/gapless2-ipod-aac1 | 74 +++++++++++++++++++--------------------
 tests/ref/fate/gapless2-ipod-aac2 | 74 +++++++++++++++++++--------------------
 3 files changed, 82 insertions(+), 76 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 5f48de1..ca2dd09 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -971,8 +971,11 @@ static void update_initial_timestamps(AVFormatContext *s, 
int stream_index,
         if (is_relative(pktl->pkt.dts))
             pktl->pkt.dts += shift;
 
-        if (st->start_time == AV_NOPTS_VALUE && pktl->pkt.pts != 
AV_NOPTS_VALUE)
+        if (st->start_time == AV_NOPTS_VALUE && pktl->pkt.pts != 
AV_NOPTS_VALUE) {
             st->start_time = pktl->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 (pktl->pkt.pts != AV_NOPTS_VALUE && delay <= MAX_REORDER_DELAY && 
has_decode_delay_been_guessed(st)) {
             pts_buffer[0] = pktl->pkt.pts;
@@ -983,8 +986,11 @@ static void update_initial_timestamps(AVFormatContext *s, 
int stream_index,
         }
     }
 
-    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/gapless2-ipod-aac1 
b/tests/ref/fate/gapless2-ipod-aac1
index 9a35d5f..15e599b 100644
--- a/tests/ref/fate/gapless2-ipod-aac1
+++ b/tests/ref/fate/gapless2-ipod-aac1
@@ -1,12 +1,12 @@
 source|[STREAM]
 source|index=0
 source|codec_name=aac
-source|start_pts=0
+source|start_pts=2112
 source|duration_ts=1294336
 source|[/STREAM]
 source|[FORMAT]
 source|format_name=mov,mp4,m4a,3gp,3g2,mj2
-source|start_time=0.000000
+source|start_time=0.047889
 source|duration=29.350023
 source|size=982382
 source|[/FORMAT]
@@ -45,44 +45,44 @@ 
source|1262|frame|pkt_pts=1293312|pkt_dts=1293312|best_effort_timestamp=1293312|
 target|[STREAM]
 target|index=0
 target|codec_name=aac
-target|start_pts=1058
+target|start_pts=-1024
 target|duration_ts=1293248
 target|[/STREAM]
 target|[FORMAT]
 target|format_name=mov,mp4,m4a,3gp,3g2,mj2
-target|start_time=0.023991
+target|start_time=-0.023220
 target|duration=29.326000
-target|size=490335
+target|size=490323
 target|[/FORMAT]
-target|1|packet|pts=1058|dts=1058|duration=1024
-target|2|packet|pts=2082|dts=2082|duration=1024
-target|3|packet|pts=3106|dts=3106|duration=1024
-target|4|packet|pts=4130|dts=4130|duration=1024
-target|5|packet|pts=5154|dts=5154|duration=1024
-target|6|packet|pts=6178|dts=6178|duration=1024
-target|7|packet|pts=7202|dts=7202|duration=1024
-target|8|packet|pts=8226|dts=8226|duration=1024
-target|1256|packet|pts=1286178|dts=1286178|duration=1024
-target|1257|packet|pts=1287202|dts=1287202|duration=1024
-target|1258|packet|pts=1288226|dts=1288226|duration=1024
-target|1259|packet|pts=1289250|dts=1289250|duration=1024
-target|1260|packet|pts=1290274|dts=1290274|duration=1024
-target|1261|packet|pts=1291298|dts=1291298|duration=1024
-target|1262|packet|pts=1292322|dts=1292322|duration=1024
-target|1263|packet|pts=1293346|dts=1293346|duration=-98
-target|1|frame|pkt_pts=1058|pkt_dts=1058|best_effort_timestamp=1058|pkt_duration=1024|nb_samples=1024
-target|2|frame|pkt_pts=2082|pkt_dts=2082|best_effort_timestamp=2082|pkt_duration=1024|nb_samples=1024
-target|3|frame|pkt_pts=3106|pkt_dts=3106|best_effort_timestamp=3106|pkt_duration=1024|nb_samples=1024
-target|4|frame|pkt_pts=4130|pkt_dts=4130|best_effort_timestamp=4130|pkt_duration=1024|nb_samples=1024
-target|5|frame|pkt_pts=5154|pkt_dts=5154|best_effort_timestamp=5154|pkt_duration=1024|nb_samples=1024
-target|6|frame|pkt_pts=6178|pkt_dts=6178|best_effort_timestamp=6178|pkt_duration=1024|nb_samples=1024
-target|7|frame|pkt_pts=7202|pkt_dts=7202|best_effort_timestamp=7202|pkt_duration=1024|nb_samples=1024
-target|8|frame|pkt_pts=8226|pkt_dts=8226|best_effort_timestamp=8226|pkt_duration=1024|nb_samples=1024
-target|1256|frame|pkt_pts=1286178|pkt_dts=1286178|best_effort_timestamp=1286178|pkt_duration=1024|nb_samples=1024
-target|1257|frame|pkt_pts=1287202|pkt_dts=1287202|best_effort_timestamp=1287202|pkt_duration=1024|nb_samples=1024
-target|1258|frame|pkt_pts=1288226|pkt_dts=1288226|best_effort_timestamp=1288226|pkt_duration=1024|nb_samples=1024
-target|1259|frame|pkt_pts=1289250|pkt_dts=1289250|best_effort_timestamp=1289250|pkt_duration=1024|nb_samples=1024
-target|1260|frame|pkt_pts=1290274|pkt_dts=1290274|best_effort_timestamp=1290274|pkt_duration=1024|nb_samples=1024
-target|1261|frame|pkt_pts=1291298|pkt_dts=1291298|best_effort_timestamp=1291298|pkt_duration=1024|nb_samples=1024
-target|1262|frame|pkt_pts=1292322|pkt_dts=1292322|best_effort_timestamp=1292322|pkt_duration=1024|nb_samples=1024
-target|1263|frame|pkt_pts=1293346|pkt_dts=1293346|best_effort_timestamp=1293346|pkt_duration=-98|nb_samples=1024
+target|1|packet|pts=-1024|dts=-1024|duration=1024
+target|2|packet|pts=0|dts=0|duration=1024
+target|3|packet|pts=1024|dts=1024|duration=1024
+target|4|packet|pts=2048|dts=2048|duration=1024
+target|5|packet|pts=3072|dts=3072|duration=1024
+target|6|packet|pts=4096|dts=4096|duration=1024
+target|7|packet|pts=5120|dts=5120|duration=1024
+target|8|packet|pts=6144|dts=6144|duration=1024
+target|1256|packet|pts=1284096|dts=1284096|duration=1024
+target|1257|packet|pts=1285120|dts=1285120|duration=1024
+target|1258|packet|pts=1286144|dts=1286144|duration=1024
+target|1259|packet|pts=1287168|dts=1287168|duration=1024
+target|1260|packet|pts=1288192|dts=1288192|duration=1024
+target|1261|packet|pts=1289216|dts=1289216|duration=1024
+target|1262|packet|pts=1290240|dts=1290240|duration=1024
+target|1263|packet|pts=1291264|dts=1291264|duration=1984
+target|1|frame|pkt_pts=-1024|pkt_dts=-1024|best_effort_timestamp=-1024|pkt_duration=1024|nb_samples=1024
+target|2|frame|pkt_pts=0|pkt_dts=0|best_effort_timestamp=0|pkt_duration=1024|nb_samples=1024
+target|3|frame|pkt_pts=1024|pkt_dts=1024|best_effort_timestamp=1024|pkt_duration=1024|nb_samples=1024
+target|4|frame|pkt_pts=2048|pkt_dts=2048|best_effort_timestamp=2048|pkt_duration=1024|nb_samples=1024
+target|5|frame|pkt_pts=3072|pkt_dts=3072|best_effort_timestamp=3072|pkt_duration=1024|nb_samples=1024
+target|6|frame|pkt_pts=4096|pkt_dts=4096|best_effort_timestamp=4096|pkt_duration=1024|nb_samples=1024
+target|7|frame|pkt_pts=5120|pkt_dts=5120|best_effort_timestamp=5120|pkt_duration=1024|nb_samples=1024
+target|8|frame|pkt_pts=6144|pkt_dts=6144|best_effort_timestamp=6144|pkt_duration=1024|nb_samples=1024
+target|1256|frame|pkt_pts=1284096|pkt_dts=1284096|best_effort_timestamp=1284096|pkt_duration=1024|nb_samples=1024
+target|1257|frame|pkt_pts=1285120|pkt_dts=1285120|best_effort_timestamp=1285120|pkt_duration=1024|nb_samples=1024
+target|1258|frame|pkt_pts=1286144|pkt_dts=1286144|best_effort_timestamp=1286144|pkt_duration=1024|nb_samples=1024
+target|1259|frame|pkt_pts=1287168|pkt_dts=1287168|best_effort_timestamp=1287168|pkt_duration=1024|nb_samples=1024
+target|1260|frame|pkt_pts=1288192|pkt_dts=1288192|best_effort_timestamp=1288192|pkt_duration=1024|nb_samples=1024
+target|1261|frame|pkt_pts=1289216|pkt_dts=1289216|best_effort_timestamp=1289216|pkt_duration=1024|nb_samples=1024
+target|1262|frame|pkt_pts=1290240|pkt_dts=1290240|best_effort_timestamp=1290240|pkt_duration=1024|nb_samples=1024
+target|1263|frame|pkt_pts=1291264|pkt_dts=1291264|best_effort_timestamp=1291264|pkt_duration=1984|nb_samples=1024
diff --git a/tests/ref/fate/gapless2-ipod-aac2 
b/tests/ref/fate/gapless2-ipod-aac2
index dfb93db..0f197a8 100644
--- a/tests/ref/fate/gapless2-ipod-aac2
+++ b/tests/ref/fate/gapless2-ipod-aac2
@@ -1,12 +1,12 @@
 source|[STREAM]
 source|index=0
 source|codec_name=aac
-source|start_pts=0
+source|start_pts=2112
 source|duration_ts=105472
 source|[/STREAM]
 source|[FORMAT]
 source|format_name=mov,mp4,m4a,3gp,3g2,mj2
-source|start_time=0.000000
+source|start_time=0.047891
 source|duration=2.391655
 source|size=7030
 source|[/FORMAT]
@@ -45,44 +45,44 @@ 
source|101|frame|pkt_pts=104448|pkt_dts=104448|best_effort_timestamp=104448|pkt_
 target|[STREAM]
 target|index=0
 target|codec_name=aac
-target|start_pts=1058
+target|start_pts=-1024
 target|duration_ts=104384
 target|[/STREAM]
 target|[FORMAT]
 target|format_name=mov,mp4,m4a,3gp,3g2,mj2
-target|start_time=0.023991
+target|start_time=-0.023220
 target|duration=2.367000
-target|size=39025
+target|size=39013
 target|[/FORMAT]
-target|1|packet|pts=1058|dts=1058|duration=1024
-target|2|packet|pts=2082|dts=2082|duration=1024
-target|3|packet|pts=3106|dts=3106|duration=1024
-target|4|packet|pts=4130|dts=4130|duration=1024
-target|5|packet|pts=5154|dts=5154|duration=1024
-target|6|packet|pts=6178|dts=6178|duration=1024
-target|7|packet|pts=7202|dts=7202|duration=1024
-target|8|packet|pts=8226|dts=8226|duration=1024
-target|95|packet|pts=97314|dts=97314|duration=1024
-target|96|packet|pts=98338|dts=98338|duration=1024
-target|97|packet|pts=99362|dts=99362|duration=1024
-target|98|packet|pts=100386|dts=100386|duration=1024
-target|99|packet|pts=101410|dts=101410|duration=1024
-target|100|packet|pts=102434|dts=102434|duration=1024
-target|101|packet|pts=103458|dts=103458|duration=1024
-target|102|packet|pts=104482|dts=104482|duration=-98
-target|1|frame|pkt_pts=1058|pkt_dts=1058|best_effort_timestamp=1058|pkt_duration=1024|nb_samples=1024
-target|2|frame|pkt_pts=2082|pkt_dts=2082|best_effort_timestamp=2082|pkt_duration=1024|nb_samples=1024
-target|3|frame|pkt_pts=3106|pkt_dts=3106|best_effort_timestamp=3106|pkt_duration=1024|nb_samples=1024
-target|4|frame|pkt_pts=4130|pkt_dts=4130|best_effort_timestamp=4130|pkt_duration=1024|nb_samples=1024
-target|5|frame|pkt_pts=5154|pkt_dts=5154|best_effort_timestamp=5154|pkt_duration=1024|nb_samples=1024
-target|6|frame|pkt_pts=6178|pkt_dts=6178|best_effort_timestamp=6178|pkt_duration=1024|nb_samples=1024
-target|7|frame|pkt_pts=7202|pkt_dts=7202|best_effort_timestamp=7202|pkt_duration=1024|nb_samples=1024
-target|8|frame|pkt_pts=8226|pkt_dts=8226|best_effort_timestamp=8226|pkt_duration=1024|nb_samples=1024
-target|95|frame|pkt_pts=97314|pkt_dts=97314|best_effort_timestamp=97314|pkt_duration=1024|nb_samples=1024
-target|96|frame|pkt_pts=98338|pkt_dts=98338|best_effort_timestamp=98338|pkt_duration=1024|nb_samples=1024
-target|97|frame|pkt_pts=99362|pkt_dts=99362|best_effort_timestamp=99362|pkt_duration=1024|nb_samples=1024
-target|98|frame|pkt_pts=100386|pkt_dts=100386|best_effort_timestamp=100386|pkt_duration=1024|nb_samples=1024
-target|99|frame|pkt_pts=101410|pkt_dts=101410|best_effort_timestamp=101410|pkt_duration=1024|nb_samples=1024
-target|100|frame|pkt_pts=102434|pkt_dts=102434|best_effort_timestamp=102434|pkt_duration=1024|nb_samples=1024
-target|101|frame|pkt_pts=103458|pkt_dts=103458|best_effort_timestamp=103458|pkt_duration=1024|nb_samples=1024
-target|102|frame|pkt_pts=104482|pkt_dts=104482|best_effort_timestamp=104482|pkt_duration=-98|nb_samples=1024
+target|1|packet|pts=-1024|dts=-1024|duration=1024
+target|2|packet|pts=0|dts=0|duration=1024
+target|3|packet|pts=1024|dts=1024|duration=1024
+target|4|packet|pts=2048|dts=2048|duration=1024
+target|5|packet|pts=3072|dts=3072|duration=1024
+target|6|packet|pts=4096|dts=4096|duration=1024
+target|7|packet|pts=5120|dts=5120|duration=1024
+target|8|packet|pts=6144|dts=6144|duration=1024
+target|95|packet|pts=95232|dts=95232|duration=1024
+target|96|packet|pts=96256|dts=96256|duration=1024
+target|97|packet|pts=97280|dts=97280|duration=1024
+target|98|packet|pts=98304|dts=98304|duration=1024
+target|99|packet|pts=99328|dts=99328|duration=1024
+target|100|packet|pts=100352|dts=100352|duration=1024
+target|101|packet|pts=101376|dts=101376|duration=1024
+target|102|packet|pts=102400|dts=102400|duration=1984
+target|1|frame|pkt_pts=-1024|pkt_dts=-1024|best_effort_timestamp=-1024|pkt_duration=1024|nb_samples=1024
+target|2|frame|pkt_pts=0|pkt_dts=0|best_effort_timestamp=0|pkt_duration=1024|nb_samples=1024
+target|3|frame|pkt_pts=1024|pkt_dts=1024|best_effort_timestamp=1024|pkt_duration=1024|nb_samples=1024
+target|4|frame|pkt_pts=2048|pkt_dts=2048|best_effort_timestamp=2048|pkt_duration=1024|nb_samples=1024
+target|5|frame|pkt_pts=3072|pkt_dts=3072|best_effort_timestamp=3072|pkt_duration=1024|nb_samples=1024
+target|6|frame|pkt_pts=4096|pkt_dts=4096|best_effort_timestamp=4096|pkt_duration=1024|nb_samples=1024
+target|7|frame|pkt_pts=5120|pkt_dts=5120|best_effort_timestamp=5120|pkt_duration=1024|nb_samples=1024
+target|8|frame|pkt_pts=6144|pkt_dts=6144|best_effort_timestamp=6144|pkt_duration=1024|nb_samples=1024
+target|95|frame|pkt_pts=95232|pkt_dts=95232|best_effort_timestamp=95232|pkt_duration=1024|nb_samples=1024
+target|96|frame|pkt_pts=96256|pkt_dts=96256|best_effort_timestamp=96256|pkt_duration=1024|nb_samples=1024
+target|97|frame|pkt_pts=97280|pkt_dts=97280|best_effort_timestamp=97280|pkt_duration=1024|nb_samples=1024
+target|98|frame|pkt_pts=98304|pkt_dts=98304|best_effort_timestamp=98304|pkt_duration=1024|nb_samples=1024
+target|99|frame|pkt_pts=99328|pkt_dts=99328|best_effort_timestamp=99328|pkt_duration=1024|nb_samples=1024
+target|100|frame|pkt_pts=100352|pkt_dts=100352|best_effort_timestamp=100352|pkt_duration=1024|nb_samples=1024
+target|101|frame|pkt_pts=101376|pkt_dts=101376|best_effort_timestamp=101376|pkt_duration=1024|nb_samples=1024
+target|102|frame|pkt_pts=102400|pkt_dts=102400|best_effort_timestamp=102400|pkt_duration=1984|nb_samples=1024
-- 
2.6.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to