From: nu774 Date: Sat, 5 Jan 2013 01:47:21 +0000 (+0900) Subject: fixed to clip before converting float to int X-Git-Tag: v0.0.2~1 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=6da14aaeb755e6205631a8734542c82b5a7ba470;p=fdkaac.git fixed to clip before converting float to int --- diff --git a/src/lpcm.c b/src/lpcm.c index 5d338c7..d8c279e 100644 --- a/src/lpcm.c +++ b/src/lpcm.c @@ -34,7 +34,7 @@ inline int lrint(double x) # endif #endif -inline int pcm_clip(int n, int min_value, int max_value) +inline double pcm_clip(double n, double min_value, double max_value) { if (n < min_value) return min_value; @@ -67,7 +67,7 @@ inline int16_t pcm_quantize_s32(int32_t n) } inline int16_t pcm_quantize_f64(double v) { - return pcm_clip(lrint(v * 32768.0), -32768, 32767); + return (int16_t)lrint(pcm_clip(v * 32768.0, -32768.0, 32767.0)); } inline int16_t pcm_s8_to_s16(int8_t n) {