This is the bug/patch tracker for Rockbox. Click here for more information.
Quick links: Bugs · Patches · Rockbox frontpage
FS#11229 - FFT: math rework
Attached to Project:
Rockbox
Opened by Delyan Kratunov (archivator) - Wednesday, 28 April 2010, 23:45 GMT+2
Last edited by Andree Buschmann (Buschel) - Wednesday, 12 May 2010, 04:42 GMT+2
Opened by Delyan Kratunov (archivator) - Wednesday, 28 April 2010, 23:45 GMT+2
Last edited by Andree Buschmann (Buschel) - Wednesday, 12 May 2010, 04:42 GMT+2
|
DetailsSimplifies the math routines, removes all 64-bit math and unused 64-bit math sqrt function.
|
This task depends upon
Closed by Andree Buschmann (Buschel)
Wednesday, 12 May 2010, 04:42 GMT+2
Reason for closing: Accepted
Additional comments about closing: Submitted with r25790
Wednesday, 12 May 2010, 04:42 GMT+2
Reason for closing: Accepted
Additional comments about closing: Submitted with r25790
* just take the logarithm without doing the square root first
* divide the result by 2
This uses the mathematical property log(x^a) = a log (x), where a = 0.5 in this case
Before the if (tmp>0) bit, tmp is at most 29 bits (an assumption made throughout the code). The sqrt call makes sure that it's at most 14 bits, so that the right shift does not overflow.
If I don't do the sqrt, the right shift is virtually guaranteed to overflow, which is what this refactoring is trying to fix.
If I don't do the right shift at all but just leave the log call (it *is* in theory a linear mapping), values < 0xFFFF will be treated as less than 1, resulting in negative and quite large values for tmp - obviously not the desired outcome. Therefore, the right shift is needed and therefore, the sqrt call is needed to guarantee that the shift does not overflow.
If I'm missing something, do let me know.