Commit ecc29730 authored by Vitor Sessak's avatar Vitor Sessak Committed by Ronald S. Bultje

lavf/utils: fix ff_interleave_compare_dts corner case.

This should fix behavior introduced by commit
96573c0d. 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: 's avatarRonald S. Bultje <rsbultje@gmail.com>
parent 23d10ce0
......@@ -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){
......
f8b3e77a1430c348dc06472571d37191 *./tests/data/lavf/lavf.avi
7e5e4db8c04f0acd16cff6b30e60d0e5 *./tests/data/lavf/lavf.avi
331032 ./tests/data/lavf/lavf.avi
./tests/data/lavf/lavf.avi CRC=0x2a83e6b0
df1eab0853a22713cf4172acbf1a6b4b *./tests/data/lavf/lavf.nut
16b9d2cf8effb7dae316c6b9248a49b7 *./tests/data/lavf/lavf.nut
319888 ./tests/data/lavf/lavf.nut
./tests/data/lavf/lavf.nut CRC=0x2a83e6b0
......@@ -2,43 +2,43 @@ ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 9908 size: 27867
ret: 0 st:-1 flags:0 ts:-1.000000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 9908 size: 27867
ret: 0 st:-1 flags:1 ts: 1.894167
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 301248 size: 27864
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 301466 size: 27864
ret: 0 st: 0 flags:0 ts: 0.800000
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 301248 size: 27864
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 301466 size: 27864
ret:-1 st: 0 flags:1 ts:-0.320000
ret:-1 st: 1 flags:0 ts: 2.586122
ret: 0 st: 1 flags:1 ts: 1.462857
ret: 0 st: 1 flags:1 dts: 1.018776 pts: 1.018776 pos: 329774 size: 209
ret: 0 st:-1 flags:0 ts: 0.365002
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 155948 size: 27955
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 156166 size: 27955
ret:-1 st:-1 flags:1 ts:-0.740831
ret:-1 st: 0 flags:0 ts: 2.160000
ret: 0 st: 0 flags:1 ts: 1.040000
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 301248 size: 27864
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 301466 size: 27864
ret: 0 st: 1 flags:0 ts:-0.052245
ret: 0 st: 1 flags:1 dts: 0.000000 pts: 0.000000 pos: 37784 size: 208
ret: 0 st: 1 flags:1 ts: 2.847347
ret: 0 st: 1 flags:1 dts: 1.018776 pts: 1.018776 pos: 329774 size: 209
ret:-1 st:-1 flags:0 ts: 1.730004
ret: 0 st:-1 flags:1 ts: 0.624171
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 155948 size: 27955
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 156166 size: 27955
ret: 0 st: 0 flags:0 ts:-0.480000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 9908 size: 27867
ret: 0 st: 0 flags:1 ts: 2.400000
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 301248 size: 27864
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 301466 size: 27864
ret:-1 st: 1 flags:0 ts: 1.306122
ret: 0 st: 1 flags:1 ts: 0.208980
ret: 0 st: 1 flags:1 dts: 0.208980 pts: 0.208980 pos: 92800 size: 209
ret: 0 st:-1 flags:0 ts:-0.904994
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 9908 size: 27867
ret: 0 st:-1 flags:1 ts: 1.989173
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 301248 size: 27864
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 301466 size: 27864
ret: 0 st: 0 flags:0 ts: 0.880000
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 301248 size: 27864
ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 301466 size: 27864
ret:-1 st: 0 flags:1 ts:-0.240000
ret:-1 st: 1 flags:0 ts: 2.664490
ret: 0 st: 1 flags:1 ts: 1.567347
ret: 0 st: 1 flags:1 dts: 1.018776 pts: 1.018776 pos: 329774 size: 209
ret: 0 st:-1 flags:0 ts: 0.460008
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 155948 size: 27955
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 156166 size: 27955
ret:-1 st:-1 flags:1 ts:-0.645825
......@@ -2,52 +2,52 @@ ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 279 size: 27837
ret: 0 st:-1 flags:0 ts:-1.000000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 279 size: 27837
ret: 0 st:-1 flags:1 ts: 1.894167
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146121 size: 27925
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925
ret: 0 st: 0 flags:0 ts: 0.800000
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146121 size: 27925
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925
ret: 0 st: 0 flags:1 ts:-0.320000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 279 size: 27837
ret: 0 st: 1 flags:0 ts: 2.586122
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146121 size: 27925
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925
ret: 0 st: 1 flags:1 ts: 1.462857
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146121 size: 27925
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925
ret: 0 st:-1 flags:0 ts: 0.365002
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 279 size: 27837
ret: 0 st:-1 flags:1 ts:-0.740831
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 279 size: 27837
ret: 0 st: 0 flags:0 ts: 2.160000
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146121 size: 27925
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925
ret: 0 st: 0 flags:1 ts: 1.040000
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146121 size: 27925
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925
ret: 0 st: 1 flags:0 ts:-0.052245
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 279 size: 27837
ret: 0 st: 1 flags:1 ts: 2.847347
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146121 size: 27925
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925
ret: 0 st:-1 flags:0 ts: 1.730004
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146121 size: 27925
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925
ret: 0 st:-1 flags:1 ts: 0.624171
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146121 size: 27925
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925
ret: 0 st: 0 flags:0 ts:-0.480000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 279 size: 27837
ret: 0 st: 0 flags:1 ts: 2.400000
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146121 size: 27925
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925
ret: 0 st: 1 flags:0 ts: 1.306122
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146121 size: 27925
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925
ret: 0 st: 1 flags:1 ts: 0.208980
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 279 size: 27837
ret: 0 st:-1 flags:0 ts:-0.904994
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 279 size: 27837
ret: 0 st:-1 flags:1 ts: 1.989173
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146121 size: 27925
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925
ret: 0 st: 0 flags:0 ts: 0.880000
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146121 size: 27925
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925
ret: 0 st: 0 flags:1 ts:-0.240000
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 279 size: 27837
ret: 0 st: 1 flags:0 ts: 2.664490
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146121 size: 27925
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925
ret: 0 st: 1 flags:1 ts: 1.567347
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146121 size: 27925
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925
ret: 0 st:-1 flags:0 ts: 0.460008
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146121 size: 27925
ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 146329 size: 27925
ret: 0 st:-1 flags:1 ts:-0.645825
ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 279 size: 27837
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment