diff options
-rw-r--r-- | apps/codecs/spc/Spc_Dsp.h | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/apps/codecs/spc/Spc_Dsp.h b/apps/codecs/spc/Spc_Dsp.h index d09b753e87..291d6ec2c8 100644 --- a/apps/codecs/spc/Spc_Dsp.h +++ b/apps/codecs/spc/Spc_Dsp.h | |||
@@ -6,6 +6,8 @@ | |||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * | 8 | * |
9 | * $Id$ | ||
10 | * | ||
9 | * Copyright (C) 2006-2007 Adam Gashlin (hcs) | 11 | * Copyright (C) 2006-2007 Adam Gashlin (hcs) |
10 | * Copyright (C) 2004-2007 Shay Green (blargg) | 12 | * Copyright (C) 2004-2007 Shay Green (blargg) |
11 | * Copyright (C) 2002 Brad Martin | 13 | * Copyright (C) 2002 Brad Martin |
@@ -880,7 +882,7 @@ static void DSP_run_( struct Spc_Dsp* this, long count, int32_t* out_buf ) | |||
880 | #if !SPC_NOINTERP | 882 | #if !SPC_NOINTERP |
881 | /* Interleved gauss table (to improve cache coherency). */ | 883 | /* Interleved gauss table (to improve cache coherency). */ |
882 | /* gauss [i * 2 + j] = normal_gauss [(1 - j) * 256 + i] */ | 884 | /* gauss [i * 2 + j] = normal_gauss [(1 - j) * 256 + i] */ |
883 | static short const gauss [512] = | 885 | static short const gauss [512] ICONST_ATTR = |
884 | { | 886 | { |
885 | 370,1305, 366,1305, 362,1304, 358,1304, 354,1304, 351,1304, 347,1304, 343,1303, | 887 | 370,1305, 366,1305, 362,1304, 358,1304, 354,1304, 351,1304, 347,1304, 343,1303, |
886 | 339,1303, 336,1303, 332,1302, 328,1302, 325,1301, 321,1300, 318,1300, 314,1299, | 888 | 339,1303, 336,1303, 332,1302, 328,1302, 325,1301, 321,1300, 318,1300, 314,1299, |
@@ -915,7 +917,6 @@ static void DSP_run_( struct Spc_Dsp* this, long count, int32_t* out_buf ) | |||
915 | 0, 434, 0, 430, 0, 426, 0, 422, 0, 418, 0, 414, 0, 410, 0, 405, | 917 | 0, 434, 0, 430, 0, 426, 0, 422, 0, 418, 0, 414, 0, 410, 0, 405, |
916 | 0, 401, 0, 397, 0, 393, 0, 389, 0, 385, 0, 381, 0, 378, 0, 374, | 918 | 0, 401, 0, 397, 0, 393, 0, 389, 0, 385, 0, 381, 0, 378, 0, 374, |
917 | }; | 919 | }; |
918 | |||
919 | /* Gaussian interpolation using most recent 4 samples */ | 920 | /* Gaussian interpolation using most recent 4 samples */ |
920 | long position = voice->position; | 921 | long position = voice->position; |
921 | voice->position += rate; | 922 | voice->position += rate; |
@@ -969,7 +970,8 @@ static void DSP_run_( struct Spc_Dsp* this, long count, int32_t* out_buf ) | |||
969 | #else | 970 | #else |
970 | /* two-point linear interpolation */ | 971 | /* two-point linear interpolation */ |
971 | #ifdef CPU_COLDFIRE | 972 | #ifdef CPU_COLDFIRE |
972 | int32_t output = (int16_t)this->noise; | 973 | int amp_0 = (int16_t)this->noise; |
974 | int amp_1; | ||
973 | 975 | ||
974 | if ( (this->r.g.noise_enables & vbit) == 0 ) | 976 | if ( (this->r.g.noise_enables & vbit) == 0 ) |
975 | { | 977 | { |
@@ -1001,12 +1003,45 @@ static void DSP_run_( struct Spc_Dsp* this, long count, int32_t* out_buf ) | |||
1001 | /* output = y0 + (result >> 12) */ | 1003 | /* output = y0 + (result >> 12) */ |
1002 | "asr.l %[sh], %[y1] \r\n" | 1004 | "asr.l %[sh], %[y1] \r\n" |
1003 | "add.l %[y0], %[y1] \r\n" | 1005 | "add.l %[y0], %[y1] \r\n" |
1004 | : [f]"+&d"(f), [y0]"=&a"(y0), [y1]"=&d"(output) | 1006 | : [f]"+&d"(f), [y0]"=&a"(y0), [y1]"=&d"(amp_0) |
1005 | : [s]"a"(voice->samples), [sh]"d"(12) | 1007 | : [s]"a"(voice->samples), [sh]"d"(12) |
1006 | ); | 1008 | ); |
1007 | } | 1009 | } |
1008 | 1010 | ||
1011 | /* apply voice envelope to output */ | ||
1012 | asm volatile ( | ||
1013 | "mac.w %[output]l, %[envx]l, %%acc0 \r\n" | ||
1014 | : | ||
1015 | : [output]"r"(amp_0), [envx]"r"(voice->envx) | ||
1016 | ); | ||
1017 | |||
1018 | /* advance voice position */ | ||
1009 | voice->position += rate; | 1019 | voice->position += rate; |
1020 | |||
1021 | /* fetch output, scale and apply left and right | ||
1022 | voice volume */ | ||
1023 | asm volatile ( | ||
1024 | "movclr.l %%acc0, %[output] \r\n" | ||
1025 | "asr.l %[sh], %[output] \r\n" | ||
1026 | "mac.l %[vvol_0], %[output], %%acc0 \r\n" | ||
1027 | "mac.l %[vvol_1], %[output], %%acc1 \r\n" | ||
1028 | : [output]"=&r"(amp_0) | ||
1029 | : [vvol_0]"r"((int)voice->volume[0]), | ||
1030 | [vvol_1]"r"((int)voice->volume[1]), | ||
1031 | [sh]"d"(11) | ||
1032 | ); | ||
1033 | |||
1034 | /* save this output into previous, scale and save in | ||
1035 | output register */ | ||
1036 | prev_outx = amp_0; | ||
1037 | raw_voice->outx = amp_0 >> 8; | ||
1038 | |||
1039 | /* fetch final voice output */ | ||
1040 | asm volatile ( | ||
1041 | "movclr.l %%acc0, %[amp_0] \r\n" | ||
1042 | "movclr.l %%acc1, %[amp_1] \r\n" | ||
1043 | : [amp_0]"=r"(amp_0), [amp_1]"=r"(amp_1) | ||
1044 | ); | ||
1010 | #else | 1045 | #else |
1011 | 1046 | ||
1012 | /* Try this one out on ARM and see - similar to above but the asm | 1047 | /* Try this one out on ARM and see - similar to above but the asm |
@@ -1043,8 +1078,6 @@ static void DSP_run_( struct Spc_Dsp* this, long count, int32_t* out_buf ) | |||
1043 | if ( this->r.g.noise_enables & vbit ) | 1078 | if ( this->r.g.noise_enables & vbit ) |
1044 | output = *(int16_t*) &this->noise; | 1079 | output = *(int16_t*) &this->noise; |
1045 | #endif | 1080 | #endif |
1046 | #endif /* CPU_COLDFIRE */ | ||
1047 | |||
1048 | output = (output * voice->envx) >> 11; | 1081 | output = (output * voice->envx) >> 11; |
1049 | 1082 | ||
1050 | /* duplicated here to give compiler more to run in parallel */ | 1083 | /* duplicated here to give compiler more to run in parallel */ |
@@ -1053,6 +1086,7 @@ static void DSP_run_( struct Spc_Dsp* this, long count, int32_t* out_buf ) | |||
1053 | 1086 | ||
1054 | prev_outx = output; | 1087 | prev_outx = output; |
1055 | raw_voice->outx = (int8_t) (output >> 8); | 1088 | raw_voice->outx = (int8_t) (output >> 8); |
1089 | #endif /* CPU_COLDFIRE */ | ||
1056 | #endif | 1090 | #endif |
1057 | 1091 | ||
1058 | #if SPC_BRRCACHE | 1092 | #if SPC_BRRCACHE |