• Andreas Rheinhardt's avatar
    avformat/utils: Avoid copying packets unnecessarily · cdba00ae
    Andreas Rheinhardt authored
    Up until now, read_frame_internal in avformat/utils.c uses a spare
    packet on the stack that serves no real purpose: At no point in this
    function is there a need for another packet besides the packet destined
    for output:
    1. If the packet doesn't need a parser, but is output as is, the content
    of the spare packet (that at this point contains a freshly read packet)
    is simply copied into the output packet (via simple assignment, not
    av_packet_move_ref, thereby confusing ownership).
    2. If the packet needs parsing, the spare packet will be reset after
    parsing and any packets resulting from the packet read will be put into
    a packet list; the output packet is not used here at all.
    3. If the stream should be discarded, the spare packet will be
    unreferenced; the output packet is not used here at all either.
    
    Therefore the spare packet and the copies can be removed in principle.
    In practice, one more thing needs to be taken care of: If ff_read_packet
    failed, the output packet was not affected, now it is. But given that
    ff_read_packet returns a blank (as if reset via av_packet_unref) packet
    on failure, there is no problem from this side either.
    Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
    cdba00ae
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...