From 5d93feb6ada860cbd51975cbe208f0ccf8a312a8 Mon Sep 17 00:00:00 2001 From: Jingning Han Date: Mon, 9 Sep 2013 16:02:07 -0700 Subject: [PATCH] Remove redundant condition check in 32x32 quant The c code implementation of 32x32 quantization does the zbin check of all coefficients prior to the quant/dequant loop, hence removing the redundant zbin check inside the loop. This only affects the c code version. SSSE3 version does not separate the zbin check out. Change-Id: Ic197a7d61d0b25fcac3cc092987651378cb56e4e --- vp9/encoder/vp9_quantize.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/vp9/encoder/vp9_quantize.c b/vp9/encoder/vp9_quantize.c index cfaa776cb..288d4c22e 100644 --- a/vp9/encoder/vp9_quantize.c +++ b/vp9/encoder/vp9_quantize.c @@ -94,7 +94,7 @@ void vp9_quantize_b_32x32_c(int16_t *coeff_ptr, intptr_t n_coeffs, uint16_t *eob_ptr, const int16_t *scan, const int16_t *iscan) { int i, rc, eob; - int zbins[2], nzbins[2], zbin; + int zbins[2], nzbins[2]; int x, y, z, sz; int idx = 0; int idx_arr[1024]; @@ -127,27 +127,21 @@ void vp9_quantize_b_32x32_c(int16_t *coeff_ptr, intptr_t n_coeffs, for (i = 0; i < idx; i++) { rc = scan[idx_arr[i]]; - // Calculate ZBIN - zbin = (zbins[rc != 0]); - z = coeff_ptr[rc]; sz = (z >> 31); // sign of z x = (z ^ sz) - sz; // x = abs(z) - if (x >= zbin) { - x += ROUND_POWER_OF_TWO(round_ptr[rc != 0], 1); - x = clamp(x, INT16_MIN, INT16_MAX); - y = (((int)(((int)(x * quant_ptr[rc != 0]) >> 16) + x)) * - quant_shift_ptr[rc != 0]) >> 15; // quantize (x) + x += ROUND_POWER_OF_TWO(round_ptr[rc != 0], 1); + x = clamp(x, INT16_MIN, INT16_MAX); + y = ((((x * quant_ptr[rc != 0]) >> 16) + x) * + quant_shift_ptr[rc != 0]) >> 15; // quantize (x) - x = (y ^ sz) - sz; // get the sign back - qcoeff_ptr[rc] = x; // write to destination - dqcoeff_ptr[rc] = x * dequant_ptr[rc != 0] / 2; // dequantized value + x = (y ^ sz) - sz; // get the sign back + qcoeff_ptr[rc] = x; // write to destination + dqcoeff_ptr[rc] = x * dequant_ptr[rc != 0] / 2; // dequantized value - if (y) { - eob = idx_arr[i]; // last nonzero coeffs - } - } + if (y) + eob = idx_arr[i]; // last nonzero coeffs } } *eob_ptr = eob + 1; -- 2.40.0