diff options
Diffstat (limited to 'apps/codecs/libmad/synth.c')
-rw-r--r-- | apps/codecs/libmad/synth.c | 169 |
1 files changed, 57 insertions, 112 deletions
diff --git a/apps/codecs/libmad/synth.c b/apps/codecs/libmad/synth.c index 5ae9811ead..89f971a1ce 100644 --- a/apps/codecs/libmad/synth.c +++ b/apps/codecs/libmad/synth.c | |||
@@ -55,6 +55,7 @@ void mad_synth_init(struct mad_synth *synth) | |||
55 | */ | 55 | */ |
56 | void mad_synth_mute(struct mad_synth *synth) | 56 | void mad_synth_mute(struct mad_synth *synth) |
57 | { | 57 | { |
58 | /* | ||
58 | unsigned int ch, s, v; | 59 | unsigned int ch, s, v; |
59 | 60 | ||
60 | for (ch = 0; ch < 2; ++ch) { | 61 | for (ch = 0; ch < 2; ++ch) { |
@@ -65,6 +66,8 @@ void mad_synth_mute(struct mad_synth *synth) | |||
65 | } | 66 | } |
66 | } | 67 | } |
67 | } | 68 | } |
69 | */ | ||
70 | memset(synth->filter, 0, sizeof(synth->filter)); | ||
68 | } | 71 | } |
69 | 72 | ||
70 | #if 0 /* dct32 asm implementation is slower on current arm systems */ | 73 | #if 0 /* dct32 asm implementation is slower on current arm systems */ |
@@ -978,6 +981,44 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame, | |||
978 | 981 | ||
979 | # else /* not FPM_COLDFIRE_EMAC and not FPM_ARM */ | 982 | # else /* not FPM_COLDFIRE_EMAC and not FPM_ARM */ |
980 | 983 | ||
984 | #define PROD_O(hi, lo, f, ptr, offset) \ | ||
985 | ML0(hi, lo, (*f)[0], ptr[ 0+offset]); \ | ||
986 | MLA(hi, lo, (*f)[1], ptr[14+offset]); \ | ||
987 | MLA(hi, lo, (*f)[2], ptr[12+offset]); \ | ||
988 | MLA(hi, lo, (*f)[3], ptr[10+offset]); \ | ||
989 | MLA(hi, lo, (*f)[4], ptr[ 8+offset]); \ | ||
990 | MLA(hi, lo, (*f)[5], ptr[ 6+offset]); \ | ||
991 | MLA(hi, lo, (*f)[6], ptr[ 4+offset]); \ | ||
992 | MLA(hi, lo, (*f)[7], ptr[ 2+offset]); | ||
993 | |||
994 | #define PROD_A(hi, lo, f, ptr, offset) \ | ||
995 | MLA(hi, lo, (*f)[0], ptr[ 0+offset]); \ | ||
996 | MLA(hi, lo, (*f)[1], ptr[14+offset]); \ | ||
997 | MLA(hi, lo, (*f)[2], ptr[12+offset]); \ | ||
998 | MLA(hi, lo, (*f)[3], ptr[10+offset]); \ | ||
999 | MLA(hi, lo, (*f)[4], ptr[ 8+offset]); \ | ||
1000 | MLA(hi, lo, (*f)[5], ptr[ 6+offset]); \ | ||
1001 | MLA(hi, lo, (*f)[6], ptr[ 4+offset]); \ | ||
1002 | MLA(hi, lo, (*f)[7], ptr[ 2+offset]); | ||
1003 | |||
1004 | #define PROD_SB(hi, lo, ptr, offset, first_idx, last_idx) \ | ||
1005 | ML0(hi, lo, (*fe)[0], ptr[first_idx]); \ | ||
1006 | MLA(hi, lo, (*fe)[1], ptr[16+offset]); \ | ||
1007 | MLA(hi, lo, (*fe)[2], ptr[18+offset]); \ | ||
1008 | MLA(hi, lo, (*fe)[3], ptr[20+offset]); \ | ||
1009 | MLA(hi, lo, (*fe)[4], ptr[22+offset]); \ | ||
1010 | MLA(hi, lo, (*fe)[5], ptr[24+offset]); \ | ||
1011 | MLA(hi, lo, (*fe)[6], ptr[26+offset]); \ | ||
1012 | MLA(hi, lo, (*fe)[7], ptr[28+offset]); \ | ||
1013 | MLA(hi, lo, (*fo)[7], ptr[29-offset]); \ | ||
1014 | MLA(hi, lo, (*fo)[6], ptr[27-offset]); \ | ||
1015 | MLA(hi, lo, (*fo)[5], ptr[25-offset]); \ | ||
1016 | MLA(hi, lo, (*fo)[4], ptr[23-offset]); \ | ||
1017 | MLA(hi, lo, (*fo)[3], ptr[21-offset]); \ | ||
1018 | MLA(hi, lo, (*fo)[2], ptr[19-offset]); \ | ||
1019 | MLA(hi, lo, (*fo)[1], ptr[17-offset]); \ | ||
1020 | MLA(hi, lo, (*fo)[0], ptr[last_idx ]); | ||
1021 | |||
981 | static | 1022 | static |
982 | void synth_full(struct mad_synth *synth, struct mad_frame const *frame, | 1023 | void synth_full(struct mad_synth *synth, struct mad_frame const *frame, |
983 | unsigned int nch, unsigned int ns) | 1024 | unsigned int nch, unsigned int ns) |
@@ -1015,23 +1056,9 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame, | |||
1015 | if(s & 1) | 1056 | if(s & 1) |
1016 | { | 1057 | { |
1017 | ptr = *D0ptr; | 1058 | ptr = *D0ptr; |
1018 | ML0(hi, lo, (*fx)[0], ptr[ 1]); | 1059 | PROD_O(hi, lo, fx, ptr, 1) |
1019 | MLA(hi, lo, (*fx)[1], ptr[15]); | ||
1020 | MLA(hi, lo, (*fx)[2], ptr[13]); | ||
1021 | MLA(hi, lo, (*fx)[3], ptr[11]); | ||
1022 | MLA(hi, lo, (*fx)[4], ptr[ 9]); | ||
1023 | MLA(hi, lo, (*fx)[5], ptr[ 7]); | ||
1024 | MLA(hi, lo, (*fx)[6], ptr[ 5]); | ||
1025 | MLA(hi, lo, (*fx)[7], ptr[ 3]); | ||
1026 | MLN(hi, lo); | 1060 | MLN(hi, lo); |
1027 | MLA(hi, lo, (*fe)[0], ptr[ 0]); | 1061 | PROD_A(hi, lo, fe, ptr, 0) |
1028 | MLA(hi, lo, (*fe)[1], ptr[14]); | ||
1029 | MLA(hi, lo, (*fe)[2], ptr[12]); | ||
1030 | MLA(hi, lo, (*fe)[3], ptr[10]); | ||
1031 | MLA(hi, lo, (*fe)[4], ptr[ 8]); | ||
1032 | MLA(hi, lo, (*fe)[5], ptr[ 6]); | ||
1033 | MLA(hi, lo, (*fe)[6], ptr[ 4]); | ||
1034 | MLA(hi, lo, (*fe)[7], ptr[ 2]); | ||
1035 | pcm[0] = SHIFT(MLZ(hi, lo)); | 1062 | pcm[0] = SHIFT(MLZ(hi, lo)); |
1036 | pcm += 16; | 1063 | pcm += 16; |
1037 | 1064 | ||
@@ -1043,76 +1070,26 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame, | |||
1043 | 1070 | ||
1044 | /* D[32 - sb][i] == -D[sb][31 - i] */ | 1071 | /* D[32 - sb][i] == -D[sb][31 - i] */ |
1045 | ptr = *D0ptr; | 1072 | ptr = *D0ptr; |
1046 | ML0(hi, lo, (*fo)[0], ptr[ 1]); | 1073 | PROD_O(hi, lo, fo, ptr, 1) |
1047 | MLA(hi, lo, (*fo)[1], ptr[15]); | ||
1048 | MLA(hi, lo, (*fo)[2], ptr[13]); | ||
1049 | MLA(hi, lo, (*fo)[3], ptr[11]); | ||
1050 | MLA(hi, lo, (*fo)[4], ptr[ 9]); | ||
1051 | MLA(hi, lo, (*fo)[5], ptr[ 7]); | ||
1052 | MLA(hi, lo, (*fo)[6], ptr[ 5]); | ||
1053 | MLA(hi, lo, (*fo)[7], ptr[ 3]); | ||
1054 | MLN(hi, lo); | 1074 | MLN(hi, lo); |
1055 | MLA(hi, lo, (*fe)[7], ptr[ 2]); | 1075 | PROD_A(hi, lo, fe, ptr, 0) |
1056 | MLA(hi, lo, (*fe)[6], ptr[ 4]); | ||
1057 | MLA(hi, lo, (*fe)[5], ptr[ 6]); | ||
1058 | MLA(hi, lo, (*fe)[4], ptr[ 8]); | ||
1059 | MLA(hi, lo, (*fe)[3], ptr[10]); | ||
1060 | MLA(hi, lo, (*fe)[2], ptr[12]); | ||
1061 | MLA(hi, lo, (*fe)[1], ptr[14]); | ||
1062 | MLA(hi, lo, (*fe)[0], ptr[ 0]); | ||
1063 | pcm[-sb] = SHIFT(MLZ(hi, lo)); | 1076 | pcm[-sb] = SHIFT(MLZ(hi, lo)); |
1064 | 1077 | ||
1065 | ptr = *D1ptr; | 1078 | ptr = *D1ptr; |
1066 | ML0(hi, lo, (*fe)[0], ptr[31 - 16]); | 1079 | PROD_SB(hi, lo, ptr, 1, 15, 30) |
1067 | MLA(hi, lo, (*fe)[1], ptr[31 - 14]); | ||
1068 | MLA(hi, lo, (*fe)[2], ptr[31 - 12]); | ||
1069 | MLA(hi, lo, (*fe)[3], ptr[31 - 10]); | ||
1070 | MLA(hi, lo, (*fe)[4], ptr[31 - 8]); | ||
1071 | MLA(hi, lo, (*fe)[5], ptr[31 - 6]); | ||
1072 | MLA(hi, lo, (*fe)[6], ptr[31 - 4]); | ||
1073 | MLA(hi, lo, (*fe)[7], ptr[31 - 2]); | ||
1074 | MLA(hi, lo, (*fo)[7], ptr[31 - 3]); | ||
1075 | MLA(hi, lo, (*fo)[6], ptr[31 - 5]); | ||
1076 | MLA(hi, lo, (*fo)[5], ptr[31 - 7]); | ||
1077 | MLA(hi, lo, (*fo)[4], ptr[31 - 9]); | ||
1078 | MLA(hi, lo, (*fo)[3], ptr[31 - 11]); | ||
1079 | MLA(hi, lo, (*fo)[2], ptr[31 - 13]); | ||
1080 | MLA(hi, lo, (*fo)[1], ptr[31 - 15]); | ||
1081 | MLA(hi, lo, (*fo)[0], ptr[31 - 1]); | ||
1082 | pcm[sb] = SHIFT(MLZ(hi, lo)); | 1080 | pcm[sb] = SHIFT(MLZ(hi, lo)); |
1083 | } | 1081 | } |
1084 | 1082 | ||
1085 | ptr = *(D0ptr + 1); | 1083 | ptr = *(D0ptr + 1); |
1086 | ML0(hi, lo, (*fo)[0], ptr[ 1]); | 1084 | PROD_O(hi, lo, fo, ptr, 1) |
1087 | MLA(hi, lo, (*fo)[1], ptr[15]); | ||
1088 | MLA(hi, lo, (*fo)[2], ptr[13]); | ||
1089 | MLA(hi, lo, (*fo)[3], ptr[11]); | ||
1090 | MLA(hi, lo, (*fo)[4], ptr[ 9]); | ||
1091 | MLA(hi, lo, (*fo)[5], ptr[ 7]); | ||
1092 | MLA(hi, lo, (*fo)[6], ptr[ 5]); | ||
1093 | MLA(hi, lo, (*fo)[7], ptr[ 3]); | ||
1094 | pcm[0] = SHIFT(-MLZ(hi, lo)); | 1085 | pcm[0] = SHIFT(-MLZ(hi, lo)); |
1095 | } | 1086 | } |
1096 | else | 1087 | else |
1097 | { | 1088 | { |
1098 | ptr = *D0ptr; | 1089 | ptr = *D0ptr; |
1099 | ML0(hi, lo, (*fx)[0], ptr[ 0]); | 1090 | PROD_O(hi, lo, fx, ptr, 0) |
1100 | MLA(hi, lo, (*fx)[1], ptr[14]); | ||
1101 | MLA(hi, lo, (*fx)[2], ptr[12]); | ||
1102 | MLA(hi, lo, (*fx)[3], ptr[10]); | ||
1103 | MLA(hi, lo, (*fx)[4], ptr[ 8]); | ||
1104 | MLA(hi, lo, (*fx)[5], ptr[ 6]); | ||
1105 | MLA(hi, lo, (*fx)[6], ptr[ 4]); | ||
1106 | MLA(hi, lo, (*fx)[7], ptr[ 2]); | ||
1107 | MLN(hi, lo); | 1091 | MLN(hi, lo); |
1108 | MLA(hi, lo, (*fe)[0], ptr[ 1]); | 1092 | PROD_A(hi, lo, fe, ptr, 1) |
1109 | MLA(hi, lo, (*fe)[1], ptr[15]); | ||
1110 | MLA(hi, lo, (*fe)[2], ptr[13]); | ||
1111 | MLA(hi, lo, (*fe)[3], ptr[11]); | ||
1112 | MLA(hi, lo, (*fe)[4], ptr[ 9]); | ||
1113 | MLA(hi, lo, (*fe)[5], ptr[ 7]); | ||
1114 | MLA(hi, lo, (*fe)[6], ptr[ 5]); | ||
1115 | MLA(hi, lo, (*fe)[7], ptr[ 3]); | ||
1116 | pcm[0] = SHIFT(MLZ(hi, lo)); | 1093 | pcm[0] = SHIFT(MLZ(hi, lo)); |
1117 | pcm += 16; | 1094 | pcm += 16; |
1118 | 1095 | ||
@@ -1124,54 +1101,18 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame, | |||
1124 | 1101 | ||
1125 | /* D[32 - sb][i] == -D[sb][31 - i] */ | 1102 | /* D[32 - sb][i] == -D[sb][31 - i] */ |
1126 | ptr = *D0ptr; | 1103 | ptr = *D0ptr; |
1127 | ML0(hi, lo, (*fo)[0], ptr[ 0]); | 1104 | PROD_O(hi, lo, fo, ptr, 0) |
1128 | MLA(hi, lo, (*fo)[1], ptr[14]); | ||
1129 | MLA(hi, lo, (*fo)[2], ptr[12]); | ||
1130 | MLA(hi, lo, (*fo)[3], ptr[10]); | ||
1131 | MLA(hi, lo, (*fo)[4], ptr[ 8]); | ||
1132 | MLA(hi, lo, (*fo)[5], ptr[ 6]); | ||
1133 | MLA(hi, lo, (*fo)[6], ptr[ 4]); | ||
1134 | MLA(hi, lo, (*fo)[7], ptr[ 2]); | ||
1135 | MLN(hi, lo); | 1105 | MLN(hi, lo); |
1136 | MLA(hi, lo, (*fe)[7], ptr[ 3]); | 1106 | PROD_A(hi, lo, fe, ptr, 1) |
1137 | MLA(hi, lo, (*fe)[6], ptr[ 5]); | ||
1138 | MLA(hi, lo, (*fe)[5], ptr[ 7]); | ||
1139 | MLA(hi, lo, (*fe)[4], ptr[ 9]); | ||
1140 | MLA(hi, lo, (*fe)[3], ptr[11]); | ||
1141 | MLA(hi, lo, (*fe)[2], ptr[13]); | ||
1142 | MLA(hi, lo, (*fe)[1], ptr[15]); | ||
1143 | MLA(hi, lo, (*fe)[0], ptr[ 1]); | ||
1144 | pcm[-sb] = SHIFT(MLZ(hi, lo)); | 1107 | pcm[-sb] = SHIFT(MLZ(hi, lo)); |
1145 | 1108 | ||
1146 | ptr = *D1ptr; | 1109 | ptr = *D1ptr; |
1147 | ML0(hi, lo, (*fe)[0], ptr[31 - 1]); | 1110 | PROD_SB(hi, lo, ptr, 0, 30, 15) |
1148 | MLA(hi, lo, (*fe)[1], ptr[31 - 15]); | ||
1149 | MLA(hi, lo, (*fe)[2], ptr[31 - 13]); | ||
1150 | MLA(hi, lo, (*fe)[3], ptr[31 - 11]); | ||
1151 | MLA(hi, lo, (*fe)[4], ptr[31 - 9]); | ||
1152 | MLA(hi, lo, (*fe)[5], ptr[31 - 7]); | ||
1153 | MLA(hi, lo, (*fe)[6], ptr[31 - 5]); | ||
1154 | MLA(hi, lo, (*fe)[7], ptr[31 - 3]); | ||
1155 | MLA(hi, lo, (*fo)[7], ptr[31 - 2]); | ||
1156 | MLA(hi, lo, (*fo)[6], ptr[31 - 4]); | ||
1157 | MLA(hi, lo, (*fo)[5], ptr[31 - 6]); | ||
1158 | MLA(hi, lo, (*fo)[4], ptr[31 - 8]); | ||
1159 | MLA(hi, lo, (*fo)[3], ptr[31 - 10]); | ||
1160 | MLA(hi, lo, (*fo)[2], ptr[31 - 12]); | ||
1161 | MLA(hi, lo, (*fo)[1], ptr[31 - 14]); | ||
1162 | MLA(hi, lo, (*fo)[0], ptr[31 - 16]); | ||
1163 | pcm[sb] = SHIFT(MLZ(hi, lo)); | 1111 | pcm[sb] = SHIFT(MLZ(hi, lo)); |
1164 | } | 1112 | } |
1165 | 1113 | ||
1166 | ptr = *(D0ptr + 1); | 1114 | ptr = *(D0ptr + 1); |
1167 | ML0(hi, lo, (*fo)[0], ptr[ 0]); | 1115 | PROD_O(hi, lo, fo, ptr, 0) |
1168 | MLA(hi, lo, (*fo)[1], ptr[14]); | ||
1169 | MLA(hi, lo, (*fo)[2], ptr[12]); | ||
1170 | MLA(hi, lo, (*fo)[3], ptr[10]); | ||
1171 | MLA(hi, lo, (*fo)[4], ptr[ 8]); | ||
1172 | MLA(hi, lo, (*fo)[5], ptr[ 6]); | ||
1173 | MLA(hi, lo, (*fo)[6], ptr[ 4]); | ||
1174 | MLA(hi, lo, (*fo)[7], ptr[ 2]); | ||
1175 | pcm[0] = SHIFT(-MLZ(hi, lo)); | 1116 | pcm[0] = SHIFT(-MLZ(hi, lo)); |
1176 | } | 1117 | } |
1177 | 1118 | ||
@@ -1184,6 +1125,7 @@ void synth_full(struct mad_synth *synth, struct mad_frame const *frame, | |||
1184 | # endif | 1125 | # endif |
1185 | # endif | 1126 | # endif |
1186 | 1127 | ||
1128 | #if 0 /* rockbox: unused */ | ||
1187 | /* | 1129 | /* |
1188 | * NAME: synth->half() | 1130 | * NAME: synth->half() |
1189 | * DESCRIPTION: perform half frequency PCM synthesis | 1131 | * DESCRIPTION: perform half frequency PCM synthesis |
@@ -1321,6 +1263,7 @@ void synth_half(struct mad_synth *synth, struct mad_frame const *frame, | |||
1321 | } | 1263 | } |
1322 | } | 1264 | } |
1323 | } | 1265 | } |
1266 | #endif /* unused */ | ||
1324 | 1267 | ||
1325 | /* | 1268 | /* |
1326 | * NAME: synth->frame() | 1269 | * NAME: synth->frame() |
@@ -1341,12 +1284,14 @@ void mad_synth_frame(struct mad_synth *synth, struct mad_frame const *frame) | |||
1341 | 1284 | ||
1342 | synth_frame = synth_full; | 1285 | synth_frame = synth_full; |
1343 | 1286 | ||
1287 | #if 0 /* rockbox: unused */ | ||
1344 | if (frame->options & MAD_OPTION_HALFSAMPLERATE) { | 1288 | if (frame->options & MAD_OPTION_HALFSAMPLERATE) { |
1345 | synth->pcm.samplerate /= 2; | 1289 | synth->pcm.samplerate /= 2; |
1346 | synth->pcm.length /= 2; | 1290 | synth->pcm.length /= 2; |
1347 | 1291 | ||
1348 | synth_frame = synth_half; | 1292 | synth_frame = synth_half; |
1349 | } | 1293 | } |
1294 | #endif | ||
1350 | 1295 | ||
1351 | synth_frame(synth, frame, nch, ns); | 1296 | synth_frame(synth, frame, nch, ns); |
1352 | 1297 | ||