1.描述
AVFrame
用來存儲解碼后的(或原始)音頻或視頻數據,位于avcodec.h文件中。
AVFrame
必須由av_frame_alloc()
分配內存,同時必須由av_frame_free()
釋放。
AVFrame
分配內存后能夠被多次用來存儲不同的數據(例如:decoder解碼后的幀)。av_frame_unref
釋放任何持幀的引用,并結構體還原到未被使用的狀態。
2.常見變量及其作用
uint8_t * data [AV_NUM_DATA_POINTERS];//解碼后原始數據(對視頻來說是YUV,RGB,對音頻來說是PCM)。
int linesize[AV_NUM_DATA_POINTERS];//在視頻中,表示圖片一行數據的大小。
uint8_t **extended_data;//指向數據平面/通道。
int width, height;//一個視頻幀的寬度和高度。
int nb_samples;//這個AVFrame中的每個音頻通道中包含的音頻幀個數。
int format;//表示解碼后的數據類型或格式,-1表示未被設置或不能識別的類型。
int key_frame;//是否為關鍵幀。
enum AVPictureType pict_type;//幀的類型。
AVRational sample_aspect_ratio;//視頻幀的寬高比,0表示未知。
int64_t pts;//顯示時間戳,表示該什么時候被顯示。
int64_t pkt_dts;//從AVPacket中拷貝的值。
int coded_picture_number;//編碼幀序號。
int display_picture_number;//顯示幀需要。
void *opaque;//用戶私有信息。
int repeat_pict;//解碼時,每幀圖片延遲的時間,extra_delay = repeat_pict / (2*fps)。
int interlaced_frame;//是否是隔行掃描
int sample_rate;//音頻的采樣率。
uint64_t channel_layout;//音頻的布局方式。
/**
* MPEG vs JPEG YUV range.
* - encoding: Set by user
* - decoding: Set by libavcodec
*/
enum AVColorRange color_range;
enum AVColorPrimaries color_primaries;
enum AVColorTransferCharacteristic color_trc;
/**
* YUV colorspace type.
* - encoding: Set by user
* - decoding: Set by libavcodec
*/
enum AVColorSpace colorspace;
enum AVChromaLocation chroma_location;
/**
* frame timestamp estimated using various heuristics, in stream time base
* - encoding: unused
* - decoding: set by libavcodec, read by user.
*/
int64_t best_effort_timestamp;
/**
* reordered pos from the last AVPacket that has been input into the decoder
* - encoding: unused
* - decoding: Read by user.
*/
int64_t pkt_pos;
/**
* duration of the corresponding packet, expressed in
* AVStream->time_base units, 0 if unknown.
* - encoding: unused
* - decoding: Read by user.
*/
int64_t pkt_duration;
/**
* metadata.
* - encoding: Set by user.
* - decoding: Set by libavcodec.
*/
AVDictionary *metadata;
/**
* decode error flags of the frame, set to a combination of
* FF_DECODE_ERROR_xxx flags if the decoder produced a frame, but there
* were errors during the decoding.
* - encoding: unused
* - decoding: set by libavcodec, read by user.
*/
int decode_error_flags;
/**
* number of audio channels, only used for audio.
* - encoding: unused
* - decoding: Read by user.
*/
int channels;//音頻通道個數
/**
* size of the corresponding packet containing the compressed
* frame.
* It is set to a negative value if unknown.
* - encoding: unused
* - decoding: set by libavcodec, read by user.
*/
int pkt_size;
int8_t *qscale_table;
int qstride;
int qscale_type;
AVBufferRef *qp_table_buf;
/**
* For hwaccel-format frames, this should be a reference to the
* AVHWFramesContext describing the frame.
*/
AVBufferRef *hw_frames_ctx;
/**
* AVBufferRef for free use by the API user. FFmpeg will never check the
* contents of the buffer ref. FFmpeg calls av_buffer_unref() on it when
* the frame is unreferenced. av_frame_copy_props() calls create a new
* reference with av_buffer_ref() for the target frame's opaque_ref field.
*
* This is unrelated to the opaque field, although it serves a similar
* purpose.
*/
AVBufferRef *opaque_ref;