Skip to content

Commit

Permalink
celt_sqrt() can return 32-bit value 32768
Browse files Browse the repository at this point in the history
EXTEND32() would warn that the input isn't 16-bit
  • Loading branch information
jmvalin committed Sep 20, 2024
1 parent 36b82ad commit 1807301
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion celt/bands.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void compute_band_energies(const CELTMode *m, const celt_sig *X, celt_ener *band
} while (++j<eBands[i+1]<<LM);
}
/* We're adding one here to ensure the normalized band isn't larger than unity norm */
bandE[i+c*m->nbEBands] = EPSILON+VSHR32(EXTEND32(celt_sqrt(sum)),-shift);
bandE[i+c*m->nbEBands] = EPSILON+VSHR32(celt_sqrt(sum),-shift);
} else {
bandE[i+c*m->nbEBands] = EPSILON;
}
Expand Down
2 changes: 1 addition & 1 deletion src/opus_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ opus_val16 compute_stereo_width(const opus_val16 *pcm, int frame_size, opus_int3
corr = SHR32(frac_div32(mem->XY,EPSILON+MULT16_16(sqrt_xx,sqrt_yy)),16);
/* Approximate loudness difference */
ldiff = MULT16_16(Q15ONE, ABS16(qrrt_xx-qrrt_yy))/(EPSILON+qrrt_xx+qrrt_yy);
width = MULT16_16_Q15(celt_sqrt(QCONST32(1.f,30)-MULT16_16(corr,corr)), ldiff);
width = MULT16_16_Q15(MIN16(Q15ONE, celt_sqrt(QCONST32(1.f,30)-MULT16_16(corr,corr))), ldiff);
/* Smoothing over one second */
mem->smoothed_width += (width-mem->smoothed_width)/frame_rate;
/* Peak follower */
Expand Down

0 comments on commit 1807301

Please sign in to comment.