[FFmpeg-devel] [PATCH] fftools/ffmpeg: Improve streamcopy

Michael Niedermayer michael at niedermayer.cc
Sat Oct 12 14:34:58 EEST 2019


On Fri, Oct 11, 2019 at 06:06:58AM +0200, Andreas Rheinhardt wrote:
> do_streamcopy() has a packet that gets zero-initialized first, then gets
> initialized via av_init_packet() after which some of its fields are
> oerwritten again with the actually desired values (unless it's EOF): The
> side data is copied into the packet with av_copy_packet_side_data() and
> if the source packet is refcounted, the packet will get a new reference
> to the source packet's data. Furthermore, the flags are copied and the
> timestamp related fields are overwritten with new values.
> 
> This commit replaces this by using av_packet_ref() to both initialize
> the packet as well as populate its fields with the right values (unless
> it's EOF again in which case the packet will still be initialized). The
> differences to the current approach are as follows:
> a) There is no call to a deprecated function (av_copy_packet_side_data())
> any more.
> b) Several fields that weren't copied before are now copied from the source
> packet to the new packet (e.g. pos). Some of them (the timestamp related
> fields) may be immediately overwritten again and some don't seem to be
> used at all (e.g. pos), but in return using av_packet_ref() allows to forgo
> the initializations.
> c) There was no check for whether copying side data fails or not. This
> has been changed: Now the program is exited in this case.
> 
> Using av_packet_ref() does not lead to unnecessary copying of data,
> because the source packets are already always refcounted (they originate
> from av_read_frame()).
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---
> After this patch there will be only call to av_copy_packet_side_data()
> left: In libavformat/movenc.c.
> Btw: Initializing the packet for flushing is actually unnecessary.
> 
>  fftools/ffmpeg.c | 24 +++++++-----------------
>  1 file changed, 7 insertions(+), 17 deletions(-)

will apply

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Does the universe only have a finite lifespan? No, its going to go on
forever, its just that you wont like living in it. -- Hiranya Peiri
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20191012/e1f4a597/attachment.sig>


More information about the ffmpeg-devel mailing list