summaryrefslogtreecommitdiff
path: root/vp8/encoder/quantize.c
diff options
context:
space:
mode:
authorTimothy B. Terriberry <tterribe@xiph.org>2010-10-11 13:49:52 -0700
committerTimothy B. Terriberry <tterribe@xiph.org>2010-10-11 13:51:35 -0700
commit82c433988583e9c2a09ebf19bb9fa20c4de001ea (patch)
tree9202c05d0138a4a86d985ee2bd7ce3777d6c9d3c /vp8/encoder/quantize.c
parentdd08db9315d77b183ba563c8a83cc4e0aee439d6 (diff)
downloadlibvpx-82c433988583e9c2a09ebf19bb9fa20c4de001ea.tar
libvpx-82c433988583e9c2a09ebf19bb9fa20c4de001ea.tar.gz
libvpx-82c433988583e9c2a09ebf19bb9fa20c4de001ea.tar.bz2
libvpx-82c433988583e9c2a09ebf19bb9fa20c4de001ea.zip
Move vp8_strict_quantize_b inside EXACT_QUANT #define.
There is currently no inexact version of this function, so do not even compile it without EXACT_QUANT. This will prevent someone from inadvertently trying to use it without the proper EXACT_QUANT setup. Change-Id: Ia13491e0128afb281c05c9222ee5987101e4010d
Diffstat (limited to 'vp8/encoder/quantize.c')
-rw-r--r--vp8/encoder/quantize.c117
1 files changed, 59 insertions, 58 deletions
diff --git a/vp8/encoder/quantize.c b/vp8/encoder/quantize.c
index d06b04896..1a8c8ebb7 100644
--- a/vp8/encoder/quantize.c
+++ b/vp8/encoder/quantize.c
@@ -118,6 +118,65 @@ void vp8_regular_quantize_b(BLOCK *b, BLOCKD *d)
d->eob = eob + 1;
}
+
+/* Perform regular quantization, with unbiased rounding and no zero bin. */
+void vp8_strict_quantize_b(BLOCK *b, BLOCKD *d)
+{
+ int i;
+ int rc;
+ int eob;
+ int x;
+ int y;
+ int z;
+ int sz;
+ short *coeff_ptr;
+ short *quant_ptr;
+ short *quant_shift_ptr;
+ short *qcoeff_ptr;
+ short *dqcoeff_ptr;
+ short *dequant_ptr;
+
+ coeff_ptr = &b->coeff[0];
+ quant_ptr = &b->quant[0][0];
+ quant_shift_ptr = &b->quant_shift[0][0];
+ qcoeff_ptr = d->qcoeff;
+ dqcoeff_ptr = d->dqcoeff;
+ dequant_ptr = &d->dequant[0][0];
+ eob = - 1;
+ vpx_memset(qcoeff_ptr, 0, 32);
+ vpx_memset(dqcoeff_ptr, 0, 32);
+ for (i = 0; i < 16; i++)
+ {
+ int dq;
+ int round;
+
+ /*TODO: These arrays should be stored in zig-zag order.*/
+ rc = vp8_default_zig_zag1d[i];
+ z = coeff_ptr[rc];
+ dq = dequant_ptr[rc];
+ round = dq >> 1;
+ /* Sign of z. */
+ sz = -(z < 0);
+ x = (z + sz) ^ sz;
+ x += round;
+ if (x >= dq)
+ {
+ /* Quantize x. */
+ y = (((x * quant_ptr[rc]) >> 16) + x) >> quant_shift_ptr[rc];
+ /* Put the sign back. */
+ x = (y + sz) ^ sz;
+ /* Save the coefficient and its dequantized value. */
+ qcoeff_ptr[rc] = x;
+ dqcoeff_ptr[rc] = x * dq;
+ /* Remember the last non-zero coefficient. */
+ if (y)
+ eob = i;
+ }
+ }
+
+ d->eob = eob + 1;
+}
+
#else
void vp8_fast_quantize_b_c(BLOCK *b, BLOCKD *d)
{
@@ -207,64 +266,6 @@ void vp8_regular_quantize_b(BLOCK *b, BLOCKD *d)
#endif
-/* Perform regular quantization, with unbiased rounding and no zero bin. */
-void vp8_strict_quantize_b(BLOCK *b, BLOCKD *d)
-{
- int i;
- int rc;
- int eob;
- int x;
- int y;
- int z;
- int sz;
- short *coeff_ptr;
- short *quant_ptr;
- short *quant_shift_ptr;
- short *qcoeff_ptr;
- short *dqcoeff_ptr;
- short *dequant_ptr;
-
- coeff_ptr = &b->coeff[0];
- quant_ptr = &b->quant[0][0];
- quant_shift_ptr = &b->quant_shift[0][0];
- qcoeff_ptr = d->qcoeff;
- dqcoeff_ptr = d->dqcoeff;
- dequant_ptr = &d->dequant[0][0];
- eob = - 1;
- vpx_memset(qcoeff_ptr, 0, 32);
- vpx_memset(dqcoeff_ptr, 0, 32);
- for (i = 0; i < 16; i++)
- {
- int dq;
- int round;
-
- /*TODO: These arrays should be stored in zig-zag order.*/
- rc = vp8_default_zig_zag1d[i];
- z = coeff_ptr[rc];
- dq = dequant_ptr[rc];
- round = dq >> 1;
- /* Sign of z. */
- sz = -(z < 0);
- x = (z + sz) ^ sz;
- x += round;
- if (x >= dq)
- {
- /* Quantize x. */
- y = (((x * quant_ptr[rc]) >> 16) + x) >> quant_shift_ptr[rc];
- /* Put the sign back. */
- x = (y + sz) ^ sz;
- /* Save the coefficient and its dequantized value. */
- qcoeff_ptr[rc] = x;
- dqcoeff_ptr[rc] = x * dq;
- /* Remember the last non-zero coefficient. */
- if (y)
- eob = i;
- }
- }
-
- d->eob = eob + 1;
-}
-
void vp8_quantize_mby(MACROBLOCK *x)
{
int i;