aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2019-02-26 00:16:29 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-02-26 00:16:29 +0000
commit00cd0bb17cc177c4a187b0b11ad35cf655b164bb (patch)
treed5bedb6f0bce3d527c7b96a59ad6766c9e364394
parent34571bd9d3ebb5a3fe1395ddae7d890ec1d5e2c8 (diff)
parent31bb626fb307d79ecdc650d0ad14aa3017f5d325 (diff)
downloadlibxaac-00cd0bb17cc177c4a187b0b11ad35cf655b164bb.tar.gz
Merge "Fix for multiplication overflow in voronoi_idx_dec function"
-rw-r--r--decoder/ixheaacd_avq_dec.c2
-rw-r--r--decoder/ixheaacd_basic_ops32.h20
2 files changed, 8 insertions, 14 deletions
diff --git a/decoder/ixheaacd_avq_dec.c b/decoder/ixheaacd_avq_dec.c
index 7097d01..3d8aed0 100644
--- a/decoder/ixheaacd_avq_dec.c
+++ b/decoder/ixheaacd_avq_dec.c
@@ -155,7 +155,7 @@ VOID ixheaacd_voronoi_idx_dec(WORD32 *kv, WORD32 m, WORD32 *y, WORD32 count) {
rem1[7] = y[7] & (m - 1);
sum = 0;
for (i = 6; i >= 1; i--) {
- tmp = 2 * kv[i];
+ tmp = ixheaacd_shl32_sat(kv[i], 1);
sum = ixheaacd_add32_sat(sum, tmp);
y[i] += tmp;
z[i] = y[i] >> count;
diff --git a/decoder/ixheaacd_basic_ops32.h b/decoder/ixheaacd_basic_ops32.h
index b25972f..247df7e 100644
--- a/decoder/ixheaacd_basic_ops32.h
+++ b/decoder/ixheaacd_basic_ops32.h
@@ -65,19 +65,13 @@ static PLATFORM_INLINE WORD32 ixheaacd_shr32(WORD32 a, WORD b) {
}
static PLATFORM_INLINE WORD32 ixheaacd_shl32_sat(WORD32 a, WORD b) {
- WORD32 out_val = a;
- for (; b > 0; b--) {
- if (a > (WORD32)0X3fffffffL) {
- out_val = MAX_32;
- break;
- } else if (a < (WORD32)0xc0000000L) {
- out_val = MIN_32;
- break;
- }
-
- a = ixheaacd_shl32(a, 1);
- out_val = a;
- }
+ WORD32 out_val;
+ if (a > (MAX_32 >> b))
+ out_val = MAX_32;
+ else if (a < (MIN_32 >> b))
+ out_val = MIN_32;
+ else
+ out_val = a << b;
return (out_val);
}