From 96573c0d7605672d69b42ae1dcf18764ce47c71a Mon Sep 17 00:00:00 2001 From: Vitor Sessak Date: Mon, 11 Apr 2011 16:20:36 -0400 Subject: lavf/utils.c: Order packets with identical PTS by stream index. This allows for more reproducible results when using multi-threading. Signed-off-by: Ronald S. Bultje --- libavformat/utils.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libavformat/utils.c') diff --git a/libavformat/utils.c b/libavformat/utils.c index f93b83f5da..6b38e66bc5 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3063,7 +3063,10 @@ static int ff_interleave_compare_dts(AVFormatContext *s, AVPacket *next, AVPacke 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; - return av_rescale_rnd(pkt->dts, b, a, AV_ROUND_DOWN) < next->dts; + int64_t dts1 = av_rescale_rnd(pkt->dts, b, a, AV_ROUND_DOWN); + if (dts1 == next->dts) + return pkt->stream_index < next->stream_index; + return dts1 < next->dts; } int av_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush){ -- cgit v1.2.3