mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
Remove abs_sum from coeff quantization.
- It's meant for checking if there are any coefficients, but we don't use it and it's annoying to remember to initialize it and pass it around. The benefit should be quite small anyway.
This commit is contained in:
parent
75042fc65d
commit
0c65a9b658
12
src/rdo.c
12
src/rdo.c
|
@ -70,7 +70,6 @@ uint32_t rdo_cost_intra(encoder_state * const encoder_state, pixel *pred, pixel
|
|||
int16_t block[LCU_WIDTH*LCU_WIDTH>>2];
|
||||
int16_t temp_block[LCU_WIDTH*LCU_WIDTH>>2];
|
||||
coefficient temp_coeff[LCU_WIDTH*LCU_WIDTH>>2];
|
||||
uint32_t ac_sum;
|
||||
uint32_t cost = 0;
|
||||
uint32_t coeffcost = 0;
|
||||
int8_t luma_scan_mode = SCAN_DIAG;
|
||||
|
@ -93,9 +92,9 @@ uint32_t rdo_cost_intra(encoder_state * const encoder_state, pixel *pred, pixel
|
|||
}
|
||||
transform2d(encoder, block,pre_quant_coeff,width,0);
|
||||
if(encoder->rdoq_enable) {
|
||||
rdoq(encoder_state, pre_quant_coeff, temp_coeff, width, width, &ac_sum, 0, luma_scan_mode, CU_INTRA,0);
|
||||
rdoq(encoder_state, pre_quant_coeff, temp_coeff, width, width, 0, luma_scan_mode, CU_INTRA,0);
|
||||
} else {
|
||||
quant(encoder_state, pre_quant_coeff, temp_coeff, width, width, &ac_sum, 0, luma_scan_mode, CU_INTRA);
|
||||
quant(encoder_state, pre_quant_coeff, temp_coeff, width, width, 0, luma_scan_mode, CU_INTRA);
|
||||
}
|
||||
dequant(encoder_state, temp_coeff, pre_quant_coeff, width, width, 0, CU_INTRA);
|
||||
itransform2d(encoder, temp_block,pre_quant_coeff,width,0);
|
||||
|
@ -391,7 +390,7 @@ static void calc_last_bits(encoder_state * const encoder_state, int32_t width, i
|
|||
* From HM 12.0
|
||||
*/
|
||||
void rdoq(encoder_state * const encoder_state, coefficient *coef, coefficient *dest_coeff, int32_t width,
|
||||
int32_t height, uint32_t *abs_sum, int8_t type, int8_t scan_mode, int8_t block_type, int8_t tr_depth)
|
||||
int32_t height, int8_t type, int8_t scan_mode, int8_t block_type, int8_t tr_depth)
|
||||
{
|
||||
const encoder_control * const encoder = encoder_state->encoder_control;
|
||||
cabac_data * const cabac = &encoder_state->cabac;
|
||||
|
@ -403,6 +402,7 @@ void rdoq(encoder_state * const encoder_state, coefficient *coef, coefficient *
|
|||
int32_t scalinglist_type= (block_type == CU_INTRA ? 0 : 3) + (int8_t)("\0\3\1\2"[type]);
|
||||
|
||||
int32_t qp_scaled = get_scaled_qp(type, encoder_state->global->QP, 0);
|
||||
uint32_t abs_sum = 0;
|
||||
|
||||
{
|
||||
int32_t q_bits = QUANT_SHIFT + qp_scaled/6 + transform_shift;
|
||||
|
@ -700,7 +700,7 @@ void rdoq(encoder_state * const encoder_state, coefficient *coef, coefficient *
|
|||
for ( scanpos = 0; scanpos < best_last_idx_p1; scanpos++ ) {
|
||||
int32_t blkPos = scan[ scanpos ];
|
||||
int32_t level = dest_coeff[ blkPos ];
|
||||
*abs_sum += level;
|
||||
abs_sum += level;
|
||||
dest_coeff[ blkPos ] = (coefficient)(( coef[ blkPos ] < 0 ) ? -level : level);
|
||||
}
|
||||
|
||||
|
@ -709,7 +709,7 @@ void rdoq(encoder_state * const encoder_state, coefficient *coef, coefficient *
|
|||
dest_coeff[ scan[ scanpos ] ] = 0;
|
||||
}
|
||||
#if ENABLE_SIGN_HIDING == 1
|
||||
if(*abs_sum >= 2) {
|
||||
if(abs_sum >= 2) {
|
||||
int64_t rd_factor = (int64_t) (
|
||||
g_inv_quant_scales[qp_scaled%6] * g_inv_quant_scales[qp_scaled%6] * (1<<(2*(qp_scaled/6)))
|
||||
/ encoder_state->global->cur_lambda_cost / 16 / (1<<(2*(encoder->bitdepth-8)))
|
||||
|
|
|
@ -43,7 +43,7 @@ extern const uint32_t g_go_rice_prefix_len[5];
|
|||
|
||||
|
||||
void rdoq(encoder_state *encoder_state, coefficient *coef, coefficient *dest_coeff, int32_t width,
|
||||
int32_t height, uint32_t *abs_sum, int8_t type, int8_t scan_mode, int8_t block_type, int8_t tr_depth);
|
||||
int32_t height, int8_t type, int8_t scan_mode, int8_t block_type, int8_t tr_depth);
|
||||
|
||||
uint32_t rdo_cost_intra(encoder_state *encoder, pixel* pred, pixel* orig_block, int width, int8_t mode);
|
||||
|
||||
|
|
|
@ -626,11 +626,12 @@ void itransform2d(const encoder_control * const encoder,int16_t *block,int16_t *
|
|||
*
|
||||
*/
|
||||
void quant(const encoder_state * const encoder_state, int16_t *coef, int16_t *q_coef, int32_t width,
|
||||
int32_t height, uint32_t *ac_sum, int8_t type, int8_t scan_idx, int8_t block_type )
|
||||
int32_t height, int8_t type, int8_t scan_idx, int8_t block_type )
|
||||
{
|
||||
const encoder_control * const encoder = encoder_state->encoder_control;
|
||||
const uint32_t log2_block_size = g_convert_to_bit[ width ] + 2;
|
||||
const uint32_t * const scan = g_sig_last_scan[ scan_idx ][ log2_block_size - 1 ];
|
||||
uint32_t ac_sum = 0;
|
||||
|
||||
#if ENABLE_SIGN_HIDING == 1
|
||||
int32_t delta_u[LCU_WIDTH*LCU_WIDTH>>2];
|
||||
|
@ -662,7 +663,7 @@ void quant(const encoder_state * const encoder_state, int16_t *coef, int16_t *q_
|
|||
|
||||
#if ENABLE_SIGN_HIDING == 1
|
||||
delta_u[n] = (int32_t)( ((int64_t)abs(coef[n]) * quant_coeff[n] - (level<<q_bits) )>> q_bits8 );
|
||||
*ac_sum += level;
|
||||
ac_sum += level;
|
||||
#endif
|
||||
|
||||
level *= sign;
|
||||
|
@ -670,7 +671,7 @@ void quant(const encoder_state * const encoder_state, int16_t *coef, int16_t *q_
|
|||
}
|
||||
|
||||
#if ENABLE_SIGN_HIDING == 1
|
||||
if(*ac_sum >= 2) {
|
||||
if(ac_sum >= 2) {
|
||||
#define SCAN_SET_SIZE 16
|
||||
#define LOG2_SCAN_SET_SIZE 4
|
||||
int32_t n,last_cg = -1, abssum = 0, subset, subpos;
|
||||
|
@ -849,10 +850,10 @@ int quantize_luma(encoder_state *const encoder_state,
|
|||
}
|
||||
|
||||
if (encoder->rdoq_enable) {
|
||||
rdoq(encoder_state, pre_quant_coeff, quant_coeff, width, width, &ac_sum, 0,
|
||||
rdoq(encoder_state, pre_quant_coeff, quant_coeff, width, width, 0,
|
||||
scan_idx_luma, cur_cu->type, cur_cu->tr_depth-cur_cu->depth);
|
||||
} else {
|
||||
quant(encoder_state, pre_quant_coeff, quant_coeff, width, width, &ac_sum, 0, scan_idx_luma, cur_cu->type);
|
||||
quant(encoder_state, pre_quant_coeff, quant_coeff, width, width, 0, scan_idx_luma, cur_cu->type);
|
||||
}
|
||||
|
||||
// Check for non-zero coeffs
|
||||
|
@ -934,10 +935,10 @@ int quantize_residual(encoder_state *const encoder_state,
|
|||
transform2d(encoder_state->encoder_control, residual_tmp, coeff_tmp, width, (color == COLOR_Y ? 0 : 65535));
|
||||
|
||||
if (encoder_state->encoder_control->rdoq_enable) {
|
||||
rdoq(encoder_state, coeff_tmp, quant_coeff_tmp, width, width, &ac_sum, (color == COLOR_Y ? 0 : 2),
|
||||
rdoq(encoder_state, coeff_tmp, quant_coeff_tmp, width, width, (color == COLOR_Y ? 0 : 2),
|
||||
scan_order, cur_cu->type, cur_cu->tr_depth-cur_cu->depth);
|
||||
} else {
|
||||
quant(encoder_state, coeff_tmp, quant_coeff_tmp, width, width, &ac_sum, (color == COLOR_Y ? 0 : 2),
|
||||
quant(encoder_state, coeff_tmp, quant_coeff_tmp, width, width, (color == COLOR_Y ? 0 : 2),
|
||||
scan_order, cur_cu->type);
|
||||
}
|
||||
|
||||
|
@ -983,7 +984,7 @@ int quantize_residual(encoder_state *const encoder_state,
|
|||
|
||||
|
||||
int decide_trskip(encoder_state * const encoder_state, cu_info *cur_cu, int8_t depth, const coeff_scan_order_t scan_idx_luma,
|
||||
int16_t *residual, uint32_t *ac_sum)
|
||||
int16_t *residual)
|
||||
{
|
||||
const encoder_control * const encoder = encoder_state->encoder_control;
|
||||
const int8_t width = LCU_WIDTH >> depth;
|
||||
|
@ -1000,9 +1001,9 @@ int decide_trskip(encoder_state * const encoder_state, cu_info *cur_cu, int8_t d
|
|||
// Test for transform skip
|
||||
transformskip(encoder, residual,pre_quant_coeff, width);
|
||||
if (encoder->rdoq_enable) {
|
||||
rdoq(encoder_state, pre_quant_coeff, temp_coeff, 4, 4, ac_sum, 0, scan_idx_luma, cur_cu->type,0);
|
||||
rdoq(encoder_state, pre_quant_coeff, temp_coeff, 4, 4, 0, scan_idx_luma, cur_cu->type,0);
|
||||
} else {
|
||||
quant(encoder_state, pre_quant_coeff, temp_coeff, 4, 4, ac_sum, 0, scan_idx_luma, cur_cu->type);
|
||||
quant(encoder_state, pre_quant_coeff, temp_coeff, 4, 4, 0, scan_idx_luma, cur_cu->type);
|
||||
}
|
||||
dequant(encoder_state, temp_coeff, pre_quant_coeff, 4, 4, 0, cur_cu->type);
|
||||
itransformskip(encoder, temp_block,pre_quant_coeff,width);
|
||||
|
@ -1011,9 +1012,9 @@ int decide_trskip(encoder_state * const encoder_state, cu_info *cur_cu, int8_t d
|
|||
|
||||
transform2d(encoder, residual,pre_quant_coeff,width,0);
|
||||
if (encoder->rdoq_enable) {
|
||||
rdoq(encoder_state, pre_quant_coeff, temp_coeff2, 4, 4, ac_sum, 0, scan_idx_luma, cur_cu->type,0);
|
||||
rdoq(encoder_state, pre_quant_coeff, temp_coeff2, 4, 4, 0, scan_idx_luma, cur_cu->type,0);
|
||||
} else {
|
||||
quant(encoder_state, pre_quant_coeff, temp_coeff2, 4, 4, ac_sum, 0, scan_idx_luma, cur_cu->type);
|
||||
quant(encoder_state, pre_quant_coeff, temp_coeff2, 4, 4, 0, scan_idx_luma, cur_cu->type);
|
||||
}
|
||||
dequant(encoder_state, temp_coeff2, pre_quant_coeff, 4, 4, 0, cur_cu->type);
|
||||
itransform2d(encoder, temp_block2,pre_quant_coeff,width,0);
|
||||
|
|
|
@ -35,7 +35,7 @@ extern const int16_t g_inv_quant_scales[6];
|
|||
|
||||
|
||||
void quant(const encoder_state *encoder_state, int16_t *coef, int16_t *q_coef, int32_t width,
|
||||
int32_t height, uint32_t *ac_sum, int8_t type, int8_t scan_idx, int8_t block_type);
|
||||
int32_t height, int8_t type, int8_t scan_idx, int8_t block_type);
|
||||
void dequant(const encoder_state *encoder_state, int16_t *q_coef, int16_t *coef, int32_t width, int32_t height,int8_t type, int8_t block_type);
|
||||
|
||||
void transformskip(const encoder_control *encoder, int16_t *block,int16_t *coeff, int8_t block_size);
|
||||
|
|
Loading…
Reference in a new issue