]> git.sesse.net Git - ffmpeg/commit
lavf/mov.c: offset index timestamps by the minimum pts to make first pts zero
authorSasi Inguva <isasi-at-google.com@ffmpeg.org>
Tue, 6 Jun 2017 18:16:01 +0000 (11:16 -0700)
committerwm4 <nfxjfg@googlemail.com>
Fri, 9 Jun 2017 16:13:33 +0000 (18:13 +0200)
commit93db5e3fc41ac0242acab86c3e4ce3a3dfb80075
treead11fafe326ae8c1299dd5f079824350d6403e85
parentc12e8f5f0b412fde9b0c3cf4ca7039ee82461139
lavf/mov.c: offset index timestamps by the minimum pts to make first pts zero

If the videos starts with B frame, then the minimum composition time
as computed by stts + ctts will be non-zero. Hence we need to shift
the DTS, so that the first pts is zero. This was the intention of that
code-block. However it was subtracting by the wrong amount.

For example, for one of the videos in the bug nonFormatted.mp4 we have

stts:
sample_count  duration
960           1001

ctts:
sample_count  duration
1             3003
2             0
1             3003
....

The resulting composition times are :  3003, 1001, 2002, 6006, ...

The minimum composition time or PTS is 1001, which should be used to
offset DTS. However the code block was wrongly using ctts[0] which is
3003. Hence the PTS was negative. This change computes the minimum pts
encountered while fixing the index, and then subtracts it from all the
timestamps after the edit list fixes are applied.

Samples files available from:

https://bugs.chromium.org/p/chromium/issues/detail?id=721451
https://bugs.chromium.org/p/chromium/issues/detail?id=723537

fate-suite/h264/twofields_packet.mp4 is a similar file starting with 2
B frames. Before this change the PTS of first two B-frames was -6006
and -3003, and I am guessing one of them got dropped when being decoded
and remuxed  to the framecrc before, and now it is not being dropped.

Signed-off-by: Sasi Inguva <isasi@google.com>
libavformat/mov.c
tests/ref/fate/h264-twofields-packet