Merge pull request #93 from bbkiwi/master
Fixed bug when APPROXNORM == 1 is used when CCEMBEDDED is not defined…
This commit is contained in:
commit
26bcc970fa
|
@ -168,33 +168,32 @@ void UpdateOutputBins32()
|
||||||
int32_t * ipt = &Sdatspace32BOut[0];
|
int32_t * ipt = &Sdatspace32BOut[0];
|
||||||
for( i = 0; i < FIXBINS; i++ )
|
for( i = 0; i < FIXBINS; i++ )
|
||||||
{
|
{
|
||||||
#if APPROXNORM == 1
|
int32_t isps = *(ipt++); //keep 32 bits
|
||||||
int32_t isps = *(ipt++); //can keep 32 bits as no need to square
|
|
||||||
int32_t ispc = *(ipt++);
|
int32_t ispc = *(ipt++);
|
||||||
#else
|
// take absolute values
|
||||||
int16_t isps = *(ipt++)>>16; //might loose some precision with this
|
isps = isps<0? -isps : isps;
|
||||||
int16_t ispc = *(ipt++)>>16;
|
ispc = ispc<0? -ispc : ispc;
|
||||||
#endif
|
|
||||||
|
|
||||||
int octave = i / FIXBPERO;
|
int octave = i / FIXBPERO;
|
||||||
|
|
||||||
//If we are running DFT32 on regular ColorChord, then we will need to
|
//If we are running DFT32 on regular ColorChord, then we will need to
|
||||||
//also update goutbins[]... But if we're on embedded systems, we only
|
//also update goutbins[]... But if we're on embedded systems, we only
|
||||||
//update embeddedbins32.
|
//update embeddedbins32.
|
||||||
#ifndef CCEMBEDDED
|
#ifndef CCEMBEDDED
|
||||||
uint32_t mux = ( (isps) * (isps)) + ((ispc) * (ispc));
|
// convert 32 bit precision isps and ispc to floating point
|
||||||
goutbins[i] = sqrtf( (float)mux );
|
float mux = ( (float)isps * (float)isps) + ((float)ispc * (float)ispc);
|
||||||
|
goutbins[i] = sqrtf(mux)/65536.0; // scale by 2^16
|
||||||
//reasonable (but arbitrary attenuation)
|
//reasonable (but arbitrary attenuation)
|
||||||
goutbins[i] /= (78<<DFTIIR)*(1<<octave);
|
goutbins[i] /= (78<<DFTIIR)*(1<<octave);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if APPROXNORM == 1
|
#if APPROXNORM == 1
|
||||||
isps = isps<0? -isps : isps;
|
// using full 32 bit precision for isps and ispc
|
||||||
ispc = ispc<0? -ispc : ispc;
|
|
||||||
uint32_t rmux = isps>ispc? isps + (ispc>>1) : ispc + (isps>>1);
|
uint32_t rmux = isps>ispc? isps + (ispc>>1) : ispc + (isps>>1);
|
||||||
rmux = rmux>>16;
|
rmux = rmux>>16; // keep most significant 16 bits
|
||||||
#else
|
#else
|
||||||
uint32_t rmux = ( (isps) * (isps)) + ((ispc) * (ispc));
|
// use the most significant 16 bits of isps and ispc when squaring
|
||||||
|
// since isps and ispc are non-negative right bit shifing is well defined
|
||||||
|
uint32_t rmux = ( (isps>>16) * (isps>>16)) + ((ispc>16) * (ispc>>16));
|
||||||
rmux = SquareRootRounded( rmux );
|
rmux = SquareRootRounded( rmux );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -24,9 +24,7 @@
|
||||||
// Will used simple approximation of norm rather than
|
// Will used simple approximation of norm rather than
|
||||||
// sum squares and approx sqrt
|
// sum squares and approx sqrt
|
||||||
#ifndef APPROXNORM
|
#ifndef APPROXNORM
|
||||||
//XXX CNL: BBKiwi added this feature but it seems to break stuff.
|
#define APPROXNORM 1
|
||||||
//For now, the correct behavior should be to default without approxnorm.
|
|
||||||
//#define APPROXNORM 1
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef OCTAVES
|
#ifndef OCTAVES
|
||||||
|
|
Loading…
Reference in a new issue