Go to the documentation of this file.
23 #ifndef AVCODEC_HEVC_HEVCDEC_H
24 #define AVCODEC_HEVC_HEVCDEC_H
26 #include <stdatomic.h>
47 #define SHIFT_CTB_WPP 2
49 #define MAX_TB_SIZE 32
51 #define DEFAULT_INTRA_TC_OFFSET 2
53 #define HEVC_CONTEXTS 199
54 #define HEVC_STAT_COEFFS 4
56 #define MRG_MAX_NUM_CANDS 5
61 #define EPEL_EXTRA_BEFORE 1
62 #define EPEL_EXTRA_AFTER 2
64 #define QPEL_EXTRA_BEFORE 3
65 #define QPEL_EXTRA_AFTER 4
68 #define EDGE_EMU_BUFFER_STRIDE 80
73 #define SAMPLE(tab, x, y) ((tab)[(y) * s->sps->width + (x)])
74 #define SAMPLE_CTB(tab, x, y) ((tab)[(y) * min_cb_width + (x)])
76 #define IS_IDR(s) ((s)->nal_unit_type == HEVC_NAL_IDR_W_RADL || (s)->nal_unit_type == HEVC_NAL_IDR_N_LP)
77 #define IS_BLA(s) ((s)->nal_unit_type == HEVC_NAL_BLA_W_RADL || (s)->nal_unit_type == HEVC_NAL_BLA_W_LP || \
78 (s)->nal_unit_type == HEVC_NAL_BLA_N_LP)
79 #define IS_IRAP(s) ((s)->nal_unit_type >= HEVC_NAL_BLA_W_LP && (s)->nal_unit_type <= HEVC_NAL_RSV_IRAP_VCL23)
352 #define HEVC_FRAME_FLAG_OUTPUT (1 << 0)
353 #define HEVC_FRAME_FLAG_SHORT_REF (1 << 1)
354 #define HEVC_FRAME_FLAG_LONG_REF (1 << 2)
355 #define HEVC_FRAME_FLAG_UNAVAILABLE (1 << 3)
436 #define BOUNDARY_LEFT_SLICE (1 << 0)
437 #define BOUNDARY_LEFT_TILE (1 << 1)
438 #define BOUNDARY_UPPER_SLICE (1 << 2)
439 #define BOUNDARY_UPPER_TILE (1 << 3)
608 int ctb_addr_ts,
const uint8_t *
data,
size_t size,
619 int x0,
int y0,
int x_cb,
int y_cb,
int min_cb_width);
623 int ct_depth,
int x0,
int y0);
678 unsigned layers_active_decode,
unsigned layers_active_output,
679 unsigned max_output,
unsigned max_dpb,
int discard);
684 int nPbW,
int nPbH,
int log2_ctb_size);
687 int nPbW,
int nPbH,
int log2_cb_size,
688 int part_idx,
int merge_idx,
MvField *
mv);
691 int nPbW,
int nPbH,
int log2_cb_size,
692 int part_idx,
int merge_idx,
696 int x,
int y,
int ctb_size);
699 int x_ctb,
int y_ctb,
int ctb_size);
702 int xBase,
int yBase,
int log2_cb_size);
705 int x0,
int y0,
int log2_trafo_size);
712 int log2_trafo_size,
enum ScanType scan_idx,
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 temporal_id
temporal_id_plus1 - 1
int ff_hevc_cu_chroma_qp_offset_idx(HEVCLocalContext *lc, int chroma_qp_offset_list_len_minus1)
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)
uint8_t flags
A combination of HEVC_FRAME_FLAG_*.
unsigned * view_pos_available
RefPicList rps[NB_RPS_TYPE]
ThreadProgress is an API to easily notify other threads about progress of any kind as long as it can ...
unsigned layers_active_output
void ff_hevc_set_neighbour_available(HEVCLocalContext *lc, int x0, int y0, int nPbW, int nPbH, int log2_ctb_size)
#define HEVC_VPS_MAX_LAYERS
uint8_t slice_initialized
1 if the independent slice segment header was successfully parsed
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)
unsigned nb_view_ids_available
static const int8_t mv[256][2]
struct AVMD5 * md5_ctx
candidate references for the current frame
void ff_hevc_flush_dpb(HEVCContext *s)
Drop all frames currently in DPB.
void ff_hevc_save_states(HEVCLocalContext *lc, const HEVCPPS *pps, int ctb_addr_ts)
This structure describes decoded (raw) audio or video data.
int ff_hevc_sao_type_idx_decode(HEVCLocalContext *lc)
MvField * tab_mvf
RefStruct reference.
int ff_hevc_intra_chroma_pred_mode_decode(HEVCLocalContext *lc)
void * hwaccel_picture_private
RefStruct reference.
const uint8_t ff_hevc_qpel_extra_before[4]
HEVCFrame * collocated_ref
int16_t y
vertical component of motion vector
const RefPicList * ff_hevc_get_ref_list(const HEVCFrame *frame, int x0, int y0)
int ff_hevc_rem_intra_luma_pred_mode_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_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_eo_class_decode(HEVCLocalContext *lc)
int ff_hevc_cu_qp_delta_abs(HEVCLocalContext *lc)
Decoded Picture Buffer (DPB).
int ff_hevc_ref_idx_lx_decode(HEVCLocalContext *lc, int num_ref_idx_lx)
uint8_t * checksum_buf
used on BE to byteswap the lines for checksumming
static void bit_depth(AudioStatsContext *s, const uint64_t *const mask, uint8_t *depth)
int ff_hevc_cbf_luma_decode(HEVCLocalContext *lc, int trafo_depth)
int ff_hevc_sao_offset_abs_decode(HEVCLocalContext *lc, int bit_depth)
int ff_hevc_cbf_cb_cr_decode(HEVCLocalContext *lc, int trafo_depth)
uint8_t ctb_up_right_flag
int32_t * tab_slice_address
HEVCCABACState * common_cabac_state
This is a pointer to the common CABAC state.
uint8_t * sao_pixel_buffer_v[3]
uint8_t * sao_pixel_buffer_h[3]
int ff_hevc_cu_qp_delta_sign_flag(HEVCLocalContext *lc)
int ff_hevc_end_of_slice_flag_decode(HEVCLocalContext *lc)
uint8_t intra_pred_mode_c[4]
unsigned finish_setup_nal_idx
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
H274FilmGrainDatabase h274db
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)
int ff_hevc_part_mode_decode(HEVCLocalContext *lc, const HEVCSPS *sps, int log2_cb_size)
struct FFRefStructPool * rpl_tab_pool
int ff_hevc_cabac_init(HEVCLocalContext *lc, const HEVCPPS *pps, int ctb_addr_ts, const uint8_t *data, size_t size, int is_wpp)
const struct HEVCContext * parent
int last_eos
last packet contains an EOS/EOB NAL
HEVCNALUnitType
Table 7-1 – NAL unit type codes and NAL unit type classes in T-REC-H.265-201802.
int slice_idx
number of the slice being currently decoded
static av_always_inline int ff_hevc_nal_is_nonref(enum HEVCNALUnitType type)
const uint8_t ff_hevc_qpel_extra[4]
RefPicListTab * rpl
RefStruct reference.
struct HEVCFrame * ref[HEVC_MAX_REFS]
struct FFRefStructPool * tab_mvf_pool
FFRefStructPool is an API for a thread-safe pool of objects managed via the RefStruct API.
const HEVCPPS * pps
RefStruct reference.
uint8_t max_trafo_depth
MaxTrafoDepth.
enum HEVCNALUnitType nal_unit_type
const HEVCVPS * vps
RefStruct reference.
int rem_intra_luma_pred_mode
Describe the class of an AVClass context structure.
uint8_t state[HEVC_CONTEXTS]
int16_t tmp[MAX_PB_SIZE *MAX_PB_SIZE]
int ff_hevc_merge_flag_decode(HEVCLocalContext *lc)
uint8_t cu_transquant_bypass_flag
unsigned * view_ids_available
RefPicListTab ** rpl_tab
RefStruct reference.
uint8_t poc_msb_present[32]
int ff_hevc_split_transform_flag_decode(HEVCLocalContext *lc, int log2_trafo_size)
int film_grain_warning_shown
int is_nalff
this flag is != 0 if bitstream is encapsulated as a format defined in 14496-15
int16_t x
horizontal component of motion vector
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)
uint8_t edge_emu_buffer[(MAX_PB_SIZE+7) *EDGE_EMU_BUFFER_STRIDE *2]
void ff_hevc_hls_filter(HEVCLocalContext *lc, const HEVCLayerContext *l, const HEVCPPS *pps, int x, int y, int ctb_size)
int nal_length_size
Number of bytes used for nal length (1, 2 or 4)
int ff_hevc_set_new_ref(HEVCContext *s, HEVCLayerContext *l, int poc)
int ff_hevc_cu_transquant_bypass_flag_decode(HEVCLocalContext *lc)
int ff_hevc_frame_rps(HEVCContext *s, HEVCLayerContext *l)
Construct the reference picture sets for the current frame.
#define DECLARE_ALIGNED(n, t, v)
void ff_hevc_unref_frame(HEVCFrame *frame, int flags)
int ff_hevc_mpm_idx_decode(HEVCLocalContext *lc)
uint8_t cabac_state[HEVC_CONTEXTS]
ContainerFifo is a FIFO for "containers" - dynamically allocated reusable structs (e....
DOVIContext dovi_ctx
Dolby Vision decoding context.
int ff_hevc_no_residual_syntax_flag_decode(HEVCLocalContext *lc)
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.
uint8_t * filter_slice_edges
int ff_hevc_inter_pred_idc_decode(HEVCLocalContext *lc, int nPbW, int nPbH)
HEVCCABACState cabac
The target for the common_cabac_state of the local contexts.
int ff_hevc_sao_merge_flag_decode(HEVCLocalContext *lc)
#define EDGE_EMU_BUFFER_STRIDE
int ff_hevc_pred_mode_decode(HEVCLocalContext *lc)
const uint8_t ff_hevc_qpel_extra_after[4]
struct ThreadProgress * wpp_progress
uint8_t stat_coeff[HEVC_STAT_COEFFS]
const HEVCPPS * pps
RefStruct reference.
enum HEVCNALUnitType first_nal_type
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
uint8_t edge_emu_buffer2[(MAX_PB_SIZE+7) *EDGE_EMU_BUFFER_STRIDE *2]
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
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_merge_idx_decode(HEVCLocalContext *lc)
main external API structure.
unsigned nb_view_pos_available
unsigned layers_active_decode
void ff_hevc_hls_mvd_coding(HEVCLocalContext *lc, int x0, int y0, int log2_cb_size)
int ff_hevc_prev_intra_luma_pred_flag_decode(HEVCLocalContext *lc)
enum PredMode pred_mode
PredMode.
HEVCLayerContext layers[HEVC_VPS_MAX_LAYERS]
AVBufferRef * rpu_buf
0 or 1 Dolby Vision RPUs.
HEVCLocalContext * local_ctx
int ff_hevc_sao_offset_sign_decode(HEVCLocalContext *lc)
struct ContainerFifo * output_fifo
int ff_hevc_log2_res_scale_abs(HEVCLocalContext *lc, int idx)
void ff_hevc_clear_refs(HEVCLayerContext *l)
Mark all frames in DPB as unused for reference.
int8_t ref_idx[2]
refIdxL0, refIdxL1
A reference to a data buffer.
uint8_t stat_coeff[HEVC_STAT_COEFFS]
int ff_hevc_slice_rpl(HEVCContext *s)
Construct the reference picture list(s) for the current slice.
int eos
current packet contains an EOS/EOB NAL
int ff_hevc_sao_band_position_decode(HEVCLocalContext *lc)
enum PartMode part_mode
PartMode.
The ProgressFrame structure.
#define flags(name, subs,...)
uint8_t intra_pred_mode[4]
int ff_hevc_pcm_flag_decode(HEVCLocalContext *lc)
int isLongTerm[HEVC_MAX_REFS]
uint8_t intra_split_flag
IntraSplitFlag.
int ff_hevc_mvp_lx_flag_decode(HEVCLocalContext *lc)
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_cu_chroma_qp_offset_flag(HEVCLocalContext *lc)