FFmpeg
Functions | Variables
frame.c File Reference
#include "channel_layout.h"
#include "avassert.h"
#include "buffer.h"
#include "common.h"
#include "cpu.h"
#include "dict.h"
#include "frame.h"
#include "imgutils.h"
#include "mem.h"
#include "samplefmt.h"
#include "hwcontext.h"

Go to the source code of this file.

Functions

static void get_frame_defaults (AVFrame *frame)
 
static void free_side_data (AVFrameSideData **ptr_sd)
 
static void wipe_side_data (AVFrameSideData ***sd, int *nb_side_data)
 
static void frame_side_data_wipe (AVFrame *frame)
 
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. More...
 
static void remove_side_data (AVFrameSideData ***sd, int *nb_side_data, const enum AVFrameSideDataType type)
 
static void remove_side_data_by_entry (AVFrameSideData ***sd, int *nb_sd, const AVFrameSideData *target)
 
AVFrameav_frame_alloc (void)
 Allocate an AVFrame and set its fields to default values. More...
 
void av_frame_free (AVFrame **frame)
 Free the frame and any dynamically allocated objects in it, e.g. More...
 
static int get_video_buffer (AVFrame *frame, int align)
 
static int get_audio_buffer (AVFrame *frame, int align)
 
int av_frame_get_buffer (AVFrame *frame, int align)
 Allocate new buffer(s) for audio or video data. More...
 
static int frame_copy_props (AVFrame *dst, const AVFrame *src, int force_copy)
 
int av_frame_ref (AVFrame *dst, const AVFrame *src)
 Set up a new reference to the data described by the source frame. More...
 
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. More...
 
AVFrameav_frame_clone (const AVFrame *src)
 Create a new frame that references the same data as src. More...
 
void av_frame_unref (AVFrame *frame)
 Unreference all the buffers referenced by frame and reset the frame fields. More...
 
void av_frame_move_ref (AVFrame *dst, AVFrame *src)
 Move everything contained in src to dst and reset src. More...
 
int av_frame_is_writable (AVFrame *frame)
 Check if the frame data is writable. More...
 
int av_frame_make_writable (AVFrame *frame)
 Ensure that the frame data is writable, avoiding data copy if possible. More...
 
int av_frame_copy_props (AVFrame *dst, const AVFrame *src)
 Copy only "metadata" fields from src to dst. More...
 
AVBufferRefav_frame_get_plane_buffer (const AVFrame *frame, int plane)
 Get the buffer reference a given data plane is stored in. More...
 
static AVFrameSideDataadd_side_data_from_buf_ext (AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type, AVBufferRef *buf, uint8_t *data, size_t size)
 
static AVFrameSideDataadd_side_data_from_buf (AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type, AVBufferRef *buf)
 
AVFrameSideDataav_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. More...
 
AVFrameSideDataav_frame_new_side_data (AVFrame *frame, enum AVFrameSideDataType type, size_t size)
 Add a new side data to a frame. More...
 
static AVFrameSideDatareplace_side_data_from_buf (AVFrameSideData *dst, AVBufferRef *buf, int flags)
 
AVFrameSideDataav_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. More...
 
AVFrameSideDataav_frame_side_data_add (AVFrameSideData ***sd, int *nb_sd, enum AVFrameSideDataType type, AVBufferRef **pbuf, unsigned int flags)
 Add a new side data entry to an array from an existing AVBufferRef. More...
 
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. More...
 
const AVFrameSideDataav_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. More...
 
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. More...
 
AVFrameSideDataav_frame_get_side_data (const AVFrame *frame, enum AVFrameSideDataType type)
 
static int frame_copy_video (AVFrame *dst, const AVFrame *src)
 
static int frame_copy_audio (AVFrame *dst, const AVFrame *src)
 
int av_frame_copy (AVFrame *dst, const AVFrame *src)
 Copy the frame data from src to dst. More...
 
void av_frame_remove_side_data (AVFrame *frame, enum AVFrameSideDataType type)
 Remove and free all side data instances of the given type. More...
 
