Mercurial > mplayer.hg
changeset 14758:94456deb0624
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...
author | rfelker |
---|---|
date | Tue, 22 Feb 2005 02:12:58 +0000 |
parents | 7a2adc5e8928 |
children | 8c1d40548612 |
files | libaf/af_format.c |
diffstat | 1 files changed, 8 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/libaf/af_format.c Mon Feb 21 23:18:31 2005 +0000 +++ b/libaf/af_format.c Tue Feb 22 02:12:58 2005 +0000 @@ -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 @@ 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 @@ 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; } }