diff options
author | rfelker <rfelker@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2005-02-22 02:12:58 +0000 |
---|---|---|
committer | rfelker <rfelker@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2005-02-22 02:12:58 +0000 |
commit | 66b1d8c94b5bcd33ab8c0857140e1eafe01011ee (patch) | |
tree | 206cd159d826076cc0c90cf1b06989aebd045441 /libaf | |
parent | aa566ac6de7d9a9172a2f55d3c5287424c589a87 (diff) | |
download | mpv-66b1d8c94b5bcd33ab8c0857140e1eafe01011ee.tar.bz2 mpv-66b1d8c94b5bcd33ab8c0857140e1eafe01011ee.tar.xz |
finally the dreaded white-noise-with-floats bug is fixed!!!!
the problem is that lrintf was not prototyped on some systems, but
it's easier and faster just not to use it at all. looks like the cola
goes to our friends the glibc developers for forgetting to put lrintf
in math.h in some versions. :))) i'm sure there are other broken libcs
too though.
also fixed a minor bug in the int->float conversion where the range
for float samples was exceeded...
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14759 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libaf')
-rw-r--r-- | libaf/af_format.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/libaf/af_format.c b/libaf/af_format.c index 673183d5db..2777fdbc42 100644 --- a/libaf/af_format.c +++ b/libaf/af_format.c @@ -14,14 +14,6 @@ #include "../bswap.h" #include "../libvo/fastmemcpy.h" -// Integer to float conversion through lrintf() -#ifdef HAVE_LRINTF -#define __USE_ISOC99 1 -#include <math.h> -#else -#define lrintf(x) ((int)(x)) -#endif - /* Functions used by play to convert the input audio to the correct format */ @@ -502,19 +494,19 @@ static void float2int(void* in, void* out, int len, int bps) switch(bps){ case(1): for(i=0;i<len;i++) - ((int8_t*)out)[i]=(int8_t)lrintf(SCHAR_MAX*((float*)in)[i]); + ((int8_t*)out)[i] = (int)(127.0 * (1.0+((float*)in)[i])) - 127; break; case(2): for(i=0;i<len;i++) - ((int16_t*)out)[i]=(int16_t)lrintf(SHRT_MAX*((float*)in)[i]); + ((int16_t*)out)[i] = (int)(32767.0 * (1.0+((float*)in)[i])) - 32767; break; case(3): for(i=0;i<len;i++) - store24bit(out, i, (int32_t)lrintf(INT_MAX*((float*)in)[i])); + store24bit(out, i, (int)(2147483647.0 * (1.0+((float*)in)[i])) - 2147483647); break; case(4): for(i=0;i<len;i++) - ((int32_t*)out)[i]=(int32_t)lrintf(INT_MAX*((float*)in)[i]); + ((int32_t*)out)[i] = (int)(2147483647.0 * (1.0+((float*)in)[i])) - 2147483647; break; } } @@ -525,19 +517,19 @@ static void int2float(void* in, void* out, int len, int bps) switch(bps){ case(1): for(i=0;i<len;i++) - ((float*)out)[i]=(1.0/SCHAR_MAX)*((float)((int8_t*)in)[i]); + ((float*)out)[i]=(1.0/128.0)*((float)((int8_t*)in)[i]); break; case(2): for(i=0;i<len;i++) - ((float*)out)[i]=(1.0/SHRT_MAX)*((float)((int16_t*)in)[i]); + ((float*)out)[i]=(1.0/32768.0)*((float)((int16_t*)in)[i]); break; case(3): for(i=0;i<len;i++) - ((float*)out)[i]=(1.0/INT_MAX)*((float)((int32_t)load24bit(in, i))); + ((float*)out)[i]=(1.0/2147483648.0)*((float)((int32_t)load24bit(in, i))); break; case(4): for(i=0;i<len;i++) - ((float*)out)[i]=(1.0/INT_MAX)*((float)((int32_t*)in)[i]); + ((float*)out)[i]=(1.0/2147483648.0)*((float)((int32_t*)in)[i]); break; } } |