lavc: improve AVCodecContext.extradata/subtitle_header documentation

Mention they are always owned and freed by the codec, except when using
deprecated avcodec_close().

Reported-By: DEATH on IRC
This commit is contained in:
Anton Khirnov
2024-12-05 10:52:03 +01:00
parent 92deed9732
commit 183c59b473

View File

@@ -515,16 +515,24 @@ typedef struct AVCodecContext {
int flags2; int flags2;
/** /**
* some codecs need / can use extradata like Huffman tables. * Out-of-band global headers that may be used by some codecs.
* MJPEG: Huffman tables *
* rv10: additional flags * - decoding: Should be set by the caller when available (typically from a
* MPEG-4: global headers (they can be in the bitstream or here) * demuxer) before opening the decoder; some decoders require this to be
* The allocated memory should be AV_INPUT_BUFFER_PADDING_SIZE bytes larger * set and will fail to initialize otherwise.
* than extradata_size to avoid problems if it is read with the bitstream reader. *
* The bytewise contents of extradata must not depend on the architecture or CPU endianness. * The array must be allocated with the av_malloc() family of functions;
* Must be allocated with the av_malloc() family of functions. * allocated size must be at least AV_INPUT_BUFFER_PADDING_SIZE bytes
* - encoding: Set/allocated/freed by libavcodec. * larger than extradata_size.
* - decoding: Set/allocated/freed by user. *
* - encoding: May be set by the encoder in avcodec_open2() (possibly
* depending on whether the AV_CODEC_FLAG_GLOBAL_HEADER flag is set).
*
* After being set, the array is owned by the codec and freed in
* avcodec_free_context().
*
* @warning the deprecated avcodec_close() function DOES NOT free this array
* for decoding, it must be freed manually by the caller.
*/ */
uint8_t *extradata; uint8_t *extradata;
int extradata_size; int extradata_size;
@@ -1895,8 +1903,16 @@ typedef struct AVCodecContext {
* For SUBTITLE_ASS subtitle type, it should contain the whole ASS * For SUBTITLE_ASS subtitle type, it should contain the whole ASS
* [Script Info] and [V4+ Styles] section, plus the [Events] line and * [Script Info] and [V4+ Styles] section, plus the [Events] line and
* the Format line following. It shouldn't include any Dialogue line. * the Format line following. It shouldn't include any Dialogue line.
* - encoding: Set/allocated/freed by user (before avcodec_open2()) *
* - decoding: Set/allocated/freed by libavcodec (by avcodec_open2()) * - encoding: May be set by the caller before avcodec_open2() to an array
* allocated with the av_malloc() family of functions.
* - decoding: May be set by libavcodec in avcodec_open2().
*
* After being set, the array is owned by the codec and freed in
* avcodec_free_context().
*
* @warning the deprecated avcodec_close() function DOES NOT free this array
* for encoding, it must be freed manually by the caller.
*/ */
int subtitle_header_size; int subtitle_header_size;
uint8_t *subtitle_header; uint8_t *subtitle_header;