mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
[cabac] Fix trskip writing
This commit is contained in:
parent
c11e30fdb4
commit
03246c031e
|
@ -345,8 +345,7 @@ void uvg_encode_ts_residual(encoder_state_t* const state,
|
||||||
{
|
{
|
||||||
//===== encode sign's =====
|
//===== encode sign's =====
|
||||||
int sign = curr_coeff < 0;
|
int sign = curr_coeff < 0;
|
||||||
CABAC_BIN(cabac, sign, "coeff_sign_flag");
|
CABAC_FBITS_UPDATE(cabac, &cabac->ctx.transform_skip_res_sign[
|
||||||
CABAC_FBITS_UPDATE(cabac, &cabac->ctx.transform_skip_sig[
|
|
||||||
uvg_sign_ctx_id_abs_ts(coeff, pos_x, pos_y, width, 0)
|
uvg_sign_ctx_id_abs_ts(coeff, pos_x, pos_y, width, 0)
|
||||||
], sign, bits, "coeff_sign_flag");
|
], sign, bits, "coeff_sign_flag");
|
||||||
maxCtxBins--;
|
maxCtxBins--;
|
||||||
|
@ -360,15 +359,15 @@ void uvg_encode_ts_residual(encoder_state_t* const state,
|
||||||
remAbsLevel = modAbsCoeff - 1;
|
remAbsLevel = modAbsCoeff - 1;
|
||||||
|
|
||||||
unsigned gt1 = !!remAbsLevel;
|
unsigned gt1 = !!remAbsLevel;
|
||||||
CABAC_FBITS_UPDATE(cabac, &cabac->ctx.transform_skip_sig[
|
CABAC_FBITS_UPDATE(cabac, &cabac->ctx.transform_skip_gt1[
|
||||||
uvg_lrg1_ctx_id_abs_ts(coeff, pos_x, pos_y, width, 0)
|
uvg_lrg1_ctx_id_abs_ts(coeff, pos_x, pos_y, width, 0)
|
||||||
], remAbsLevel & 1, bits, "abs_level_gtx_flag");
|
], gt1, bits, "abs_level_gtx_flag");
|
||||||
maxCtxBins--;
|
maxCtxBins--;
|
||||||
|
|
||||||
if (gt1)
|
if (gt1)
|
||||||
{
|
{
|
||||||
remAbsLevel -= 1;
|
remAbsLevel -= 1;
|
||||||
CABAC_FBITS_UPDATE(cabac, &cabac->ctx.transform_skip_par, gt1, bits, "par_level_flag");
|
CABAC_FBITS_UPDATE(cabac, &cabac->ctx.transform_skip_par, remAbsLevel & 1, bits, "par_level_flag");
|
||||||
maxCtxBins--;
|
maxCtxBins--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -393,11 +392,7 @@ void uvg_encode_ts_residual(encoder_state_t* const state,
|
||||||
if (absLevel >= cutoffVal)
|
if (absLevel >= cutoffVal)
|
||||||
{
|
{
|
||||||
unsigned gt2 = (absLevel >= (cutoffVal + 2));
|
unsigned gt2 = (absLevel >= (cutoffVal + 2));
|
||||||
cabac->cur_ctx = &cabac->ctx.transform_skip_gt2[cutoffVal >> 1];
|
CABAC_FBITS_UPDATE(cabac, &cabac->ctx.transform_skip_gt2[cutoffVal >> 1], gt2, bits, "abs_level_gtx_flag");
|
||||||
CABAC_BIN(cabac, gt2, "abs_level_gtx_flag");
|
|
||||||
CABAC_FBITS_UPDATE(cabac, &cabac->ctx.transform_skip_sig[
|
|
||||||
kvz_lrg1_ctx_id_abs_ts(coeff, pos_x, pos_y, width, 0)
|
|
||||||
], gt2, bits, "abs_level_gtx_flag");
|
|
||||||
maxCtxBins--;
|
maxCtxBins--;
|
||||||
}
|
}
|
||||||
cutoffVal += 2;
|
cutoffVal += 2;
|
||||||
|
@ -1394,6 +1389,11 @@ bool uvg_write_split_flag(const encoder_state_t * const state, cabac_data_t* cab
|
||||||
split_model += 3 * (split_num >> 1);
|
split_model += 3 * (split_num >> 1);
|
||||||
|
|
||||||
cabac->cur_ctx = &(cabac->ctx.split_flag_model[split_model]);
|
cabac->cur_ctx = &(cabac->ctx.split_flag_model[split_model]);
|
||||||
|
if(cabac->only_count && !split_flag) {
|
||||||
|
|
||||||
|
//printf("%hu %hu %d %d %d\n", state->search_cabac.ctx.split_flag_model[split_model].state[0], state->search_cabac.ctx.split_flag_model[split_model].state[1],
|
||||||
|
// split_model, x, y);
|
||||||
|
}
|
||||||
CABAC_FBITS_UPDATE(cabac, &(cabac->ctx.split_flag_model[split_model]), split_flag, bits, "split_flag");
|
CABAC_FBITS_UPDATE(cabac, &(cabac->ctx.split_flag_model[split_model]), split_flag, bits, "split_flag");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -338,7 +338,7 @@ double uvg_cu_rd_cost_luma(const encoder_state_t *const state,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_set && state->encoder_control->cfg.trskip_enable && width <= (1 << state->encoder_control->cfg.trskip_max_size)) {
|
if (is_set && state->encoder_control->cfg.trskip_enable && width <= (1 << state->encoder_control->cfg.trskip_max_size)) {
|
||||||
CABAC_FBITS_UPDATE(cabac, &cabac->ctx.transform_skip_model_luma, tr_cu->tr_idx == MTS_SKIP, tr_tree_bits, "transform_skip_flag");
|
CABAC_FBITS_UPDATE(cabac, &cabac->ctx.transform_skip_model_luma, pred_cu->tr_idx == MTS_SKIP, tr_tree_bits, "transform_skip_flag");
|
||||||
}
|
}
|
||||||
|
|
||||||
// SSD between reconstruction and original
|
// SSD between reconstruction and original
|
||||||
|
|
|
@ -556,8 +556,6 @@ int uvg_quantize_residual_trskip(
|
||||||
state, cur_cu, width, color, scan_order,
|
state, cur_cu, width, color, scan_order,
|
||||||
1, in_stride, width,
|
1, in_stride, width,
|
||||||
ref_in, pred_in, skip.rec, skip.coeff, false, lmcs_chroma_adj);
|
ref_in, pred_in, skip.rec, skip.coeff, false, lmcs_chroma_adj);
|
||||||
skip.cost = uvg_pixels_calc_ssd(ref_in, skip.rec, in_stride, width, width);
|
|
||||||
skip.cost += uvg_get_coeff_cost(state, skip.coeff, NULL, width, 0, scan_order, 1) * state->frame->lambda;
|
|
||||||
|
|
||||||
/* if (noskip.cost <= skip.cost) {
|
/* if (noskip.cost <= skip.cost) {
|
||||||
*trskip_out = 0;
|
*trskip_out = 0;
|
||||||
|
|
Loading…
Reference in a new issue