Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.xiph.org/xiph/opus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jmvalin@jmvalin.ca>2017-05-24 08:21:51 +0300
committerJean-Marc Valin <jmvalin@jmvalin.ca>2017-05-24 08:21:51 +0300
commit3609a2218e05abc96bb9b5edd875ec16a92ba699 (patch)
tree7b5bf47fcf009e85f646078bf4cac00acd2ce2d5
parenta671ac5582fe598f3a46e659873eb7bbc9010cb1 (diff)
Fixes some fixed-point 16-bit int overflowsv1.2-beta
The code would have run fine on 32-bit archs, but would have overflowed on a 16-bit arch
-rw-r--r--celt/celt_encoder.c2
-rw-r--r--celt/pitch.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/celt/celt_encoder.c b/celt/celt_encoder.c
index 6d884726..4851208a 100644
--- a/celt/celt_encoder.c
+++ b/celt/celt_encoder.c
@@ -843,7 +843,7 @@ static int alloc_trim_analysis(const CELTMode *m, const celt_norm *X,
} while (++c<C);
diff /= C*(end-1);
/*printf("%f\n", diff);*/
- trim -= MAX16(-QCONST16(2.f, 8), MIN16(QCONST16(2.f, 8), SHR16(diff+QCONST16(1.f, DB_SHIFT),DB_SHIFT-8)/6 ));
+ trim -= MAX32(-QCONST16(2.f, 8), MIN32(QCONST16(2.f, 8), SHR32(diff+QCONST16(1.f, DB_SHIFT),DB_SHIFT-8)/6 ));
trim -= SHR16(surround_trim, DB_SHIFT-8);
trim -= 2*SHR16(tf_estimate, 14-8);
#ifndef DISABLE_FLOAT_API
diff --git a/celt/pitch.c b/celt/pitch.c
index bf46e7d5..42f526bf 100644
--- a/celt/pitch.c
+++ b/celt/pitch.c
@@ -424,7 +424,7 @@ static opus_val16 compute_pitch_gain(opus_val32 xy, opus_val32 xx, opus_val32 yy
sx = celt_ilog2(xx)-14;
sy = celt_ilog2(yy)-14;
shift = sx + sy;
- x2y2 = MULT16_16_Q14(VSHR32(xx, sx), VSHR32(yy, sy));
+ x2y2 = SHR32(MULT16_16(VSHR32(xx, sx), VSHR32(yy, sy)), 14);
if (shift & 1) {
if (x2y2 < 32768)
{