changeset 36384:e79bac50b920

Use correct types for constants. Otherwise the compiler might insert a conversion from float to double and back.
author reimar
date Sun, 20 Oct 2013 12:51:35 +0000
parents 12b7f66d1a47
children fc93e82b8afc
files libaf/af_format.c
diffstat 1 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/libaf/af_format.c	Fri Oct 18 18:03:21 2013 +0000
+++ b/libaf/af_format.c	Sun Oct 20 12:51:35 2013 +0000
@@ -491,28 +491,28 @@
   switch(bps){
   case(1):
     for(i=0;i<len;i++)
-      ((int8_t *)out)[i] = av_clip_int8(lrintf(128.0 * in[i]));
+      ((int8_t *)out)[i] = av_clip_int8(lrintf(128.0f * in[i]));
     break;
   case(2):
     for(i=0;i<len;i++)
-      ((int16_t*)out)[i] = av_clip_int16(lrintf(32768.0 * in[i]));
+      ((int16_t*)out)[i] = av_clip_int16(lrintf(32768.0f * in[i]));
     break;
   case(3):
     for(i=0;i<len;i++){
-      f = in[i] * 8388608;
+      f = in[i] * 8388608.0f;
       store24bit(out, i,   av_clip(lrintf(f), -1*(1<<23), (1<<23)-1) << 8);
     }
     break;
   case(4):
     for(i=0;i<len;i++){
       f = in[i];
-      if (f <= -1.0)
+      if (f <= -1.0f)
         ((int32_t*)out)[i] = INT_MIN;
       else
-      if (f >=  1.0)//no need to use corrected constant, rounding won't cause overflow
+      if (f >=  1.0f)//no need to use corrected constant, rounding won't cause overflow
         ((int32_t*)out)[i] = INT_MAX;
       else
-        ((int32_t*)out)[i] = lrintf(f*2147483648.0);
+        ((int32_t*)out)[i] = lrintf(f*2147483648.0f);
 
     }
     break;
@@ -525,19 +525,19 @@
   switch(bps){
   case(1):
     for(i=0;i<len;i++)
-      out[i]=(1.0/128.0)*((int8_t*)in)[i];
+      out[i]=(1.0f/128.0f)*((int8_t*)in)[i];
     break;
   case(2):
     for(i=0;i<len;i++)
-      out[i]=(1.0/32768.0)*((int16_t*)in)[i];
+      out[i]=(1.0f/32768.0f)*((int16_t*)in)[i];
     break;
   case(3):
     for(i=0;i<len;i++)
-      out[i]=(1.0/2147483648.0)*((int32_t)load24bit(in, i));
+      out[i]=(1.0f/2147483648.0f)*((int32_t)load24bit(in, i));
     break;
   case(4):
     for(i=0;i<len;i++)
-      out[i]=(1.0/2147483648.0)*((int32_t*)in)[i];
+      out[i]=(1.0f/2147483648.0f)*((int32_t*)in)[i];
     break;
   }
 }