Loading...
Searching...
No Matches
AVFrame
libavutil » Data Structures

AVFrame is an abstraction for reference-counted raw multimedia data. More...

## Topics

| AV_FRAME_FLAGS
| Flags describing additional frame properties.

## Files

file | frame.h
| reference-counted frame API

## Data Structures

struct | AVFrameSideData
| Structure to hold side data for an AVFrame. More...
struct | AVSideDataDescriptor
| This struct describes the properties of a side data type. More...
struct | AVRegionOfInterest
| Structure describing a single Region Of Interest. More...
struct | AVFrame
| This structure describes decoded (raw) audio or video data. More...

## Macros

#define | AV_FRAME_SIDE_DATA_FLAG_UNIQUE (1 << 0)
| Remove existing entries before adding new ones.
#define | AV_FRAME_SIDE_DATA_FLAG_REPLACE (1 << 1)
| Don't add a new entry if another of the same type exists.
#define | AV_FRAME_SIDE_DATA_FLAG_NEW_REF (1 << 2)
| Create a new reference to the passed in buffer instead of taking ownership of it.

## Enumerations

enum

AVFrameSideDataType {
AV_FRAME_DATA_PANSCAN , AV_FRAME_DATA_A53_CC , AV_FRAME_DATA_STEREO3D , AV_FRAME_DATA_MATRIXENCODING ,
AV_FRAME_DATA_DOWNMIX_INFO , AV_FRAME_DATA_REPLAYGAIN , AV_FRAME_DATA_DISPLAYMATRIX , AV_FRAME_DATA_AFD ,
AV_FRAME_DATA_MOTION_VECTORS , AV_FRAME_DATA_SKIP_SAMPLES , AV_FRAME_DATA_AUDIO_SERVICE_TYPE , AV_FRAME_DATA_MASTERING_DISPLAY_METADATA ,
AV_FRAME_DATA_GOP_TIMECODE , AV_FRAME_DATA_SPHERICAL , AV_FRAME_DATA_CONTENT_LIGHT_LEVEL , AV_FRAME_DATA_ICC_PROFILE ,
AV_FRAME_DATA_S12M_TIMECODE , AV_FRAME_DATA_DYNAMIC_HDR_PLUS , AV_FRAME_DATA_REGIONS_OF_INTEREST , AV_FRAME_DATA_VIDEO_ENC_PARAMS ,
AV_FRAME_DATA_SEI_UNREGISTERED , AV_FRAME_DATA_FILM_GRAIN_PARAMS , AV_FRAME_DATA_DETECTION_BBOXES , AV_FRAME_DATA_DOVI_RPU_BUFFER ,
AV_FRAME_DATA_DOVI_METADATA , AV_FRAME_DATA_DYNAMIC_HDR_VIVID , AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT , AV_FRAME_DATA_VIDEO_HINT ,
AV_FRAME_DATA_LCEVC , AV_FRAME_DATA_VIEW_ID , AV_FRAME_DATA_3D_REFERENCE_DISPLAYS
}

enum | AVActiveFormatDescription { AV_AFD_SAME = 8 , AV_AFD_4_3 = 9 , AV_AFD_16_9 = 10 , AV_AFD_14_9 = 11 , AV_AFD_4_3_SP_14_9 = 13 , AV_AFD_16_9_SP_14_9 = 14 , AV_AFD_SP_4_3 = 15 }
enum | AVSideDataProps { AV_SIDE_DATA_PROP_GLOBAL = (1 << 0) , AV_SIDE_DATA_PROP_MULTI = (1 << 1) , AV_SIDE_DATA_PROP_SIZE_DEPENDENT = (1 << 2) , AV_SIDE_DATA_PROP_COLOR_DEPENDENT = (1 << 3) , AV_SIDE_DATA_PROP_CHANNEL_DEPENDENT = (1 << 4) }
enum | { AV_FRAME_CROP_UNALIGNED = 1 << 0 }
| Flags for frame cropping. More...

## Functions

