colorchord
colorchord copied to clipboard
Improving accuracy in goutbins calc in DFT32.c
In the orginal code isps and ispc loose 16 bits accuracy to prevent overflow at line 197 when they are squared. With the APPROXNORM == 1 option this was not neccessary. However isps and ispc are also used to compute goutbins in the non-CCEMBEDDED case. With floating point calculations the higher accuracy values should be used. I think it would be better to always compute isps and ispc as in lines 172 and 173 irregardless of APPROXNORM.
Calculate 185 by
float mux = ( ((float)isps) * ((float)isps)) + (((float)ispc) * ((float)ispc));
goutbins[i] = sqrtf( (float)mux )/65536.0;
Calculate 197 by
uint32_t rmux = ( (isps>>16) * (isps>>16)) + ((ispc>>16) * (ispc>>16));
See #93