• Andreas Rheinhardt's avatar
    avformat/oggenc: Avoid allocating and copying when writing page data · d0bd00c8
    Andreas Rheinhardt authored
    When the Ogg muxer writes a page, it has to do three things: It needs to
    write a page header, then it has to actually copy the page data and then
    it has to calculate and write a CRC checksum of both header as well as
    data at a certain position in the page header.
    
    To do this, the muxer used a dynamic buffer for both writing as well as
    calculating the checksum via an AVIOContext's feature to automatically
    calculate checksums on the data it writes. This entails an allocation of
    an AVIOContext, of the opaque specific to dynamic buffers and of the
    buffer itself (which may be reallocated multiple times) as well as
    memcopying the data (first into the AVIOContext's small write buffer,
    then into the dynamic buffer's big buffer).
    
    This commit changes this: The page header is no longer written into a
    dynamic buffer any more; instead the (small) page header is written into
    a small buffer on the stack. The CRC is then calculated directly via
    av_crc() on both the page header as well as the page data. Then both the
    page header and the page data are written.
    
    Finally, ogg_write_page() can now no longer fail, so it has been
    modified to return nothing; this also fixed a bug in the only caller of
    this function: It didn't check the return value.
    Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
    d0bd00c8
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...
.mailmap 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...