AVFrame * | av_frame_alloc (void)
| Allocate an AVFrame and set its fields to default values.
void | av_frame_free (AVFrame **frame)
| Free the frame and any dynamically allocated objects in it, e.g.
int | av_frame_ref (AVFrame *dst, const AVFrame *src)
| Set up a new reference to the data described by the source frame.
int | av_frame_replace (AVFrame *dst, const AVFrame *src)
| Ensure the destination frame refers to the same data described by the source frame, either by creating a new reference for each AVBufferRef from src if they differ from those in dst, by allocating new buffers and copying data if src is not reference counted, or by unrefencing it if src is empty.
AVFrame * | av_frame_clone (const AVFrame *src)
| Create a new frame that references the same data as src.
void | av_frame_unref (AVFrame *frame)
| Unreference all the buffers referenced by frame and reset the frame fields.
void | av_frame_move_ref (AVFrame *dst, AVFrame *src)
| Move everything contained in src to dst and reset src.
int | av_frame_get_buffer (AVFrame *frame, int align)
| Allocate new buffer(s) for audio or video data.
int | av_frame_is_writable (AVFrame *frame)
| Check if the frame data is writable.
int | av_frame_make_writable (AVFrame *frame)
| Ensure that the frame data is writable, avoiding data copy if possible.
int | av_frame_copy (AVFrame *dst, const AVFrame *src)
| Copy the frame data from src to dst.
int | av_frame_copy_props (AVFrame *dst, const AVFrame *src)
| Copy only "metadata" fields from src to dst.
AVBufferRef * | av_frame_get_plane_buffer (const AVFrame *frame, int plane)
| Get the buffer reference a given data plane is stored in.
AVFrameSideData * | av_frame_new_side_data (AVFrame *frame, enum AVFrameSideDataType type, size_t size)
| Add a new side data to a frame.
AVFrameSideData * | av_frame_new_side_data_from_buf (AVFrame *frame, enum AVFrameSideDataType type, AVBufferRef *buf)
| Add a new side data to a frame from an existing AVBufferRef.
AVFrameSideData * | av_frame_get_side_data (const AVFrame *frame, enum AVFrameSideDataType type)
void | av_frame_remove_side_data (AVFrame *frame, enum AVFrameSideDataType type)
| Remove and free all side data instances of the given type.
int | av_frame_apply_cropping (AVFrame *frame, int flags)
| Crop the given video AVFrame according to its crop_left/crop_top/crop_right/ crop_bottom fields.
const char * | av_frame_side_data_name (enum AVFrameSideDataType type)
const AVSideDataDescriptor * | av_frame_side_data_desc (enum AVFrameSideDataType type)
void | av_frame_side_data_free (AVFrameSideData ***sd, int *nb_sd)
| Free all side data entries and their contents, then zeroes out the values which the pointers are pointing to.
AVFrameSideData * | av_frame_side_data_new (AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type, size_t size, unsigned int flags)
| Add new side data entry to an array.
AVFrameSideData * | av_frame_side_data_add (AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type, AVBufferRef **buf, unsigned int flags)
| Add a new side data entry to an array from an existing AVBufferRef.
int | av_frame_side_data_clone (AVFrameSideData ***sd, int *nb_sd, const AVFrameSideData *src, unsigned int flags)
| Add a new side data entry to an array based on existing side data, taking a reference towards the contained AVBufferRef.
const AVFrameSideData * | av_frame_side_data_get_c (const AVFrameSideData *const *sd, const int nb_sd, enum AVFrameSideDataType type)
| Get a side data entry of a specific type from an array.
static const AVFrameSideData * | av_frame_side_data_get (AVFrameSideData *const *sd, const int nb_sd, enum AVFrameSideDataType type)
| Wrapper around av_frame_side_data_get_c() to workaround the limitation that for any type T the conversion from T * const * to const T * const * is not performed automatically in C.
void | av_frame_side_data_remove (AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type)
| Remove and free all side data instances of the given type from an array.
void | av_frame_side_data_remove_by_props (AVFrameSideData ***sd, int *nb_sd, int props)
| Remove and free all side data instances that match any of the given side data properties.

## Detailed Description

