Fix fixed-point gain wrap-around on invalid packet

Not really a problem in practice (the packet is broken anyway)
but caught by asan.
This commit is contained in:
Jean-Marc Valin 2025-03-21 10:41:18 -04:00
parent b5aad6a282
commit fba923d83a
No known key found for this signature in database
GPG key ID: 8D2952BBB52C646D

View file

@ -428,7 +428,7 @@ void unquant_coarse_energy(const CELTMode *m, int start, int end, celt_glog *old
{
const unsigned char *prob_model = e_prob_model[LM][intra];
int i, c;
opus_val32 prev[2] = {0, 0};
opus_val64 prev[2] = {0, 0};
opus_val16 coef;
opus_val16 beta;
opus_int32 budget;
@ -481,7 +481,7 @@ void unquant_coarse_energy(const CELTMode *m, int start, int end, celt_glog *old
oldEBands[i+c*m->nbEBands] = MAXG(-GCONST(9.f), oldEBands[i+c*m->nbEBands]);
tmp = MULT16_32_Q15(coef,oldEBands[i+c*m->nbEBands]) + prev[c] + q;
#ifdef FIXED_POINT
tmp = MAX32(-GCONST(28.f), tmp);
tmp = MIN32(GCONST(28.f), MAX32(-GCONST(28.f), tmp));
#endif
oldEBands[i+c*m->nbEBands] = tmp;
prev[c] = prev[c] + q - MULT16_32_Q15(beta,q);