[FFmpeg-devel] [libav-devel] [PATCH 1/4] avcodec/a64multienc: use av_frame_ref instead of copying the frame

Andreas Cadhalpun andreas.cadhalpun at googlemail.com
Mon Feb 23 18:15:49 CET 2015

On 23.02.2015 16:06, Luca Barbato wrote:
> On 23/02/15 16:02, Andreas Cadhalpun wrote:
>> Why should coded_frame be allocated? Is this documented somewhere?
> In the doxygen documentation.

It's a bit terse:
  the picture in the bitstream
  - encoding: Set by libavcodec.
  - decoding: unused

>> It seems many audio encoders don't do that, as well as e.g.
>> libopenh264enc and libwebpenc.
> Either the documentation or the encoders should be fixed.

The documentation could definitely be improved by making it clearer, 
when coded_frame has to be allocated.

Note that usage of coded_frame was removed from most audio codecs in 
commit f073b1500e3b53835034b7421db0a1cf5bea05a0:
lavc: remove disabled FF_API_OLD_ENCODE_AUDIO cruft

So the documentation should probably say that it's only required to be 
set for video codecs. Attached is a patch for that.

Ensuring this rule could be done with a dummy codec_frame as Michael 
suggests [1].

>> Anyway, the memleak can also be fixed by adding av_frame_unref(p) before
>> the av_frame_ref.
> I was guessing right then =)

Indeed. =)

Best regards,

1: https://ffmpeg.org/pipermail/ffmpeg-devel/2015-February/169247.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-doc-clarify-when-codec_frame-must-be-allocated.patch
Type: text/x-diff
Size: 814 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150223/2604513f/attachment.bin>

More information about the ffmpeg-devel mailing list