fixed to clip before converting float to int
authornu774 <honeycomb77@gmail.com>
Sat, 5 Jan 2013 01:47:21 +0000 (10:47 +0900)
committernu774 <honeycomb77@gmail.com>
Sat, 5 Jan 2013 01:47:21 +0000 (10:47 +0900)
src/lpcm.c

index 5d338c7b814e2d7557d9b29f39105b6f5fffd970..d8c279e8d9e25f7afdfebc581441bd5ceffdd28f 100644 (file)
@@ -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)
 {
This page took 0.011065 seconds and 4 git commands to generate.