mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 21:25:19 -05:00
Optimise/touchup some asm macros in dsp.h, and also remove some now unneeded ones. Add config.h to dsp.c so that these macros actually get used, and also do some minor nitpicks to the resampler while I'm at it.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12322 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
7ba8aec5af
commit
96e5e9eef8
2 changed files with 56 additions and 72 deletions
|
|
@ -19,6 +19,7 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sound.h>
|
#include <sound.h>
|
||||||
|
#include "config.h"
|
||||||
#include "dsp.h"
|
#include "dsp.h"
|
||||||
#include "eq.h"
|
#include "eq.h"
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
|
|
@ -268,7 +269,6 @@ static int downsample(int32_t **dst, int32_t **src, int count,
|
||||||
|
|
||||||
/* Wrap phase accumulator back to start of next frame. */
|
/* Wrap phase accumulator back to start of next frame. */
|
||||||
r->phase = phase - (count << 16);
|
r->phase = phase - (count << 16);
|
||||||
r->delta = delta;
|
|
||||||
r->last_sample[0] = src[0][count - 1];
|
r->last_sample[0] = src[0][count - 1];
|
||||||
r->last_sample[1] = src[1][count - 1];
|
r->last_sample[1] = src[1][count - 1];
|
||||||
return i;
|
return i;
|
||||||
|
|
@ -282,12 +282,12 @@ static long upsample(int32_t **dst, int32_t **src, int count, struct resample_da
|
||||||
int i = 0, j;
|
int i = 0, j;
|
||||||
int pos;
|
int pos;
|
||||||
int num_channels = dsp->stereo_mode == STEREO_MONO ? 1 : 2;
|
int num_channels = dsp->stereo_mode == STEREO_MONO ? 1 : 2;
|
||||||
|
|
||||||
while ((pos = phase >> 16) == 0)
|
while ((phase >> 16) == 0)
|
||||||
{
|
{
|
||||||
for (j = 0; j < num_channels; j++)
|
for (j = 0; j < num_channels; j++)
|
||||||
*d[j]++ = r->last_sample[j] + FRACMUL((phase & 0xffff) << 15,
|
*d[j]++ = r->last_sample[j] + FRACMUL((phase & 0xffff) << 15,
|
||||||
src[j][pos] - r->last_sample[j]);
|
src[j][0] - r->last_sample[j]);
|
||||||
phase += delta;
|
phase += delta;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
@ -303,7 +303,6 @@ static long upsample(int32_t **dst, int32_t **src, int count, struct resample_da
|
||||||
|
|
||||||
/* Wrap phase accumulator back to start of next frame. */
|
/* Wrap phase accumulator back to start of next frame. */
|
||||||
r->phase = phase - (count << 16);
|
r->phase = phase - (count << 16);
|
||||||
r->delta = delta;
|
|
||||||
r->last_sample[0] = src[0][count - 1];
|
r->last_sample[0] = src[0][count - 1];
|
||||||
r->last_sample[1] = src[1][count - 1];
|
r->last_sample[1] = src[1][count - 1];
|
||||||
return i;
|
return i;
|
||||||
|
|
|
||||||
119
apps/dsp.h
119
apps/dsp.h
|
|
@ -49,6 +49,9 @@ enum {
|
||||||
|
|
||||||
/* A bunch of fixed point assembler helper macros */
|
/* A bunch of fixed point assembler helper macros */
|
||||||
#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
|
#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
|
||||||
|
/* These macros use the Coldfire EMAC extension and need the MACSR flags set
|
||||||
|
* to fractional mode with no rounding.
|
||||||
|
*/
|
||||||
|
|
||||||
/* Multiply two S.31 fractional integers and return the sign bit and the
|
/* Multiply two S.31 fractional integers and return the sign bit and the
|
||||||
* 31 most significant bits of the result.
|
* 31 most significant bits of the result.
|
||||||
|
|
@ -56,9 +59,9 @@ enum {
|
||||||
#define FRACMUL(x, y) \
|
#define FRACMUL(x, y) \
|
||||||
({ \
|
({ \
|
||||||
long t; \
|
long t; \
|
||||||
asm volatile ("mac.l %[a], %[b], %%acc0\n\t" \
|
asm ("mac.l %[a], %[b], %%acc0\n\t" \
|
||||||
"movclr.l %%acc0, %[t]\n\t" \
|
"movclr.l %%acc0, %[t]\n\t" \
|
||||||
: [t] "=r" (t) : [a] "r" (x), [b] "r" (y)); \
|
: [t] "=r" (t) : [a] "r" (x), [b] "r" (y)); \
|
||||||
t; \
|
t; \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -69,70 +72,50 @@ enum {
|
||||||
#define FRACMUL_SHL(x, y, z) \
|
#define FRACMUL_SHL(x, y, z) \
|
||||||
({ \
|
({ \
|
||||||
long t, t2; \
|
long t, t2; \
|
||||||
asm volatile ("mac.l %[a], %[b], %%acc0\n\t" \
|
asm ("mac.l %[a], %[b], %%acc0\n\t" \
|
||||||
"moveq.l %[d], %[t]\n\t" \
|
"moveq.l %[d], %[t]\n\t" \
|
||||||
"move.l %%accext01, %[t2]\n\t" \
|
"move.l %%accext01, %[t2]\n\t" \
|
||||||
"and.l %[mask], %[t2]\n\t" \
|
"and.l %[mask], %[t2]\n\t" \
|
||||||
"lsr.l %[t], %[t2]\n\t" \
|
"lsr.l %[t], %[t2]\n\t" \
|
||||||
"movclr.l %%acc0, %[t]\n\t" \
|
"movclr.l %%acc0, %[t]\n\t" \
|
||||||
"asl.l %[c], %[t]\n\t" \
|
"asl.l %[c], %[t]\n\t" \
|
||||||
"or.l %[t2], %[t]\n\t" \
|
"or.l %[t2], %[t]\n\t" \
|
||||||
: [t] "=d" (t), [t2] "=d" (t2) \
|
: [t] "=&d" (t), [t2] "=&d" (t2) \
|
||||||
: [a] "r" (x), [b] "r" (y), [mask] "d" (0xff), \
|
: [a] "r" (x), [b] "r" (y), [mask] "d" (0xff), \
|
||||||
[c] "i" ((z)), [d] "i" (8 - (z))); \
|
[c] "i" ((z)), [d] "i" (8 - (z))); \
|
||||||
t; \
|
t; \
|
||||||
})
|
})
|
||||||
|
|
||||||
/* Multiply one S.31-bit and one S8.23 fractional integer and return the
|
|
||||||
* sign bit and the 31 most significant bits of the result.
|
|
||||||
*/
|
|
||||||
#define FRACMUL_8(x, y) \
|
|
||||||
({ \
|
|
||||||
long t; \
|
|
||||||
long u; \
|
|
||||||
asm volatile ("mac.l %[a], %[b], %%acc0\n\t" \
|
|
||||||
"move.l %%accext01, %[u]\n\t" \
|
|
||||||
"movclr.l %%acc0, %[t]\n\t" \
|
|
||||||
: [t] "=r" (t), [u] "=r" (u) : [a] "r" (x), [b] "r" (y)); \
|
|
||||||
(t << 8) | (u & 0xff); \
|
|
||||||
})
|
|
||||||
|
|
||||||
/* Multiply one S.31-bit and one S8.23 fractional integer and return the
|
/* Multiply one S.31-bit and one S8.23 fractional integer and return the
|
||||||
* sign bit and the 31 most significant bits of the result. Load next value
|
* sign bit and the 31 most significant bits of the result. Load next value
|
||||||
* to multiply with into x from s (and increase s); x must contain the
|
* to multiply with into x from s (and increase s); x must contain the
|
||||||
* initial value.
|
* initial value.
|
||||||
*/
|
*/
|
||||||
#define FRACMUL_8_LOOP_PART(x, s, d, y) \
|
|
||||||
{ \
|
|
||||||
long u; \
|
|
||||||
asm volatile ("mac.l %[a], %[b], (%[c])+, %[a], %%acc0\n\t" \
|
|
||||||
"move.l %%accext01, %[u]\n\t" \
|
|
||||||
"movclr.l %%acc0, %[t]" \
|
|
||||||
: [a] "+r" (x), [c] "+a" (s), [t] "=r" (d), [u] "=r" (u) \
|
|
||||||
: [b] "r" (y)); \
|
|
||||||
d = (d << 8) | (u & 0xff); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define FRACMUL_8_LOOP(x, y, s, d) \
|
#define FRACMUL_8_LOOP(x, y, s, d) \
|
||||||
{ \
|
{ \
|
||||||
long t; \
|
long t, t2; \
|
||||||
FRACMUL_8_LOOP_PART(x, s, t, y); \
|
asm volatile ("mac.l %[a], %[b], (%[src])+, %[a], %%acc0\n\t" \
|
||||||
asm volatile ("move.l %[t],(%[d])+" \
|
"move.l %%accext01, %[t2]\n\t" \
|
||||||
: [d] "+a" (d)\
|
"movclr.l %%acc0, %[t]\n\t" \
|
||||||
: [t] "r" (t)); \
|
"asl.l #8, %[t]\n\t" \
|
||||||
|
"move.b %[t2], %[t]\n\t" \
|
||||||
|
"move.l %[t], (%[dst])+\n\t" \
|
||||||
|
: [a] "+r" (x), [src] "+a" (s), [dst] "+a" (d), \
|
||||||
|
[t] "=r" (t), [t2] "=r" (t2) \
|
||||||
|
: [b] "r" (y)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ACC(acc, x, y) \
|
#define ACC(acc, x, y) \
|
||||||
(void)acc; \
|
(void)acc; \
|
||||||
asm volatile ("mac.l %[a], %[b], %%acc0" \
|
asm ("mac.l %[a], %[b], %%acc0" \
|
||||||
: : [a] "i,r" (x), [b] "i,r" (y));
|
: : [a] "i,r" (x), [b] "i,r" (y));
|
||||||
|
|
||||||
#define GET_ACC(acc) \
|
#define GET_ACC(acc) \
|
||||||
({ \
|
({ \
|
||||||
long t; \
|
long t; \
|
||||||
(void)acc; \
|
(void)acc; \
|
||||||
asm volatile ("movclr.l %%acc0, %[t]" \
|
asm ("movclr.l %%acc0, %[t]" \
|
||||||
: [t] "=r" (t)); \
|
: [t] "=r" (t)); \
|
||||||
t; \
|
t; \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -145,11 +128,12 @@ enum {
|
||||||
*/
|
*/
|
||||||
#define FRACMUL(x, y) \
|
#define FRACMUL(x, y) \
|
||||||
({ \
|
({ \
|
||||||
long t; \
|
long t, t2; \
|
||||||
asm volatile ("smull r0, r1, %[a], %[b]\n\t" \
|
asm ("smull %[t], %[t2], %[a], %[b]\n\t" \
|
||||||
"mov %[t], r1, asl #1\n\t" \
|
"mov %[t2], %[t2], asl #1\n\t" \
|
||||||
"orr %[t], %[t], r0, lsr #31\n\t" \
|
"orr %[t], %[t2], %[t], lsr #31\n\t" \
|
||||||
: [t] "=r" (t) : [a] "r" (x), [b] "r" (y) : "r0", "r1"); \
|
: [t] "=&r" (t), [t2] "=&r" (t2) \
|
||||||
|
: [a] "r" (x), [b] "r" (y)); \
|
||||||
t; \
|
t; \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -158,14 +142,13 @@ enum {
|
||||||
*/
|
*/
|
||||||
#define FRACMUL_SHL(x, y, z) \
|
#define FRACMUL_SHL(x, y, z) \
|
||||||
({ \
|
({ \
|
||||||
long t; \
|
long t, t2; \
|
||||||
asm volatile ("smull r0, r1, %[a], %[b]\n\t" \
|
asm ("smull %[t], %[t2], %[a], %[b]\n\t" \
|
||||||
"mov %[t], r1, asl %[c]\n\t" \
|
"mov %[t2], %[t2], asl %[c]\n\t" \
|
||||||
"orr %[t], %[t], r0, lsr %[d]\n\t" \
|
"orr %[t], %[t2], %[t], lsr %[d]\n\t" \
|
||||||
: [t] "=r" (t) \
|
: [t] "=&r" (t), [t2] "=&r" (t2) \
|
||||||
: [a] "r" (x), [b] "r" (y), \
|
: [a] "r" (x), [b] "r" (y), \
|
||||||
[c] "M" ((z) + 1), [d] "M" (31 - (z)) \
|
[c] "M" ((z) + 1), [d] "M" (31 - (z))); \
|
||||||
: "r0", "r1"); \
|
|
||||||
t; \
|
t; \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -180,10 +163,12 @@ enum {
|
||||||
*/
|
*/
|
||||||
#define FRACMUL_8_LOOP(x, y, s, d) \
|
#define FRACMUL_8_LOOP(x, y, s, d) \
|
||||||
({ \
|
({ \
|
||||||
asm volatile ("smull r0, r1, %[a], %[b]\n\t" \
|
long t, t2; \
|
||||||
"mov %[t], r1, asl #9\n\t" \
|
asm volatile ("smull %[t], %[t2], %[a], %[b]\n\t" \
|
||||||
"orr %[t], %[t], r0, lsr #23\n\t" \
|
"mov %[t2], %[t2], asl #9\n\t" \
|
||||||
: [t] "=r" (*(d)++) : [a] "r" (x), [b] "r" (y) : "r0", "r1"); \
|
"orr %[d], %[t2], %[t], lsr #23\n\t" \
|
||||||
|
: [d] "=&r" (*(d)++), [t] "=&r" (t), [t2] "=&r" (t2) \
|
||||||
|
: [a] "r" (x), [b] "r" (y)); \
|
||||||
x = *(s)++; \
|
x = *(s)++; \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -193,8 +178,8 @@ enum {
|
||||||
#define ACC(acc, x, y) acc += FRACMUL(x, y)
|
#define ACC(acc, x, y) acc += FRACMUL(x, y)
|
||||||
#define GET_ACC(acc) acc
|
#define GET_ACC(acc) acc
|
||||||
#define FRACMUL(x, y) (long) (((((long long) (x)) * ((long long) (y))) >> 31))
|
#define FRACMUL(x, y) (long) (((((long long) (x)) * ((long long) (y))) >> 31))
|
||||||
#define FRACMUL_SHL(x, y, z) ((long)(((((long long) (x)) * ((long long) (y))) >> (31 - (z)))))
|
#define FRACMUL_SHL(x, y, z) \
|
||||||
#define FRACMUL_8(x, y) (long) (((((long long) (x)) * ((long long) (y))) >> 23))
|
((long)(((((long long) (x)) * ((long long) (y))) >> (31 - (z)))))
|
||||||
#define FRACMUL_8_LOOP(x, y, s, d) \
|
#define FRACMUL_8_LOOP(x, y, s, d) \
|
||||||
({ \
|
({ \
|
||||||
long t = x; \
|
long t = x; \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue