aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-01-03 17:44:15 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-01-04 15:10:44 +0100
commit863f4c3c7170270f78049e390670d2b83fbe67d3 (patch)
treedde8e9b50f65050200b5247433dedb0ac94accc8 /libavformat/utils.c
parentcd7037dd7ac14823619cf1649922b0ef31310291 (diff)
downloadffmpeg-863f4c3c7170270f78049e390670d2b83fbe67d3.tar.gz
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>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 549238fbbd..f0685eef60 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -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);
}
}