AVFrame is an abstraction for reference-counted raw multimedia data.

## Macro Definition Documentation

## AV_FRAME_SIDE_DATA_FLAG_UNIQUE

#define AV_FRAME_SIDE_DATA_FLAG_UNIQUE (1 << 0)

Remove existing entries before adding new ones.

Definition at line 1035 of file frame.h.

## AV_FRAME_SIDE_DATA_FLAG_REPLACE

#define AV_FRAME_SIDE_DATA_FLAG_REPLACE (1 << 1)

Don't add a new entry if another of the same type exists.

Applies only for side data types without the AV_SIDE_DATA_PROP_MULTI prop.

Definition at line 1040 of file frame.h.

## AV_FRAME_SIDE_DATA_FLAG_NEW_REF

#define AV_FRAME_SIDE_DATA_FLAG_NEW_REF (1 << 2)

Create a new reference to the passed in buffer instead of taking ownership of it.

Definition at line 1045 of file frame.h.

## Enumeration Type Documentation

## AVFrameSideDataType

enum AVFrameSideDataType

Enumerator
AV_FRAME_DATA_PANSCAN | The data is the AVPanScan struct defined in libavcodec.
AV_FRAME_DATA_A53_CC | ATSC A53 Part 4 Closed Captions. A53 CC bitstream is stored as uint8_t in AVFrameSideData.data. The number of bytes of CC data is AVFrameSideData.size.
AV_FRAME_DATA_STEREO3D | Stereoscopic 3d metadata. The data is the AVStereo3D struct defined in libavutil/stereo3d.h.
AV_FRAME_DATA_MATRIXENCODING | The data is the AVMatrixEncoding enum defined in libavutil/channel_layout.h.
AV_FRAME_DATA_DOWNMIX_INFO | Metadata relevant to a downmix procedure. The data is the AVDownmixInfo struct defined in libavutil/downmix_info.h.
AV_FRAME_DATA_REPLAYGAIN | ReplayGain information in the form of the AVReplayGain struct.
AV_FRAME_DATA_DISPLAYMATRIX | This side data contains a 3x3 transformation matrix describing an affine transformation that needs to be applied to the frame for correct presentation. See libavutil/display.h for a detailed description of the data.
AV_FRAME_DATA_AFD | Active Format Description data consisting of a single byte as specified in ETSI TS 101 154 using AVActiveFormatDescription enum.
AV_FRAME_DATA_MOTION_VECTORS | Motion vectors exported by some codecs (on demand through the export_mvs flag set in the libavcodec AVCodecContext flags2 option). The data is the AVMotionVector struct defined in libavutil/motion_vector.h.

AV_FRAME_DATA_SKIP_SAMPLES

Recommends skipping the specified number of samples.

This is exported only if the "skip_manual" AVOption is set in libavcodec. This has the same format as AV_PKT_DATA_SKIP_SAMPLES.

u32le number of samples to skip from start of this packet
u32le number of samples to skip from end of this packet
u8 reason for start skip
u8 reason for end skip (0=padding silence, 1=convergence)

