1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

lavc/hevc/cabac: stop accessing parameter sets through HEVCParamSets

Instead, accept PPS/SPS as function arguments.

Makes the code shorter and significantly reduces diff in future commits.
This commit is contained in:
Anton Khirnov 2024-05-31 13:55:39 +02:00
parent b38aecffec
commit d0868d70ea
3 changed files with 102 additions and 96 deletions

View File

@ -399,25 +399,25 @@ static const uint8_t diag_scan8x8_inv[8][8] = {
{ 28, 36, 43, 49, 54, 58, 61, 63, },
};
void ff_hevc_save_states(HEVCLocalContext *lc, int ctb_addr_ts)
void ff_hevc_save_states(HEVCLocalContext *lc, const HEVCPPS *pps,
int ctb_addr_ts)
{
const HEVCContext *const s = lc->parent;
if (s->ps.pps->entropy_coding_sync_enabled_flag &&
(ctb_addr_ts % s->ps.sps->ctb_width == 2 ||
(s->ps.sps->ctb_width == 2 &&
ctb_addr_ts % s->ps.sps->ctb_width == 0))) {
const HEVCSPS *const sps = pps->sps;
if (pps->entropy_coding_sync_enabled_flag &&
(ctb_addr_ts % sps->ctb_width == 2 ||
(sps->ctb_width == 2 &&
ctb_addr_ts % sps->ctb_width == 0))) {
memcpy(lc->common_cabac_state->state, lc->cabac_state, HEVC_CONTEXTS);
if (s->ps.sps->persistent_rice_adaptation_enabled) {
if (sps->persistent_rice_adaptation_enabled) {
memcpy(lc->common_cabac_state->stat_coeff, lc->stat_coeff, HEVC_STAT_COEFFS);
}
}
}
static void load_states(HEVCLocalContext *lc, const HEVCContext *s)
static void load_states(HEVCLocalContext *lc, const HEVCSPS *sps)
{
memcpy(lc->cabac_state, lc->common_cabac_state->state, HEVC_CONTEXTS);
if (s->ps.sps->persistent_rice_adaptation_enabled) {
if (sps->persistent_rice_adaptation_enabled) {
memcpy(lc->stat_coeff, lc->common_cabac_state->stat_coeff, HEVC_STAT_COEFFS);
}
}
@ -451,32 +451,33 @@ static void cabac_init_state(HEVCLocalContext *lc, const HEVCContext *s)
lc->stat_coeff[i] = 0;
}
int ff_hevc_cabac_init(HEVCLocalContext *lc, int ctb_addr_ts,
const uint8_t *data, size_t size)
int ff_hevc_cabac_init(HEVCLocalContext *lc, const HEVCPPS *pps,
int ctb_addr_ts, const uint8_t *data, size_t size)
{
const HEVCContext *const s = lc->parent;
const HEVCSPS *const sps = pps->sps;
if (ctb_addr_ts == s->ps.pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]) {
if (ctb_addr_ts == pps->ctb_addr_rs_to_ts[s->sh.slice_ctb_addr_rs]) {
int ret = ff_init_cabac_decoder(&lc->cc, data, size);
if (ret < 0)
return ret;
if (s->sh.dependent_slice_segment_flag == 0 ||
(s->ps.pps->tiles_enabled_flag &&
s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[ctb_addr_ts - 1]))
(pps->tiles_enabled_flag &&
pps->tile_id[ctb_addr_ts] != pps->tile_id[ctb_addr_ts - 1]))
cabac_init_state(lc, s);
if (!s->sh.first_slice_in_pic_flag &&
s->ps.pps->entropy_coding_sync_enabled_flag) {
if (ctb_addr_ts % s->ps.sps->ctb_width == 0) {
if (s->ps.sps->ctb_width == 1)
pps->entropy_coding_sync_enabled_flag) {
if (ctb_addr_ts % sps->ctb_width == 0) {
if (sps->ctb_width == 1)
cabac_init_state(lc, s);
else if (s->sh.dependent_slice_segment_flag == 1)
load_states(lc, s);
load_states(lc, sps);
}
}
} else {
if (s->ps.pps->tiles_enabled_flag &&
s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[ctb_addr_ts - 1]) {
if (pps->tiles_enabled_flag &&
pps->tile_id[ctb_addr_ts] != pps->tile_id[ctb_addr_ts - 1]) {
int ret;
if (s->threads_number == 1)
ret = cabac_reinit(lc);
@ -487,8 +488,8 @@ int ff_hevc_cabac_init(HEVCLocalContext *lc, int ctb_addr_ts,
return ret;
cabac_init_state(lc, s);
}
if (s->ps.pps->entropy_coding_sync_enabled_flag) {
if (ctb_addr_ts % s->ps.sps->ctb_width == 0) {
if (pps->entropy_coding_sync_enabled_flag) {
if (ctb_addr_ts % sps->ctb_width == 0) {
int ret;
get_cabac_terminate(&lc->cc);
if (s->threads_number == 1)
@ -499,10 +500,10 @@ int ff_hevc_cabac_init(HEVCLocalContext *lc, int ctb_addr_ts,
if (ret < 0)
return ret;
if (s->ps.sps->ctb_width == 1)
if (sps->ctb_width == 1)
cabac_init_state(lc, s);
else
load_states(lc, s);
load_states(lc, sps);
}
}
}
@ -536,10 +537,10 @@ int ff_hevc_sao_band_position_decode(HEVCLocalContext *lc)
return value;
}
int ff_hevc_sao_offset_abs_decode(HEVCLocalContext *lc)
int ff_hevc_sao_offset_abs_decode(HEVCLocalContext *lc, int bit_depth)
{
int i = 0;
int length = (1 << (FFMIN(lc->parent->ps.sps->bit_depth, 10) - 5)) - 1;
int length = (1 << (FFMIN(bit_depth, 10) - 5)) - 1;
while (i < length && get_cabac_bypass(&lc->cc))
i++;
@ -568,17 +569,15 @@ int ff_hevc_cu_transquant_bypass_flag_decode(HEVCLocalContext *lc)
return GET_CABAC(CU_TRANSQUANT_BYPASS_FLAG_OFFSET);
}
int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, int x0, int y0, int x_cb, int y_cb)
int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, int x0, int y0,
int x_cb, int y_cb, int min_cb_width)
{
const HEVCContext *const s = lc->parent;
int min_cb_width = s->ps.sps->min_cb_width;
int inc = 0;
int x0b = av_mod_uintp2(x0, s->ps.sps->log2_ctb_size);
int y0b = av_mod_uintp2(y0, s->ps.sps->log2_ctb_size);
if (lc->ctb_left_flag || x0b)
if (lc->ctb_left_flag || x0)
inc = !!SAMPLE_CTB(s->skip_flag, x_cb - 1, y_cb);
if (lc->ctb_up_flag || y0b)
if (lc->ctb_up_flag || y0)
inc += !!SAMPLE_CTB(s->skip_flag, x_cb, y_cb - 1);
return GET_CABAC(SKIP_FLAG_OFFSET + inc);
@ -621,9 +620,9 @@ int ff_hevc_cu_chroma_qp_offset_flag(HEVCLocalContext *lc)
return GET_CABAC(CU_CHROMA_QP_OFFSET_FLAG_OFFSET);
}
int ff_hevc_cu_chroma_qp_offset_idx(HEVCLocalContext *lc)
int ff_hevc_cu_chroma_qp_offset_idx(HEVCLocalContext *lc, int chroma_qp_offset_list_len_minus1)
{
int c_max= FFMAX(5, lc->parent->ps.pps->chroma_qp_offset_list_len_minus1);
int c_max= FFMAX(5, chroma_qp_offset_list_len_minus1);
int i = 0;
while (i < c_max && GET_CABAC(CU_CHROMA_QP_OFFSET_IDX_OFFSET))
@ -637,10 +636,10 @@ int ff_hevc_pred_mode_decode(HEVCLocalContext *lc)
return GET_CABAC(PRED_MODE_FLAG_OFFSET);
}
int ff_hevc_split_coding_unit_flag_decode(HEVCLocalContext *lc, int ct_depth, int x0, int y0)
int ff_hevc_split_coding_unit_flag_decode(HEVCLocalContext *lc, const HEVCSPS *sps,
int ct_depth, int x0, int y0)
{
const HEVCContext *const s = lc->parent;
const HEVCSPS *const sps = s->ps.sps;
int inc = 0, depth_left = 0, depth_top = 0;
int x0b = av_mod_uintp2(x0, sps->log2_ctb_size);
int y0b = av_mod_uintp2(y0, sps->log2_ctb_size);
@ -658,11 +657,11 @@ int ff_hevc_split_coding_unit_flag_decode(HEVCLocalContext *lc, int ct_depth, in
return GET_CABAC(SPLIT_CODING_UNIT_FLAG_OFFSET + inc);
}
int ff_hevc_part_mode_decode(HEVCLocalContext *lc, int log2_cb_size)
int ff_hevc_part_mode_decode(HEVCLocalContext *lc, const HEVCSPS *sps, int log2_cb_size)
{
if (GET_CABAC(PART_MODE_OFFSET)) // 1
return PART_2Nx2N;
if (log2_cb_size == lc->parent->ps.sps->log2_min_cb_size) {
if (log2_cb_size == sps->log2_min_cb_size) {
if (lc->cu.pred_mode == MODE_INTRA) // 0
return PART_NxN;
if (GET_CABAC(PART_MODE_OFFSET + 1)) // 01
@ -674,7 +673,7 @@ int ff_hevc_part_mode_decode(HEVCLocalContext *lc, int log2_cb_size)
return PART_NxN; // 000
}
if (!lc->parent->ps.sps->amp_enabled) {
if (!sps->amp_enabled) {
if (GET_CABAC(PART_MODE_OFFSET + 1)) // 01
return PART_2NxN;
return PART_Nx2N;
@ -979,7 +978,8 @@ static av_always_inline int coeff_sign_flag_decode(HEVCLocalContext *lc, uint8_t
return ret;
}
void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0,
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)
{
@ -989,6 +989,7 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0,
y_c = (y_cg << 2) + scan_y_off[n]; \
} while (0)
const HEVCContext *const s = lc->parent;
const HEVCSPS *const sps = pps->sps;
int transform_skip_flag = 0;
int last_significant_coeff_x, last_significant_coeff_y;
@ -1003,10 +1004,10 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0,
const uint8_t *scan_x_cg, *scan_y_cg, *scan_x_off, *scan_y_off;
ptrdiff_t stride = s->cur_frame->f->linesize[c_idx];
int hshift = s->ps.sps->hshift[c_idx];
int vshift = s->ps.sps->vshift[c_idx];
int hshift = sps->hshift[c_idx];
int vshift = sps->vshift[c_idx];
uint8_t *dst = &s->cur_frame->f->data[c_idx][(y0 >> vshift) * stride +
((x0 >> hshift) << s->ps.sps->pixel_shift)];
((x0 >> hshift) << sps->pixel_shift)];
int16_t *coeffs = (int16_t*)(c_idx ? lc->edge_emu_buffer2 : lc->edge_emu_buffer);
uint8_t significant_coeff_group_flag[8][8] = {{0}};
int explicit_rdpcm_flag = 0;
@ -1041,25 +1042,25 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0,
};
int qp_y = lc->qp_y;
if (s->ps.pps->transform_skip_enabled_flag &&
log2_trafo_size <= s->ps.pps->log2_max_transform_skip_block_size) {
if (pps->transform_skip_enabled_flag &&
log2_trafo_size <= pps->log2_max_transform_skip_block_size) {
transform_skip_flag = hevc_transform_skip_flag_decode(lc, c_idx);
}
if (c_idx == 0) {
qp = qp_y + s->ps.sps->qp_bd_offset;
qp = qp_y + sps->qp_bd_offset;
} else {
int qp_i, offset;
if (c_idx == 1)
offset = s->ps.pps->cb_qp_offset + s->sh.slice_cb_qp_offset +
offset = pps->cb_qp_offset + s->sh.slice_cb_qp_offset +
lc->tu.cu_qp_offset_cb;
else
offset = s->ps.pps->cr_qp_offset + s->sh.slice_cr_qp_offset +
offset = pps->cr_qp_offset + s->sh.slice_cr_qp_offset +
lc->tu.cu_qp_offset_cr;
qp_i = av_clip(qp_y + offset, - s->ps.sps->qp_bd_offset, 57);
if (s->ps.sps->chroma_format_idc == 1) {
qp_i = av_clip(qp_y + offset, - sps->qp_bd_offset, 57);
if (sps->chroma_format_idc == 1) {
if (qp_i < 30)
qp = qp_i;
else if (qp_i > 43)
@ -1073,18 +1074,18 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0,
qp = qp_i;
}
qp += s->ps.sps->qp_bd_offset;
qp += sps->qp_bd_offset;
}
shift = s->ps.sps->bit_depth + log2_trafo_size - 5;
shift = sps->bit_depth + log2_trafo_size - 5;
add = 1 << (shift-1);
scale = level_scale[rem6[qp]] << (div6[qp]);
scale_m = 16; // default when no custom scaling lists.
dc_scale = 16;
if (s->ps.sps->scaling_list_enabled && !(transform_skip_flag && log2_trafo_size > 2)) {
const ScalingList *sl = s->ps.pps->scaling_list_data_present_flag ?
&s->ps.pps->scaling_list : &s->ps.sps->scaling_list;
if (sps->scaling_list_enabled && !(transform_skip_flag && log2_trafo_size > 2)) {
const ScalingList *sl = pps->scaling_list_data_present_flag ?
&pps->scaling_list : &sps->scaling_list;
int matrix_id = lc->cu.pred_mode != MODE_INTRA;
matrix_id = 3 * matrix_id + c_idx;
@ -1100,7 +1101,7 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0,
dc_scale = 0;
}
if (lc->cu.pred_mode == MODE_INTER && s->ps.sps->explicit_rdpcm_enabled &&
if (lc->cu.pred_mode == MODE_INTER && sps->explicit_rdpcm_enabled &&
(transform_skip_flag || lc->cu.cu_transquant_bypass_flag)) {
explicit_rdpcm_flag = explicit_rdpcm_flag_decode(lc, c_idx);
if (explicit_rdpcm_flag) {
@ -1231,7 +1232,7 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0,
};
const uint8_t *ctx_idx_map_p;
int scf_offset = 0;
if (s->ps.sps->transform_skip_context_enabled &&
if (sps->transform_skip_context_enabled &&
(transform_skip_flag || lc->cu.cu_transquant_bypass_flag)) {
ctx_idx_map_p = &ctx_idx_map[4 * 16];
if (c_idx == 0) {
@ -1272,7 +1273,7 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0,
}
}
if (implicit_non_zero_coeff == 0) {
if (s->ps.sps->transform_skip_context_enabled &&
if (sps->transform_skip_context_enabled &&
(transform_skip_flag || lc->cu.cu_transquant_bypass_flag)) {
if (c_idx == 0) {
scf_offset = 42;
@ -1317,7 +1318,7 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0,
// initialize first elem of coeff_bas_level_greater1_flag
int ctx_set = (i > 0 && c_idx == 0) ? 2 : 0;
if (s->ps.sps->persistent_rice_adaptation_enabled) {
if (sps->persistent_rice_adaptation_enabled) {
if (!transform_skip_flag && !lc->cu.cu_transquant_bypass_flag)
sb_type = 2 * (c_idx == 0 ? 1 : 0);
else
@ -1346,7 +1347,7 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0,
if (lc->cu.cu_transquant_bypass_flag ||
(lc->cu.pred_mode == MODE_INTRA &&
s->ps.sps->implicit_rdpcm_enabled && transform_skip_flag &&
sps->implicit_rdpcm_enabled && transform_skip_flag &&
(pred_mode_intra == 10 || pred_mode_intra == 26 )) ||
explicit_rdpcm_flag)
sign_hidden = 0;
@ -1356,7 +1357,7 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0,
if (first_greater1_coeff_idx != -1) {
coeff_abs_level_greater1_flag[first_greater1_coeff_idx] += coeff_abs_level_greater2_flag_decode(lc, c_idx, ctx_set);
}
if (!s->ps.pps->sign_data_hiding_flag || !sign_hidden ) {
if (!pps->sign_data_hiding_flag || !sign_hidden ) {
coeff_sign_flag = coeff_sign_flag_decode(lc, nb_significant_coeff_flag) << (16 - nb_significant_coeff_flag);
} else {
coeff_sign_flag = coeff_sign_flag_decode(lc, nb_significant_coeff_flag - 1) << (16 - (nb_significant_coeff_flag - 1));
@ -1372,8 +1373,8 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0,
trans_coeff_level += last_coeff_abs_level_remaining;
if (trans_coeff_level > (3 << c_rice_param))
c_rice_param = s->ps.sps->persistent_rice_adaptation_enabled ? c_rice_param + 1 : FFMIN(c_rice_param + 1, 4);
if (s->ps.sps->persistent_rice_adaptation_enabled && !rice_init) {
c_rice_param = sps->persistent_rice_adaptation_enabled ? c_rice_param + 1 : FFMIN(c_rice_param + 1, 4);
if (sps->persistent_rice_adaptation_enabled && !rice_init) {
int c_rice_p_init = lc->stat_coeff[sb_type] / 4;
if (last_coeff_abs_level_remaining >= (3 << c_rice_p_init))
lc->stat_coeff[sb_type]++;
@ -1388,8 +1389,8 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0,
trans_coeff_level = 1 + last_coeff_abs_level_remaining;
if (trans_coeff_level > (3 << c_rice_param))
c_rice_param = s->ps.sps->persistent_rice_adaptation_enabled ? c_rice_param + 1 : FFMIN(c_rice_param + 1, 4);
if (s->ps.sps->persistent_rice_adaptation_enabled && !rice_init) {
c_rice_param = sps->persistent_rice_adaptation_enabled ? c_rice_param + 1 : FFMIN(c_rice_param + 1, 4);
if (sps->persistent_rice_adaptation_enabled && !rice_init) {
int c_rice_p_init = lc->stat_coeff[sb_type] / 4;
if (last_coeff_abs_level_remaining >= (3 << c_rice_p_init))
lc->stat_coeff[sb_type]++;
@ -1399,7 +1400,7 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0,
rice_init = 1;
}
}
if (s->ps.pps->sign_data_hiding_flag && sign_hidden) {
if (pps->sign_data_hiding_flag && sign_hidden) {
sum_abs += trans_coeff_level;
if (n == first_nz_pos_in_cg && (sum_abs&1))
trans_coeff_level = -trans_coeff_level;
@ -1408,7 +1409,7 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0,
trans_coeff_level = -trans_coeff_level;
coeff_sign_flag <<= 1;
if(!lc->cu.cu_transquant_bypass_flag) {
if (s->ps.sps->scaling_list_enabled && !(transform_skip_flag && log2_trafo_size > 2)) {
if (sps->scaling_list_enabled && !(transform_skip_flag && log2_trafo_size > 2)) {
if(y_c || x_c || log2_trafo_size < 4) {
switch(log2_trafo_size) {
case 3: pos = (y_c << 3) + x_c; break;
@ -1436,15 +1437,15 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0,
}
if (lc->cu.cu_transquant_bypass_flag) {
if (explicit_rdpcm_flag || (s->ps.sps->implicit_rdpcm_enabled &&
if (explicit_rdpcm_flag || (sps->implicit_rdpcm_enabled &&
(pred_mode_intra == 10 || pred_mode_intra == 26))) {
int mode = s->ps.sps->implicit_rdpcm_enabled ? (pred_mode_intra == 26) : explicit_rdpcm_dir_flag;
int mode = sps->implicit_rdpcm_enabled ? (pred_mode_intra == 26) : explicit_rdpcm_dir_flag;
s->hevcdsp.transform_rdpcm(coeffs, log2_trafo_size, mode);
}
} else {
if (transform_skip_flag) {
int rot = s->ps.sps->transform_skip_rotation_enabled &&
int rot = sps->transform_skip_rotation_enabled &&
log2_trafo_size == 2 &&
lc->cu.pred_mode == MODE_INTRA;
if (rot) {
@ -1454,7 +1455,7 @@ void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0,
s->hevcdsp.dequant(coeffs, log2_trafo_size);
if (explicit_rdpcm_flag || (s->ps.sps->implicit_rdpcm_enabled &&
if (explicit_rdpcm_flag || (sps->implicit_rdpcm_enabled &&
lc->cu.pred_mode == MODE_INTRA &&
(pred_mode_intra == 10 || pred_mode_intra == 26))) {
int mode = explicit_rdpcm_flag ? explicit_rdpcm_dir_flag : (pred_mode_intra == 26);

View File

@ -1097,7 +1097,7 @@ static void hls_sao_param(HEVCLocalContext *lc, int rx, int ry)
continue;
for (i = 0; i < 4; i++)
SET_SAO(offset_abs[c_idx][i], ff_hevc_sao_offset_abs_decode(lc));
SET_SAO(offset_abs[c_idx][i], ff_hevc_sao_offset_abs_decode(lc, s->ps.sps->bit_depth));
if (sao->type_idx[c_idx] == SAO_BAND) {
for (i = 0; i < 4; i++) {
@ -1198,7 +1198,7 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0,
if (cu_chroma_qp_offset_flag) {
int cu_chroma_qp_offset_idx = 0;
if (s->ps.pps->chroma_qp_offset_list_len_minus1 > 0) {
cu_chroma_qp_offset_idx = ff_hevc_cu_chroma_qp_offset_idx(lc);
cu_chroma_qp_offset_idx = ff_hevc_cu_chroma_qp_offset_idx(lc, s->ps.pps->chroma_qp_offset_list_len_minus1);
av_log(s->avctx, AV_LOG_ERROR,
"cu_chroma_qp_offset_idx not yet tested.\n");
}
@ -1232,7 +1232,7 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0,
lc->tu.cross_pf = 0;
if (cbf_luma)
ff_hevc_hls_residual_coding(lc, x0, y0, log2_trafo_size, scan_idx, 0);
ff_hevc_hls_residual_coding(lc, s->ps.pps, x0, y0, log2_trafo_size, scan_idx, 0);
if (s->ps.sps->chroma_format_idc && (log2_trafo_size > 2 || s->ps.sps->chroma_format_idc == 3)) {
int trafo_size_h = 1 << (log2_trafo_size_c + s->ps.sps->hshift[1]);
int trafo_size_v = 1 << (log2_trafo_size_c + s->ps.sps->vshift[1]);
@ -1250,7 +1250,7 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0,
s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0 + (i << log2_trafo_size_c), 1);
}
if (cbf_cb[i])
ff_hevc_hls_residual_coding(lc, x0, y0 + (i << log2_trafo_size_c),
ff_hevc_hls_residual_coding(lc, s->ps.pps, x0, y0 + (i << log2_trafo_size_c),
log2_trafo_size_c, scan_idx_c, 1);
else
if (lc->tu.cross_pf) {
@ -1280,7 +1280,7 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0,
s->hpc.intra_pred[log2_trafo_size_c - 2](lc, x0, y0 + (i << log2_trafo_size_c), 2);
}
if (cbf_cr[i])
ff_hevc_hls_residual_coding(lc, x0, y0 + (i << log2_trafo_size_c),
ff_hevc_hls_residual_coding(lc, s->ps.pps, x0, y0 + (i << log2_trafo_size_c),
log2_trafo_size_c, scan_idx_c, 2);
else
if (lc->tu.cross_pf) {
@ -1309,7 +1309,7 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0,
s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase + (i << log2_trafo_size), 1);
}
if (cbf_cb[i])
ff_hevc_hls_residual_coding(lc, xBase, yBase + (i << log2_trafo_size),
ff_hevc_hls_residual_coding(lc, s->ps.pps, xBase, yBase + (i << log2_trafo_size),
log2_trafo_size, scan_idx_c, 1);
}
for (i = 0; i < (s->ps.sps->chroma_format_idc == 2 ? 2 : 1); i++) {
@ -1319,7 +1319,7 @@ static int hls_transform_unit(HEVCLocalContext *lc, int x0, int y0,
s->hpc.intra_pred[log2_trafo_size - 2](lc, xBase, yBase + (i << log2_trafo_size), 2);
}
if (cbf_cr[i])
ff_hevc_hls_residual_coding(lc, xBase, yBase + (i << log2_trafo_size),
ff_hevc_hls_residual_coding(lc, s->ps.pps, xBase, yBase + (i << log2_trafo_size),
log2_trafo_size, scan_idx_c, 2);
}
}
@ -2263,7 +2263,10 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, int x0, i
lc->cu.cu_transquant_bypass_flag = 0;
if (s->sh.slice_type != HEVC_SLICE_I) {
uint8_t skip_flag = ff_hevc_skip_flag_decode(lc, x0, y0, x_cb, y_cb);
const int x0b = av_mod_uintp2(x0, s->ps.sps->log2_ctb_size);
const int y0b = av_mod_uintp2(y0, s->ps.sps->log2_ctb_size);
uint8_t skip_flag = ff_hevc_skip_flag_decode(lc, x0b, y0b, x_cb, y_cb,
min_cb_width);
x = y_cb * min_cb_width + x_cb;
for (y = 0; y < length; y++) {
@ -2292,7 +2295,7 @@ static int hls_coding_unit(HEVCLocalContext *lc, const HEVCContext *s, int x0, i
lc->cu.pred_mode = ff_hevc_pred_mode_decode(lc);
if (lc->cu.pred_mode != MODE_INTRA ||
log2_cb_size == s->ps.sps->log2_min_cb_size) {
lc->cu.part_mode = ff_hevc_part_mode_decode(lc, log2_cb_size);
lc->cu.part_mode = ff_hevc_part_mode_decode(lc, s->ps.sps, log2_cb_size);
lc->cu.intra_split_flag = lc->cu.part_mode == PART_NxN &&
lc->cu.pred_mode == MODE_INTRA;
}
@ -2408,7 +2411,7 @@ static int hls_coding_quadtree(HEVCLocalContext *lc, int x0, int y0,
if (x0 + cb_size <= s->ps.sps->width &&
y0 + cb_size <= s->ps.sps->height &&
log2_cb_size > s->ps.sps->log2_min_cb_size) {
split_cu = ff_hevc_split_coding_unit_flag_decode(lc, cb_depth, x0, y0);
split_cu = ff_hevc_split_coding_unit_flag_decode(lc, s->ps.sps, cb_depth, x0, y0);
} else {
split_cu = (log2_cb_size > s->ps.sps->log2_min_cb_size);
}
@ -2562,7 +2565,7 @@ static int hls_decode_entry(HEVCContext *s, GetBitContext *gb)
y_ctb = (ctb_addr_rs / ((s->ps.sps->width + ctb_size - 1) >> s->ps.sps->log2_ctb_size)) << s->ps.sps->log2_ctb_size;
hls_decode_neighbour(lc, x_ctb, y_ctb, ctb_addr_ts);
ret = ff_hevc_cabac_init(lc, ctb_addr_ts, slice_data, slice_size);
ret = ff_hevc_cabac_init(lc, s->ps.pps, ctb_addr_ts, slice_data, slice_size);
if (ret < 0) {
s->tab_slice_address[ctb_addr_rs] = -1;
return ret;
@ -2582,7 +2585,7 @@ static int hls_decode_entry(HEVCContext *s, GetBitContext *gb)
ctb_addr_ts++;
ff_hevc_save_states(lc, ctb_addr_ts);
ff_hevc_save_states(lc, s->ps.pps, ctb_addr_ts);
ff_hevc_hls_filters(lc, s->ps.pps, x_ctb, y_ctb, ctb_size);
}
@ -2629,7 +2632,7 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist,
return 0;
}
ret = ff_hevc_cabac_init(lc, ctb_addr_ts, data, data_size);
ret = ff_hevc_cabac_init(lc, s->ps.pps, ctb_addr_ts, data, data_size);
if (ret < 0)
goto error;
hls_sao_param(lc, x_ctb >> s->ps.sps->log2_ctb_size, y_ctb >> s->ps.sps->log2_ctb_size);
@ -2642,7 +2645,7 @@ static int hls_decode_entry_wpp(AVCodecContext *avctxt, void *hevc_lclist,
ctb_addr_ts++;
ff_hevc_save_states(lc, ctb_addr_ts);
ff_hevc_save_states(lc, s->ps.pps, ctb_addr_ts);
ff_thread_report_progress2(s->avctx, ctb_row, thread, 1);
ff_hevc_hls_filters(lc, s->ps.pps, x_ctb, y_ctb, ctb_size);

View File

@ -576,23 +576,24 @@ int ff_hevc_frame_rps(HEVCContext *s);
*/
int ff_hevc_slice_rpl(HEVCContext *s);
void ff_hevc_save_states(HEVCLocalContext *lc, int ctb_addr_ts);
int ff_hevc_cabac_init(HEVCLocalContext *lc, int ctb_addr_ts,
const uint8_t *data, size_t size);
void ff_hevc_save_states(HEVCLocalContext *lc, const HEVCPPS *pps,
int ctb_addr_ts);
int ff_hevc_cabac_init(HEVCLocalContext *lc, const HEVCPPS *pps,
int ctb_addr_ts, const uint8_t *data, size_t size);
int ff_hevc_sao_merge_flag_decode(HEVCLocalContext *lc);
int ff_hevc_sao_type_idx_decode(HEVCLocalContext *lc);
int ff_hevc_sao_band_position_decode(HEVCLocalContext *lc);
int ff_hevc_sao_offset_abs_decode(HEVCLocalContext *lc);
int ff_hevc_sao_offset_abs_decode(HEVCLocalContext *lc, int bit_depth);
int ff_hevc_sao_offset_sign_decode(HEVCLocalContext *lc);
int ff_hevc_sao_eo_class_decode(HEVCLocalContext *lc);
int ff_hevc_end_of_slice_flag_decode(HEVCLocalContext *lc);
int ff_hevc_cu_transquant_bypass_flag_decode(HEVCLocalContext *lc);
int ff_hevc_skip_flag_decode(HEVCLocalContext *lc, int x0, int y0,
int x_cb, int y_cb);
int x_cb, int y_cb, int min_cb_width);
int ff_hevc_pred_mode_decode(HEVCLocalContext *lc);
int ff_hevc_split_coding_unit_flag_decode(HEVCLocalContext *lc, int ct_depth,
int x0, int y0);
int ff_hevc_part_mode_decode(HEVCLocalContext *lc, int log2_cb_size);
int ff_hevc_split_coding_unit_flag_decode(HEVCLocalContext *lc, const HEVCSPS *sps,
int ct_depth, int x0, int y0);
int ff_hevc_part_mode_decode(HEVCLocalContext *lc, const HEVCSPS *sps, int log2_cb_size);
int ff_hevc_pcm_flag_decode(HEVCLocalContext *lc);
int ff_hevc_prev_intra_luma_pred_flag_decode(HEVCLocalContext *lc);
int ff_hevc_mpm_idx_decode(HEVCLocalContext *lc);
@ -666,8 +667,9 @@ void ff_hevc_deblocking_boundary_strengths(HEVCLocalContext *lc, const HEVCPPS *
int ff_hevc_cu_qp_delta_sign_flag(HEVCLocalContext *lc);
int ff_hevc_cu_qp_delta_abs(HEVCLocalContext *lc);
int ff_hevc_cu_chroma_qp_offset_flag(HEVCLocalContext *lc);
int ff_hevc_cu_chroma_qp_offset_idx(HEVCLocalContext *lc);
void ff_hevc_hls_residual_coding(HEVCLocalContext *lc, int x0, int y0,
int ff_hevc_cu_chroma_qp_offset_idx(HEVCLocalContext *lc, int chroma_qp_offset_list_len_minus1);
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);