mirror of
https://gitee.com/openharmony/third_party_libsnd
synced 2025-02-22 03:40:56 +00:00
src/sndfile.c: Fix SFC_SET_SCALE_FLOAT_INT_READ
Before this fix it was possible for a the float/double to short/int conversion to cause wrap-around distortion.
This commit is contained in:
parent
4b14e45190
commit
d87b2319b0
@ -964,7 +964,8 @@ sf_command (SNDFILE *sndfile, int command, void *data, int datasize)
|
||||
|
||||
psf->float_int_mult = (datasize != 0) ? SF_TRUE : SF_FALSE ;
|
||||
if (psf->float_int_mult && psf->float_max < 0.0)
|
||||
psf->float_max = psf_calc_signal_max (psf, SF_FALSE) ;
|
||||
/* Scale to prevent wrap-around distortion. */
|
||||
psf->float_max = (32768.0 / 32767.0) * psf_calc_signal_max (psf, SF_FALSE) ;
|
||||
return old_value ;
|
||||
|
||||
case SFC_SET_SCALE_INT_FLOAT_WRITE :
|
||||
|
Loading…
x
Reference in New Issue
Block a user