AV_FRAME_DATA_AUDIO_SERVICE_TYPE | This side data must be associated with an audio frame and corresponds to enum AVAudioServiceType defined in avcodec.h.
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA | Mastering display metadata associated with a video frame. The payload is an AVMasteringDisplayMetadata type and contains information about the mastering display color volume.
AV_FRAME_DATA_GOP_TIMECODE | The GOP timecode in 25 bit timecode format. Data format is 64-bit integer. This is set on the first frame of a GOP that has a temporal reference of 0.
AV_FRAME_DATA_SPHERICAL | The data represents the AVSphericalMapping structure defined in libavutil/spherical.h.
AV_FRAME_DATA_CONTENT_LIGHT_LEVEL | Content light level (based on CTA-861.3). This payload contains data in the form of the AVContentLightMetadata struct.
AV_FRAME_DATA_ICC_PROFILE | The data contains an ICC profile as an opaque octet buffer following the format described by ISO 15076-1 with an optional name defined in the metadata key entry "name".
AV_FRAME_DATA_S12M_TIMECODE | Timecode which conforms to SMPTE ST 12-1. The data is an array of 4 uint32_t where the first uint32_t describes how many (1-3) of the other timecodes are used. The timecode format is described in the documentation of av_timecode_get_smpte_from_framenum() function in libavutil/timecode.h.
AV_FRAME_DATA_DYNAMIC_HDR_PLUS | HDR dynamic metadata associated with a video frame. The payload is an AVDynamicHDRPlus type and contains information for color volume transform - application 4 of SMPTE 2094-40:2016 standard.
AV_FRAME_DATA_REGIONS_OF_INTEREST | Regions Of Interest, the data is an array of AVRegionOfInterest type, the number of array element is implied by AVFrameSideData.size / AVRegionOfInterest.self_size.
AV_FRAME_DATA_VIDEO_ENC_PARAMS | Encoding parameters for a video frame, as described by AVVideoEncParams.
AV_FRAME_DATA_SEI_UNREGISTERED | User data unregistered metadata associated with a video frame. This is the H.26[45] UDU SEI message, and shouldn't be used for any other purpose The data is stored as uint8_t in AVFrameSideData.data which is 16 bytes of uuid_iso_iec_11578 followed by AVFrameSideData.size - 16 bytes of user_data_payload_byte.
AV_FRAME_DATA_FILM_GRAIN_PARAMS | Film grain parameters for a frame, described by AVFilmGrainParams. Must be present for every frame which should have film grain applied. May be present multiple times, for example when there are multiple alternative parameter sets for different video signal characteristics. The user should select the most appropriate set for the application.
AV_FRAME_DATA_DETECTION_BBOXES | Bounding boxes for object detection and classification, as described by AVDetectionBBoxHeader.
AV_FRAME_DATA_DOVI_RPU_BUFFER | Dolby Vision RPU raw data, suitable for passing to x265 or other libraries. Array of uint8_t, with NAL emulation bytes intact.
AV_FRAME_DATA_DOVI_METADATA | Parsed Dolby Vision metadata, suitable for passing to a software implementation. The payload is the AVDOVIMetadata struct defined in libavutil/dovi_meta.h.
AV_FRAME_DATA_DYNAMIC_HDR_VIVID | HDR Vivid dynamic metadata associated with a video frame. The payload is an AVDynamicHDRVivid type and contains information for color volume transform - CUVA 005.1-2021.
AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT | Ambient viewing environment metadata, as defined by H.274.
AV_FRAME_DATA_VIDEO_HINT | Provide encoder-specific hinting information about changed/unchanged portions of a frame. It can be used to pass information about which macroblocks can be skipped because they didn't change from the corresponding ones in the previous frame. This could be useful for applications which know this information in advance to speed up encoding.
AV_FRAME_DATA_LCEVC | Raw LCEVC payload data, as a uint8_t array, with NAL emulation bytes intact.
AV_FRAME_DATA_VIEW_ID | This side data must be associated with a video frame. The presence of this side data indicates that the video stream is composed of multiple views (e.g. stereoscopic 3D content, cf. H.264 Annex H or H.265 Annex G). The data is an int storing the view ID.

AV_FRAME_DATA_3D_REFERENCE_DISPLAYS

This side data contains information about the reference display width(s) and reference viewing distance(s) as well as information about the corresponding reference stereo pair(s), i.e., the pair(s) of views to be displayed for the viewer's left and right eyes on the reference display at the reference viewing distance.

The payload is the AV3DReferenceDisplaysInfo struct defined in libavutil/tdrdi.h.

Definition at line 49 of file frame.h.

## AVActiveFormatDescription

enum AVActiveFormatDescription

Enumerator
AV_AFD_SAME |
AV_AFD_4_3 |
AV_AFD_16_9 |
AV_AFD_14_9 |
AV_AFD_4_3_SP_14_9 |
AV_AFD_16_9_SP_14_9 |
AV_AFD_SP_4_3 |

Definition at line 259 of file frame.h.

## AVSideDataProps

enum AVSideDataProps

