mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-24 02:24:07 +00:00
Clean up quantization sign hiding.
- To allow for later configuration at runtime.
This commit is contained in:
parent
c940ccb549
commit
804a3b648b
|
@ -138,28 +138,20 @@ void quant(const encoder_state * const encoder_state, int16_t *coef, int16_t *q_
|
||||||
const encoder_control * const encoder = encoder_state->encoder_control;
|
const encoder_control * const encoder = encoder_state->encoder_control;
|
||||||
const uint32_t log2_block_size = g_convert_to_bit[ width ] + 2;
|
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 ];
|
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];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int32_t qp_scaled = get_scaled_qp(type, encoder_state->global->QP, 0);
|
int32_t qp_scaled = get_scaled_qp(type, encoder_state->global->QP, 0);
|
||||||
|
|
||||||
//New block for variable definitions
|
//New block for variable definitions
|
||||||
{
|
{
|
||||||
int32_t n;
|
const uint32_t log2_tr_size = g_convert_to_bit[ width ] + 2;
|
||||||
uint32_t log2_tr_size = g_convert_to_bit[ width ] + 2;
|
const int32_t scalinglist_type = (block_type == CU_INTRA ? 0 : 3) + (int8_t)("\0\3\1\2"[type]);
|
||||||
int32_t scalinglist_type = (block_type == CU_INTRA ? 0 : 3) + (int8_t)("\0\3\1\2"[type]);
|
|
||||||
|
|
||||||
const int32_t *quant_coeff = encoder->scaling_list.quant_coeff[log2_tr_size-2][scalinglist_type][qp_scaled%6];
|
const int32_t *quant_coeff = encoder->scaling_list.quant_coeff[log2_tr_size-2][scalinglist_type][qp_scaled%6];
|
||||||
|
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 = ((encoder_state->global->slicetype == SLICE_I) ? 171 : 85) << (q_bits - 9);
|
||||||
|
const int32_t q_bits8 = q_bits - 8;
|
||||||
|
|
||||||
int32_t transform_shift = MAX_TR_DYNAMIC_RANGE - encoder->bitdepth - log2_tr_size; //!< Represents scaling through forward transform
|
for (int32_t n = 0; n < width * height; n++) {
|
||||||
int32_t q_bits = QUANT_SHIFT + qp_scaled/6 + transform_shift;
|
|
||||||
int32_t add = ((encoder_state->global->slicetype == SLICE_I) ? 171 : 85) << (q_bits - 9);
|
|
||||||
|
|
||||||
int32_t q_bits8 = q_bits - 8;
|
|
||||||
for (n = 0; n < width * height; n++) {
|
|
||||||
int32_t level;
|
int32_t level;
|
||||||
int32_t sign;
|
int32_t sign;
|
||||||
|
|
||||||
|
@ -168,16 +160,22 @@ void quant(const encoder_state * const encoder_state, int16_t *coef, int16_t *q_
|
||||||
|
|
||||||
level = ((int64_t)abs(level) * quant_coeff[n] + add ) >> q_bits;
|
level = ((int64_t)abs(level) * quant_coeff[n] + add ) >> q_bits;
|
||||||
|
|
||||||
#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;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
level *= sign;
|
level *= sign;
|
||||||
q_coef[n] = (int16_t)(CLIP( -32768, 32767, level));
|
q_coef[n] = (int16_t)(CLIP( -32768, 32767, level));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLE_SIGN_HIDING == 1
|
#if ENABLE_SIGN_HIDING == 1
|
||||||
|
int32_t delta_u[LCU_WIDTH*LCU_WIDTH >> 2];
|
||||||
|
uint32_t ac_sum = 0;
|
||||||
|
|
||||||
|
for (int32_t n = 0; n < width * height; n++) {
|
||||||
|
int32_t level;
|
||||||
|
level = coef[n];
|
||||||
|
level = ((int64_t)abs(level) * quant_coeff[n] + add) >> q_bits;
|
||||||
|
delta_u[n] = (int32_t)(((int64_t)abs(coef[n]) * quant_coeff[n] - (level << q_bits)) >> q_bits8);
|
||||||
|
ac_sum += level;
|
||||||
|
}
|
||||||
|
|
||||||
if(ac_sum >= 2) {
|
if(ac_sum >= 2) {
|
||||||
#define SCAN_SET_SIZE 16
|
#define SCAN_SET_SIZE 16
|
||||||
#define LOG2_SCAN_SET_SIZE 4
|
#define LOG2_SCAN_SET_SIZE 4
|
||||||
|
@ -257,7 +255,7 @@ void quant(const encoder_state * const encoder_state, int16_t *coef, int16_t *q_
|
||||||
#undef SCAN_SET_SIZE
|
#undef SCAN_SET_SIZE
|
||||||
#undef LOG2_SCAN_SET_SIZE
|
#undef LOG2_SCAN_SET_SIZE
|
||||||
}
|
}
|
||||||
#endif
|
#endif // SIGN_HIDING
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue