[FFmpeg-devel] [PATCHv4 2/3] avformat/utils: increase detected start_time with skip_samples
Marton Balint
cus at passwd.hu
Sun Mar 13 00:52:46 CET 2016
Signed-off-by: Marton Balint <cus at passwd.hu>
---
libavformat/utils.c | 10 ++++++++--
tests/ref/fate/gaplessinfo-itunes1 | 4 ++--
tests/ref/fate/gaplessinfo-itunes2 | 4 ++--
3 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/libavformat/utils.c b/libavformat/utils.c
index e0aea87..ccb76d2 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/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
--
2.6.2
More information about the ffmpeg-devel
mailing list