const AVSideDataDescriptorav_frame_side_data_desc (enum AVFrameSideDataType type)
 
const char * av_frame_side_data_name (enum AVFrameSideDataType type)
 
static int calc_cropping_offsets (size_t offsets[4], const AVFrame *frame, const AVPixFmtDescriptor *desc)
 
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. More...
 

Variables

static const AVSideDataDescriptor sd_props []
 

Function Documentation

◆ get_frame_defaults()

static void get_frame_defaults ( AVFrame frame)
static

Definition at line 61 of file frame.c.

Referenced by av_frame_alloc(), av_frame_move_ref(), and av_frame_unref().

◆ free_side_data()

static void free_side_data ( AVFrameSideData **  ptr_sd)
static

Definition at line 87 of file frame.c.

Referenced by remove_side_data(), remove_side_data_by_entry(), and wipe_side_data().

◆ wipe_side_data()

static void wipe_side_data ( AVFrameSideData ***  sd,
int nb_side_data 
)
static

Definition at line 96 of file frame.c.

Referenced by av_frame_side_data_free(), and frame_side_data_wipe().

◆ frame_side_data_wipe()

static void frame_side_data_wipe ( AVFrame frame)
static

Definition at line 106 of file frame.c.

Referenced by av_frame_replace(), av_frame_unref(), and frame_copy_props().

◆ remove_side_data()

static void remove_side_data ( AVFrameSideData ***  sd,
int nb_side_data,
const enum AVFrameSideDataType  type 
)
static

◆ remove_side_data_by_entry()

static void remove_side_data_by_entry ( AVFrameSideData ***  sd,
int nb_sd,
const AVFrameSideData target 
)
static

Definition at line 131 of file frame.c.

Referenced by av_frame_side_data_clone().

◆ get_video_buffer()

static int get_video_buffer ( AVFrame frame,
int  align 
)
static

Definition at line 169 of file frame.c.

Referenced by av_frame_get_buffer().

◆ get_audio_buffer()

static int get_audio_buffer ( AVFrame frame,
int  align 
)
static

Definition at line 238 of file frame.c.

Referenced by av_frame_get_buffer().

◆ frame_copy_props()

static int frame_copy_props ( AVFrame dst,
const AVFrame src,
int  force_copy 
)
static

Definition at line 302 of file frame.c.

Referenced by av_frame_copy_props(), av_frame_ref(), and av_frame_replace().

◆ add_side_data_from_buf_ext()

static AVFrameSideData* add_side_data_from_buf_ext ( AVFrameSideData ***  sd,
int nb_sd,
enum AVFrameSideDataType  type,
AVBufferRef buf,
uint8_t *  data,
size_t  size 
)
static

Definition at line 744 of file frame.c.

Referenced by add_side_data_from_buf(), and av_frame_side_data_clone().

◆ add_side_data_from_buf()

static AVFrameSideData* add_side_data_from_buf ( AVFrameSideData ***  sd,
int nb_sd,
enum AVFrameSideDataType  type,
AVBufferRef buf 
)
static

◆ replace_side_data_from_buf()

static AVFrameSideData* replace_side_data_from_buf ( AVFrameSideData dst,
AVBufferRef buf,
int  flags 
)
static

Definition at line 807 of file frame.c.

Referenced by av_frame_side_data_add(), and av_frame_side_data_new().

◆ frame_copy_video()

static int frame_copy_video ( AVFrame dst,
const AVFrame src 
)
static

Definition at line 956 of file frame.c.

Referenced by av_frame_copy().

◆ frame_copy_audio()

static int frame_copy_audio ( AVFrame dst,
const AVFrame src 
)
static

Definition at line 979 of file frame.c.

Referenced by av_frame_copy().

◆ calc_cropping_offsets()

static int calc_cropping_offsets ( size_t  offsets[4],
const AVFrame frame,
const AVPixFmtDescriptor desc 
)
static

Definition at line 1032 of file frame.c.

Referenced by av_frame_apply_cropping().

Variable Documentation

◆ sd_props

