All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions
frame.h File Reference
#include <stdint.h>
#include "libavcodec/version.h"
#include "avutil.h"
#include "buffer.h"
#include "dict.h"
#include "rational.h"
#include "samplefmt.h"

Go to the source code of this file.

Data Structures

struct  AVFrameSideData
struct  AVFrame
 This structure describes decoded (raw) audio or video data. More...




enum  AVColorSpace {
enum  AVFrameSideDataType { AV_FRAME_DATA_PANSCAN }


int64_t av_frame_get_best_effort_timestamp (const AVFrame *frame)
 Accessors for some AVFrame fields.
void av_frame_set_best_effort_timestamp (AVFrame *frame, int64_t val)
int64_t av_frame_get_pkt_duration (const AVFrame *frame)
void av_frame_set_pkt_duration (AVFrame *frame, int64_t val)
int64_t av_frame_get_pkt_pos (const AVFrame *frame)
void av_frame_set_pkt_pos (AVFrame *frame, int64_t val)
int64_t av_frame_get_channel_layout (const AVFrame *frame)
void av_frame_set_channel_layout (AVFrame *frame, int64_t val)
int av_frame_get_channels (const AVFrame *frame)
void av_frame_set_channels (AVFrame *frame, int val)
int av_frame_get_sample_rate (const AVFrame *frame)
void av_frame_set_sample_rate (AVFrame *frame, int val)
AVDictionaryav_frame_get_metadata (const AVFrame *frame)
void av_frame_set_metadata (AVFrame *frame, AVDictionary *val)
int av_frame_get_decode_error_flags (const AVFrame *frame)
void av_frame_set_decode_error_flags (AVFrame *frame, int val)
int av_frame_get_pkt_size (const AVFrame *frame)
void av_frame_set_pkt_size (AVFrame *frame, int val)
AVDictionary ** avpriv_frame_get_metadatap (AVFrame *frame)
int8_t * av_frame_get_qp_table (AVFrame *f, int *stride, int *type)
int av_frame_set_qp_table (AVFrame *f, AVBufferRef *buf, int stride, int type)
enum AVColorSpace av_frame_get_colorspace (const AVFrame *frame)
void av_frame_set_colorspace (AVFrame *frame, enum AVColorSpace val)
enum AVColorRange av_frame_get_color_range (const AVFrame *frame)
void av_frame_set_color_range (AVFrame *frame, enum AVColorRange val)
const char * av_get_colorspace_name (enum AVColorSpace val)
 Get the name of a colorspace.
AVFrameav_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, AVFrame *src)
 Setup a new reference to the data described by a given frame.
