ref: 94806e029d774afb002e80a36007725fd29d40b2
parent: 78cde4f593ef7b7014d64219a8986e79c115cdb9
parent: d3fe3b2abb90caf87f76e46d83a2acfcfcc5b687
author: Alex Converse <[email protected]>
date: Thu Apr 28 15:44:03 EDT 2016
Merge "Avoid an unsigned overflow in invert_quant"
--- a/vp10/encoder/quantize.c
+++ b/vp10/encoder/quantize.c
@@ -219,12 +219,12 @@
static void invert_quant(int16_t *quant, int16_t *shift, int d) {
unsigned t;
- int l;
+ int l, m;
t = d;
for (l = 0; t > 1; l++)
t >>= 1;
- t = 1 + (1 << (16 + l)) / d;
- *quant = (int16_t)(t - (1 << 16));
+ m = 1 + (1 << (16 + l)) / d;
+ *quant = (int16_t)(m - (1 << 16));
*shift = 1 << (16 - l);
}
--- a/vp8/encoder/vp8_quantize.c
+++ b/vp8/encoder/vp8_quantize.c
@@ -227,12 +227,12 @@
if(improved_quant)
{
unsigned t;
- int l;
+ int l, m;
t = d;
for(l = 0; t > 1; l++)
t>>=1;
- t = 1 + (1<<(16+l))/d;
- *quant = (short)(t - (1<<16));
+ m = 1 + (1<<(16+l))/d;
+ *quant = (short)(m - (1<<16));
*shift = l;
/* use multiplication and constant shift by 16 */
*shift = 1 << (16 - *shift);
--- a/vp9/encoder/vp9_quantize.c
+++ b/vp9/encoder/vp9_quantize.c
@@ -219,12 +219,12 @@
static void invert_quant(int16_t *quant, int16_t *shift, int d) {
unsigned t;
- int l;
+ int l, m;
t = d;
for (l = 0; t > 1; l++)
t >>= 1;
- t = 1 + (1 << (16 + l)) / d;
- *quant = (int16_t)(t - (1 << 16));
+ m = 1 + (1 << (16 + l)) / d;
+ *quant = (int16_t)(m - (1 << 16));
*shift = 1 << (16 - l);
}