mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
SPC Codec: Refactor for CPU and clean up some things.
CPU optimization gets its own files in which to fill-in optimizable routines. Some pointless #if 0's for profiling need removal. Those macros are empty if not profiling. Force some functions that are undesirable to be force-inlined by the compiler to be not inlined. Change-Id: Ia7b7e45380d7efb20c9b1a4d52e05db3ef6bbaab
This commit is contained in:
parent
a17d6de5bc
commit
87021f7c0a
12 changed files with 1693 additions and 1298 deletions
253
lib/rbcodec/codecs/libspc/cpu/spc_dsp_armv4.c
Normal file
253
lib/rbcodec/codecs/libspc/cpu/spc_dsp_armv4.c
Normal file
|
@ -0,0 +1,253 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2007-2010 Michael Sevakis (jhMikeS)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#if !SPC_NOINTERP
|
||||
|
||||
#define SPC_GAUSSIAN_FAST_INTERP
|
||||
static inline int gaussian_fast_interp( int16_t const* samples,
|
||||
int32_t position,
|
||||
int16_t const* fwd,
|
||||
int16_t const* rev )
|
||||
{
|
||||
int output;
|
||||
int t0, t1, t2, t3;
|
||||
|
||||
asm volatile (
|
||||
"ldrsh %[t0], [%[samp]] \n"
|
||||
"ldrsh %[t2], [%[fwd]] \n"
|
||||
"ldrsh %[t1], [%[samp], #2] \n"
|
||||
"ldrsh %[t3], [%[fwd], #2] \n"
|
||||
"mul %[out], %[t0], %[t2] \n" /* out= fwd[0]*samp[0] */
|
||||
"ldrsh %[t0], [%[samp], #4] \n"
|
||||
"ldrsh %[t2], [%[rev], #2] \n"
|
||||
"mla %[out], %[t1], %[t3], %[out] \n" /* out+=fwd[1]*samp[1] */
|
||||
"ldrsh %[t1], [%[samp], #6] \n"
|
||||
"ldrsh %[t3], [%[rev]] \n"
|
||||
"mla %[out], %[t0], %[t2], %[out] \n" /* out+=rev[1]*samp[2] */
|
||||
"mla %[out], %[t1], %[t3], %[out] \n" /* out+=rev[0]*samp[3] */
|
||||
: [out]"=&r"(output),
|
||||
[t0]"=&r"(t0), [t1]"=&r"(t1), [t2]"=&r"(t2), [t3]"=&r"(t3)
|
||||
: [fwd]"r"(fwd), [rev]"r"(rev),
|
||||
[samp]"r"(samples + (position >> 12)));
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
#define SPC_GAUSSIAN_FAST_AMP
|
||||
static inline int gaussian_fast_amp( struct voice_t* voice, int output,
|
||||
int* amp_0, int* amp_1 )
|
||||
{
|
||||
int t0;
|
||||
|
||||
asm volatile (
|
||||
"mov %[t0], %[out], asr #11 \n"
|
||||
"mul %[out], %[t0], %[envx] \n"
|
||||
: [out]"+r"(output), [t0]"=&r"(t0)
|
||||
: [envx]"r"((int) voice->envx));
|
||||
|
||||
asm volatile (
|
||||
"mov %[out], %[out], asr #11 \n"
|
||||
"mul %[a0], %[out], %[v0] \n"
|
||||
"mul %[a1], %[out], %[v1] \n"
|
||||
: [out]"+r"(output),
|
||||
[a0]"=&r"(*amp_0), [a1]"=r"(*amp_1)
|
||||
: [v0]"r"((int) voice->volume [0]),
|
||||
[v1]"r"((int) voice->volume [1]));
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
#define SPC_GAUSSIAN_SLOW_INTERP
|
||||
static inline int gaussian_slow_interp( int16_t const* samples,
|
||||
int32_t position,
|
||||
int16_t const* fwd,
|
||||
int16_t const* rev )
|
||||
{
|
||||
int output;
|
||||
int t0, t1, t2, t3;
|
||||
|
||||
asm volatile (
|
||||
"ldrsh %[t0], [%[samp]] \n"
|
||||
"ldrsh %[t2], [%[fwd]] \n"
|
||||
"ldrsh %[t1], [%[samp], #2] \n"
|
||||
"ldrsh %[t3], [%[fwd], #2] \n"
|
||||
"mul %[out], %[t2], %[t0] \n" /* fwd[0]*samp[0] */
|
||||
"ldrsh %[t2], [%[rev], #2] \n"
|
||||
"mul %[t0], %[t3], %[t1] \n" /* fwd[1]*samp[1] */
|
||||
"ldrsh %[t1], [%[samp], #4] \n"
|
||||
"mov %[out], %[out], asr #12 \n"
|
||||
"ldrsh %[t3], [%[rev]] \n"
|
||||
"mul %[t2], %[t1], %[t2] \n" /* rev[1]*samp[2] */
|
||||
"ldrsh %[t1], [%[samp], #6] \n"
|
||||
"add %[t0], %[out], %[t0], asr #12 \n"
|
||||
"mul %[t3], %[t1], %[t3] \n" /* rev[0]*samp[3] */
|
||||
"add %[t2], %[t0], %[t2], asr #12 \n"
|
||||
"mov %[t2], %[t2], lsl #17 \n"
|
||||
"mov %[t3], %[t3], asr #12 \n"
|
||||
"mov %[t3], %[t3], asl #1 \n"
|
||||
"add %[out], %[t3], %[t2], asr #16 \n"
|
||||
: [out]"=&r"(output),
|
||||
[t0]"=&r"(t0), [t1]"=&r"(t1), [t2]"=&r"(t2), [t3]"=&r"(t3)
|
||||
: [fwd]"r"(fwd), [rev]"r"(rev),
|
||||
[samp]"r"(samples + (position >> 12)));
|
||||
|
||||
return CLAMP16( output );
|
||||
}
|
||||
|
||||
#define SPC_GAUSSIAN_SLOW_AMP
|
||||
static inline int gaussian_slow_amp( struct voice_t* voice, int output,
|
||||
int* amp_0, int* amp_1 )
|
||||
{
|
||||
int t0;
|
||||
|
||||
asm volatile (
|
||||
"mul %[t0], %[out], %[envx]"
|
||||
: [t0]"=r"(t0)
|
||||
: [out]"r"(output), [envx]"r"((int) voice->envx));
|
||||
asm volatile (
|
||||
"mov %[t0], %[t0], asr #11 \n"
|
||||
"bic %[t0], %[t0], #0x1 \n"
|
||||
"mul %[a0], %[t0], %[v0] \n"
|
||||
"mul %[a1], %[t0], %[v1] \n"
|
||||
: [t0]"+r"(t0),
|
||||
[a0]"=&r"(*amp_0), [a1]"=r"(*amp_1)
|
||||
: [v0]"r"((int) voice->volume [0]),
|
||||
[v1]"r"((int) voice->volume [1]));
|
||||
|
||||
return t0;
|
||||
}
|
||||
|
||||
#else /* SPC_NOINTERP */
|
||||
|
||||
#define SPC_LINEAR_INTERP
|
||||
static inline int linear_interp( int16_t const* samples, int32_t position )
|
||||
{
|
||||
int output = (int) samples;
|
||||
int y1;
|
||||
|
||||
asm volatile(
|
||||
"mov %[y1], %[f], lsr #12 \n"
|
||||
"eor %[f], %[f], %[y1], lsl #12 \n"
|
||||
"add %[y1], %[y0], %[y1], lsl #1 \n"
|
||||
"ldrsh %[y0], [%[y1], #2] \n"
|
||||
"ldrsh %[y1], [%[y1], #4] \n"
|
||||
"sub %[y1], %[y1], %[y0] \n"
|
||||
"mul %[f], %[y1], %[f] \n"
|
||||
"add %[y0], %[y0], %[f], asr #12 \n"
|
||||
: [f]"+r"(position), [y0]"+r"(output), [y1]"=&r"(y1));
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
#define SPC_LINEAR_AMP
|
||||
static inline int linear_amp( struct voice_t* voice, int output,
|
||||
int* amp_0, int* amp_1 )
|
||||
{
|
||||
int t0;
|
||||
|
||||
asm volatile(
|
||||
"mul %[t0], %[out], %[envx]"
|
||||
: [t0]"=&r"(t0)
|
||||
: [out]"r"(output), [envx]"r"(voice->envx));
|
||||
asm volatile(
|
||||
"mov %[t0], %[t0], asr #11 \n"
|
||||
"mul %[a1], %[t0], %[v1] \n"
|
||||
"mul %[a0], %[t0], %[v0] \n"
|
||||
: [t0]"+r"(t0),
|
||||
[a0]"=&r"(*amp_0), [a1]"=&r"(*amp_1)
|
||||
: [v0]"r"((int) voice->volume [0]),
|
||||
[v1]"r"((int) voice->volume [1]));
|
||||
|
||||
return t0;
|
||||
}
|
||||
|
||||
#endif /* !SPC_NOINTERP */
|
||||
|
||||
|
||||
#if !SPC_NOECHO
|
||||
|
||||
#define SPC_DSP_ECHO_APPLY
|
||||
|
||||
/* Echo filter history */
|
||||
static int32_t fir_buf[FIR_BUF_CNT] IBSS_ATTR_SPC
|
||||
__attribute__(( aligned(FIR_BUF_ALIGN*1) ));
|
||||
|
||||
static inline void echo_init( struct Spc_Dsp* this )
|
||||
{
|
||||
this->fir.ptr = fir_buf;
|
||||
ci->memset( fir_buf, 0, sizeof fir_buf );
|
||||
}
|
||||
|
||||
static inline void echo_apply( struct Spc_Dsp* this, uint8_t *echo_ptr,
|
||||
int* out_0, int* out_1 )
|
||||
{
|
||||
int t0 = GET_LE16SA( echo_ptr );
|
||||
int t1 = GET_LE16SA( echo_ptr + 2 );
|
||||
|
||||
/* Keep last 8 samples */
|
||||
int32_t *fir_ptr;
|
||||
asm volatile (
|
||||
"add %[p], %[t_p], #8 \n"
|
||||
"bic %[t_p], %[p], %[mask] \n"
|
||||
"str %[t0], [%[p], #-8] \n"
|
||||
"str %[t1], [%[p], #-4] \n"
|
||||
/* duplicate at +8 eliminates wrap checking below */
|
||||
"str %[t0], [%[p], #56] \n"
|
||||
"str %[t1], [%[p], #60] \n"
|
||||
: [p]"=&r"(fir_ptr), [t_p]"+r"(this->fir.ptr)
|
||||
: [t0]"r"(t0), [t1]"r"(t1), [mask]"i"(~FIR_BUF_MASK));
|
||||
|
||||
int32_t *fir_coeff = this->fir.coeff;
|
||||
|
||||
asm volatile (
|
||||
"ldmia %[c]!, { r0-r1 } \n"
|
||||
"ldmia %[p]!, { r4-r5 } \n"
|
||||
"mul %[acc0], r0, %[acc0] \n"
|
||||
"mul %[acc1], r0, %[acc1] \n"
|
||||
"mla %[acc0], r4, r1, %[acc0] \n"
|
||||
"mla %[acc1], r5, r1, %[acc1] \n"
|
||||
"ldmia %[c]!, { r0-r1 } \n"
|
||||
"ldmia %[p]!, { r2-r5 } \n"
|
||||
"mla %[acc0], r2, r0, %[acc0] \n"
|
||||
"mla %[acc1], r3, r0, %[acc1] \n"
|
||||
"mla %[acc0], r4, r1, %[acc0] \n"
|
||||
"mla %[acc1], r5, r1, %[acc1] \n"
|
||||
"ldmia %[c]!, { r0-r1 } \n"
|
||||
"ldmia %[p]!, { r2-r5 } \n"
|
||||
"mla %[acc0], r2, r0, %[acc0] \n"
|
||||
"mla %[acc1], r3, r0, %[acc1] \n"
|
||||
"mla %[acc0], r4, r1, %[acc0] \n"
|
||||
"mla %[acc1], r5, r1, %[acc1] \n"
|
||||
"ldmia %[c]!, { r0-r1 } \n"
|
||||
"ldmia %[p]!, { r2-r5 } \n"
|
||||
"mla %[acc0], r2, r0, %[acc0] \n"
|
||||
"mla %[acc1], r3, r0, %[acc1] \n"
|
||||
"mla %[acc0], r4, r1, %[acc0] \n"
|
||||
"mla %[acc1], r5, r1, %[acc1] \n"
|
||||
: [acc0]"+r"(t0), [acc1]"+r"(t1),
|
||||
[p]"+r"(fir_ptr), [c]"+r"(fir_coeff)
|
||||
:
|
||||
: "r0", "r1", "r2", "r3", "r4", "r5");
|
||||
|
||||
*out_0 = t0;
|
||||
*out_1 = t1;
|
||||
}
|
||||
|
||||
#endif /* SPC_NOECHO */
|
45
lib/rbcodec/codecs/libspc/cpu/spc_dsp_armv4.h
Normal file
45
lib/rbcodec/codecs/libspc/cpu/spc_dsp_armv4.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2007-2010 Michael Sevakis (jhMikeS)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#if !SPC_NOECHO
|
||||
|
||||
#define SPC_DSP_ECHO_APPLY
|
||||
|
||||
enum
|
||||
{
|
||||
FIR_BUF_CNT = FIR_BUF_HALF * 2 * 2,
|
||||
FIR_BUF_SIZE = FIR_BUF_CNT * sizeof ( int32_t ),
|
||||
FIR_BUF_ALIGN = FIR_BUF_SIZE,
|
||||
FIR_BUF_MASK = ~((FIR_BUF_ALIGN / 2) | (sizeof ( int32_t ) * 2 - 1))
|
||||
};
|
||||
|
||||
/* Echo filter structure embedded in struct Spc_Dsp */
|
||||
struct echo_filter
|
||||
{
|
||||
/* fir_buf [i + 8] == fir_buf [i], to avoid wrap checking in FIR code */
|
||||
int32_t* ptr;
|
||||
/* FIR history is interleaved with guard to eliminate wrap checking
|
||||
* when convolving.
|
||||
* |LL|RR|LL|RR|LL|RR|LL|RR|LL|RR|LL|RR|LL|RR|LL|RR|...
|
||||
* |--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--| */
|
||||
/* copy of echo FIR constants as int32_t, for faster access */
|
||||
int32_t coeff [VOICE_COUNT];
|
||||
};
|
||||
#endif /* SPC_NOECHO */
|
244
lib/rbcodec/codecs/libspc/cpu/spc_dsp_armv6.c
Normal file
244
lib/rbcodec/codecs/libspc/cpu/spc_dsp_armv6.c
Normal file
|
@ -0,0 +1,244 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2010 Michael Sevakis (jhMikeS)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#if !SPC_NOINTERP
|
||||
|
||||
#define SPC_GAUSSIAN_FAST_INTERP
|
||||
static inline int gaussian_fast_interp( int16_t const* samples,
|
||||
int32_t position,
|
||||
int16_t const* fwd,
|
||||
int16_t const* rev )
|
||||
{
|
||||
int output;
|
||||
int t0, t1, t2, t3;
|
||||
|
||||
asm volatile (
|
||||
/* NOTE: often-unaligned accesses */
|
||||
"ldr %[t0], [%[samp]] \n" /* t0=i0i1 */
|
||||
"ldr %[t2], [%[fwd]] \n" /* t2=f0f1 */
|
||||
"ldr %[t1], [%[samp], #4] \n" /* t1=i2i3 */
|
||||
"ldr %[t3], [%[rev]] \n" /* t3=r0r1 */
|
||||
"smuad %[out], %[t0], %[t2] \n" /* out=f0*i0+f1*i1 */
|
||||
"smladx %[out], %[t1], %[t3], %[out] \n" /* out+=r1*i2+r0*i3 */
|
||||
: [out]"=r"(output),
|
||||
[t0]"=&r"(t0), [t1]"=&r"(t1), [t2]"=&r"(t2), [t3]"=r"(t3)
|
||||
: [fwd]"r"(fwd), [rev]"r"(rev),
|
||||
[samp]"r"(samples + (position >> 12)));
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
#define SPC_GAUSSIAN_FAST_AMP
|
||||
static inline int gaussian_fast_amp( struct voice_t* voice, int output,
|
||||
int* amp_0, int* amp_1 )
|
||||
{
|
||||
int t0;
|
||||
|
||||
asm volatile (
|
||||
"mov %[t0], %[out], asr #(11-5) \n" /* To do >> 16 below */
|
||||
"mul %[out], %[t0], %[envx] \n"
|
||||
: [out]"+r"(output), [t0]"=&r"(t0)
|
||||
: [envx]"r"((int) voice->envx));
|
||||
|
||||
asm volatile (
|
||||
"smulwb %[a0], %[out], %[v0] \n" /* amp * vol >> 16 */
|
||||
"smulwb %[a1], %[out], %[v1] \n"
|
||||
: [a0]"=&r"(*amp_0), [a1]"=r"(*amp_1)
|
||||
: [out]"r"(output),
|
||||
[v0]"r"(voice->volume [0]),
|
||||
[v1]"r"(voice->volume [1]));
|
||||
|
||||
return output >> 5; /* 'output' still 5 bits too big */
|
||||
}
|
||||
|
||||
#define SPC_GAUSSIAN_SLOW_INTERP
|
||||
static inline int gaussian_slow_interp( int16_t const* samples,
|
||||
int32_t position,
|
||||
int16_t const* fwd,
|
||||
int16_t const* rev )
|
||||
{
|
||||
int output;
|
||||
int t0, t1, t2, t3;
|
||||
|
||||
asm volatile (
|
||||
/* NOTE: often-unaligned accesses */
|
||||
"ldr %[t0], [%[samp]] \n" /* t0=i0i1 */
|
||||
"ldr %[t2], [%[fwd]] \n" /* t2=f0f1 */
|
||||
"ldr %[t1], [%[samp], #4] \n" /* t1=i2i3 */
|
||||
"ldr %[t3], [%[rev]] \n" /* t3=f2f3 */
|
||||
"smulbb %[out], %[t0], %[t2] \n" /* out=f0*i0 */
|
||||
"smultt %[t0], %[t0], %[t2] \n" /* t0=f1*i1 */
|
||||
"smulbt %[t2], %[t1], %[t3] \n" /* t2=r1*i2 */
|
||||
"smultb %[t3], %[t1], %[t3] \n" /* t3=r0*i3 */
|
||||
: [out]"=r"(output),
|
||||
[t0]"=&r"(t0), [t1]"=&r"(t1), [t2]"=&r"(t2), [t3]"=r"(t3)
|
||||
: [fwd]"r"(fwd), [rev]"r"(rev),
|
||||
[samp]"r"(samples + (position >> 12)));
|
||||
|
||||
asm volatile (
|
||||
"mov %[out], %[out], asr #12 \n"
|
||||
"add %[t0], %[out], %[t0], asr #12 \n"
|
||||
"add %[t2], %[t0], %[t2], asr #12 \n"
|
||||
"pkhbt %[t0], %[t2], %[t3], asl #4 \n" /* t3[31:16], t2[15:0] */
|
||||
"sadd16 %[t0], %[t0], %[t0] \n" /* t3[31:16]*2, t2[15:0]*2 */
|
||||
"qsubaddx %[out], %[t0], %[t0] \n" /* out[15:0]=
|
||||
* sat16(t3[31:16]+t2[15:0]) */
|
||||
: [out]"+r"(output),
|
||||
[t0]"+r"(t0), [t2]"+r"(t2), [t3]"+r"(t3));
|
||||
|
||||
/* output will be sign-extended in next step */
|
||||
return output;
|
||||
}
|
||||
|
||||
#define SPC_GAUSSIAN_SLOW_AMP
|
||||
static inline int gaussian_slow_amp( struct voice_t* voice, int output,
|
||||
int* amp_0, int* amp_1 )
|
||||
{
|
||||
asm volatile (
|
||||
"smulbb %[out], %[out], %[envx]"
|
||||
: [out]"+r"(output)
|
||||
: [envx]"r"(voice->envx));
|
||||
|
||||
asm volatile (
|
||||
"mov %[out], %[out], asr #11 \n"
|
||||
"bic %[out], %[out], #0x1 \n"
|
||||
"smulbb %[amp_0], %[out], %[v0] \n"
|
||||
"smulbb %[amp_1], %[out], %[v1] \n"
|
||||
: [out]"+r"(output),
|
||||
[amp_0]"=&r"(*amp_0), [amp_1]"=r"(*amp_1)
|
||||
: [v0]"r"(voice->volume[0]), [v1]"r"(voice->volume[1]));
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
#endif /* !SPC_NOINTERP */
|
||||
|
||||
#if !SPC_NOECHO
|
||||
|
||||
#define SPC_DSP_ECHO_APPLY
|
||||
|
||||
/* Echo filter history */
|
||||
static int32_t fir_buf[FIR_BUF_CNT] IBSS_ATTR_SPC
|
||||
__attribute__(( aligned(FIR_BUF_ALIGN*1) ));
|
||||
|
||||
static inline void echo_init( struct Spc_Dsp* this )
|
||||
{
|
||||
this->fir.ptr = fir_buf;
|
||||
ci->memset( fir_buf, 0, sizeof fir_buf );
|
||||
}
|
||||
|
||||
static inline void echo_apply(struct Spc_Dsp* this,
|
||||
uint8_t* const echo_ptr, int* out_0, int* out_1)
|
||||
{
|
||||
/* Keep last 8 samples */
|
||||
int32_t* fir_ptr;
|
||||
int t0;
|
||||
asm volatile (
|
||||
"ldr %[t0], [%[ep]] \n"
|
||||
"add %[p], %[t_p], #4 \n"
|
||||
"bic %[t_p], %[p], %[mask] \n"
|
||||
"str %[t0], [%[p], #-4] \n"
|
||||
/* duplicate at +8 eliminates wrap checking below */
|
||||
"str %[t0], [%[p], #28] \n"
|
||||
: [p]"=&r"(fir_ptr), [t_p]"+r"(this->fir.ptr),
|
||||
[t0]"=&r"(t0)
|
||||
: [ep]"r"(echo_ptr), [mask]"i"(~FIR_BUF_MASK));
|
||||
|
||||
int32_t* fir_coeff = (int32_t *)this->fir.coeff;
|
||||
|
||||
asm volatile ( /* L0R0 = acc0 */
|
||||
"ldmia %[p]!, { r2-r5 } \n" /* L1R1-L4R4 = r2-r5 */
|
||||
"ldmia %[c]!, { r0-r1 } \n" /* C0C1-C2C3 = r0-r1 */
|
||||
"pkhbt %[acc0], %[t0], r2, asl #16 \n" /* L0R0,L1R1->L0L1,R0R1 */
|
||||
"pkhtb r2, r2, %[t0], asr #16 \n"
|
||||
"smuad %[acc0], %[acc0], r0 \n" /* acc0=L0*C0+L1*C1 */
|
||||
"smuad %[acc1], r2, r0 \n" /* acc1=R0*C0+R1*C1 */
|
||||
"pkhbt %[t0], r3, r4, asl #16 \n" /* L2R2,L3R3->L2L3,R2R3 */
|
||||
"pkhtb r4, r4, r3, asr #16 \n"
|
||||
"smlad %[acc0], %[t0], r1, %[acc0] \n" /* acc0+=L2*C2+L3*C3 */
|
||||
"smlad %[acc1], r4, r1, %[acc1] \n" /* acc1+=R2*C2+R3*C3 */
|
||||
"ldmia %[p], { r2-r4 } \n" /* L5R5-L7R7 = r2-r4 */
|
||||
"ldmia %[c], { r0-r1 } \n" /* C4C5-C6C7 = r0-r1 */
|
||||
"pkhbt %[t0], r5, r2, asl #16 \n" /* L4R4,L5R5->L4L5,R4R5 */
|
||||
"pkhtb r2, r2, r5, asr #16 \n"
|
||||
"smlad %[acc0], %[t0], r0, %[acc0] \n" /* acc0+=L4*C4+L5*C5 */
|
||||
"smlad %[acc1], r2, r0, %[acc1] \n" /* acc1+=R4*C4+R5*C5 */
|
||||
"pkhbt %[t0], r3, r4, asl #16 \n" /* L6R6,L7R7->L6L7,R6R7 */
|
||||
"pkhtb r4, r4, r3, asr #16 \n"
|
||||
"smlad %[acc0], %[t0], r1, %[acc0] \n" /* acc0+=L6*C6+L7*C7 */
|
||||
"smlad %[acc1], r4, r1, %[acc1] \n" /* acc1+=R6*C6+R7*C7 */
|
||||
: [t0]"+r"(t0), [acc0]"=&r"(*out_0), [acc1]"=&r"(*out_1),
|
||||
[p]"+r"(fir_ptr), [c]"+r"(fir_coeff)
|
||||
:
|
||||
: "r0", "r1", "r2", "r3", "r4", "r5");
|
||||
}
|
||||
|
||||
#define SPC_DSP_ECHO_FEEDBACK
|
||||
static inline void echo_feedback(struct Spc_Dsp* this, uint8_t* echo_ptr,
|
||||
int echo_0, int echo_1, int fb_0, int fb_1)
|
||||
{
|
||||
int e0, e1;
|
||||
asm volatile (
|
||||
"mov %[e0], %[ei0], asl #7 \n"
|
||||
"mov %[e1], %[ei1], asl #7 \n"
|
||||
"mla %[e0], %[fb0], %[ef], %[e0] \n"
|
||||
"mla %[e1], %[fb1], %[ef], %[e1] \n"
|
||||
: [e0]"=&r"(e0), [e1]"=&r"(e1)
|
||||
: [ei0]"r"(echo_0), [ei1]"r"(echo_1),
|
||||
[fb0]"r"(fb_0), [fb1]"r"(fb_1),
|
||||
[ef]"r"((int)this->r.g.echo_feedback));
|
||||
asm volatile (
|
||||
"ssat %[e0], #16, %[e0], asr #14 \n"
|
||||
"ssat %[e1], #16, %[e1], asr #14 \n"
|
||||
"pkhbt %[e0], %[e0], %[e1], lsl #16 \n"
|
||||
"str %[e0], [%[ep]] \n"
|
||||
: [e0]"+r"(e0), [e1]"+r"(e1)
|
||||
: [ep]"r"((int32_t *)echo_ptr));
|
||||
}
|
||||
|
||||
#define SPC_DSP_GENERATE_OUTPUT
|
||||
static inline void echo_output( struct Spc_Dsp* this, int global_muting,
|
||||
int global_vol_0, int global_vol_1, int chans_0, int chans_1,
|
||||
int fb_0, int fb_1, int* out_0, int* out_1 )
|
||||
{
|
||||
int t0, t1;
|
||||
|
||||
asm volatile (
|
||||
"mul %[t0], %[gv0], %[ch0] \n"
|
||||
"mul %[t1], %[gv1], %[ch1] \n"
|
||||
: [t0]"=&r"(t0), [t1]"=r"(t1)
|
||||
: [gv0]"r"(global_vol_0), [gv1]"r"(global_vol_1),
|
||||
[ch0]"r"(chans_0), [ch1]"r"(chans_1));
|
||||
asm volatile (
|
||||
"mla %[t0], %[i0], %[ev0], %[t0] \n"
|
||||
"mla %[t1], %[i1], %[ev1], %[t1] \n"
|
||||
: [t0]"+r"(t0), [t1]"+r"(t1)
|
||||
: [i0]"r"(fb_0), [i1]"r"(fb_1),
|
||||
[ev0]"r"((int)this->r.g.echo_volume_0),
|
||||
[ev1]"r"((int)this->r.g.echo_volume_1));
|
||||
asm volatile (
|
||||
"mov %[o0], %[t0], asr %[gm] \n"
|
||||
"mov %[o1], %[t1], asr %[gm] \n"
|
||||
: [o0]"=&r"(*out_0), [o1]"=r"(*out_1)
|
||||
: [t0]"r"(t0), [t1]"r"(t1),
|
||||
[gm]"r"(global_muting));
|
||||
}
|
||||
|
||||
#endif /* SPC_NOECHO */
|
45
lib/rbcodec/codecs/libspc/cpu/spc_dsp_armv6.h
Normal file
45
lib/rbcodec/codecs/libspc/cpu/spc_dsp_armv6.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2010 Michael Sevakis (jhMikeS)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#if !SPC_NOECHO
|
||||
|
||||
#define SPC_DSP_ECHO_APPLY
|
||||
|
||||
enum
|
||||
{
|
||||
FIR_BUF_CNT = FIR_BUF_HALF * 2,
|
||||
FIR_BUF_SIZE = FIR_BUF_CNT * sizeof ( int32_t ),
|
||||
FIR_BUF_ALIGN = FIR_BUF_SIZE,
|
||||
FIR_BUF_MASK = ~((FIR_BUF_ALIGN / 2) | (sizeof ( int32_t ) - 1))
|
||||
};
|
||||
|
||||
/* Echo filter structure embedded in struct Spc_Dsp */
|
||||
struct echo_filter
|
||||
{ /* fir_buf [i + 8] == fir_buf [i], to avoid wrap checking in FIR code */
|
||||
int32_t* ptr;
|
||||
/* FIR history is interleaved with guard to eliminate wrap checking
|
||||
* when convolving.
|
||||
* |LR|LR|LR|LR|LR|LR|LR|LR|--|--|--|--|--|--|--|--| */
|
||||
/* copy of echo FIR constants as int16_t, loaded as int32 for
|
||||
* halfword, packed multiples */
|
||||
int16_t coeff [VOICE_COUNT];
|
||||
};
|
||||
|
||||
#endif /* SPC_NOECHO */
|
198
lib/rbcodec/codecs/libspc/cpu/spc_dsp_coldfire.c
Normal file
198
lib/rbcodec/codecs/libspc/cpu/spc_dsp_coldfire.c
Normal file
|
@ -0,0 +1,198 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2007 Michael Sevakis (jhMikeS)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#if SPC_NOINTERP
|
||||
|
||||
#define SPC_LINEAR_INTERP
|
||||
static inline int linear_interp( int16_t const* samples, int32_t position )
|
||||
{
|
||||
uint32_t f = position;
|
||||
int32_t y0, y1;
|
||||
|
||||
/**
|
||||
* output = y0 + f*y1 - f*y0
|
||||
*/
|
||||
asm volatile (
|
||||
"move.l %[f], %[y1] \n" /* separate frac and whole */
|
||||
"and.l #0xfff, %[f] \n"
|
||||
"asr.l %[sh], %[y1] \n"
|
||||
"move.l 2(%[s], %[y1].l*2), %[y1] \n" /* y0=upper, y1=lower */
|
||||
"mac.w %[f]l, %[y1]l, %%acc0 \n" /* %acc0 = f*y1 */
|
||||
"msac.w %[f]l, %[y1]u, %%acc0 \n" /* %acc0 -= f*y0 */
|
||||
"swap %[y1] \n" /* separate out y0 and sign extend */
|
||||
"movea.w %[y1], %[y0] \n"
|
||||
"movclr.l %%acc0, %[y1] \n" /* fetch, scale down, add y0 */
|
||||
"asr.l %[sh], %[y1] \n" /* output = y0 + (result >> 12) */
|
||||
"add.l %[y0], %[y1] \n"
|
||||
: [f]"+d"(f), [y0]"=&a"(y0), [y1]"=&d"(y1)
|
||||
: [s]"a"(samples), [sh]"d"(12));
|
||||
|
||||
return y1;
|
||||
}
|
||||
|
||||
#define SPC_LINEAR_AMP
|
||||
static inline int linear_amp( struct voice_t* voice, int output,
|
||||
int* amp_0, int* amp_1 )
|
||||
{
|
||||
asm volatile (
|
||||
"mac.w %[out]l, %[envx]l, %%acc0"
|
||||
:
|
||||
: [out]"r"(output), [envx]"r"(voice->envx));
|
||||
asm volatile (
|
||||
"movclr.l %%acc0, %[out] \n"
|
||||
"asr.l #8, %[out] \n"
|
||||
"mac.l %[v0], %[out], %%acc0 \n"
|
||||
"mac.l %[v1], %[out], %%acc1 \n"
|
||||
"asr.l #3, %[out] \n"
|
||||
: [out]"+r"(output)
|
||||
: [v0]"r"((int) voice->volume [0]),
|
||||
[v1]"r"((int) voice->volume [1]));
|
||||
asm volatile (
|
||||
"movclr.l %%acc0, %[a0] \n"
|
||||
"asr.l #3, %[a0] \n"
|
||||
"movclr.l %%acc1, %[a1] \n"
|
||||
"asr.l #3, %[a1] \n"
|
||||
: [a0]"=d"(*amp_0), [a1]"=d"(*amp_1));
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
#endif /* SPC_NOINTERP */
|
||||
|
||||
|
||||
#if !SPC_NOECHO
|
||||
|
||||
#define SPC_DSP_ECHO_APPLY
|
||||
|
||||
/* Echo filter history */
|
||||
static int32_t fir_buf[FIR_BUF_CNT] IBSS_ATTR_SPC
|
||||
__attribute__(( aligned(FIR_BUF_ALIGN*1) ));
|
||||
|
||||
static inline void echo_init( struct Spc_Dsp* this )
|
||||
{
|
||||
/* Initialize mask register with the buffer address mask */
|
||||
asm volatile ("move.l %0, %%mask" : : "i"(FIR_BUF_MASK));
|
||||
this->fir.ptr = fir_buf;
|
||||
this->fir.hist_ptr = &fir_buf [1];
|
||||
ci->memset( fir_buf, 0, sizeof fir_buf );
|
||||
}
|
||||
|
||||
static inline void echo_apply( struct Spc_Dsp* this, uint8_t* echo_ptr,
|
||||
int* out_0, int* out_1 )
|
||||
{
|
||||
int t0, t1, t2;
|
||||
|
||||
t1 = swap_odd_even32( *(int32_t *)echo_ptr );
|
||||
|
||||
/* Keep last 8 samples */
|
||||
*this->fir.ptr = t1;
|
||||
this->fir.ptr = this->fir.hist_ptr;
|
||||
|
||||
asm volatile (
|
||||
"move.l (%[c]) , %[t2] \n"
|
||||
"mac.w %[t1]u, %[t2]u, <<, (%[p])+&, %[t0], %%acc0 \n"
|
||||
"mac.w %[t1]l, %[t2]u, <<, (%[p])& , %[t1], %%acc1 \n"
|
||||
"mac.w %[t0]u, %[t2]l, << , %%acc0 \n"
|
||||
"mac.w %[t0]l, %[t2]l, <<, 4(%[c]) , %[t2], %%acc1 \n"
|
||||
"mac.w %[t1]u, %[t2]u, <<, 4(%[p])& , %[t0], %%acc0 \n"
|
||||
"mac.w %[t1]l, %[t2]u, <<, 8(%[p])& , %[t1], %%acc1 \n"
|
||||
"mac.w %[t0]u, %[t2]l, << , %%acc0 \n"
|
||||
"mac.w %[t0]l, %[t2]l, <<, 8(%[c]) , %[t2], %%acc1 \n"
|
||||
"mac.w %[t1]u, %[t2]u, <<, 12(%[p])& , %[t0], %%acc0 \n"
|
||||
"mac.w %[t1]l, %[t2]u, <<, 16(%[p])& , %[t1], %%acc1 \n"
|
||||
"mac.w %[t0]u, %[t2]l, << , %%acc0 \n"
|
||||
"mac.w %[t0]l, %[t2]l, <<, 12(%[c]) , %[t2], %%acc1 \n"
|
||||
"mac.w %[t1]u, %[t2]u, <<, 20(%[p])& , %[t0], %%acc0 \n"
|
||||
"mac.w %[t1]l, %[t2]u, << , %%acc1 \n"
|
||||
"mac.w %[t0]u, %[t2]l, << , %%acc0 \n"
|
||||
"mac.w %[t0]l, %[t2]l, << , %%acc1 \n"
|
||||
: [t0]"=&r"(t0), [t1]"+r"(t1), [t2]"=&r"(t2),
|
||||
[p]"+a"(this->fir.hist_ptr)
|
||||
: [c]"a"(this->fir.coeff));
|
||||
asm volatile (
|
||||
"movclr.l %%acc0, %[o0] \n"
|
||||
"movclr.l %%acc1, %[o1] \n"
|
||||
"mac.l %[ev0], %[o0], >>, %%acc2 \n" /* echo volume */
|
||||
"mac.l %[ev1], %[o1], >>, %%acc3 \n"
|
||||
: [o0]"=&r"(*out_0), [o1]"=&r"(*out_1)
|
||||
: [ev0]"r"((int) this->r.g.echo_volume_0),
|
||||
[ev1]"r"((int) this->r.g.echo_volume_1));
|
||||
}
|
||||
|
||||
#define SPC_DSP_ECHO_FEEDBACK
|
||||
static inline void echo_feedback( struct Spc_Dsp* this, uint8_t* echo_ptr,
|
||||
int echo_0, int echo_1, int fb_0, int fb_1 )
|
||||
{
|
||||
asm volatile (
|
||||
/* scale echo voices; saturate if overflow */
|
||||
"mac.l %[sh], %[e1] , %%acc1 \n"
|
||||
"mac.l %[sh], %[e0] , %%acc0 \n"
|
||||
/* add scaled output from FIR filter */
|
||||
"mac.l %[fb1], %[ef], <<, %%acc1 \n"
|
||||
"mac.l %[fb0], %[ef], <<, %%acc0 \n"
|
||||
:
|
||||
: [e0]"d"(echo_0), [e1]"d"(echo_1),
|
||||
[fb0]"r"(fb_0), [fb1]"r"(fb_1),
|
||||
[ef]"r"((int)this->r.g.echo_feedback),
|
||||
[sh]"r"(1 << 9));
|
||||
/* swap and fetch feedback results */
|
||||
int t0;
|
||||
asm volatile(
|
||||
"move.l #0x00ff00ff, %[t0] \n"
|
||||
"movclr.l %%acc1, %[e1] \n"
|
||||
"swap.w %[e1] \n"
|
||||
"movclr.l %%acc0, %[e0] \n"
|
||||
"move.w %[e1], %[e0] \n"
|
||||
"and.l %[e0], %[t0] \n"
|
||||
"eor.l %[t0], %[e0] \n"
|
||||
"lsl.l #8, %[t0] \n"
|
||||
"lsr.l #8, %[e0] \n"
|
||||
"or.l %[e0], %[t0] \n"
|
||||
: [e0]"=&d"(echo_0), [e1]"=&d"(echo_1),
|
||||
[t0]"=&d"(t0));
|
||||
|
||||
/* save final feedback into echo buffer */
|
||||
*(int32_t *)echo_ptr = t0;
|
||||
}
|
||||
|
||||
#define SPC_DSP_GENERATE_OUTPUT
|
||||
static inline void echo_output( struct Spc_Dsp* this, int global_muting,
|
||||
int global_vol_0, int global_vol_1, int chans_0, int chans_1,
|
||||
int fb_0, int fb_1, int* out_0, int* out_1 )
|
||||
{
|
||||
asm volatile (
|
||||
"mac.l %[ch0], %[gv0], %%acc2 \n" /* global volume */
|
||||
"mac.l %[ch1], %[gv1], %%acc3 \n"
|
||||
:
|
||||
: [ch0]"r"(chans_0), [gv0]"r"(global_vol_0),
|
||||
[ch1]"r"(chans_1), [gv1]"r"(global_vol_1));
|
||||
asm volatile (
|
||||
"movclr.l %%acc2, %[a0] \n" /* fetch mixed output */
|
||||
"movclr.l %%acc3, %[a1] \n"
|
||||
"asr.l %[gm], %[a0] \n" /* scale by global_muting shift */
|
||||
"asr.l %[gm], %[a1] \n"
|
||||
: [a0]"=&d"(*out_0), [a1]"=&d"(*out_1)
|
||||
: [gm]"d"(global_muting));
|
||||
|
||||
/* scaled echo is stored in %acc2 and %acc3 */
|
||||
(void)this; (void)fb_0; (void)fb_1;
|
||||
}
|
||||
|
||||
#endif /* !SPC_NOECHO */
|
45
lib/rbcodec/codecs/libspc/cpu/spc_dsp_coldfire.h
Normal file
45
lib/rbcodec/codecs/libspc/cpu/spc_dsp_coldfire.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2007 Michael Sevakis (jhMikeS)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#if !SPC_NOECHO
|
||||
|
||||
#define SPC_DSP_ECHO_APPLY
|
||||
|
||||
enum
|
||||
{
|
||||
FIR_BUF_CNT = FIR_BUF_HALF,
|
||||
FIR_BUF_SIZE = FIR_BUF_CNT * sizeof ( int32_t ),
|
||||
FIR_BUF_ALIGN = FIR_BUF_SIZE * 2,
|
||||
FIR_BUF_MASK = ~((FIR_BUF_ALIGN / 2) | (sizeof ( int32_t ) - 1))
|
||||
};
|
||||
|
||||
/* Echo filter structure embedded in struct Spc_Dsp */
|
||||
struct echo_filter
|
||||
{
|
||||
/* FIR history is interleaved. Hardware handles wrapping by mask.
|
||||
* |LR|LR|LR|LR|LR|LR|LR|LR| */
|
||||
int32_t* ptr;
|
||||
/* wrapped address just behind current position -
|
||||
allows mac.w to increment and mask ptr */
|
||||
int32_t* hist_ptr;
|
||||
/* copy of echo FIR constants as int16_t for use with mac.w */
|
||||
int16_t coeff [VOICE_COUNT];
|
||||
};
|
||||
#endif /* !SPC_NOECHO */
|
|
@ -213,7 +213,9 @@ struct cpu_ram_t
|
|||
#define RAM ram.ram
|
||||
extern struct cpu_ram_t ram;
|
||||
|
||||
long CPU_run( THIS, long start_time ) ICODE_ATTR_SPC;
|
||||
long CPU_run( THIS, long start_time )
|
||||
ICODE_ATTR_SPC;
|
||||
|
||||
void CPU_Init( THIS );
|
||||
|
||||
/* The DSP portion (awe!) */
|
||||
|
@ -261,6 +263,7 @@ struct globals_t
|
|||
char unused9 [2];
|
||||
};
|
||||
|
||||
enum { ENV_RATE_INIT = 0x7800 };
|
||||
enum state_t
|
||||
{ /* -1, 0, +1 allows more efficient if statements */
|
||||
state_decay = -1,
|
||||
|
@ -278,64 +281,61 @@ struct cache_entry_t
|
|||
};
|
||||
|
||||
enum { BRR_BLOCK_SIZE = 16 };
|
||||
enum { BRR_CACHE_SIZE = 0x20000 + 32} ;
|
||||
enum { BRR_CACHE_SIZE = 0x20000 + 32};
|
||||
|
||||
#if SPC_BRRCACHE
|
||||
struct voice_wave_t
|
||||
{
|
||||
int16_t const* samples; /* decoded samples in cache */
|
||||
long position; /* position in samples buffer, 12-bit frac */
|
||||
long end; /* end position in samples buffer */
|
||||
int loop; /* length of looping area */
|
||||
unsigned block_header; /* header byte from current BRR block */
|
||||
uint8_t const* addr; /* BRR waveform address in RAM */
|
||||
};
|
||||
#else /* !SPC_BRRCACHE */
|
||||
struct voice_wave_t
|
||||
{
|
||||
int16_t samples [3 + BRR_BLOCK_SIZE + 1]; /* last decoded block */
|
||||
int32_t position; /* position in samples buffer, 12-bit frac */
|
||||
unsigned block_header; /* header byte from current BRR block */
|
||||
uint8_t const* addr; /* BRR waveform address in RAM */
|
||||
};
|
||||
#endif /* SPC_BRRCACHE */
|
||||
|
||||
struct voice_t
|
||||
{
|
||||
#if SPC_BRRCACHE
|
||||
int16_t const* samples;
|
||||
long wave_end;
|
||||
int wave_loop;
|
||||
#else
|
||||
int16_t samples [3 + BRR_BLOCK_SIZE + 1];
|
||||
int block_header; /* header byte from current block */
|
||||
#endif
|
||||
uint8_t const* addr;
|
||||
struct voice_wave_t wave;
|
||||
short volume [2];
|
||||
long position;/* position in samples buffer, with 12-bit fraction */
|
||||
short envx;
|
||||
short env_mode;
|
||||
short env_timer;
|
||||
short key_on_delay;
|
||||
short rate;
|
||||
};
|
||||
|
||||
#if SPC_BRRCACHE
|
||||
/* a little extra for samples that go past end */
|
||||
extern int16_t BRRcache [BRR_CACHE_SIZE];
|
||||
#if !SPC_NOECHO
|
||||
enum { FIR_BUF_HALF = 8 };
|
||||
#endif
|
||||
|
||||
enum { FIR_BUF_HALF = 8 };
|
||||
struct Spc_Dsp;
|
||||
|
||||
#if defined(CPU_COLDFIRE)
|
||||
/* global because of the large aligment requirement for hardware masking -
|
||||
* L-R interleaved 16-bit samples for easy loading and mac.w use.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
FIR_BUF_CNT = FIR_BUF_HALF,
|
||||
FIR_BUF_SIZE = FIR_BUF_CNT * sizeof ( int32_t ),
|
||||
FIR_BUF_ALIGN = FIR_BUF_SIZE * 2,
|
||||
FIR_BUF_MASK = ~((FIR_BUF_ALIGN / 2) | (sizeof ( int32_t ) - 1))
|
||||
};
|
||||
#elif defined (CPU_ARM)
|
||||
/* These must go before the definition of struct Spc_Dsp because a
|
||||
definition of struct echo_filter is required. Only declarations
|
||||
are created unless SPC_DSP_C is defined before including these. */
|
||||
#if defined(CPU_ARM)
|
||||
#if ARM_ARCH >= 6
|
||||
enum
|
||||
{
|
||||
FIR_BUF_CNT = FIR_BUF_HALF * 2,
|
||||
FIR_BUF_SIZE = FIR_BUF_CNT * sizeof ( int32_t ),
|
||||
FIR_BUF_ALIGN = FIR_BUF_SIZE,
|
||||
FIR_BUF_MASK = ~((FIR_BUF_ALIGN / 2) | (sizeof ( int32_t ) - 1))
|
||||
};
|
||||
#include "cpu/spc_dsp_armv6.h"
|
||||
#else
|
||||
enum
|
||||
{
|
||||
FIR_BUF_CNT = FIR_BUF_HALF * 2 * 2,
|
||||
FIR_BUF_SIZE = FIR_BUF_CNT * sizeof ( int32_t ),
|
||||
FIR_BUF_ALIGN = FIR_BUF_SIZE,
|
||||
FIR_BUF_MASK = ~((FIR_BUF_ALIGN / 2) | (sizeof ( int32_t ) * 2 - 1))
|
||||
};
|
||||
#endif /* ARM_ARCH */
|
||||
#endif /* CPU_* */
|
||||
#include "cpu/spc_dsp_armv4.h"
|
||||
#endif
|
||||
#elif defined (CPU_COLDFIRE)
|
||||
#include "cpu/spc_dsp_coldfire.h"
|
||||
#endif
|
||||
|
||||
/* Above may still use generic implementations. Also defines final
|
||||
function names. */
|
||||
#include "spc_dsp_generic.h"
|
||||
|
||||
struct Spc_Dsp
|
||||
{
|
||||
|
@ -347,48 +347,16 @@ struct Spc_Dsp
|
|||
int16_t align;
|
||||
} r;
|
||||
|
||||
unsigned echo_pos;
|
||||
int keys_down;
|
||||
int noise_count;
|
||||
uint16_t noise; /* also read as int16_t */
|
||||
|
||||
#if defined(CPU_COLDFIRE)
|
||||
/* FIR history is interleaved. Hardware handles wrapping by mask.
|
||||
* |LR|LR|LR|LR|LR|LR|LR|LR| */
|
||||
int32_t *fir_ptr;
|
||||
/* wrapped address just behind current position -
|
||||
allows mac.w to increment and mask fir_ptr */
|
||||
int32_t *last_fir_ptr;
|
||||
/* copy of echo FIR constants as int16_t for use with mac.w */
|
||||
int16_t fir_coeff [VOICE_COUNT];
|
||||
#elif defined (CPU_ARM)
|
||||
/* fir_buf [i + 8] == fir_buf [i], to avoid wrap checking in FIR code */
|
||||
int32_t *fir_ptr;
|
||||
#if ARM_ARCH >= 6
|
||||
/* FIR history is interleaved with guard to eliminate wrap checking
|
||||
* when convolving.
|
||||
* |LR|LR|LR|LR|LR|LR|LR|LR|--|--|--|--|--|--|--|--| */
|
||||
/* copy of echo FIR constants as int16_t, loaded as int32 for
|
||||
* halfword, packed multiples */
|
||||
int16_t fir_coeff [VOICE_COUNT];
|
||||
#else
|
||||
/* FIR history is interleaved with guard to eliminate wrap checking
|
||||
* when convolving.
|
||||
* |LL|RR|LL|RR|LL|RR|LL|RR|LL|RR|LL|RR|LL|RR|LL|RR|...
|
||||
* |--|--|--|--|--|--|--|--|--|--|--|--|--|--|--|--| */
|
||||
/* copy of echo FIR constants as int32_t, for faster access */
|
||||
int32_t fir_coeff [VOICE_COUNT];
|
||||
#endif /* ARM_ARCH */
|
||||
#else /* Unoptimized CPU */
|
||||
/* fir_buf [i + 8] == fir_buf [i], to avoid wrap checking in FIR code */
|
||||
int fir_pos; /* (0 to 7) */
|
||||
int fir_buf [FIR_BUF_HALF * 2] [2];
|
||||
/* copy of echo FIR constants as int, for faster access */
|
||||
int fir_coeff [VOICE_COUNT];
|
||||
#endif
|
||||
|
||||
struct voice_t voice_state [VOICE_COUNT];
|
||||
|
||||
#if !SPC_NOECHO
|
||||
unsigned echo_pos;
|
||||
struct echo_filter fir;
|
||||
#endif /* !SPC_NOECHO */
|
||||
|
||||
#if SPC_BRRCACHE
|
||||
uint8_t oldsize;
|
||||
struct cache_entry_t wave_entry [256];
|
||||
|
@ -396,7 +364,9 @@ struct Spc_Dsp
|
|||
#endif
|
||||
};
|
||||
|
||||
void DSP_run_( struct Spc_Dsp* this, long count, int32_t* out_buf ) ICODE_ATTR_SPC;
|
||||
void DSP_run_( struct Spc_Dsp* this, long count, int32_t* out_buf )
|
||||
ICODE_ATTR_SPC;
|
||||
|
||||
void DSP_reset( struct Spc_Dsp* this );
|
||||
|
||||
static inline void DSP_run( struct Spc_Dsp* this, long count, int32_t* out )
|
||||
|
@ -474,7 +444,8 @@ void SPC_Init( THIS );
|
|||
int SPC_load_spc( THIS, const void* data, long size );
|
||||
|
||||
/**************** DSP interaction ****************/
|
||||
void DSP_write( struct Spc_Dsp* this, int i, int data ) ICODE_ATTR_SPC;
|
||||
void DSP_write( struct Spc_Dsp* this, int i, int data )
|
||||
ICODE_ATTR_SPC;
|
||||
|
||||
static inline int DSP_read( struct Spc_Dsp* this, int i )
|
||||
{
|
||||
|
@ -482,10 +453,14 @@ static inline int DSP_read( struct Spc_Dsp* this, int i )
|
|||
return this->r.reg [i];
|
||||
}
|
||||
|
||||
int SPC_read( THIS, unsigned addr, long const time ) ICODE_ATTR_SPC;
|
||||
void SPC_write( THIS, unsigned addr, int data, long const time ) ICODE_ATTR_SPC;
|
||||
int SPC_read( THIS, unsigned addr, long const time )
|
||||
ICODE_ATTR_SPC;
|
||||
|
||||
void SPC_write( THIS, unsigned addr, int data, long const time )
|
||||
ICODE_ATTR_SPC;
|
||||
|
||||
/**************** Sample generation ****************/
|
||||
int SPC_play( THIS, long count, int32_t* out ) ICODE_ATTR_SPC;
|
||||
int SPC_play( THIS, long count, int32_t* out )
|
||||
ICODE_ATTR_SPC;
|
||||
|
||||
#endif /* _SPC_CODEC_H_ */
|
||||
|
|
|
@ -113,9 +113,7 @@ enum { st_c = 0x01 };
|
|||
|
||||
long CPU_run( THIS, long start_time )
|
||||
{
|
||||
#if 0
|
||||
ENTER_TIMER(cpu);
|
||||
#endif
|
||||
|
||||
register long spc_time_ = start_time;
|
||||
|
||||
|
@ -1036,9 +1034,7 @@ out_of_time:
|
|||
this->r.x = (uint8_t) x;
|
||||
this->r.y = (uint8_t) y;
|
||||
|
||||
#if 0
|
||||
EXIT_TIMER(cpu);
|
||||
#endif
|
||||
return spc_time_;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
211
lib/rbcodec/codecs/libspc/spc_dsp_generic.c
Normal file
211
lib/rbcodec/codecs/libspc/spc_dsp_generic.c
Normal file
|
@ -0,0 +1,211 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2006-2007 Adam Gashlin (hcs)
|
||||
* Copyright (C) 2004-2007 Shay Green (blargg)
|
||||
* Copyright (C) 2002 Brad Martin
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
static inline int apply_gen_envx( struct voice_t* voice, int output )
|
||||
{
|
||||
return (output * voice->envx) >> 11;
|
||||
}
|
||||
|
||||
static inline int apply_gen_volume( struct voice_t* voice, int output,
|
||||
int* amp_0, int* amp_1 )
|
||||
{
|
||||
*amp_0 = voice->volume [0] * output;
|
||||
*amp_1 = voice->volume [1] * output;
|
||||
return output;
|
||||
}
|
||||
|
||||
static inline int apply_gen_amp( struct voice_t* voice, int output,
|
||||
int* amp_0, int* amp_1)
|
||||
{
|
||||
output = apply_gen_envx( voice, output );
|
||||
output = apply_gen_volume( voice, output, amp_0, amp_1 );
|
||||
return output;
|
||||
}
|
||||
|
||||
#if !SPC_NOINTERP
|
||||
|
||||
#ifndef SPC_GAUSSIAN_FAST_INTERP
|
||||
static inline int gaussian_fast_interp( int16_t const* samples,
|
||||
int32_t position,
|
||||
int16_t const* fwd,
|
||||
int16_t const* rev )
|
||||
{
|
||||
samples += position >> 12;
|
||||
return (fwd [0] * samples [0] +
|
||||
fwd [1] * samples [1] +
|
||||
rev [1] * samples [2] +
|
||||
rev [0] * samples [3]) >> 11;
|
||||
}
|
||||
#endif /* SPC_GAUSSIAN_FAST_INTERP */
|
||||
|
||||
#ifndef SPC_GAUSSIAN_FAST_AMP
|
||||
#define gaussian_fast_amp apply_amp
|
||||
#endif /* SPC_GAUSSIAN_FAST_AMP */
|
||||
|
||||
#ifndef SPC_GAUSSIAN_SLOW_INTERP
|
||||
static inline int gaussian_slow_interp( int16_t const* samples,
|
||||
int32_t position,
|
||||
int16_t const* fwd,
|
||||
int16_t const* rev )
|
||||
{
|
||||
int output;
|
||||
samples += position >> 12;
|
||||
output = (fwd [0] * samples [0]) & ~0xFFF;
|
||||
output = (output + fwd [1] * samples [1]) & ~0xFFF;
|
||||
output = (output + rev [1] * samples [2]) >> 12;
|
||||
output = (int16_t) (output * 2);
|
||||
output += ((rev [0] * samples [3]) >> 12) * 2;
|
||||
return CLAMP16( output );
|
||||
}
|
||||
#endif /* SPC_GAUSSIAN_SLOW_INTERP */
|
||||
|
||||
#ifndef SPC_GAUSSIAN_SLOW_AMP
|
||||
static inline int gaussian_slow_amp( struct voice_t* voice, int output,
|
||||
int *amp_0, int *amp_1 )
|
||||
{
|
||||
output = apply_gen_envx( voice, output ) & ~1;
|
||||
output = apply_gen_volume( voice, output, amp_0, amp_1 );
|
||||
return output;
|
||||
}
|
||||
#endif /* SPC_GAUSSIAN_SLOW_AMP */
|
||||
|
||||
#define interp gaussian_slow_interp
|
||||
#define apply_amp gaussian_slow_amp
|
||||
|
||||
#else /* SPC_NOINTERP */
|
||||
|
||||
#ifndef SPC_LINEAR_INTERP
|
||||
static inline int linear_interp( int16_t const* samples, int32_t position )
|
||||
{
|
||||
int32_t fraction = position & 0xfff;
|
||||
int16_t const* pos = (samples + (position >> 12)) + 1;
|
||||
return pos[0] + ((fraction * (pos[1] - pos[0])) >> 12);
|
||||
}
|
||||
#endif /* SPC_LINEAR_INTERP */
|
||||
|
||||
#define interp( samp, pos, fwd, rev ) \
|
||||
linear_interp( (samp), (pos) )
|
||||
|
||||
#ifndef SPC_LINEAR_AMP
|
||||
#define linear_amp apply_gen_amp
|
||||
#endif /* SPC_LINEAR_AMP */
|
||||
|
||||
#define apply_amp linear_amp
|
||||
#endif /* SPC_NOINTERP */
|
||||
|
||||
|
||||
#if !SPC_NOECHO
|
||||
|
||||
#ifndef SPC_DSP_ECHO_APPLY
|
||||
/* Init FIR filter */
|
||||
static inline void echo_init( struct Spc_Dsp* this )
|
||||
{
|
||||
this->fir.pos = 0;
|
||||
ci->memset( this->fir.buf, 0, sizeof this->fir.buf );
|
||||
}
|
||||
|
||||
/* Apply FIR filter */
|
||||
static inline void echo_apply(struct Spc_Dsp* this,
|
||||
uint8_t* const echo_ptr, int* out_0, int* out_1)
|
||||
{
|
||||
int fb_0 = GET_LE16SA( echo_ptr );
|
||||
int fb_1 = GET_LE16SA( echo_ptr + 2 );
|
||||
|
||||
/* Keep last 8 samples */
|
||||
int (* const fir_ptr) [2] = this->fir.buf + this->fir.pos;
|
||||
this->fir.pos = (this->fir.pos + 1) & (FIR_BUF_HALF - 1);
|
||||
|
||||
fir_ptr [ 0] [0] = fb_0;
|
||||
fir_ptr [ 0] [1] = fb_1;
|
||||
/* duplicate at +8 eliminates wrap checking below */
|
||||
fir_ptr [FIR_BUF_HALF] [0] = fb_0;
|
||||
fir_ptr [FIR_BUF_HALF] [1] = fb_1;
|
||||
|
||||
fb_0 *= this->fir.coeff [0];
|
||||
fb_1 *= this->fir.coeff [0];
|
||||
|
||||
#define DO_PT( i ) \
|
||||
fb_0 += fir_ptr [i] [0] * this->fir.coeff [i]; \
|
||||
fb_1 += fir_ptr [i] [1] * this->fir.coeff [i];
|
||||
|
||||
DO_PT( 1 )
|
||||
DO_PT( 2 )
|
||||
DO_PT( 3 )
|
||||
DO_PT( 4 )
|
||||
DO_PT( 5 )
|
||||
DO_PT( 6 )
|
||||
DO_PT( 7 )
|
||||
|
||||
#undef DO_PT
|
||||
|
||||
*out_0 = fb_0;
|
||||
*out_1 = fb_1;
|
||||
}
|
||||
#endif /* SPC_DSP_ECHO_APPLY */
|
||||
|
||||
#ifndef SPC_DSP_ECHO_FEEDBACK
|
||||
/* Feedback into echo buffer */
|
||||
static inline void echo_feedback( struct Spc_Dsp* this, uint8_t *echo_ptr,
|
||||
int echo_0, int echo_1, int fb_0, int fb_1 )
|
||||
{
|
||||
int e0 = (echo_0 >> 7) + ((fb_0 * this->r.g.echo_feedback) >> 14);
|
||||
int e1 = (echo_1 >> 7) + ((fb_1 * this->r.g.echo_feedback) >> 14);
|
||||
e0 = CLAMP16( e0 );
|
||||
SET_LE16A( echo_ptr , e0 );
|
||||
e1 = CLAMP16( e1 );
|
||||
SET_LE16A( echo_ptr + 2, e1 );
|
||||
}
|
||||
#endif /* SPC_DSP_ECHO_FEEDBACK */
|
||||
|
||||
#ifndef SPC_DSP_GENERATE_OUTPUT
|
||||
/* Generate final output */
|
||||
static inline void echo_output( struct Spc_Dsp* this, int global_muting,
|
||||
int global_vol_0, int global_vol_1, int chans_0, int chans_1,
|
||||
int fb_0, int fb_1, int* out_0, int* out_1 )
|
||||
{
|
||||
*out_0 = (chans_0 * global_vol_0 + fb_0 * this->r.g.echo_volume_0)
|
||||
>> global_muting;
|
||||
*out_1 = (chans_1 * global_vol_1 + fb_1 * this->r.g.echo_volume_1)
|
||||
>> global_muting;
|
||||
}
|
||||
#endif /* SPC_DSP_GENERATE_OUTPUT */
|
||||
|
||||
#define mix_output echo_output
|
||||
|
||||
#else /* SPC_NOECHO */
|
||||
|
||||
#ifndef SPC_DSP_GENERATE_OUTPUT
|
||||
/* Generate final output */
|
||||
static inline void noecho_output( struct Spc_Dsp* this, int global_muting,
|
||||
int global_vol_0, int global_vol_1, int chans_0, int chans_1,
|
||||
int* out_0, int* out_1 )
|
||||
{
|
||||
*out_0 = (chans_0 * global_vol_0) >> global_muting;
|
||||
*out_1 = (chans_1 * global_vol_1) >> global_muting;
|
||||
(void)this;
|
||||
}
|
||||
#endif /* SPC_DSP_GENERATE_OUTPUT */
|
||||
|
||||
#define mix_output(this, gm, gv0, gv1, ch0, ch1, fb_0, fb_1, o0, o1) \
|
||||
noecho_output( (this), (gm), (gv0), (gv1), (ch0), (ch1), (o0), (o1) )
|
||||
|
||||
#endif /* !SPC_NOECHO */
|
45
lib/rbcodec/codecs/libspc/spc_dsp_generic.h
Normal file
45
lib/rbcodec/codecs/libspc/spc_dsp_generic.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2006-2007 Adam Gashlin (hcs)
|
||||
* Copyright (C) 2004-2007 Shay Green (blargg)
|
||||
* Copyright (C) 2002 Brad Martin
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
****************************************************************************/
|
||||
#if !SPC_NOECHO
|
||||
|
||||
#ifndef SPC_DSP_ECHO_APPLY
|
||||
enum
|
||||
{
|
||||
FIR_BUF_CNT = FIR_BUF_HALF * 2 * 2,
|
||||
FIR_BUF_SIZE = FIR_BUF_CNT * sizeof ( int32_t ),
|
||||
FIR_BUF_ALIGN = FIR_BUF_SIZE,
|
||||
FIR_BUF_MASK = ~((FIR_BUF_ALIGN / 2) | (sizeof ( int32_t ) * 2 - 1))
|
||||
};
|
||||
|
||||
/* Echo filter structure embedded in struct Spc_Dsp */
|
||||
struct echo_filter
|
||||
{
|
||||
/* fir_buf [i + 8] == fir_buf [i], to avoid wrap checking in FIR code */
|
||||
int pos; /* (0 to 7) */
|
||||
int buf [FIR_BUF_HALF * 2] [2];
|
||||
/* copy of echo FIR constants as int, for faster access */
|
||||
int coeff [VOICE_COUNT];
|
||||
};
|
||||
#endif /* SPC_DSP_ECHO_APPLY */
|
||||
|
||||
#endif /* !SPC_NOECHO */
|
|
@ -32,8 +32,8 @@ struct cpu_ram_t ram IBSS_ATTR_SPC_LARGE_IRAM CACHEALIGN_ATTR;
|
|||
|
||||
/**************** Timers ****************/
|
||||
|
||||
static void Timer_run_( struct Timer* t, long time ) ICODE_ATTR_SPC;
|
||||
static void Timer_run_( struct Timer* t, long time )
|
||||
static void NO_INLINE ICODE_ATTR_SPC
|
||||
Timer_run_( struct Timer* t, long time )
|
||||
{
|
||||
/* when disabled, next_tick should always be in the future */
|
||||
assert( t->enabled );
|
||||
|
@ -60,7 +60,7 @@ static inline void Timer_run( struct Timer* t, long time )
|
|||
/**************** SPC emulator ****************/
|
||||
/* 1.024 MHz clock / 32000 samples per second */
|
||||
|
||||
static void SPC_enable_rom( THIS, int enable )
|
||||
static void NO_INLINE SPC_enable_rom( THIS, int enable )
|
||||
{
|
||||
if ( this->rom_enabled != enable )
|
||||
{
|
||||
|
@ -186,8 +186,8 @@ int SPC_load_spc( THIS, const void* data, long size )
|
|||
}
|
||||
|
||||
/**************** DSP interaction ****************/
|
||||
static void SPC_run_dsp_( THIS, long time ) ICODE_ATTR_SPC;
|
||||
static void SPC_run_dsp_( THIS, long time )
|
||||
static void NO_INLINE ICODE_ATTR_SPC
|
||||
SPC_run_dsp_( THIS, long time )
|
||||
{
|
||||
/* divide by CLOCKS_PER_SAMPLE */
|
||||
int count = ((time - this->next_dsp) >> 5) + 1;
|
||||
|
@ -383,13 +383,10 @@ int SPC_play( THIS, long count, int32_t* out )
|
|||
}
|
||||
|
||||
/* Catch DSP up to present */
|
||||
#if 0
|
||||
ENTER_TIMER(cpu);
|
||||
#endif
|
||||
SPC_run_dsp( this, -EXTRA_CLOCKS );
|
||||
#if 0
|
||||
EXIT_TIMER(cpu);
|
||||
#endif
|
||||
|
||||
assert( this->next_dsp == CLOCKS_PER_SAMPLE - EXTRA_CLOCKS );
|
||||
assert( this->sample_buf - out == count );
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue