This callback is called at the beginning of each frame to get data
buffer(s) for it. There may be one contiguous buffer for all the data or
there may be a buffer per each data plane or anything in between. What
this means is, you may set however many entries in buf[] you feel necessary.
Each buffer must be reference-counted using the AVBuffer API (see description
of buf[] below).
The following fields will be set in the frame before this callback is
called:
- format
- width, height (video only)
- sample_rate, channel_layout, nb_samples (audio only)
Their values may differ from the corresponding values in
AVCodecContext. This callback must use the frame values, not the codec
context values, to calculate the required buffer size.
This callback must fill the following fields in the frame:
- data[]
- linesize[]
- extended_data:
* if the data is planar audio with more than 8 channels, then this
callback must allocate and fill extended_data to contain all pointers
to all data planes. data[] must hold as many pointers as it can.
extended_data must be allocated with av_malloc() and will be freed in
av_frame_unref().
* otherwise exended_data must point to data
- buf[] must contain one or more pointers to AVBufferRef structures. Each of
the frame's data and extended_data pointers must be contained in these. That
is, one AVBufferRef for each allocated chunk of memory, not necessarily one
AVBufferRef per data[] entry. See: av_buffer_create(), av_buffer_alloc(),
and av_buffer_ref().
- extended_buf and nb_extended_buf must be allocated with av_malloc() by
this callback and filled with the extra buffers if there are more
buffers than buf[] can hold. extended_buf will be freed in
av_frame_unref().
If CODEC_CAP_DR1 is not set then get_buffer2() must call
avcodec_default_get_buffer2() instead of providing buffers allocated by
some other means.
Each data plane must be aligned to the maximum required by the target
CPU.
@see avcodec_default_get_buffer2()
Video:
If AV_GET_BUFFER_FLAG_REF is set in flags then the frame may be reused
(read and/or written to if it is writable) later by libavcodec.
avcodec_align_dimensions2() should be used to find the required width and
height, as they normally need to be rounded up to the next multiple of 16.
Some decoders do not support linesizes changing between frames.
If frame multithreading is used and thread_safe_callbacks is set,
this callback may be called from a different thread, but not from more
than one at once. Does not need to be reentrant.
@see avcodec_align_dimensions2()
Audio:
Decoders request a buffer of a particular size by setting
AVFrame.nb_samples prior to calling get_buffer2(). The decoder may,
however, utilize only part of the buffer by setting AVFrame.nb_samples
to a smaller value in the output frame.
As a convenience, av_samples_get_buffer_size() and
av_samples_fill_arrays() in libavutil may be used by custom get_buffer2()
functions to find the required data size and to fill data pointers and
linesize. In AVFrame.linesize, only linesize[0] may be set for audio
since all planes must be the same size.
This callback is called at the beginning of each frame to get data buffer(s) for it. There may be one contiguous buffer for all the data or there may be a buffer per each data plane or anything in between. What this means is, you may set however many entries in buf[] you feel necessary. Each buffer must be reference-counted using the AVBuffer API (see description of buf[] below).
The following fields will be set in the frame before this callback is called: - format - width, height (video only) - sample_rate, channel_layout, nb_samples (audio only) Their values may differ from the corresponding values in AVCodecContext. This callback must use the frame values, not the codec context values, to calculate the required buffer size.
This callback must fill the following fields in the frame: - data[] - linesize[] - extended_data: * if the data is planar audio with more than 8 channels, then this callback must allocate and fill extended_data to contain all pointers to all data planes. data[] must hold as many pointers as it can. extended_data must be allocated with av_malloc() and will be freed in av_frame_unref(). * otherwise exended_data must point to data - buf[] must contain one or more pointers to AVBufferRef structures. Each of the frame's data and extended_data pointers must be contained in these. That is, one AVBufferRef for each allocated chunk of memory, not necessarily one AVBufferRef per data[] entry. See: av_buffer_create(), av_buffer_alloc(), and av_buffer_ref(). - extended_buf and nb_extended_buf must be allocated with av_malloc() by this callback and filled with the extra buffers if there are more buffers than buf[] can hold. extended_buf will be freed in av_frame_unref().
If CODEC_CAP_DR1 is not set then get_buffer2() must call avcodec_default_get_buffer2() instead of providing buffers allocated by some other means.
Each data plane must be aligned to the maximum required by the target CPU.
@see avcodec_default_get_buffer2()
Video:
If AV_GET_BUFFER_FLAG_REF is set in flags then the frame may be reused (read and/or written to if it is writable) later by libavcodec.
avcodec_align_dimensions2() should be used to find the required width and height, as they normally need to be rounded up to the next multiple of 16.
Some decoders do not support linesizes changing between frames.
If frame multithreading is used and thread_safe_callbacks is set, this callback may be called from a different thread, but not from more than one at once. Does not need to be reentrant.
@see avcodec_align_dimensions2()
Audio:
Decoders request a buffer of a particular size by setting AVFrame.nb_samples prior to calling get_buffer2(). The decoder may, however, utilize only part of the buffer by setting AVFrame.nb_samples to a smaller value in the output frame.
As a convenience, av_samples_get_buffer_size() and av_samples_fill_arrays() in libavutil may be used by custom get_buffer2() functions to find the required data size and to fill data pointers and linesize. In AVFrame.linesize, only linesize[0] may be set for audio since all planes must be the same size.
@see av_samples_get_buffer_size(), av_samples_fill_arrays()
- encoding: unused - decoding: Set by libavcodec, user can override.