Enable sign hiding in quant_avx2 and fix a bug in kvz_encode_coeff_nxn_generic()

This commit is contained in:
Marko Viitanen 2021-02-12 16:40:28 +02:00
parent 113b94f5e1
commit e05dcdb193
2 changed files with 6 additions and 5 deletions

View file

@ -349,8 +349,8 @@ void kvz_quant_avx2(const encoder_state_t * const state, const coeff_t * __restr
int32_t height, int8_t type, int8_t scan_idx, int8_t block_type)
{
const encoder_control_t * const encoder = state->encoder_control;
//const uint32_t log2_block_size = kvz_g_convert_to_bit[width] + 2;
//const uint32_t * const scan = kvz_g_sig_last_scan[scan_idx][log2_block_size - 1];
const uint32_t log2_block_size = kvz_g_convert_to_bit[width] + 2;
const uint32_t * const scan = kvz_g_sig_last_scan[scan_idx][log2_block_size - 1];
int32_t qp_scaled = kvz_get_scaled_qp(type, state->qp, (encoder->bitdepth - 8) * 6);
const uint32_t log2_tr_size = kvz_g_convert_to_bit[width] + 2;
@ -359,7 +359,7 @@ void kvz_quant_avx2(const encoder_state_t * const state, const coeff_t * __restr
const int32_t transform_shift = MAX_TR_DYNAMIC_RANGE - encoder->bitdepth - log2_tr_size; //!< Represents scaling through forward transform
const int32_t q_bits = QUANT_SHIFT + qp_scaled / 6 + transform_shift;
const int32_t add = ((state->frame->slicetype == KVZ_SLICE_I) ? 171 : 85) << (q_bits - 9);
//const int32_t q_bits8 = q_bits - 8;
const int32_t q_bits8 = q_bits - 8;
uint32_t ac_sum = 0;
int32_t last_cg = -1;
@ -433,7 +433,7 @@ void kvz_quant_avx2(const encoder_state_t * const state, const coeff_t * __restr
temp = _mm_add_epi32(temp, _mm_shuffle_epi32(temp, _MM_SHUFFLE(1, 0, 3, 2)));
temp = _mm_add_epi32(temp, _mm_shuffle_epi32(temp, _MM_SHUFFLE(0, 1, 0, 1)));
ac_sum += _mm_cvtsi128_si32(temp);
/*
// Signhiding disabled in VVC
if (!encoder->cfg.signhide_enable || ac_sum < 2)
return;
@ -505,7 +505,7 @@ void kvz_quant_avx2(const encoder_state_t * const state, const coeff_t * __restr
#undef VEC_WIDTH
#undef SCAN_SET_SIZE
#undef LOG2_SCAN_SET_SIZE
*/
}
#if KVZ_BIT_DEPTH == 8

View file

@ -273,6 +273,7 @@ void kvz_encode_coeff_nxn_generic(encoder_state_t * const state,
quant_state = (quant_state_transition_table >> ((quant_state << 2) + ((coeff_abs & 1) << 1))) & 3;
if (coeff_abs) {
num_non_zero++;
first_nz_pos_in_cg = scan_pos;
last_nz_pos_in_cg = MAX(last_nz_pos_in_cg, scan_pos);
coeff_signs <<= 1;
if (coeff[blk_pos] < 0) coeff_signs++;