summaryrefslogtreecommitdiff
path: root/vp8/encoder/quantize.c
diff options
context:
space:
mode:
authorYaowu Xu <yaowu@google.com>2010-10-06 13:28:36 -0700
committerYaowu Xu <yaowu@google.com>2010-10-06 13:28:36 -0700
commitd338d14c6bcf1bd9f9d028cf7ee177503076da47 (patch)
treef68dbab9705c9553cd02ab4507a9403f580e03f4 /vp8/encoder/quantize.c
parent7be093ea4d50c8d38438f88cb9fa817c1c9de8dd (diff)
downloadlibvpx-d338d14c6bcf1bd9f9d028cf7ee177503076da47.tar
libvpx-d338d14c6bcf1bd9f9d028cf7ee177503076da47.tar.gz
libvpx-d338d14c6bcf1bd9f9d028cf7ee177503076da47.tar.bz2
libvpx-d338d14c6bcf1bd9f9d028cf7ee177503076da47.zip
optimize fast_quantizer c version
As the zbin and rounding constants are normalized, rounding effectively does the zbinning, therefore the zbin operation can be removed. In addition, the memset on the two arrays are no longer necessary. Change-Id: If39c353c42d7e052296cb65322e5218810b5cc4c
Diffstat (limited to 'vp8/encoder/quantize.c')
-rw-r--r--vp8/encoder/quantize.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/vp8/encoder/quantize.c b/vp8/encoder/quantize.c
index 20ec9d11b..d06b04896 100644
--- a/vp8/encoder/quantize.c
+++ b/vp8/encoder/quantize.c
@@ -125,38 +125,29 @@ void vp8_fast_quantize_b_c(BLOCK *b, BLOCKD *d)
int zbin;
int x, y, z, sz;
short *coeff_ptr = &b->coeff[0];
- short *zbin_ptr = &b->zbin[0][0];
short *round_ptr = &b->round[0][0];
short *quant_ptr = &b->quant[0][0];
short *qcoeff_ptr = d->qcoeff;
short *dqcoeff_ptr = d->dqcoeff;
short *dequant_ptr = &d->dequant[0][0];
- vpx_memset(qcoeff_ptr, 0, 32);
- vpx_memset(dqcoeff_ptr, 0, 32);
-
eob = -1;
-
for (i = 0; i < 16; i++)
{
rc = vp8_default_zig_zag1d[i];
z = coeff_ptr[rc];
- zbin = zbin_ptr[rc] ;
sz = (z >> 31); // sign of z
x = (z ^ sz) - sz; // x = abs(z)
- if (x >= zbin)
- {
- y = ((x + round_ptr[rc]) * quant_ptr[rc]) >> 16; // quantize (x)
- x = (y ^ sz) - sz; // get the sign back
- qcoeff_ptr[rc] = x; // write to destination
- dqcoeff_ptr[rc] = x * dequant_ptr[rc]; // dequantized value
+ y = ((x + round_ptr[rc]) * quant_ptr[rc]) >> 16; // quantize (x)
+ x = (y ^ sz) - sz; // get the sign back
+ qcoeff_ptr[rc] = x; // write to destination
+ dqcoeff_ptr[rc] = x * dequant_ptr[rc]; // dequantized value
- if (y)
- {
- eob = i; // last nonzero coeffs
- }
+ if (y)
+ {
+ eob = i; // last nonzero coeffs
}
}
d->eob = eob + 1;