Enumerator
AV_SIDE_DATA_PROP_GLOBAL | The side data type can be used in stream-global structures. Side data types without this property are only meaningful on per-frame basis.
AV_SIDE_DATA_PROP_MULTI | Multiple instances of this side data type can be meaningfully present in a single side data array.
AV_SIDE_DATA_PROP_SIZE_DEPENDENT | Side data depends on the video dimensions. Side data with this property loses its meaning when rescaling or cropping the image, unless either recomputed or adjusted to the new resolution.
AV_SIDE_DATA_PROP_COLOR_DEPENDENT | Side data depends on the video color space. Side data with this property loses its meaning when changing the video color encoding, e.g. by adapting to a different set of primaries or transfer characteristics.
AV_SIDE_DATA_PROP_CHANNEL_DEPENDENT | Side data depends on the channel layout. Side data with this property loses its meaning when downmixing or upmixing, unless either recomputed or adjusted to the new layout.

Definition at line 284 of file frame.h.

## anonymous enum

anonymous enum

Flags for frame cropping.

Enumerator

AV_FRAME_CROP_UNALIGNED

Apply the maximum possible cropping, even if it requires setting the AVFrame.data[] entries to unaligned pointers.

Passing unaligned data to FFmpeg API is generally not allowed, and causes undefined behavior (such as crashes). You can pass unaligned data only to FFmpeg APIs that are explicitly documented to accept it. Use this flag only if you absolutely know what you are doing.

Definition at line 980 of file frame.h.

## Function Documentation

## av_frame_alloc()

AVFrame * av_frame_alloc | ( | void |  | ) |

Allocate an AVFrame and set its fields to default values.

The resulting struct must be freed using av_frame_free().

Returns
  An AVFrame filled with default values or NULL on failure.

Note
  this only allocates the AVFrame itself, not the data buffers. Those must be allocated through other means, e.g. with av_frame_get_buffer() or manually.

Examples
  decode_audio.c, decode_filter_audio.c, decode_filter_video.c, decode_video.c, demux_decode.c, encode_audio.c, encode_video.c, extract_mvs.c, filter_audio.c, hw_decode.c, mux.c, qsv_decode.c, qsv_transcode.c, transcode.c, transcode_aac.c, vaapi_encode.c, and vaapi_transcode.c.

Referenced by alloc_audio_frame(), alloc_frame(), dec_enc(), dec_enc(), decode_write(), init_filters(), init_input_frame(), init_output_frame(), main(), main(), and open_input_file().

## av_frame_free()

void av_frame_free | ( | AVFrame ** | frame | ) |

Free the frame and any dynamically allocated objects in it, e.g.

extended_data. If the frame is reference counted, it will be unreferenced first.

Parameters

  frame | frame to be freed. The pointer will be set to NULL.

Examples
  decode_audio.c, decode_filter_audio.c, decode_filter_video.c, decode_video.c, demux_decode.c, encode_audio.c, encode_video.c, extract_mvs.c, filter_audio.c, hw_decode.c, mux.c, qsv_decode.c, qsv_transcode.c, transcode.c, transcode_aac.c, vaapi_encode.c, and vaapi_transcode.c.

Referenced by close_stream(), dec_enc(), dec_enc(), decode_write(), init_output_frame(), load_encode_and_write(), main(), main(), and read_decode_convert_and_store().

## av_frame_ref()

int av_frame_ref | ( | AVFrame * | dst,
|  | const AVFrame * | src )

Set up a new reference to the data described by the source frame.

Copy frame properties from src to dst and create a new reference for each AVBufferRef from src.

If src is not reference counted, new buffers are allocated and the data is copied.

Warning
  : dst MUST have been either unreferenced with av_frame_unref(dst), or newly allocated with av_frame_alloc() before calling this function, or undefined behavior will occur.

Returns
  0 on success, a negative AVERROR on error

## av_frame_replace()

int av_frame_replace | ( | AVFrame * | dst,
|  | const AVFrame * | src )

Ensure the destination frame refers to the same data described by the source frame, either by creating a new reference for each AVBufferRef from src if they differ from those in dst, by allocating new buffers and copying data if src is not reference counted, or by unrefencing it if src is empty.