AVFrameav_frame_clone (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 everythnig 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_props (AVFrame *dst, const AVFrame *src)
 Copy only "metadata" fields from src to dst.
AVBufferRefav_frame_get_plane_buffer (AVFrame *frame, int plane)
 Get the buffer reference a given data plane is stored in.
AVFrameSideDataav_frame_new_side_data (AVFrame *frame, enum AVFrameSideDataType type, int size)
 Add a new side data to a frame.
AVFrameSideDataav_frame_get_side_data (const AVFrame *frame, enum AVFrameSideDataType type)

Macro Definition Documentation


Definition at line 44 of file frame.h.

Referenced by get_pixel_format().


Definition at line 436 of file frame.h.

Referenced by ac3_decode_frame(), and cpia_decode_frame().


Definition at line 437 of file frame.h.

Enumeration Type Documentation


also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B


also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601


also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above


Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16.


Not part of ABI.

Definition at line 33 of file frame.h.


the normal 219*2^(n-8) "MPEG" YUV ranges


the normal 2^n-1 "JPEG" YUV ranges


Not part of ABI.

Definition at line 46 of file frame.h.


The data is the AVPanScan struct defined in libavcodec.

Definition at line 53 of file frame.h.

Function Documentation

int64_t av_frame_get_best_effort_timestamp ( const AVFrame frame)

Accessors for some AVFrame fields.

The position of these field in the structure is not part of the ABI, they should not be accessed directly outside libavcodec.


Referenced by decode_video(), get_video_frame(), main(), and movie_push_frame().

void av_frame_set_best_effort_timestamp ( AVFrame frame,
int64_t  val 
int64_t av_frame_get_pkt_duration ( const AVFrame frame)
void av_frame_set_pkt_duration ( AVFrame frame,
int64_t  val 
int64_t av_frame_get_pkt_pos ( const AVFrame frame)
void av_frame_set_pkt_pos ( AVFrame frame,
int64_t  val 
int64_t av_frame_get_channel_layout ( const AVFrame frame)
void av_frame_set_channel_layout ( AVFrame frame,
int64_t  val 
int av_frame_get_channels ( const AVFrame frame)
void av_frame_set_channels ( AVFrame frame,
int  val 
int av_frame_get_sample_rate ( const AVFrame frame)
void av_frame_set_sample_rate ( AVFrame frame,
int  val 

Referenced by request_frame().

AVDictionary* av_frame_get_metadata ( const AVFrame frame)
void av_frame_set_metadata ( AVFrame frame,
AVDictionary val 

Referenced by decode_frame().

int av_frame_get_decode_error_flags ( const AVFrame frame)
void av_frame_set_decode_error_flags ( AVFrame frame,
int  val 
int av_frame_get_pkt_size ( const AVFrame frame)

Referenced by show_frame().

void av_frame_set_pkt_size ( AVFrame frame,
int  val 
AVDictionary** avpriv_frame_get_metadatap ( AVFrame frame)
int8_t* av_frame_get_qp_table ( AVFrame f,
int *  stride,
int *  type 

Definition at line 62 of file frame.c.

Referenced by filter_frame(), and pp_filter_frame().

int av_frame_set_qp_table ( AVFrame f,
AVBufferRef buf,
int  stride,
int  type 

Definition at line 49 of file frame.c.

Referenced by ff_mjpeg_decode_frame(), and ff_mpv_export_qp_table().

enum AVColorSpace av_frame_get_colorspace ( const AVFrame frame)
void av_frame_set_colorspace ( AVFrame frame,
enum AVColorSpace  val 
enum AVColorRange av_frame_get_color_range ( const AVFrame frame)
void av_frame_set_color_range ( AVFrame frame,
enum AVColorRange  val 

Referenced by ff_init_buffer_info().

const char* av_get_colorspace_name ( enum AVColorSpace  val)

Get the name of a colorspace.

a static string identifying the colorspace; can be NULL.

Definition at line 73 of file frame.c.

Referenced by avcodec_string().

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().

An AVFrame filled with default values or NULL on failure.
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.

Definition at line 110 of file frame.c.

Referenced by a64multi_init_encoder(), aasc_decode_init(), amv_encode_picture(), av_buffersink_get_samples(), av_buffersrc_add_frame_flags(), av_buffersrc_add_frame_internal(), av_frame_clone(), avcodec_alloc_frame(), avs_decode_init(), bethsoftvid_decode_init(), bmp_encode_init(), cdg_decode_init(), cinepak_decode_init(), cinvideo_decode_init(), cmv_decode_init(), cpia_decode_init(), decode_audio(), decode_entropy_coded_image(), decode_init(), decode_video(), dirac_decode_init(), dnxhd_encode_init(), dvvideo_init_encoder(), encode_init(), encode_init_ls(), escape124_decode_init(), ff_cavs_init(), ff_default_get_audio_buffer(), ff_default_get_video_buffer(), ff_mjpeg_decode_init(), ff_MPV_encode_init(), ff_thread_video_encode_frame(), ff_vf_next_put_image(), ff_vp56_init_context(), ffv1_common_init(), flashsv_decode_init(), flashsv_encode_init(), flic_decode_init(), frame_thread_init(), gif_decode_init(), gif_encode_frame(), gif_encode_init(), hevc_init_context(), init(), init_frames(), init_thread_copy(), ipvideo_decode_init(), ir2_decode_init(), join_request_frame(), lavfi_read_header(), libopenjpeg_encode_frame(), libschroedinger_encode_init(), main(), mca(), mimic_decode_init(), mimic_init_thread_copy(), mm_decode_init(), movie_push_frame(), mp_decode_init(), msrle_decode_init(), mss1_decode_init(), mss2_decode_init(), mss3_decode_init(), mss4_decode_init(), msvideo1_decode_init(), mvc_decode_init(), mxpeg_decode_init(), paf_vid_init(), pam_encode_init(), pcx_encode_init(), png_dec_init(), png_enc_init(), pnm_encode_init(), qtrle_decode_init(), qtrle_encode_init(), read_interval_packets(), roq_decode_init(), roq_encode_init(), rpza_decode_init(), seqvideo_decode_init(), sgirle_decode_init(), smc_decode_init(), smvjpeg_decode_init(), sub2video_prepare(), svq1_encode_init(), targa_encode_init(), tgv_decode_init(), truemotion1_decode_init(), tscc2_decode_init(), ulti_decode_init(), vc1_decode_init(), video_thread(), vmdvideo_decode_init(), vp8_init_frames(), vp8_lossy_decode_alpha(), vp9_decode_init(), X264_init(), xan_decode_init(), XAVS_init(), xvid_encode_init(), yop_decode_init(), and zerocodec_decode_init().

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.

frameframe to be freed. The pointer will be set to NULL.

Definition at line 123 of file frame.c.

Referenced by a64multi_close_encoder(), aasc_decode_end(), add_to_queue(), amv_encode_picture(), apply_lut(), av_buffersink_get_frame_flags(), av_buffersink_get_samples(), av_buffersrc_add_frame_flags(), av_buffersrc_add_frame_internal(), av_frame_clone(), avcodec_encode_audio2(), avfilter_link_free(), avs_decode_end(), bethsoftvid_decode_end(), blend_frame(), bmp_encode_close(), cdg_decode_end(), channelmap_filter_frame(), cinepak_decode_end(), cinvideo_decode_end(), cmv_decode_end(), cmv_decode_init(), compand_delay(), compand_nodelay(), config_output(), config_video_output(), cpia_decode_end(), decimate_uninit(), decode_close(), decode_end(), decode_flush(), decode_init(), dirac_decode_end(), dirac_decode_init(), dnxhd_encode_end(), encode_close(), encode_end(), escape124_decode_close(), ff_bufqueue_add(), ff_bufqueue_discard_all(), ff_cavs_end(), ff_default_get_audio_buffer(), ff_default_get_video_buffer(), ff_filter_frame_framed(), ff_filter_frame_needs_framing(), ff_framesync_get_frame(), ff_framesync_uninit(), ff_mjpeg_decode_end(), ff_MPV_encode_end(), ff_snow_common_end(), ff_vc1_decode_end(), ff_vf_next_put_image(), ff_vp56_free_context(), ff_vp8_decode_free(), ffmpeg_cleanup(), ffv1_close(), fieldmatch_uninit(), filter_frame(), fixstride(), flashsv_decode_end(), flashsv_encode_end(), flic_decode_end(), flush_fifo(), frame_thread_free(), framesync_advance(), geq_filter_frame(), get_best_frame(), gif_decode_close(), gif_encode_close(), hevc_decode_free(), if(), image_ctx_free(), init_frames(), ipvideo_decode_end(), ipvideo_decode_init(), ir2_decode_end(), join_request_frame(), join_uninit(), lavfi_read_close(), libopenjpeg_encode_frame(), libschroedinger_encode_close(), main(), mimic_decode_end(), mm_decode_end(), movie_push_frame(), movie_uninit(), mp_decode_end(), msrle_decode_end(), mss1_decode_end(), mss2_decode_end(), mss3_decode_end(), mss3_decode_init(), mss4_decode_end(), msvideo1_decode_end(), mvc_decode_end(), mxpeg_decode_end(), null_filter_frame(), output_frame(), pad_last_frame(), paf_vid_close(), pam_encode_close(), pcx_encode_close(), png_dec_end(), png_enc_close(), pnm_encode_close(), pp_filter_frame(), process_frame(), qtrle_decode_end(), qtrle_encode_end(), read_from_fifo(), read_interval_packets(), request_frame(), return_audio_frame(), roq_decode_end(), roq_decode_init(), roq_encode_end(), rpza_decode_end(), seqvideo_decode_end(), sgirle_decode_end(), smc_decode_end(), smvjpeg_decode_end(), Stagefright_close(), Stagefright_decode_frame(), stream_component_close(), sunrast_encode_close(), svq1_decode_end(), svq1_encode_end(), targa_encode_close(), tgv_decode_end(), truemotion1_decode_end(), tscc2_decode_end(), ulti_decode_end(), uninit(), video_thread(), vmdvideo_decode_end(), vp3_decode_end(), vp8_lossless_decode_frame(), vp8_lossy_decode_alpha(), vp9_decode_free(), worker(), write_to_fifo(), X264_close(), xan_decode_end(), XAVS_close(), yae_clear(), yop_decode_close(), and zerocodec_decode_close().

int av_frame_ref ( AVFrame dst,
AVFrame src 

Setup a new reference to the data described by a given 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.

0 on success, a negative AVERROR on error

Definition at line 247 of file frame.c.

Referenced by aasc_decode_frame(), amv_encode_picture(), av_buffersink_get_frame_flags(), av_buffersrc_add_frame_flags(), av_frame_clone(), avs_decode_frame(), bethsoftvid_decode_frame(), cavs_decode_frame(), cdg_decode_frame(), cinepak_decode_frame(), cinvideo_decode_frame(), cmv_decode_frame(), copy_frame(), cpia_decode_frame(), decode_frame(), decode_video(), dirac_decode_frame(), encode_frame(), encode_picture_lossless(), escape124_decode_frame(), ff_h263_decode_frame(), ff_hevc_output_frame(), ff_mjpeg_decode_frame(), ff_rv34_decode_frame(), ff_thread_ref_frame(), ff_vp56_decode_frame(), ff_vp56_decode_mbs(), ff_vp8_decode_frame(), finish_frame(), flashsv_decode_frame(), flic_decode_frame_15_16BPP(), flic_decode_frame_8BPP(), get_delayed_pic(), gif_decode_frame(), gif_encode_frame(), h261_decode_frame(), ipvideo_decode_frame(), ir2_decode_frame(), libopenjpeg_encode_frame(), load_input_picture(), mimic_decode_frame(), mjpegb_decode_frame(), mm_decode_frame(), mp_decode_frame(), mpeg_decode_frame(), msrle_decode_frame(), mss1_decode_frame(), mss2_decode_frame(), mss3_decode_frame(), mss4_decode_frame(), msvideo1_decode_frame(), mvc_decode_frame(), mxpeg_decode_frame(), output_frame(), paf_vid_decode(), qtrle_decode_frame(), roq_decode_frame(), rpza_decode_frame(), rv10_decode_frame(), seqvideo_decode_frame(), sgirle_decode_frame(), slice_end(), smc_decode_frame(), smvjpeg_decode_frame(), svq1_decode_frame(), svq3_decode_frame(), tgv_decode_frame(), truemotion1_decode_frame(), tscc2_decode_frame(), ulti_decode_frame(), vc1_decode_frame(), vmdvideo_decode_frame(), vp9_decode_frame(), xan_decode_frame(), yop_decode_frame(), and zerocodec_decode_frame().

AVFrame* av_frame_clone ( AVFrame src)

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

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

newly created AVFrame on success, NULL on error.

Definition at line 338 of file frame.c.

Referenced by create_weave_frame(), ff_framesync_get_frame(), ff_vf_next_put_image(), filter_frame(), push_frame(), request_frame(), and return_audio_frame().

void av_frame_unref ( AVFrame frame)

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

Definition at line 351 of file frame.c.

Referenced by aac_decode_frame_int(), audio_decode_frame(), audio_get_buffer(), av_frame_free(), av_frame_make_writable(), av_frame_ref(), avcodec_close(), avcodec_decode_audio4(), avcodec_decode_video2(), avcodec_flush_buffers(), cavs_decode_frame(), cdg_decode_frame(), cmv_decode_frame(), cmv_process_header(), codec_reinit(), copy_frame(), decode_frame(), decode_pic(), decode_subframe(), decode_video(), dirac_decode_data_unit(), dirac_decode_frame(), encode_frame(), encode_picture_lossless(), escape124_decode_frame(), execute_code(), ff_mjpeg_decode_end(), ff_mjpeg_decode_sof(), ff_mpeg_unref_picture(), ff_snow_release_buffer(), ff_thread_flush(), ff_thread_release_buffer(), ff_vp56_decode_frame(), ff_vp56_decode_mbs(), fixstride(), flashsv_decode_frame(), flush(), frame_configure_elements(), frame_worker_thread(), free_picture(), free_sequence_buffers(), get_audio_buffer(), get_video_buffer(), get_video_frame(), gif_decode_frame(), gif_encode_frame(), hevc_frame_start(), hls_slice_header(), ipvideo_decode_frame(), lavfi_read_packet(), main(), mss2_decode_frame(), mxpeg_decode_frame(), reap_filters(), reget_buffer_internal(), release_delayed_buffers(), select_input_picture(), smvjpeg_decode_frame(), sub2video_get_blank_frame(), svq1_decode_frame(), svq1_flush(), svq3_decode_end(), svq3_decode_frame(), tgv_decode_frame(), truemotion1_decode_header(), video_get_buffer(), video_thread(), vmdvideo_decode_frame(), vorbis_decode_frame(), vp9_decode_flush(), vp9_decode_frame(), vp9_decode_free(), worker(), xan_decode_frame(), and zerocodec_decode_frame().

void av_frame_move_ref ( AVFrame dst,
AVFrame src 
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 channel_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.

frameframe in which to store the new buffers.
alignrequired buffer size alignment
0 on success, a negative AVERROR on error.

Definition at line 234 of file frame.c.

Referenced by av_frame_make_writable(), av_frame_ref(), decode_entropy_coded_image(), ff_default_get_audio_buffer(), ff_default_get_video_buffer(), ff_MPV_encode_init(), pad_last_frame(), and sub2video_get_blank_frame().

int av_frame_is_writable ( AVFrame frame)

Check if the frame data is writable.

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()

Definition at line 382 of file frame.c.

Referenced by apply_lut(), av_frame_make_writable(), compand_nodelay(), ff_filter_frame_framed(), filter_frame(), frame_needs_copy(), and reget_buffer_internal().

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.

0 on success, a negative AVERROR on error.
See Also
av_frame_is_writable(), av_buffer_is_writable(), av_buffer_make_writable()

Definition at line 399 of file frame.c.

Referenced by ff_framesync_get_frame(), ff_h263_decode_frame(), ff_print_debug_info2(), and filter_frame().

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.

Definition at line 446 of file frame.c.

Referenced by apply_lut(), av_frame_make_writable(), av_frame_ref(), blend_frame(), compand_delay(), compand_nodelay(), create_weave_frame(), ff_filter_frame_framed(), ff_filter_frame_needs_framing(), filter(), filter_frame(), fixstride(), geq_filter_frame(), load_input_picture(), pad_last_frame(), pp_filter_frame(), return_frame(), and select_input_picture().

AVBufferRef* av_frame_get_plane_buffer ( AVFrame frame,
int  plane 

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

planeindex of the data plane of interest in frame->extended_data.
the buffer reference that contains the plane or NULL if the input frame is not valid.

Definition at line 513 of file frame.c.

Referenced by buffer_needs_copy(), and join_request_frame().

AVFrameSideData* av_frame_new_side_data ( AVFrame frame,
enum AVFrameSideDataType  type,
int  size 

Add a new side data to a frame.

framea frame to which the side data should be added
typetype of the added side data
sizesize of the side data
newly added side data on success, NULL on error

Definition at line 544 of file frame.c.

Referenced by av_frame_copy_props(), and mpeg_field_start().

AVFrameSideData* av_frame_get_side_data ( const AVFrame frame,
enum AVFrameSideDataType  type 
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.

Definition at line 577 of file frame.c.