mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 11:24:05 +00:00
[intra] Fix chroma cbf counting for 4x4
This commit is contained in:
parent
2feb3daaaf
commit
8c939c1405
|
@ -718,6 +718,7 @@ static void encode_transform_coeff(encoder_state_t * const state,
|
|||
if ((cur_cu->type == CU_INTRA || tr_depth > 0 || cb_flag_u || cb_flag_v) && !only_chroma) {
|
||||
cabac->cur_ctx = &(cabac->ctx.qt_cbf_model_luma[0]);
|
||||
CABAC_BIN(cabac, cb_flag_y, "cbf_luma");
|
||||
// printf("%hu %hu %d %d\n", cabac->ctx.qt_cbf_model_luma[0].state[0], cabac->ctx.qt_cbf_model_luma[0].state[1], x, y);
|
||||
}
|
||||
|
||||
if (cb_flag_y | cb_flag_u | cb_flag_v) {
|
||||
|
@ -888,8 +889,11 @@ int uvg_encode_inter_prediction_unit(encoder_state_t * const state,
|
|||
return non_zero_mvd;
|
||||
}
|
||||
|
||||
static void encode_chroma_intra_cu(cabac_data_t* const cabac, const cu_info_t* const cur_cu, const int cclm_enabled, double
|
||||
* bits_out) {
|
||||
static void encode_chroma_intra_cu(
|
||||
cabac_data_t* const cabac,
|
||||
const cu_info_t* const cur_cu,
|
||||
const int cclm_enabled,
|
||||
double* bits_out) {
|
||||
unsigned pred_mode = 0;
|
||||
unsigned chroma_pred_modes[8] = {0, 50, 18, 1, 67, 81, 82, 83};
|
||||
int8_t chroma_intra_dir = cur_cu->intra.mode_chroma;
|
||||
|
@ -900,10 +904,9 @@ static void encode_chroma_intra_cu(cabac_data_t* const cabac, const cu_info_t* c
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
double bits = 0;
|
||||
bool derived_mode = chroma_intra_dir == luma_intra_dir;
|
||||
bool cclm_mode = chroma_intra_dir > 67;
|
||||
double bits = 0;
|
||||
|
||||
if (cclm_enabled) {
|
||||
CABAC_FBITS_UPDATE(cabac, &cabac->ctx.cclm_flag, cclm_mode, bits, "cclm_flag");
|
||||
|
@ -971,6 +974,7 @@ static void encode_chroma_intra_cu(cabac_data_t* const cabac, const cu_info_t* c
|
|||
if (cabac->only_count && bits_out) *bits_out += 2 + bits;
|
||||
//}
|
||||
}
|
||||
else if (cabac->only_count && bits_out)*bits_out += bits;
|
||||
}
|
||||
|
||||
void uvg_encode_intra_luma_coding_unit(const encoder_state_t * const state,
|
||||
|
|
12
src/search.c
12
src/search.c
|
@ -401,7 +401,7 @@ double uvg_cu_rd_cost_chroma(const encoder_state_t *const state,
|
|||
}
|
||||
|
||||
// See luma for why the second condition
|
||||
if (depth < MAX_PU_DEPTH && !skip_residual_coding) {
|
||||
if (!skip_residual_coding) {
|
||||
const int tr_depth = depth - pred_cu->depth;
|
||||
cabac_data_t* cabac = (cabac_data_t*)&state->search_cabac;
|
||||
cabac_ctx_t *ctx = &(cabac->ctx.qt_cbf_model_cb[0]);
|
||||
|
@ -503,7 +503,7 @@ static double cu_rd_cost_tr_split_accurate(const encoder_state_t* const state,
|
|||
|
||||
}
|
||||
|
||||
if(state->encoder_control->chroma_format != UVG_CSP_400 && !skip_residual_coding) {
|
||||
if(state->encoder_control->chroma_format != UVG_CSP_400 && !skip_residual_coding && (depth != 4 || (x_px % 8 && y_px % 8))) {
|
||||
if(tr_cu->depth == depth || cbf_is_set(pred_cu->cbf, depth - 1, COLOR_U)) {
|
||||
CABAC_FBITS_UPDATE(cabac, &(cabac->ctx.qt_cbf_model_cb[0]), cb_flag_u, tr_tree_bits, "cbf_cb");
|
||||
}
|
||||
|
@ -532,7 +532,7 @@ static double cu_rd_cost_tr_split_accurate(const encoder_state_t* const state,
|
|||
cb_flag_v)
|
||||
&& !skip_residual_coding)
|
||||
{
|
||||
cabac_ctx_t* ctx = &(cabac->ctx.qt_cbf_model_luma[!is_tr_split]);
|
||||
cabac_ctx_t* ctx = &(cabac->ctx.qt_cbf_model_luma[0]);
|
||||
|
||||
CABAC_FBITS_UPDATE(cabac, ctx, cb_flag_y, tr_tree_bits, "cbf_y_search");
|
||||
}
|
||||
|
@ -1170,9 +1170,9 @@ static double search_cu(encoder_state_t * const state, int x, int y, int depth,
|
|||
// the split costs at least as much as not splitting.
|
||||
if (cur_cu->type == CU_NOTSET || cbf || state->encoder_control->cfg.cu_split_termination == UVG_CU_SPLIT_TERMINATION_OFF) {
|
||||
if (split_cost < cost) split_cost += search_cu(state, x, y, depth + 1, work_tree);
|
||||
if (split_cost < cost) split_cost += search_cu(state, x + half_cu, y, depth + 1, work_tree);
|
||||
if (split_cost < cost) split_cost += search_cu(state, x, y + half_cu, depth + 1, work_tree);
|
||||
if (split_cost < cost) split_cost += search_cu(state, x + half_cu, y + half_cu, depth + 1, work_tree);
|
||||
if (split_cost < cost || 1) split_cost += search_cu(state, x + half_cu, y, depth + 1, work_tree);
|
||||
if (split_cost < cost || 1) split_cost += search_cu(state, x, y + half_cu, depth + 1, work_tree);
|
||||
if (split_cost < cost || 1) split_cost += search_cu(state, x + half_cu, y + half_cu, depth + 1, work_tree);
|
||||
} else {
|
||||
split_cost = INT_MAX;
|
||||
}
|
||||
|
|
|
@ -1192,7 +1192,7 @@ static void get_rough_cost_for_2n_modes(
|
|||
if(multi_ref_idx) {
|
||||
bits[i] = mrl + not_mip;
|
||||
bits[i] += CTX_ENTROPY_FBITS(&(state->search_cabac.ctx.multi_ref_line[1]), multi_ref_idx != 1);
|
||||
bits[i] += MIN((mode + i + 1) % 6, 4);
|
||||
bits[i] += MIN(((mode + i) % 5) + 1, 4);
|
||||
}
|
||||
else if(search_data[mode + i].pred_cu.intra.mip_flag) {
|
||||
bits[i] = mip + 1;
|
||||
|
@ -1250,6 +1250,9 @@ static int8_t search_intra_rdo(
|
|||
const int tr_depth = CLIP(1, MAX_PU_DEPTH, depth + state->encoder_control->cfg.tr_depth_intra);
|
||||
|
||||
for (int mode = 0; mode < modes_to_check; mode++) {
|
||||
if(mode == 0) {
|
||||
printf("%hu %hu %d %d\n", state->search_cabac.ctx.qt_cbf_model_luma[0].state[0], state->search_cabac.ctx.qt_cbf_model_luma[0].state[1], x_px, y_px);
|
||||
}
|
||||
double rdo_bitcost = uvg_luma_mode_bits(state, &search_data[mode].pred_cu, x_px, y_px, depth, lcu);
|
||||
search_data[mode].pred_cu.tr_idx = MTS_TR_NUM;
|
||||
search_data[mode].bits = rdo_bitcost;
|
||||
|
|
Loading…
Reference in a new issue