Frame properties on dst will be replaced by those from src.

Returns
  0 on success, a negative AVERROR on error. On error, dst is unreferenced.

## av_frame_clone()

AVFrame * av_frame_clone | ( | const AVFrame * | src | ) |

Create a new frame that references the same data as src.

This is a shortcut for av_frame_alloc()+av_frame_ref().

Returns
  newly created AVFrame on success, NULL on error.

## av_frame_unref()

void av_frame_unref | ( | AVFrame * | frame | ) |

Unreference all the buffers referenced by frame and reset the frame fields.

Examples
  decode_filter_audio.c, decode_filter_video.c, demux_decode.c, extract_mvs.c, filter_audio.c, qsv_decode.c, and transcode.c.

Referenced by decode_packet(), decode_packet(), decode_packet(), filter_encode_write_frame(), main(), and main().

## av_frame_move_ref()

void av_frame_move_ref | ( | AVFrame * | dst,
|  | AVFrame * | src )

Move everything contained in src to dst and reset src.

Warning
  : dst is not unreferenced, but directly overwritten without reading or deallocating its contents. Call av_frame_unref(dst) manually before calling this function to ensure that no memory is leaked.

## av_frame_get_buffer()

int av_frame_get_buffer | ( | AVFrame * | frame,
|  | int | align )

Allocate new buffer(s) for audio or video data.

The following fields must be set on frame before calling this function:

- format (pixel format for video, sample format for audio)
- width and height for video
- nb_samples and ch_layout for audio

This function will fill AVFrame.data and AVFrame.buf arrays and, if necessary, allocate and fill AVFrame.extended_data and AVFrame.extended_buf. For planar formats, one buffer will be allocated for each plane.

Warning
  : if frame already has been allocated, calling this function will leak memory. In addition, undefined behavior can occur in certain cases.

Parameters

  frame | frame in which to store the new buffers.
  align | Required buffer size and data pointer alignment. If equal to 0, alignment will be chosen automatically for the current CPU. It is highly recommended to pass 0 here unless you know what you are doing.

Returns
  0 on success, a negative AVERROR on error.

Examples
  encode_audio.c, encode_video.c, filter_audio.c, mux.c, transcode_aac.c, and vaapi_encode.c.

Referenced by alloc_audio_frame(), alloc_frame(), get_input(), init_output_frame(), main(), and main().

## av_frame_is_writable()

int av_frame_is_writable | ( | AVFrame * | frame | ) |

Check if the frame data is writable.

Returns
  A positive value if the frame data is writable (which is true if and only if each of the underlying buffers has only one reference, namely the one stored in this frame). Return 0 otherwise.

If 1 is returned the answer is valid until av_buffer_ref() is called on any of the underlying AVBufferRefs (e.g. through av_frame_ref() or directly).

See also
  av_frame_make_writable(), av_buffer_is_writable()

## av_frame_make_writable()

int av_frame_make_writable | ( | AVFrame * | frame | ) |

Ensure that the frame data is writable, avoiding data copy if possible.

Do nothing if the frame is writable, allocate new buffers and copy the data if it is not. Non-refcounted frames behave as non-writable, i.e. a copy is always made.

Returns
  0 on success, a negative AVERROR on error.

See also
  av_frame_is_writable(), av_buffer_is_writable(), av_buffer_make_writable()

Examples
  encode_audio.c, encode_video.c, and mux.c.

Referenced by get_video_frame(), main(), and write_audio_frame().

## av_frame_copy()

int av_frame_copy | ( | AVFrame * | dst,
|  | const AVFrame * | src )

Copy the frame data from src to dst.

This function does not allocate anything, dst must be already initialized and allocated with the same parameters as src.

This function only copies the frame data (i.e. the contents of the data / extended data arrays), not any other properties.

Returns
  >= 0 on success, a negative AVERROR on error.

## av_frame_copy_props()

int av_frame_copy_props | ( | AVFrame * | dst,
|  | const AVFrame * | src )

