[FFmpeg-devel] [PATCH] aacenc: Free any extradata before re-allocating.

Hendrik Leppkes h.leppkes at gmail.com
Tue Feb 6 18:55:17 EET 2018


On Tue, Feb 6, 2018 at 5:40 PM, Josh Allmann <joshua.allmann at gmail.com> wrote:
> If the encoder has its avctx fields set by
> avcodec_parameters_to_context, then the extradata is deep-copied.

But it shouldn't have. Thats not a common pattern. What source codec
parameters would you use for an encoder? What if an encoder doesn't
actually generate any extradata (in audio, very few actually do), you
could end up writing entirely unrelated extradata (say aac extradata
with an ac3 stream), which results in all sorts of weird files.

This could be repeated for all sorts of odd fields which are not
necessarily used by every encoder. For encoding, you should allocate a
context, and set the relevant properties manually (for audio, mostly
sample rate and channel count). Everything else should remain empty.
Its not intended for another context to be copied into an encoder
context.

Every field is documented who gets to write to it, and for extradata
for encoding its the encoder, not the user, so if you write into it
for an encoding context, you are using the API wrong.

- Hendrik


More information about the ffmpeg-devel mailing list