const AVSideDataDescriptor sd_props[]
static
Initial value:
= {
[AV_FRAME_DATA_PANSCAN] = { "AVPanScan" },
[AV_FRAME_DATA_A53_CC] = { "ATSC A53 Part 4 Closed Captions" },
[AV_FRAME_DATA_MATRIXENCODING] = { "AVMatrixEncoding" },
[AV_FRAME_DATA_DOWNMIX_INFO] = { "Metadata relevant to a downmix procedure" },
[AV_FRAME_DATA_AFD] = { "Active format description" },
[AV_FRAME_DATA_MOTION_VECTORS] = { "Motion vectors" },
[AV_FRAME_DATA_SKIP_SAMPLES] = { "Skip samples" },
[AV_FRAME_DATA_GOP_TIMECODE] = { "GOP timecode" },
[AV_FRAME_DATA_S12M_TIMECODE] = { "SMPTE 12-1 timecode" },
[AV_FRAME_DATA_DYNAMIC_HDR_PLUS] = { "HDR Dynamic Metadata SMPTE2094-40 (HDR10+)" },
[AV_FRAME_DATA_DYNAMIC_HDR_VIVID] = { "HDR Dynamic Metadata CUVA 005.1 2021 (Vivid)" },
[AV_FRAME_DATA_REGIONS_OF_INTEREST] = { "Regions Of Interest" },
[AV_FRAME_DATA_VIDEO_ENC_PARAMS] = { "Video encoding parameters" },
[AV_FRAME_DATA_FILM_GRAIN_PARAMS] = { "Film grain parameters" },
[AV_FRAME_DATA_DETECTION_BBOXES] = { "Bounding boxes for object detection and classification" },
[AV_FRAME_DATA_DOVI_RPU_BUFFER] = { "Dolby Vision RPU Data" },
[AV_FRAME_DATA_DOVI_METADATA] = { "Dolby Vision Metadata" },
[AV_FRAME_DATA_CONTENT_LIGHT_LEVEL] = { "Content light level metadata", AV_SIDE_DATA_PROP_GLOBAL },
[AV_FRAME_DATA_SPHERICAL] = { "Spherical Mapping", AV_SIDE_DATA_PROP_GLOBAL },
[AV_FRAME_DATA_SEI_UNREGISTERED] = { "H.26[45] User Data Unregistered SEI message", AV_SIDE_DATA_PROP_MULTI },
}

Definition at line 31 of file frame.c.

Referenced by av_frame_side_data_desc().