Copy only "metadata" fields from src to dst.

Metadata for the purpose of this function are those fields that do not affect the data layout in the buffers. E.g. pts, sample rate (for audio) or sample aspect ratio (for video), but not width/height or channel layout. Side data is also copied.

## av_frame_get_plane_buffer()

AVBufferRef * av_frame_get_plane_buffer | ( | const AVFrame * | frame,
|  | int | plane )

Get the buffer reference a given data plane is stored in.

Parameters

  frame | the frame to get the plane's buffer from
  plane | index of the data plane of interest in frame->extended_data.

Returns
  the buffer reference that contains the plane or NULL if the input frame is not valid.

## av_frame_new_side_data()

AVFrameSideData * av_frame_new_side_data | ( | AVFrame * | frame,
|  | enum AVFrameSideDataType | type,
|  | size_t | size )

Add a new side data to a frame.

Parameters

  frame | a frame to which the side data should be added
  type | type of the added side data
  size | size of the side data

Returns
  newly added side data on success, NULL on error

## av_frame_new_side_data_from_buf()

AVFrameSideData * av_frame_new_side_data_from_buf | ( | AVFrame * | frame,
|  | enum AVFrameSideDataType | type,
|  | AVBufferRef * | buf )

Add a new side data to a frame from an existing AVBufferRef.

Parameters

  frame | a frame to which the side data should be added
  type | the type of the added side data
  buf | an AVBufferRef to add as side data. The ownership of the reference is transferred to the frame.

Returns
  newly added side data on success, NULL on error. On failure the frame is unchanged and the AVBufferRef remains owned by the caller.

## av_frame_get_side_data()

AVFrameSideData * av_frame_get_side_data | ( | const AVFrame * | frame,
|  | enum AVFrameSideDataType | type )

Returns
  a pointer to the side data of a given type on success, NULL if there is no side data with such type in this frame.

Examples
  extract_mvs.c.

Referenced by decode_packet().

## av_frame_remove_side_data()

void av_frame_remove_side_data | ( | AVFrame * | frame,
|  | enum AVFrameSideDataType | type )

Remove and free all side data instances of the given type.

## av_frame_apply_cropping()

int av_frame_apply_cropping | ( | AVFrame * | frame,
|  | int | flags )

Crop the given video AVFrame according to its crop_left/crop_top/crop_right/ crop_bottom fields.

If cropping is successful, the function will adjust the data pointers and the width/height fields, and set the crop fields to 0.

In all cases, the cropping boundaries will be rounded to the inherent alignment of the pixel format. In some cases, such as for opaque hwaccel formats, the left/top cropping is ignored. The crop fields are set to 0 even if the cropping was rounded or ignored.

Parameters

  frame | the frame which should be cropped
  flags | Some combination of AV_FRAME_CROP_* flags, or 0.

Returns
  >= 0 on success, a negative AVERROR on error. If the cropping fields were invalid, AVERROR(ERANGE) is returned, and nothing is changed.

## av_frame_side_data_name()

const char * av_frame_side_data_name | ( | enum AVFrameSideDataType | type | ) |

Returns
  a string identifying the side data type

## av_frame_side_data_desc()

const AVSideDataDescriptor * av_frame_side_data_desc | ( | enum AVFrameSideDataType | type | ) |

Returns
  side data descriptor corresponding to a given side data type, NULL when not available.

## av_frame_side_data_free()

void av_frame_side_data_free | ( | AVFrameSideData *** | sd,
|  | int * | nb_sd )

Free all side data entries and their contents, then zeroes out the values which the pointers are pointing to.

Parameters

  sd | pointer to array of side data to free. Will be set to NULL upon return.
  nb_sd | pointer to an integer containing the number of entries in the array. Will be set to 0 upon return.

## av_frame_side_data_new()

AVFrameSideData * av_frame_side_data_new | ( | AVFrameSideData *** | sd,
|  | int * | nb_sd,
|  | enum AVFrameSideDataType | type,
|  | size_t | size,
|  | unsigned int | flags )

Add new side data entry to an array.

