Index: apps/codecs/libatrac/atrac3.c =================================================================== --- apps/codecs/libatrac/atrac3.c (revision 22246) +++ apps/codecs/libatrac/atrac3.c (working copy) @@ -50,6 +50,7 @@ #include "../librm/rm.h" #include "atrac3data.h" +#include "atrac3data_fixed.h" #define JOINT_STEREO 0x12 #define STEREO 0x2 @@ -128,7 +129,7 @@ } ATRAC3Context; static DECLARE_ALIGNED_16(float,mdct_window[512]); -static float qmf_window[48]; +static int32_t qmf_window[48]; static VLC spectral_coeff_tab[7]; static float SFTable[64]; static float gain_tab1[16]; @@ -150,7 +151,20 @@ * @param temp temp buffer */ +static inline int32_t fixmul31(int32_t x, int32_t y) +{ + int64_t temp; + temp = x; + temp *= y; + temp >>= 31; //16+31-16 = 31 bits + + return (int32_t)temp; +} + +#define fixtof64(x) (float)((float)(x) / (float)(1 << 16)) //does not work on int64_t! +#define ftofix32(x) ((int32_t)((x) * (float)(1 << 16) + ((x) < 0 ? -0.5 : 0.5))) + static void iqmf (float *inlo, float *inhi, unsigned int nIn, float *pOut, float *delayBuf, float *temp) { int i, j; @@ -171,16 +185,16 @@ /* loop2 */ p1 = temp; for (j = nIn; j != 0; j--) { - float s1 = 0.0; - float s2 = 0.0; + int32_t s1 = 0; + int32_t s2 = 0; for (i = 0; i < 48; i += 2) { - s1 += p1[i] * qmf_window[i]; - s2 += p1[i+1] * qmf_window[i+1]; + s1 += fixmul31(ftofix32(p1[i]), qmf_window[i]); + s2 += fixmul31(ftofix32(p1[i+1]), qmf_window[i+1]); } - pOut[0] = s2; - pOut[1] = s1; + pOut[0] = fixtof64(s2); + pOut[1] = fixtof64(s1); p1 += 2; pOut += 2; @@ -260,7 +274,7 @@ static av_cold void init_atrac3_transforms(ATRAC3Context *q) { float enc_window[256]; - float s; + int32_t s; int i; /* Generate the mdct window, for details see @@ -275,8 +289,9 @@ } /* Generate the QMF window. */ + //MIKE: converted this to Fixed already for (i=0 ; i<24; i++) { - s = qmf_48tap_half[i] * 2.0; + s = qmf_48tap_half_fix[i] << 1; qmf_window[i] = s; qmf_window[47 - i] = s; } Index: apps/codecs/libatrac/convert.c =================================================================== --- apps/codecs/libatrac/convert.c (revision 0) +++ apps/codecs/libatrac/convert.c (revision 0) @@ -0,0 +1,14 @@ +#include +#include + +int main(){ + static const float iMaxQuant[8] = { + 0.0, 1.0/1.5, 1.0/2.5, 1.0/3.5, 1.0/4.5, 1.0/7.5, 1.0/15.5, 1.0/31.5 + }; + + int i; + for (i=0; i< 8; i++){ + printf("%x ",(int32_t) (iMaxQuant[i]*2147483648)); + } + +} Property changes on: apps/codecs/libatrac/convert.c ___________________________________________________________________ Added: svn:executable + * Index: apps/codecs/libatrac/atrac3data_fixed.h =================================================================== --- apps/codecs/libatrac/atrac3data_fixed.h (revision 0) +++ apps/codecs/libatrac/atrac3data_fixed.h (revision 0) @@ -0,0 +1,20 @@ + + +/* tables for the scalefactor decoding */ +/* scaled by 2^31*/ + +static const int32_t iMaxQuant_fix[8] = { + 0x0, 0x55555580, 0x33333340, 0x24924940, 0x1c71c720, 0x11111120, 0x8421080 + 0x4104108 +}; + + +/* transform data */ +/* floating point values scaled by 2^31 */ +static const int32_t qmf_48tap_half_fix[24] = { + 0xffff855e, 0xfffcfbca, 0xfffe28eb, 0x9de6b, 0x7f028, 0xffe40d08, + 0xffeef140, 0x42a692, 0x19ab1f, 0xff75dec7, 0xffe738f5, 0x100e928, + 0xfffdfedf, 0xfe478b84, 0x50b279, 0x2c83f88, 0xff005ad7, 0xfba2ee80, + 0x2685970, 0x6f42798, 0xfa6b6f10, 0xf3475f80, 0x10e7f7c0, 0x3b6c44c0 +}; + Property changes on: apps/codecs/libatrac/atrac3data_fixed.h ___________________________________________________________________ Added: svn:executable + *