[FFmpeg-devel] [PATCHv2 2/3] avformat/utils: increase detected start_time with skip_samples
wm4
nfxjfg at googlemail.com
Tue Mar 8 22:12:58 CET 2016
On Tue, 8 Mar 2016 21:29:52 +0100
Marton Balint <cus at passwd.hu> wrote:
> Signed-off-by: Marton Balint <cus at passwd.hu>
> ---
> libavformat/utils.c | 10 ++++--
> tests/ref/fate/gapless2-ipod-aac1 | 72 +++++++++++++++++++--------------------
> tests/ref/fate/gapless2-ipod-aac2 | 72 +++++++++++++++++++--------------------
> 3 files changed, 80 insertions(+), 74 deletions(-)
>
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index f4ae8b4..bb1c290 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);
> + }
> }
I'm a probably bit late here, but what's the rationale of increasing the
start time?
Maybe it's like this: the first packet has a negative timestamp, so
utils.c sets the start_time to something negative, so this has to be
compensated again so that the start time is 0?
More information about the ffmpeg-devel
mailing list