AV_FRAME_DATA_A53_CC
@ AV_FRAME_DATA_A53_CC
ATSC A53 Part 4 Closed Captions.
Definition: frame.h:59
AV_FRAME_DATA_DOVI_METADATA
@ AV_FRAME_DATA_DOVI_METADATA
Parsed Dolby Vision metadata, suitable for passing to a software implementation.
Definition: frame.h:208
AV_FRAME_DATA_FILM_GRAIN_PARAMS
@ AV_FRAME_DATA_FILM_GRAIN_PARAMS
Film grain parameters for a frame, described by AVFilmGrainParams.
Definition: frame.h:188
AV_FRAME_DATA_S12M_TIMECODE
@ AV_FRAME_DATA_S12M_TIMECODE
Timecode which conforms to SMPTE ST 12-1.
Definition: frame.h:152
AV_FRAME_DATA_DOVI_RPU_BUFFER
@ AV_FRAME_DATA_DOVI_RPU_BUFFER
Dolby Vision RPU raw data, suitable for passing to x265 or other libraries.
Definition: frame.h:201
AV_FRAME_DATA_DISPLAYMATRIX
@ AV_FRAME_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
Definition: frame.h:85
AV_FRAME_DATA_MATRIXENCODING
@ AV_FRAME_DATA_MATRIXENCODING
The data is the AVMatrixEncoding enum defined in libavutil/channel_layout.h.
Definition: frame.h:68
AV_FRAME_DATA_AUDIO_SERVICE_TYPE
@ AV_FRAME_DATA_AUDIO_SERVICE_TYPE
This side data must be associated with an audio frame and corresponds to enum AVAudioServiceType defi...
Definition: frame.h:114
AV_SIDE_DATA_PROP_MULTI
@ AV_SIDE_DATA_PROP_MULTI
Multiple instances of this side data type can be meaningfully present in a single side data array.
Definition: frame.h:270
AV_SIDE_DATA_PROP_GLOBAL
@ AV_SIDE_DATA_PROP_GLOBAL
The side data type can be used in stream-global structures.
Definition: frame.h:264
AV_FRAME_DATA_DYNAMIC_HDR_VIVID
@ AV_FRAME_DATA_DYNAMIC_HDR_VIVID
HDR Vivid dynamic metadata associated with a video frame.
Definition: frame.h:215
AV_FRAME_DATA_SPHERICAL
@ AV_FRAME_DATA_SPHERICAL
The data represents the AVSphericalMapping structure defined in libavutil/spherical....
Definition: frame.h:131
AV_FRAME_DATA_ICC_PROFILE
@ AV_FRAME_DATA_ICC_PROFILE
The data contains an ICC profile as an opaque octet buffer following the format described by ISO 1507...
Definition: frame.h:144
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
@ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata associated with a video frame.
Definition: frame.h:120
AV_FRAME_DATA_AFD
@ AV_FRAME_DATA_AFD
Active Format Description data consisting of a single byte as specified in ETSI TS 101 154 using AVAc...
Definition: frame.h:90
AV_FRAME_DATA_SEI_UNREGISTERED
@ AV_FRAME_DATA_SEI_UNREGISTERED
User data unregistered metadata associated with a video frame.
Definition: frame.h:178
AV_FRAME_DATA_REPLAYGAIN
@ AV_FRAME_DATA_REPLAYGAIN
ReplayGain information in the form of the AVReplayGain struct.
Definition: frame.h:77
AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT
@ AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT
Ambient viewing environment metadata, as defined by H.274.
Definition: frame.h:220
AV_FRAME_DATA_PANSCAN
@ AV_FRAME_DATA_PANSCAN
The data is the AVPanScan struct defined in libavcodec.
Definition: frame.h:53
AV_FRAME_DATA_SKIP_SAMPLES
@ AV_FRAME_DATA_SKIP_SAMPLES
Recommmends skipping the specified number of samples.
Definition: frame.h:109
AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
@ AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
Definition: frame.h:137
AV_FRAME_DATA_STEREO3D
@ AV_FRAME_DATA_STEREO3D
Stereoscopic 3d metadata.
Definition: frame.h:64
AV_FRAME_DATA_GOP_TIMECODE
@ AV_FRAME_DATA_GOP_TIMECODE
The GOP timecode in 25 bit timecode format.
Definition: frame.h:125
AV_FRAME_DATA_DYNAMIC_HDR_PLUS
@ AV_FRAME_DATA_DYNAMIC_HDR_PLUS
HDR dynamic metadata associated with a video frame.
Definition: frame.h:159
AV_FRAME_DATA_VIDEO_ENC_PARAMS
@ AV_FRAME_DATA_VIDEO_ENC_PARAMS
Encoding parameters for a video frame, as described by AVVideoEncParams.
Definition: frame.h:170
AV_FRAME_DATA_REGIONS_OF_INTEREST
@ AV_FRAME_DATA_REGIONS_OF_INTEREST
Regions Of Interest, the data is an array of AVRegionOfInterest type, the number of array element is ...
Definition: frame.h:165
AV_FRAME_DATA_MOTION_VECTORS
@ AV_FRAME_DATA_MOTION_VECTORS
Motion vectors exported by some codecs (on demand through the export_mvs flag set in the libavcodec A...
Definition: frame.h:97
AV_FRAME_DATA_DOWNMIX_INFO
@ AV_FRAME_DATA_DOWNMIX_INFO
Metadata relevant to a downmix procedure.
Definition: frame.h:73
AV_FRAME_DATA_DETECTION_BBOXES
@ AV_FRAME_DATA_DETECTION_BBOXES
Bounding boxes for object detection and classification, as described by AVDetectionBBoxHeader.
Definition: frame.h:194