Parameters

  sd | pointer to array of side data to which to add another entry, or to NULL in order to start a new array.
  nb_sd | pointer to an integer containing the number of entries in the array.
  type | type of the added side data
  size | size of the side data
  flags | Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0.

Returns
  newly added side data on success, NULL on error.

Note
  In case of AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of matching AVFrameSideDataType will be removed before the addition is attempted.
  In case of AV_FRAME_SIDE_DATA_FLAG_REPLACE being set, if an entry of the same type already exists, it will be replaced instead.

## av_frame_side_data_add()

AVFrameSideData * av_frame_side_data_add | ( | AVFrameSideData *** | sd,
|  | int * | nb_sd,
|  | enum AVFrameSideDataType | type,
|  | AVBufferRef ** | buf,
|  | unsigned int | flags )

Add a new side data entry to an array from an existing AVBufferRef.

Parameters

  sd | pointer to array of side data to which to add another entry, or to NULL in order to start a new array.
  nb_sd | pointer to an integer containing the number of entries in the array.
  type | type of the added side data
  buf | Pointer to AVBufferRef to add to the array. On success, the function takes ownership of the AVBufferRef and *buf is set to NULL, unless AV_FRAME_SIDE_DATA_FLAG_NEW_REF is set in which case the ownership will remain with the caller.
  flags | Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0.

Returns
  newly added side data on success, NULL on error.

Note
  In case of AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of matching AVFrameSideDataType will be removed before the addition is attempted.
  In case of AV_FRAME_SIDE_DATA_FLAG_REPLACE being set, if an entry of the same type already exists, it will be replaced instead.

## av_frame_side_data_clone()

int av_frame_side_data_clone | ( | AVFrameSideData *** | sd,
|  | int * | nb_sd,
|  | const AVFrameSideData * | src,
|  | unsigned int | flags )

Add a new side data entry to an array based on existing side data, taking a reference towards the contained AVBufferRef.

Parameters

  sd | pointer to array of side data to which to add another entry, or to NULL in order to start a new array.
  nb_sd | pointer to an integer containing the number of entries in the array.
  src | side data to be cloned, with a new reference utilized for the buffer.
  flags | Some combination of AV_FRAME_SIDE_DATA_FLAG_* flags, or 0.

Returns
  negative error code on failure, >=0 on success.

Note
  In case of AV_FRAME_SIDE_DATA_FLAG_UNIQUE being set, entries of matching AVFrameSideDataType will be removed before the addition is attempted.
  In case of AV_FRAME_SIDE_DATA_FLAG_REPLACE being set, if an entry of the same type already exists, it will be replaced instead.

## av_frame_side_data_get_c()

const AVFrameSideData * av_frame_side_data_get_c | ( | const AVFrameSideData *const * | sd,
|  | const int | nb_sd,
|  | enum AVFrameSideDataType | type )

Get a side data entry of a specific type from an array.

Parameters

  sd | array of side data.
  nb_sd | integer containing the number of entries in the array.
  type | type of side data to be queried

Returns
  a pointer to the side data of a given type on success, NULL if there is no side data with such type in this set.

Referenced by av_frame_side_data_get().

## av_frame_side_data_get()

const AVFrameSideData * av_frame_side_data_get | ( | AVFrameSideData *const * | sd,
|  | const int | nb_sd,
|  | enum AVFrameSideDataType | type )

inline static

Wrapper around av_frame_side_data_get_c() to workaround the limitation that for any type T the conversion from T * const * to const T * const * is not performed automatically in C.

See also
  av_frame_side_data_get_c()

Definition at line 1138 of file frame.h.

## av_frame_side_data_remove()

void av_frame_side_data_remove | ( | AVFrameSideData *** | sd,
|  | int * | nb_sd,
|  | enum AVFrameSideDataType | type )

Remove and free all side data instances of the given type from an array.

## av_frame_side_data_remove_by_props()

void av_frame_side_data_remove_by_props | ( | AVFrameSideData *** | sd,
|  | int * | nb_sd,
|  | int | props )

Remove and free all side data instances that match any of the given side data properties.

(See enum AVSideDataProps)