forked from len0rd/rockbox
Added Coldfire ASM optimised crossfeed function. Have not measured speed improvement, but it is faster. Also moved activation check for crossfeed out of function to avoid a function call if it's not activated.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7891 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
4202df0549
commit
df37db99ce
1 changed files with 141 additions and 64 deletions
87
apps/dsp.c
87
apps/dsp.c
|
|
@ -169,7 +169,7 @@ struct crossfeed_data
|
|||
static struct dsp_config dsp_conf[2] IBSS_ATTR;
|
||||
static struct dither_data dither_data[2] IBSS_ATTR;
|
||||
static struct resample_data resample_data[2][2] IBSS_ATTR;
|
||||
static struct crossfeed_data crossfeed_data IBSS_ATTR;
|
||||
struct crossfeed_data crossfeed_data IBSS_ATTR;
|
||||
|
||||
extern int current_codec;
|
||||
struct dsp_config *dsp;
|
||||
|
|
@ -446,11 +446,88 @@ static long dither_sample(long sample, long bias, long mask,
|
|||
* the src array if gain was applied.
|
||||
* Note that this must be called before the resampler.
|
||||
*/
|
||||
#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
|
||||
static const long crossfeed_coefs[6] ICONST_ATTR = {
|
||||
LOW, LOW_COMP, HIGH_NEG, HIGH_COMP, ATT, ATT_COMP
|
||||
};
|
||||
|
||||
static void apply_crossfeed(long* src[], int count)
|
||||
{
|
||||
asm volatile (
|
||||
"lea.l crossfeed_data, %%a1 \n"
|
||||
"lea.l (16, %%a1), %%a0 \n"
|
||||
"movem.l (%%a1), %%d0-%%d3 \n"
|
||||
"move.l (120, %%a1), %%d4 \n"
|
||||
/* fetch left, right, LOW and LOW_COMP for first iteration */
|
||||
"move.l (%[src0]), %%d5 \n"
|
||||
"move.l (%[src1]), %%d6 \n"
|
||||
"move.l (%[coef])+, %%a1 \n"
|
||||
"move.l (%[coef])+, %%a2 \n"
|
||||
/* Register usage in loop:
|
||||
* a0 = &delay[0][0], a1 & a2 = coefs
|
||||
* d0 = low_left, d1 = low_right,
|
||||
* d2 = high_left, d3 = high_right,
|
||||
* d4 = delay line index,
|
||||
* d5 = src[0][i], d6 = src[1][i].
|
||||
* The rest are described in asm constraint list.
|
||||
*/
|
||||
".cfloop:"
|
||||
/* LOW*low_left + LOW_COMP*left */
|
||||
"mac.l %%a1, %%d0, %%acc0 \n"
|
||||
"mac.l %%a2, %%d5, %%acc0 \n"
|
||||
/* LOW*low_right + LOW_COMP*right */
|
||||
"mac.l %%a1, %%d1, (%[coef])+, %%a1, %%acc1 \n" /* a1 = HIGH_NEG */
|
||||
"mac.l %%a2, %%d6, (%[coef])+, %%a2, %%acc1 \n" /* a2 = HIGH_COMP */
|
||||
"movclr.l %%acc0, %%d0 \n" /* get low_left */
|
||||
"movclr.l %%acc1, %%d1 \n" /* get low_right */
|
||||
/* HIGH_NEG*high_left + HIGH_COMP*left */
|
||||
"mac.l %%a1, %%d2, %%acc0 \n"
|
||||
"mac.l %%a2, %%d5, %%acc0 \n"
|
||||
/* HIGH_NEG*hifh_right + HIGH_COMP+*right */
|
||||
"mac.l %%a1, %%d3, (%[coef])+, %%a1, %%acc1 \n" /* a1 = ATT */
|
||||
"mac.l %%a2, %%d6, (%[coef])+, %%a2, %%acc1 \n" /* a2 = ATT_COMP */
|
||||
"lea.l (-6*4, %[coef]), %[coef] \n" /* coef = &coefs[0] */
|
||||
"move.l (%%a0, %%d4*4), %%a3 \n" /* a3=delay[0][idx] */
|
||||
"move.l (52, %%a0, %%d4*4), %%d5 \n" /* d5=delay[1][idx] */
|
||||
"movclr.l %%acc0, %%d2 \n" /* get high_left */
|
||||
"movclr.l %%acc1, %%d3 \n" /* get high_right */
|
||||
/* ATT*delay_r + ATT_COMP*high_left */
|
||||
"mac.l %%a1, %%d5, (4, %[src0]), %%d5, %%acc0\n" /* d5 = src[0][i+1] */
|
||||
"mac.l %%a2, %%d2, (4, %[src1]), %%d6, %%acc0\n" /* d6 = src[1][i+1] */
|
||||
/* ATT*delay_l + ATT_COMP*high_right */
|
||||
"mac.l %%a1, %%a3, (%[coef])+, %%a1, %%acc1 \n" /* a1 = LOW */
|
||||
"mac.l %%a2, %%d3, (%[coef])+, %%a2, %%acc1 \n" /* a2 = LOW_COMP */
|
||||
|
||||
if (dsp->crossfeed_enabled && src[0] != src[1])
|
||||
{
|
||||
/* save crossfed samples to output */
|
||||
"movclr.l %%acc0, %%a3 \n"
|
||||
"move.l %%a3, (%[src0])+ \n" /* src[0][i++] = out_l */
|
||||
"movclr.l %%acc1, %%a3 \n"
|
||||
"move.l %%a3, (%[src1])+ \n" /* src[1][i++] = out_r */
|
||||
"move.l %%d0, (%%a0, %%d4*4) \n" /* delay[0][index] = low_left */
|
||||
"move.l %%d1, (52, %%a0, %%d4*4)\n" /* delay[1][index] = low_right */
|
||||
"addq.l #1, %%d4 \n" /* index++ */
|
||||
"cmp.l #13, %%d4 \n" /* if (index >= 13) { */
|
||||
"jlt .nowrap \n"
|
||||
"clr.l %%d4 \n" /* index = 0 */
|
||||
".nowrap: \n" /* } */
|
||||
"subq.l #1, %[count] \n"
|
||||
"jne .cfloop \n"
|
||||
/* save data back to struct */
|
||||
"lea.l crossfeed_data, %%a1 \n"
|
||||
"movem.l %%d0-%%d3, (%%a1) \n"
|
||||
"move.l %%d4, (120, %%a1) \n"
|
||||
/* NOTE: We _just_ have enough registers for our use here, clobber just
|
||||
one more and GCC will fail. */
|
||||
:
|
||||
: [count] "d" (count),
|
||||
[src0] "a" (src[0]), [src1] "a" (src[1]), [coef] "a" (crossfeed_coefs)
|
||||
: "d0", "d1", "d2", "d3", "d4", "d5", "d6",
|
||||
"a0", "a1", "a2", "a3"
|
||||
);
|
||||
}
|
||||
#else
|
||||
static void apply_crossfeed(long* src[], int count)
|
||||
{
|
||||
long a; /* accumulator */
|
||||
|
||||
long low_left = crossfeed_data.lowpass[0];
|
||||
|
|
@ -508,9 +585,8 @@ static void apply_crossfeed(long* src[], int count)
|
|||
crossfeed_data.lowpass[1] = low_right;
|
||||
crossfeed_data.highpass[0] = high_left;
|
||||
crossfeed_data.highpass[1] = high_right;
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Apply a constant gain to the samples (e.g., for ReplayGain). May update
|
||||
* the src array if gain was applied.
|
||||
|
|
@ -615,6 +691,7 @@ long dsp_process(char* dst, char* src[], long size)
|
|||
size -= samples;
|
||||
apply_gain(tmp, samples);
|
||||
samples = resample(tmp, samples);
|
||||
if (dsp->crossfeed_enabled && dsp->stereo_mode != STEREO_MONO)
|
||||
apply_crossfeed(tmp, samples);
|
||||
write_samples((short*) dst, tmp, samples);
|
||||
written += samples;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue