23#ifndef AVCODEC_HEVC_HEVCDEC_H
24#define AVCODEC_HEVC_HEVCDEC_H
45#define SHIFT_CTB_WPP 2
49#define DEFAULT_INTRA_TC_OFFSET 2
51#define HEVC_CONTEXTS 199
52#define HEVC_STAT_COEFFS 4
54#define MRG_MAX_NUM_CANDS 5
59#define EPEL_EXTRA_BEFORE 1
60#define EPEL_EXTRA_AFTER 2
62#define QPEL_EXTRA_BEFORE 3
63#define QPEL_EXTRA_AFTER 4
66#define EDGE_EMU_BUFFER_STRIDE 80
71#define SAMPLE(tab, x, y) ((tab)[(y) * s->sps->width + (x)])
72#define SAMPLE_CTB(tab, x, y) ((tab)[(y) * min_cb_width + (x)])
74#define IS_IDR(s) ((s)->nal_unit_type == HEVC_NAL_IDR_W_RADL || (s)->nal_unit_type == HEVC_NAL_IDR_N_LP)
75#define IS_BLA(s) ((s)->nal_unit_type == HEVC_NAL_BLA_W_RADL || (s)->nal_unit_type == HEVC_NAL_BLA_W_LP || \
76 (s)->nal_unit_type == HEVC_NAL_BLA_N_LP)
77#define IS_IRAP(s) ((s)->nal_unit_type >= HEVC_NAL_BLA_W_LP && (s)->nal_unit_type <= HEVC_NAL_RSV_IRAP_VCL23)
79#define HEVC_RECOVERY_UNSPECIFIED INT_MAX
80#define HEVC_RECOVERY_END INT_MIN
81#define HEVC_IS_RECOVERING(s) ((s)->recovery_poc != HEVC_RECOVERY_UNSPECIFIED && (s)->recovery_poc != HEVC_RECOVERY_END)
354#define HEVC_FRAME_FLAG_OUTPUT (1 << 0)
355#define HEVC_FRAME_FLAG_SHORT_REF (1 << 1)
356#define HEVC_FRAME_FLAG_LONG_REF (1 << 2)
357#define HEVC_FRAME_FLAG_UNAVAILABLE (1 << 3)
358#define HEVC_FRAME_FLAG_CORRUPT (1 << 4)
439#define BOUNDARY_LEFT_SLICE (1 << 0)
440#define BOUNDARY_LEFT_TILE (1 << 1)
441#define BOUNDARY_UPPER_SLICE (1 << 2)
442#define BOUNDARY_UPPER_TILE (1 << 3)
611 int ctb_addr_ts,
const uint8_t *
data,
size_t size,
622 int x0,
int y0,
int x_cb,
int y_cb,
int min_cb_width);
626 int ct_depth,
int x0,
int y0);
681 unsigned layers_active_decode,
unsigned layers_active_output,
682 unsigned max_output,
unsigned max_dpb,
int discard);
687 int nPbW,
int nPbH,
int log2_ctb_size);
690 int nPbW,
int nPbH,
int log2_cb_size,
691 int part_idx,
int merge_idx,
MvField *
mv);
694 int nPbW,
int nPbH,
int log2_cb_size,
695 int part_idx,
int merge_idx,
699 int x,
int y,
int ctb_size);
702 int x_ctb,
int y_ctb,
int ctb_size);
705 int xBase,
int yBase,
int log2_cb_size);
708 int x0,
int y0,
int log2_trafo_size);
715 int log2_trafo_size,
enum ScanType scan_idx,
static void bit_depth(AudioStatsContext *s, const uint64_t *const mask, uint8_t *depth)
Libavcodec external API header.
refcounted data buffer API
Context Adaptive Binary Arithmetic Coder.
#define flags(name, subs,...)
static int FUNC sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
#define HEVC_VPS_MAX_LAYERS
int ff_hevc_end_of_slice_flag_decode(HEVCLocalContext *lc)
int ff_hevc_cu_transquant_bypass_flag_decode(HEVCLocalContext *lc)
int ff_hevc_output_frames(HEVCContext *s, unsigned layers_active_decode, unsigned layers_active_output, unsigned max_output, unsigned max_dpb, int discard)
Find frames in the DPB that are ready for output and either write them to the output FIFO or drop the...
int ff_hevc_sao_type_idx_decode(HEVCLocalContext *lc)
void ff_hevc_set_qPy(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, int xBase, int yBase, int log2_cb_size)
int ff_hevc_no_residual_syntax_flag_decode(HEVCLocalContext *lc)
int ff_hevc_sao_merge_flag_decode(HEVCLocalContext *lc)
void ff_hevc_flush_dpb(HEVCContext *s)
Drop all frames currently in DPB.
int ff_hevc_merge_flag_decode(HEVCLocalContext *lc)
int ff_hevc_cu_chroma_qp_offset_flag(HEVCLocalContext *lc)
int ff_hevc_cu_chroma_qp_offset_idx(HEVCLocalContext *lc, int chroma_qp_offset_list_len_minus1)
int ff_hevc_sao_offset_abs_decode(HEVCLocalContext *lc, int bit_depth)
int ff_hevc_frame_nb_refs(const SliceHeader *sh, const HEVCPPS *pps, unsigned layer_idx)
Get the number of candidate references for the current frame.
int ff_hevc_res_scale_sign_flag(HEVCLocalContext *lc, int idx)
void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, int x0, int y0, int log2_trafo_size)
int ff_hevc_cu_qp_delta_abs(HEVCLocalContext *lc)
int ff_hevc_mvp_lx_flag_decode(HEVCLocalContext *lc)
void ff_hevc_clear_refs(HEVCLayerContext *l)
Mark all frames in DPB as unused for reference.
void ff_hevc_save_states(HEVCLocalContext *lc, const HEVCPPS *pps, int ctb_addr_ts)
int ff_hevc_split_transform_flag_decode(HEVCLocalContext *lc, int log2_trafo_size)
int ff_hevc_cabac_init(HEVCLocalContext *lc, const HEVCPPS *pps, int ctb_addr_ts, const uint8_t *data, size_t size, int is_wpp)
int ff_hevc_log2_res_scale_abs(HEVCLocalContext *lc, int idx)
const RefPicList * ff_hevc_get_ref_list(const HEVCFrame *frame, int x0, int y0)
int ff_hevc_sao_eo_class_decode(HEVCLocalContext *lc)
void ff_hevc_hls_mvd_coding(HEVCLocalContext *lc, int x0, int y0, int log2_cb_size)
int ff_hevc_set_new_ref(HEVCContext *s, HEVCLayerContext *l, int poc)
int ff_hevc_frame_rps(HEVCContext *s, HEVCLayerContext *l)
Construct the reference picture sets for the current frame.
int ff_hevc_mpm_idx_decode(HEVCLocalContext *lc)
void ff_hevc_luma_mv_mvp_mode(HEVCLocalContext *lc, const HEVCPPS *pps, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int part_idx, int merge_idx, MvField *mv, int mvp_lx_flag, int LX)
int ff_hevc_is_alpha_video(const HEVCContext *s)
int ff_hevc_sao_band_position_decode(HEVCLocalContext *lc)
int ff_hevc_inter_pred_idc_decode(HEVCLocalContext *lc, int nPbW, int nPbH)
void ff_hevc_hls_filters(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, int x_ctb, int y_ctb, int ctb_size)
int ff_hevc_cbf_cb_cr_decode(HEVCLocalContext *lc, int trafo_depth)
int ff_hevc_rem_intra_luma_pred_mode_decode(HEVCLocalContext *lc)
int ff_hevc_sao_offset_sign_decode(HEVCLocalContext *lc)
int ff_hevc_intra_chroma_pred_mode_decode(HEVCLocalContext *lc)
int ff_hevc_cbf_luma_decode(HEVCLocalContext *lc, int trafo_depth)
int ff_hevc_merge_idx_decode(HEVCLocalContext *lc)
static av_always_inline int ff_hevc_nal_is_nonref(enum HEVCNALUnitType type)
const uint8_t ff_hevc_qpel_extra_after[4]
void ff_hevc_set_neighbour_available(HEVCLocalContext *lc, int x0, int y0, int nPbW, int nPbH, int log2_ctb_size)
void ff_hevc_luma_mv_merge_mode(HEVCLocalContext *lc, const HEVCPPS *pps, int x0, int y0, int nPbW, int nPbH, int log2_cb_size, int part_idx, int merge_idx, MvField *mv)
void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, const HEVCPPS *pps, int x0, int y0, int log2_trafo_size, enum ScanType scan_idx, int c_idx)
int ff_hevc_split_coding_unit_flag_decode(HEVCLocalContext *lc, uint8_t *tab_ct_depth, const HEVCSPS *sps, int ct_depth, int x0, int y0)
int ff_hevc_pcm_flag_decode(HEVCLocalContext *lc)
int ff_hevc_part_mode_decode(HEVCLocalContext *lc, const HEVCSPS *sps, int log2_cb_size)
void ff_hevc_unref_frame(HEVCFrame *frame, int flags)
int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, uint8_t *skip_flag, int x0, int y0, int x_cb, int y_cb, int min_cb_width)
int ff_hevc_cu_qp_delta_sign_flag(HEVCLocalContext *lc)
void ff_hevc_hls_filter(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, int x, int y, int ctb_size)
int ff_hevc_prev_intra_luma_pred_flag_decode(HEVCLocalContext *lc)
int ff_hevc_slice_rpl(HEVCContext *s)
Construct the reference picture list(s) for the current slice.
const uint8_t ff_hevc_qpel_extra[4]
int ff_hevc_pred_mode_decode(HEVCLocalContext *lc)
#define EDGE_EMU_BUFFER_STRIDE
int ff_hevc_ref_idx_lx_decode(HEVCLocalContext *lc, int num_ref_idx_lx)
const uint8_t ff_hevc_qpel_extra_before[4]
static const int8_t mv[256][2]
HEVCNALUnitType
Table 7-1 – NAL unit type codes and NAL unit type classes in T-REC-H.265-201802.
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
A reference to a data buffer.
Describe the class of an AVClass context structure.
main external API structure.
AVContainerFifo is a FIFO for "containers" - dynamically allocated reusable structs (e....
This structure describes decoded (raw) audio or video data.
AVRefStructPool is an API for a thread-safe pool of objects managed via the RefStruct API.
enum PredMode pred_mode
PredMode.
uint8_t intra_split_flag
IntraSplitFlag.
uint8_t max_trafo_depth
MaxTrafoDepth.
enum PartMode part_mode
PartMode.
uint8_t cu_transquant_bypass_flag
uint8_t state[HEVC_CONTEXTS]
uint8_t stat_coeff[HEVC_STAT_COEFFS]
int is_nalff
this flag is != 0 if bitstream is encapsulated as a format defined in 14496-15
HEVCLocalContext * local_ctx
int film_grain_warning_shown
int last_eos
last packet contains an EOS/EOB NAL
unsigned nb_view_pos_available
int temporal_id
temporal_id_plus1 - 1
AVBufferRef * rpu_buf
0 or 1 Dolby Vision RPUs.
const HEVCPPS * pps
RefStruct reference.
struct AVContainerFifo * output_fifo
int nal_length_size
Number of bytes used for nal length (1, 2 or 4)
unsigned nb_view_ids_available
HEVCLayerContext layers[HEVC_VPS_MAX_LAYERS]
HEVCFrame * collocated_ref
struct ThreadProgress * wpp_progress
uint8_t * checksum_buf
used on BE to byteswap the lines for checksumming
unsigned * view_pos_available
unsigned finish_setup_nal_idx
HEVCCABACState cabac
The target for the common_cabac_state of the local contexts.
unsigned * view_ids_available
RefPicList rps[NB_RPS_TYPE]
candidate references for the current frame
int eos
current packet contains an EOS/EOB NAL
unsigned layers_active_output
DOVIContext dovi_ctx
Dolby Vision decoding context.
uint8_t slice_initialized
1 if the independent slice segment header was successfully parsed
enum HEVCNALUnitType first_nal_type
const HEVCVPS * vps
RefStruct reference.
enum HEVCNALUnitType nal_unit_type
int slice_idx
number of the slice being currently decoded
unsigned layers_active_decode
RefPicListTab ** rpl_tab
RefStruct reference.
void * hwaccel_picture_private
RefStruct reference.
const HEVCPPS * pps
RefStruct reference.
RefPicListTab * rpl
RefStruct reference.
uint8_t flags
A combination of HEVC_FRAME_FLAG_*.
MvField * tab_mvf
RefStruct reference.
uint8_t * filter_slice_edges
struct AVRefStructPool * rpl_tab_pool
int32_t * tab_slice_address
uint8_t * sao_pixel_buffer_h[3]
struct AVRefStructPool * tab_mvf_pool
uint8_t * sao_pixel_buffer_v[3]
uint8_t edge_emu_buffer[(MAX_PB_SIZE+7) *EDGE_EMU_BUFFER_STRIDE *2]
uint8_t cabac_state[HEVC_CONTEXTS]
const struct HEVCContext * parent
int16_t tmp[MAX_PB_SIZE *MAX_PB_SIZE]
HEVCCABACState * common_cabac_state
This is a pointer to the common CABAC state.
uint8_t ctb_up_right_flag
uint8_t edge_emu_buffer2[(MAX_PB_SIZE+7) *EDGE_EMU_BUFFER_STRIDE *2]
uint8_t stat_coeff[HEVC_STAT_COEFFS]
uint8_t poc_msb_present[32]
int8_t ref_idx[2]
refIdxL0, refIdxL1
int16_t x
horizontal component of motion vector
int16_t y
vertical component of motion vector
uint8_t intra_pred_mode_c[4]
uint8_t intra_pred_mode[4]
int rem_intra_luma_pred_mode
The ProgressFrame structure.
int isLongTerm[HEVC_MAX_REFS]
struct HEVCFrame * ref[HEVC_MAX_REFS]
ThreadProgress is an API to easily notify other threads about progress of any kind as long as it can ...
Core video DSP helper functions.