• Andreas Rheinhardt's avatar
    avformat/av1: Improve filtering AV1 OBUs · d4bbc0db
    Andreas Rheinhardt authored
    Both ISOBMFF as well as Matroska require certain OBUs to be stripped
    before muxing them. There are two functions for this purpose; one writes
    directly into an AVIOContext, the other returns a freshly allocated
    buffer with the undesired units stripped away.
    
    The latter one actually relies on the former by means of a dynamic
    buffer. This has several drawbacks: The underlying buffer might have to
    be reallocated multiple times; the buffer will eventually be
    overallocated; the data will not be directly copied into the final
    buffer, but rather first in the write buffer (in chunks of 1024 byte)
    and then written in these chunks. Moreover, the API for dynamic buffers
    is defective wrt error checking and as a consequence, the earlier code
    would indicate a length of -AV_INPUT_BUFFER_PADDING_SIZE on allocation
    failure, but it would not return an error; there would also be no error
    in case the arbitrary limit of INT_MAX/2 that is currently imposed on
    dynamic buffers is hit.
    
    This commit changes this: The buffer is now parsed twice, once to get
    the precise length which will then be allocated; and once to actually
    write the data.
    
    For a 22.7mb/s file with average framesize 113 kB this improved the time
    for the calls to ff_av1_filter_obus_buf() when writing Matroska from
    753662 decicycles to 313319 decicycles (based upon 50 runs a 2048 frames
    each); for another 1.5mb/s file (with average framesize of 7.3 kB) it
    improved from 79270 decicycles to 34539 decicycles (based upon 50 runs a
    4096 frames).
    Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
    Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
    d4bbc0db
Name
Last commit
Last update
compat Loading commit data...
doc Loading commit data...
ffbuild Loading commit data...
fftools 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...
configure Loading commit data...