Commit 2ccd2c90 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/aacsbr_fixed: Fix multiple runtime error: left shift of negative value -407

Fixes: 1674/clusterfuzz-testcase-minimized-6092531563495424
Fixes: 1686/clusterfuzz-testcase-minimized-6282691643179008

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpegSigned-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 55b56a8d
...@@ -2800,9 +2800,9 @@ static void spectral_to_sample(AACContext *ac, int samples) ...@@ -2800,9 +2800,9 @@ static void spectral_to_sample(AACContext *ac, int samples)
int j; int j;
/* preparation for resampler */ /* preparation for resampler */
for(j = 0; j<samples; j++){ for(j = 0; j<samples; j++){
che->ch[0].ret[j] = (int32_t)av_clip64((int64_t)che->ch[0].ret[j]<<7, INT32_MIN, INT32_MAX-0x8000)+0x8000; che->ch[0].ret[j] = (int32_t)av_clip64((int64_t)che->ch[0].ret[j]*128, INT32_MIN, INT32_MAX-0x8000)+0x8000;
if(type == TYPE_CPE) if(type == TYPE_CPE)
che->ch[1].ret[j] = (int32_t)av_clip64((int64_t)che->ch[1].ret[j]<<7, INT32_MIN, INT32_MAX-0x8000)+0x8000; che->ch[1].ret[j] = (int32_t)av_clip64((int64_t)che->ch[1].ret[j]*128, INT32_MIN, INT32_MAX-0x8000)+0x8000;
} }
} }
#endif /* USE_FIXED */ #endif /* USE_FIXED */
......
...@@ -289,7 +289,7 @@ static void sbr_hf_inverse_filter(SBRDSPContext *dsp, ...@@ -289,7 +289,7 @@ static void sbr_hf_inverse_filter(SBRDSPContext *dsp,
if (shift >= 3) if (shift >= 3)
alpha0[k][0] = 0x7fffffff; alpha0[k][0] = 0x7fffffff;
else { else {
a00.mant <<= 1; a00.mant *= 2;
shift = 2-shift; shift = 2-shift;
if (shift == 0) if (shift == 0)
alpha0[k][0] = a00.mant; alpha0[k][0] = a00.mant;
...@@ -303,7 +303,7 @@ static void sbr_hf_inverse_filter(SBRDSPContext *dsp, ...@@ -303,7 +303,7 @@ static void sbr_hf_inverse_filter(SBRDSPContext *dsp,
if (shift >= 3) if (shift >= 3)
alpha0[k][1] = 0x7fffffff; alpha0[k][1] = 0x7fffffff;
else { else {
a01.mant <<= 1; a01.mant *= 2;
shift = 2-shift; shift = 2-shift;
if (shift == 0) if (shift == 0)
alpha0[k][1] = a01.mant; alpha0[k][1] = a01.mant;
...@@ -316,7 +316,7 @@ static void sbr_hf_inverse_filter(SBRDSPContext *dsp, ...@@ -316,7 +316,7 @@ static void sbr_hf_inverse_filter(SBRDSPContext *dsp,
if (shift >= 3) if (shift >= 3)
alpha1[k][0] = 0x7fffffff; alpha1[k][0] = 0x7fffffff;
else { else {
a10.mant <<= 1; a10.mant *= 2;
shift = 2-shift; shift = 2-shift;
if (shift == 0) if (shift == 0)
alpha1[k][0] = a10.mant; alpha1[k][0] = a10.mant;
...@@ -330,7 +330,7 @@ static void sbr_hf_inverse_filter(SBRDSPContext *dsp, ...@@ -330,7 +330,7 @@ static void sbr_hf_inverse_filter(SBRDSPContext *dsp,
if (shift >= 3) if (shift >= 3)
alpha1[k][1] = 0x7fffffff; alpha1[k][1] = 0x7fffffff;
else { else {
a11.mant <<= 1; a11.mant *= 2;
shift = 2-shift; shift = 2-shift;
if (shift == 0) if (shift == 0)
alpha1[k][1] = a11.mant; alpha1[k][1] = a11.mant;
......
...@@ -116,7 +116,7 @@ static av_always_inline SoftFloat autocorr_calc(int64_t accu) ...@@ -116,7 +116,7 @@ static av_always_inline SoftFloat autocorr_calc(int64_t accu)
} else { } else {
nz = 0; nz = 0;
while (FFABS(i) < 0x40000000) { while (FFABS(i) < 0x40000000) {
i <<= 1; i *= 2;
nz++; nz++;
} }
nz = 32-nz; nz = 32-nz;
...@@ -125,7 +125,7 @@ static av_always_inline SoftFloat autocorr_calc(int64_t accu) ...@@ -125,7 +125,7 @@ static av_always_inline SoftFloat autocorr_calc(int64_t accu)
round = 1U << (nz-1); round = 1U << (nz-1);
mant = (int)((accu + round) >> nz); mant = (int)((accu + round) >> nz);
mant = (mant + 0x40)>>7; mant = (mant + 0x40)>>7;
mant <<= 6; mant *= 64;
expo = nz + 15; expo = nz + 15;
return av_int2sf(mant, 30 - expo); return av_int2sf(mant, 30 - expo);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment