Index: source/libvpx/vp8/encoder/quantize.c |
=================================================================== |
--- source/libvpx/vp8/encoder/quantize.c (revision 191025) |
+++ source/libvpx/vp8/encoder/quantize.c (working copy) |
@@ -50,8 +50,8 @@ |
if (x >= zbin) |
{ |
x += round_ptr[rc]; |
- y = (((x * quant_ptr[rc]) >> 16) + x) |
- >> quant_shift_ptr[rc]; /* quantize (x) */ |
+ y = ((((x * quant_ptr[rc]) >> 16) + x) |
+ * quant_shift_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 */ |
@@ -113,7 +113,7 @@ |
short *zbin_ptr = b->zbin; |
short *round_ptr = b->round; |
short *quant_ptr = b->quant; |
- unsigned char *quant_shift_ptr = b->quant_shift; |
+ short *quant_shift_ptr = b->quant_shift; |
short *qcoeff_ptr = d->qcoeff; |
short *dqcoeff_ptr = d->dqcoeff; |
short *dequant_ptr = d->dequant; |
@@ -138,8 +138,8 @@ |
if (x >= zbin) |
{ |
x += round_ptr[rc]; |
- y = (((x * quant_ptr[rc]) >> 16) + x) |
- >> quant_shift_ptr[rc]; /* quantize (x) */ |
+ y = ((((x * quant_ptr[rc]) >> 16) + x) |
+ * quant_shift_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 */ |
@@ -167,7 +167,7 @@ |
int sz; |
short *coeff_ptr; |
short *quant_ptr; |
- unsigned char *quant_shift_ptr; |
+ short *quant_shift_ptr; |
short *qcoeff_ptr; |
short *dqcoeff_ptr; |
short *dequant_ptr; |
@@ -198,7 +198,7 @@ |
if (x >= dq) |
{ |
/* Quantize x. */ |
- y = (((x * quant_ptr[rc]) >> 16) + x) >> quant_shift_ptr[rc]; |
+ y = ((((x * quant_ptr[rc]) >> 16) + x) * quant_shift_ptr[rc]) >> 16; |
/* Put the sign back. */ |
x = (y + sz) ^ sz; |
/* Save the coefficient and its dequantized value. */ |
@@ -406,7 +406,7 @@ |
#define EXACT_QUANT |
#ifdef EXACT_QUANT |
static void invert_quant(int improved_quant, short *quant, |
- unsigned char *shift, short d) |
+ short *shift, short d) |
{ |
if(improved_quant) |
{ |
@@ -418,11 +418,15 @@ |
t = 1 + (1<<(16+l))/d; |
*quant = (short)(t - (1<<16)); |
*shift = l; |
+ /* use multiplication and constant shift by 16 */ |
+ *shift = 1 << (16 - *shift); |
} |
else |
{ |
*quant = (1 << 16) / d; |
*shift = 0; |
+ /* use multiplication and constant shift by 16 */ |
+ *shift = 1 << (16 - *shift); |
} |
} |