HEVCContext和HEVCFrame是ffmpeg的HEVC解码中非常重要的结构体。
首先来看下HEVCContext,定义位于libavcodec\Hevc.h中。代码如下:
typedef struct HEVCContext {
const AVClass *c; // needed by private avoptions
AVCodecContext *avctx;
struct HEVCContext *sList[MAX_NB_THREADS];
HEVCLocalContext *HEVClcList[MAX_NB_THREADS];
HEVCLocalContext *HEVClc;
uint8_t threads_type;
uint8_t threads_number;
int width;
int height;
uint8_t *cabac_state;
/** 1 if the independent slice segment header was successfully parsed */
uint8_t slice_initialized;
AVFrame *frame;
AVFrame *output_frame;
uint8_t *sao_pixel_buffer_h[3];
uint8_t *sao_pixel_buffer_v[3];
HEVCParamSets ps;
AVBufferPool *tab_mvf_pool;
AVBufferPool *rpl_tab_pool;
///< candidate references for the current frame
RefPicList rps[5];
SliceHeader sh;
SAOParams *sao;
DBParams *deblock;
enum NALUnitType nal_unit_type;
int temporal_id; ///< temporal_id_plus1 - 1
HEVCFrame *ref;
HEVCFrame DPB[32];
int poc;
int pocTid0;
int slice_idx; ///< number of the slice being currently decoded
int eos; ///< current packet contains an EOS/EOB NAL
int last_eos; ///< last packet contains an EOS/EOB NAL
int max_ra;
int bs_width;
int bs_height;
int is_decoded;
int no_rasl_output_flag;
HEVCPredContext hpc;
HEVCDSPContext hevcdsp;
VideoDSPContext vdsp;
BswapDSPContext bdsp;
int8_t *qp_y_tab;
uint8_t *horizontal_bs;
uint8_t *vertical_bs;
int32_t *tab_slice_address;
// CU
uint8_t *skip_flag;
uint8_t *tab_ct_depth;
// PU
uint8_t *tab_ipm;
uint8_t *cbf_luma; // cbf_luma of colocated TU
uint8_t *is_pcm;
// CTB-level flags affecting loop filter operation
uint8_t *filter_slice_edges;
/** used on BE to byteswap the