From ecc297308ff3cb8b20359df44108ac299b22bdf1 Mon Sep 17 00:00:00 2001 From: Vitor Sessak Date: Sat, 7 May 2011 22:48:29 +0200 Subject: lavf/utils: fix ff_interleave_compare_dts corner case. This should fix behavior introduced by commit 96573c0d7605672d69b42ae1dcf18764ce47c71a. Av_rescale_rnd() is not lossless so if two timestamps are equal after being rescaled they are not always actually identical. This patch use av_compare_ts() to get always a correct result. Signed-off-by: Ronald S. Bultje --- libavformat/utils.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'libavformat/utils.c') diff --git a/libavformat/utils.c b/libavformat/utils.c index 425b4b3..7959102 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2972,12 +2972,12 @@ static int ff_interleave_compare_dts(AVFormatContext *s, AVPacket *next, AVPacke { AVStream *st = s->streams[ pkt ->stream_index]; AVStream *st2= s->streams[ next->stream_index]; - int64_t a= st2->time_base.num * (int64_t)st ->time_base.den; - int64_t b= st ->time_base.num * (int64_t)st2->time_base.den; - int64_t dts1 = av_rescale_rnd(pkt->dts, b, a, AV_ROUND_DOWN); - if (dts1 == next->dts) + int comp = av_compare_ts(next->dts, st2->time_base, pkt->dts, + st->time_base); + + if (comp == 0) return pkt->stream_index < next->stream_index; - return dts1 < next->dts; + return comp > 0; } int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush){ -- cgit v1.1