• Dale Curtis's avatar
    avformat/mov: Fix trampling of ctts during seeks when sidx support is enabled. · 37e8edc9
    Dale Curtis authored
    When sidx box support is enabled, the code will skip reading all
    trun boxes (each containing ctts entries for samples inthat box).
    
    If seeks are attempted before all ctts values are known, the old
    code would dump ctts entries into the wrong location. These are
    then used to compute pts values which leads to out of order and
    incorrectly timestamped packets.
    
    This patch fixes ctts processing by always using the index returned
    by av_add_index_entry() as the ctts_data index. When the index gains
    new entries old values are reshuffled as appropriate.
    
    This approach makes sense since the mov demuxer is already relying
    on the mapping of AVIndex entries to samples for correct demuxing.
    
    As a result of this all ctts entries are now 1-count. A followup
    change will be submitted to remove support for > 1 count entries
    which will simplify seeking.
    
    Notes for future improvement:
    Probably there are other boxes (stts, stsc, etc) that are impacted
    by this issue... this patch only attempts to fix ctts since it
    completely breaks packet timestamping.
    
    This patch continues using an array for the ctts data, which is not
    the most ideal given the rearrangement that needs to happen (via
    memmove as new entries are read in). Ideally AVIndex and the ctts
    data would be set-type structures so addition is always worst case
    O(lg(n)) instead of the O(n^2) that exists now; this slowdown is
    noticeable during seeks.
    Signed-off-by: 's avatarDale Curtis <dalecurtis@chromium.org>
    Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
    37e8edc9
Name
Last commit
Last update
compat Loading commit data...
doc Loading commit data...
ffbuild Loading commit data...
libavcodec Loading commit data...
libavdevice Loading commit data...
libavfilter Loading commit data...
libavformat Loading commit data...
libavresample Loading commit data...
libavutil Loading commit data...
libpostproc Loading commit data...
libswresample Loading commit data...
libswscale Loading commit data...
presets Loading commit data...
tests Loading commit data...
tools Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.travis.yml Loading commit data...
CONTRIBUTING.md Loading commit data...
COPYING.GPLv2 Loading commit data...
COPYING.GPLv3 Loading commit data...
COPYING.LGPLv2.1 Loading commit data...
COPYING.LGPLv3 Loading commit data...
CREDITS Loading commit data...
Changelog Loading commit data...
INSTALL.md Loading commit data...
LICENSE.md Loading commit data...
MAINTAINERS Loading commit data...
Makefile Loading commit data...
README.md Loading commit data...
RELEASE Loading commit data...
cmdutils.c Loading commit data...
cmdutils.h Loading commit data...
cmdutils_opencl.c Loading commit data...
configure Loading commit data...
ffmpeg.c Loading commit data...
ffmpeg.h Loading commit data...
ffmpeg_cuvid.c Loading commit data...
ffmpeg_filter.c Loading commit data...
ffmpeg_hw.c Loading commit data...
ffmpeg_opt.c Loading commit data...
ffmpeg_qsv.c Loading commit data...
ffmpeg_videotoolbox.c Loading commit data...
ffplay.c Loading commit data...
ffprobe.c Loading commit data...
ffserver.c Loading commit data...
ffserver_config.c Loading commit data...
ffserver_config.h Loading commit data...