mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-11 22:22:33 -05:00
Small correction to avoid overflow within calculate_V()-function. Re-enable full precision for ARM as speed-optimized version is not that much faster anymore.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17750 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
5acfae2a3c
commit
f0087f06aa
2 changed files with 5 additions and 3 deletions
|
|
@ -37,7 +37,7 @@
|
||||||
#if defined(CPU_COLDFIRE)
|
#if defined(CPU_COLDFIRE)
|
||||||
// do nothing
|
// do nothing
|
||||||
#elif defined(CPU_ARM)
|
#elif defined(CPU_ARM)
|
||||||
#define OPTIMIZE_FOR_SPEED
|
//#define OPTIMIZE_FOR_SPEED
|
||||||
#else
|
#else
|
||||||
#define OPTIMIZE_FOR_SPEED
|
#define OPTIMIZE_FOR_SPEED
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -115,8 +115,8 @@ static const MPC_SAMPLE_FORMAT Di_opt [512] ICONST_ATTR = {
|
||||||
|
|
||||||
#undef D
|
#undef D
|
||||||
|
|
||||||
// needed to prevent from internal overflow in calculate_V
|
// needed to prevent from internal overflow in calculate_V (see below)
|
||||||
#define OVERFLOW_FIX 1
|
#define OVERFLOW_FIX 2
|
||||||
|
|
||||||
// V-coefficients were expanded (<<) by V_COEFFICIENT_EXPAND
|
// V-coefficients were expanded (<<) by V_COEFFICIENT_EXPAND
|
||||||
#define V_COEFFICIENT_EXPAND 27
|
#define V_COEFFICIENT_EXPAND 27
|
||||||
|
|
@ -128,6 +128,7 @@ static const MPC_SAMPLE_FORMAT Di_opt [512] ICONST_ATTR = {
|
||||||
#define MPC_MULTIPLY_V(sample, vcoef) ( MPC_SHR_RND(sample, 12) * vcoef )
|
#define MPC_MULTIPLY_V(sample, vcoef) ( MPC_SHR_RND(sample, 12) * vcoef )
|
||||||
|
|
||||||
// pre- and postscale are used to avoid internal overflow in synthesis calculation
|
// pre- and postscale are used to avoid internal overflow in synthesis calculation
|
||||||
|
// samples are s15.0, v-coefs are 4.12 -> internal format is s19.12
|
||||||
#define MPC_MULTIPLY_V_PRESCALE(sample, vcoef) ( MPC_SHR_RND(sample, (12+OVERFLOW_FIX)) * vcoef )
|
#define MPC_MULTIPLY_V_PRESCALE(sample, vcoef) ( MPC_SHR_RND(sample, (12+OVERFLOW_FIX)) * vcoef )
|
||||||
#define MPC_MULTIPLY_V_POSTSCALE(sample, vcoef) ( MPC_SHR_RND(sample, (12-OVERFLOW_FIX)) * vcoef )
|
#define MPC_MULTIPLY_V_POSTSCALE(sample, vcoef) ( MPC_SHR_RND(sample, (12-OVERFLOW_FIX)) * vcoef )
|
||||||
#define MPC_V_POSTSCALE(sample) (sample<<OVERFLOW_FIX)
|
#define MPC_V_POSTSCALE(sample) (sample<<OVERFLOW_FIX)
|
||||||
|
|
@ -141,6 +142,7 @@ static const MPC_SAMPLE_FORMAT Di_opt [512] ICONST_ATTR = {
|
||||||
#define MPC_MULTIPLY_V(sample, vcoef) ( (MPC_MULTIPLY_FRACT(sample, vcoef)) << (32-V_COEFFICIENT_EXPAND) )
|
#define MPC_MULTIPLY_V(sample, vcoef) ( (MPC_MULTIPLY_FRACT(sample, vcoef)) << (32-V_COEFFICIENT_EXPAND) )
|
||||||
|
|
||||||
// pre- and postscale are used to avoid internal overflow in synthesis calculation
|
// pre- and postscale are used to avoid internal overflow in synthesis calculation
|
||||||
|
// samples are s15.14, v-coefs are 4.27 -> internal format is s19.12
|
||||||
#define MPC_MULTIPLY_V_PRESCALE(sample, vcoef) ( (MPC_MULTIPLY_FRACT(sample, vcoef)) << (32-V_COEFFICIENT_EXPAND-OVERFLOW_FIX) )
|
#define MPC_MULTIPLY_V_PRESCALE(sample, vcoef) ( (MPC_MULTIPLY_FRACT(sample, vcoef)) << (32-V_COEFFICIENT_EXPAND-OVERFLOW_FIX) )
|
||||||
#define MPC_MULTIPLY_V_POSTSCALE(sample, vcoef) ( (MPC_MULTIPLY_FRACT(sample, vcoef)) << (32-V_COEFFICIENT_EXPAND+OVERFLOW_FIX) )
|
#define MPC_MULTIPLY_V_POSTSCALE(sample, vcoef) ( (MPC_MULTIPLY_FRACT(sample, vcoef)) << (32-V_COEFFICIENT_EXPAND+OVERFLOW_FIX) )
|
||||||
#define MPC_V_POSTSCALE(sample) (sample<<OVERFLOW_FIX)
|
#define MPC_V_POSTSCALE(sample) (sample<<OVERFLOW_FIX)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue