diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2016-07-24 17:54:56 -0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2016-07-24 21:36:06 -0400 |
commit | 84043f7cf7e00351264ee97d85333fa9a3fc8f97 (patch) | |
tree | d219dab06354de9cddb0ef1c4ce52d19870aa5de /celt | |
parent | 223657b51b0a74e8bc0b6e15841b61c08776ee5b (diff) | |
download | libopus-84043f7cf7e00351264ee97d85333fa9a3fc8f97.tar.gz |
Fixes a shift<0 issue in transient_analysis()
Fixes a potential overflow in high-passed signal for transient detection
and ensures that the shift can never go negative
Diffstat (limited to 'celt')
-rw-r--r-- | celt/celt_encoder.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/celt/celt_encoder.c b/celt/celt_encoder.c index 1f6d0ce9..4473b37b 100644 --- a/celt/celt_encoder.c +++ b/celt/celt_encoder.c @@ -272,7 +272,7 @@ static int transient_analysis(const opus_val32 * OPUS_RESTRICT in, int len, int mem0 = mem1 + y - 2*x; mem1 = x - .5f*y; #endif - tmp[i] = EXTRACT16(SHR32(y,2)); + tmp[i] = SROUND16(y, 2); /*printf("%f ", tmp[i]);*/ } /*printf("\n");*/ @@ -283,7 +283,7 @@ static int transient_analysis(const opus_val32 * OPUS_RESTRICT in, int len, int /* Normalize tmp to max range */ { int shift=0; - shift = 14-celt_ilog2(1+celt_maxabs16(tmp, len)); + shift = 14-celt_ilog2(MAX16(1, celt_maxabs16(tmp, len))); if (shift!=0) { for (i=0;i<len;i++) |