1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-28 20:53:54 +02:00

avformat/utils: fix rounding error accumulation for generated dts in compute_pkt_fields()

This only updates the case where there is no B frame reordering delay.

Tested-by: Anssi Hannula <anssi.hannula@iki.fi>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2014-01-03 17:44:15 +01:00
parent cd7037dd7a
commit 863f4c3c71

View File

@ -1046,6 +1046,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
{
int num, den, presentation_delayed, delay, i;
int64_t offset;
AVRational duration;
if (s->flags & AVFMT_FLAG_NOFILLIN)
return;
@ -1087,12 +1088,15 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
pkt->dts= AV_NOPTS_VALUE;
}
duration = av_mul_q((AVRational){pkt->duration, 1}, st->time_base);
if (pkt->duration == 0) {
ff_compute_frame_duration(&num, &den, st, pc, pkt);
if (den && num) {
duration = (AVRational){num, den};
pkt->duration = av_rescale_rnd(1, num * (int64_t)st->time_base.den, den * (int64_t)st->time_base.num, AV_ROUND_DOWN);
}
}
if(pkt->duration != 0 && (s->packet_buffer || s->parse_queue))
update_initial_durations(s, st, pkt->stream_index, pkt->duration);
@ -1138,7 +1142,6 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
} else if (pkt->pts != AV_NOPTS_VALUE ||
pkt->dts != AV_NOPTS_VALUE ||
pkt->duration ) {
int duration = pkt->duration;
/* presentation is not delayed : PTS and DTS are the same */
if (pkt->pts == AV_NOPTS_VALUE)
@ -1149,7 +1152,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
pkt->pts = st->cur_dts;
pkt->dts = pkt->pts;
if (pkt->pts != AV_NOPTS_VALUE)
st->cur_dts = pkt->pts + duration;
st->cur_dts = av_add_stable(st->time_base, pkt->pts, duration, 1);
}
}