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"
Include dependency graph for frame.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

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

Macros

#define AV_NUM_DATA_POINTERS   8
 
#define FF_DECODE_ERROR_INVALID_BITSTREAM   1
 
#define FF_DECODE_ERROR_MISSING_REFERENCE   2
 

Typedefs

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

Enumerations

enum  AVFrameSideDataType { AV_FRAME_DATA_PANSCAN }
 

Functions

int64_t av_frame_get_best_effort_timestamp (const AVFrame *frame)
 Accessors for some AVFrame fields. More...
 
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)
 
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...
 
int av_frame_ref (AVFrame *dst, AVFrame *src)
 Setup a new reference to the data described by an given frame. More...
 
AVFrameav_frame_clone (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 everythnig contained in src to dst and reset src. More...
 
int av_frame_get_buffer (AVFrame *frame, int align)
 Allocate new buffer(s) for audio or video data. 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 (AVFrame *frame, int plane)
 Get the buffer reference a given data plane is stored in. More...
 
AVFrameSideDataav_frame_new_side_data (AVFrame *frame, enum AVFrameSideDataType type, int size)
 Add a new side data to a frame. More...
 
AVFrameSideDataav_frame_get_side_data (AVFrame *frame, enum AVFrameSideDataType type)
 

Macro Definition Documentation

#define FF_DECODE_ERROR_INVALID_BITSTREAM   1

Definition at line 413 of file frame.h.

Referenced by ac3_decode_frame(), and cpia_decode_frame().

#define FF_DECODE_ERROR_MISSING_REFERENCE   2

Definition at line 414 of file frame.h.

Typedef Documentation

typedef struct AVFrame AVFrame

This structure describes decoded (raw) audio or video data.

AVFrame must be allocated using av_frame_alloc(). Note that this only allocates the AVFrame itself, the buffers for the data must be managed through other means (see below). AVFrame must be freed with av_frame_free().

AVFrame is typically allocated once and then reused multiple times to hold different data (e.g. a single AVFrame to hold frames received from a decoder). In such a case, av_frame_unref() will free any references held by the frame and reset it to its original clean state before it is reused again.

The data described by an AVFrame is usually reference counted through the AVBuffer API. The underlying buffer references are stored in AVFrame.buf / AVFrame.extended_buf. An AVFrame is considered to be reference counted if at least one reference is set, i.e. if AVFrame.buf[0] != NULL. In such a case, every single data plane must be contained in one of the buffers in AVFrame.buf or AVFrame.extended_buf. There may be a single buffer for all the data, or one separate buffer for each plane, or anything in between.

sizeof(AVFrame) is not a part of the public ABI, so new fields may be added to the end with a minor bump. Similarly fields that are marked as to be only accessed by av_opt_ptr() can be reordered. This allows 2 forks to add fields without breaking compatibility with each other.

Enumeration Type Documentation

Enumerator
AV_FRAME_DATA_PANSCAN 

The data is the AVPanScan struct defined in libavcodec.

Definition at line 33 of file frame.h.

Function Documentation

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

Returns
newly created AVFrame on success, NULL on error.

Definition at line 317 of file frame.c.

Referenced by config_input(), create_weave_frame(), ff_vf_next_put_image(), filter_frame(), push_frame(), request_frame(), and return_audio_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 424 of file frame.c.

Referenced by av_frame_make_writable(), av_frame_ref(), create_weave_frame(), ff_filter_frame_framed(), ff_filter_frame_needs_framing(), filter_frame(), geq_filter_frame(), pp_filter_frame(), and return_frame().

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
frameframe to be freed. The pointer will be set to NULL.

Definition at line 108 of file frame.c.

Referenced by aasc_decode_end(), add_to_queue(), av_buffersink_get_frame_flags(), av_buffersink_get_samples(), av_buffersink_set_frame_size(), av_buffersrc_add_frame_flags(), av_buffersrc_add_frame_internal(), av_frame_clone(), avfilter_link_free(), cdg_decode_end(), channelmap_filter_frame(), cinepak_decode_end(), cmv_decode_end(), cmv_decode_init(), config_input(), config_output(), config_video_output(), cpia_decode_end(), decimate_uninit(), decode_close(), decode_end(), exit_program(), 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_vf_next_put_image(), ff_vp56_free_context(), fieldmatch_uninit(), filter_frame(), flush_fifo(), geq_filter_frame(), get_best_frame(), gif_decode_close(), gif_encode_close(), init_frames(), ipvideo_decode_end(), ipvideo_decode_init(), join_request_frame(), join_uninit(), lavfi_read_close(), main(), mimic_decode_end(), movie_push_frame(), movie_uninit(), mss4_decode_end(), mvc_decode_end(), null_filter_frame(), output_frame(), paf_vid_close(), png_dec_end(), pp_filter_frame(), process_frame(), read_from_fifo(), request_frame(), return_audio_frame(), roq_decode_end(), roq_decode_init(), roq_encode_end(), sgirle_decode_end(), stream_component_close(), svq1_decode_end(), try_filter_frame(), tscc2_decode_end(), uninit(), video_thread(), vp3_decode_end(), vp8_decode_free(), worker(), write_to_fifo(), xan_decode_end(), yae_clear(), and yop_decode_close().

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

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.

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

Definition at line 215 of file frame.c.

Referenced by av_frame_make_writable(), av_frame_ref(), ff_default_get_video_buffer(), and sub2video_get_blank_frame().

int64_t av_frame_get_channel_layout ( const AVFrame frame)

Referenced by print_frame(), and show_frame().

int av_frame_get_decode_error_flags ( const AVFrame frame)
AVDictionary* av_frame_get_metadata ( const AVFrame frame)
int64_t av_frame_get_pkt_duration ( const AVFrame frame)
int av_frame_get_pkt_size ( const AVFrame frame)

Referenced by show_frame().

AVBufferRef* av_frame_get_plane_buffer ( AVFrame frame,
int  plane 
)

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

Parameters
planeindex 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.

Definition at line 489 of file frame.c.

Referenced by buffer_needs_copy(), and join_request_frame().

int8_t* av_frame_get_qp_table ( AVFrame f,
int *  stride,
int *  type 
)

Definition at line 64 of file frame.c.

Referenced by pp_filter_frame().

int av_frame_get_sample_rate ( const AVFrame frame)
AVFrameSideData* av_frame_get_side_data ( 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.

Definition at line 553 of file frame.c.

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

Definition at line 361 of file frame.c.

Referenced by av_frame_make_writable(), 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.

Returns
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 377 of file frame.c.

Referenced by ff_print_debug_info2(), and filter_frame().

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

Add a new side data to a frame.

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

Definition at line 520 of file frame.c.

Referenced by av_frame_copy_props(), and mpeg_field_start().

int av_frame_ref ( AVFrame dst,
AVFrame src 
)

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

Returns
0 on success, a negative AVERROR on error

Definition at line 228 of file frame.c.

Referenced by aasc_decode_frame(), 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_audio(), decode_frame(), decode_video(), dirac_decode_frame(), encode_picture_lossless(), escape124_decode_frame(), escape130_decode_frame(), ff_h263_decode_frame(), ff_mjpeg_decode_frame(), ff_rv34_decode_frame(), ff_thread_ref_frame(), ff_vp56_decode_frame(), ff_vp56_decode_mbs(), 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(), 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(), svq1_decode_frame(), svq3_decode_frame(), tgv_decode_frame(), truemotion1_decode_frame(), tscc2_decode_frame(), ulti_decode_frame(), vc1_decode_frame(), vmdvideo_decode_frame(), vp3_decode_frame(), vp8_decode_frame(), xan_decode_frame(), yop_decode_frame(), and zerocodec_decode_frame().

void av_frame_set_best_effort_timestamp ( AVFrame frame,
int64_t  val 
)
void av_frame_set_channel_layout ( AVFrame frame,
int64_t  val 
)
void av_frame_set_channels ( AVFrame frame,
int  val 
)
void av_frame_set_decode_error_flags ( AVFrame frame,
int  val 
)
void av_frame_set_metadata ( AVFrame frame,
AVDictionary val 
)

Referenced by decode_frame().

void av_frame_set_pkt_duration ( AVFrame frame,
int64_t  val 
)
void av_frame_set_pkt_size ( AVFrame frame,
int  val 
)
int av_frame_set_qp_table ( AVFrame f,
AVBufferRef buf,
int  stride,
int  type 
)

Definition at line 51 of file frame.c.

Referenced by ff_mjpeg_decode_frame(), and ff_mpv_export_qp_table().

void av_frame_set_sample_rate ( AVFrame frame,
int  val 
)

Referenced by request_frame().

void av_frame_unref ( AVFrame frame)

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

Definition at line 330 of file frame.c.

Referenced by audio_decode_frame(), audio_get_buffer(), av_buffersrc_add_frame_internal(), av_frame_free(), av_frame_make_writable(), av_frame_ref(), avcodec_close(), avcodec_decode_audio4(), avcodec_decode_video2(), avcodec_default_release_buffer(), avs_decode_end(), bethsoftvid_decode_end(), cavs_decode_frame(), cdg_decode_frame(), cinvideo_decode_end(), cmv_decode_frame(), cmv_process_header(), copy_frame(), decode_audio(), decode_close(), decode_end(), decode_flush(), decode_frame(), decode_pic(), decode_video(), dirac_decode_frame(), dvvideo_close(), encode_end(), encode_picture_lossless(), escape124_decode_close(), escape124_decode_frame(), escape130_decode_close(), escape130_decode_frame(), execute_code(), ff_mjpeg_decode_end(), ff_mjpeg_decode_sof(), ff_mpeg_unref_picture(), ff_snow_common_end(), ff_snow_release_buffer(), ff_thread_flush(), ff_thread_release_buffer(), ff_vc1_decode_blocks(), ff_vc1_decode_end(), ff_vp56_decode_frame(), ff_vp56_decode_mbs(), ffv1_close(), flashsv_decode_end(), flashsv_decode_frame(), flic_decode_end(), flush(), frame_configure_elements(), frame_thread_free(), free_picture(), free_sequence_buffers(), get_audio_buffer(), get_video_buffer(), get_video_frame(), gif_decode_frame(), gif_encode_frame(), ipvideo_decode_frame(), ir2_decode_end(), lavfi_read_packet(), main(), mm_decode_end(), mp_decode_end(), msrle_decode_end(), mss1_decode_end(), mss2_decode_end(), mss2_decode_frame(), mss3_decode_end(), msvideo1_decode_end(), mxpeg_decode_end(), mxpeg_decode_frame(), qtrle_decode_end(), reap_filters(), reget_buffer_internal(), release_delayed_buffers(), rpza_decode_end(), select_input_picture(), seqvideo_decode_end(), smc_decode_end(), sub2video_get_blank_frame(), svq1_decode_frame(), svq1_encode_end(), svq1_flush(), svq3_decode_end(), svq3_decode_frame(), tgv_decode_end(), tgv_decode_frame(), truemotion1_decode_end(), truemotion1_decode_header(), ulti_decode_end(), video_get_buffer(), video_thread(), vmdvideo_decode_end(), vmdvideo_decode_frame(), vorbis_decode_frame(), vp3_decode_frame(), worker(), xan_decode_frame(), zerocodec_decode_close(), and zerocodec_decode_frame().

AVDictionary** avpriv_frame_get_metadatap ( AVFrame frame)