Index: apps/codecs/libatrac/atrac3data.h
===================================================================
--- apps/codecs/libatrac/atrac3data.h (revision 24645)
+++ apps/codecs/libatrac/atrac3data.h (working copy)
@@ -117,11 +117,11 @@


/* tables for the scalefactor decoding */
-
+/* not needed anymore
static const float iMaxQuant[8] = {
0.0, 1.0/1.5, 1.0/2.5, 1.0/3.5, 1.0/4.5, 1.0/7.5, 1.0/15.5, 1.0/31.5
};
-
+*/
static const uint16_t subbandTab[33] = {
0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224,
256, 288, 320, 352, 384, 416, 448, 480, 512, 576, 640, 704, 768, 896, 1024
Index: apps/codecs/libatrac/atrac3.c
===================================================================
--- apps/codecs/libatrac/atrac3.c (revision 24645)
+++ apps/codecs/libatrac/atrac3.c (working copy)
@@ -66,6 +66,7 @@
* @param inlo lower part of spectrum
* @param inhi higher part of spectrum
* @param nIn size of spectrum buffer
+ *
*/

#if defined(CPU_ARM)
@@ -98,6 +99,20 @@
* @param in input buffer
* @param win windowing coefficients
* @param nIn size of spectrum buffer
+ * Reference implementation:
+ *
+ * for (j = nIn; j != 0; j--) {
+ * s1 = fixmul32(in[0], win[0]);
+ * s2 = fixmul32(in[1], win[1]);
+ * for (i = 2; i < 48; i += 2) {
+ * s1 += fixmul31(in[i ], win[i ]);
+ * s2 += fixmul31(in[i+1], win[i+1]);
+ * }
+ * out[0] = s2;
+ * out[1] = s1;
+ * in += 2;
+ * out += 2;
+ * }
*/

#if defined(CPU_ARM)
@@ -116,16 +131,62 @@
int32_t i, j, s1, s2;

for (j = nIn; j != 0; j--) {
- /* i=0 */
- s1 = fixmul31(win[0], in[0]);
- s2 = fixmul31(win[1], in[1]);
-
- /* i=2..46 */
- for (i = 2; i < 48; i += 2) {
- s1 += fixmul31(win[i ], in[i ]);
- s2 += fixmul31(win[i+1], in[i+1]);
- }
-
+ i = 0;
+ /* 0.. 7 */
+ s1 = fixmul31(win[i], in[i]); i++;
+ s2 = fixmul31(win[i], in[i]); i++;
+ s1 += fixmul31(win[i], in[i]); i++;
+ s2 += fixmul31(win[i], in[i]); i++;
+ s1 += fixmul31(win[i], in[i]); i++;
+ s2 += fixmul31(win[i], in[i]); i++;
+ s1 += fixmul31(win[i], in[i]); i++;
+ s2 += fixmul31(win[i], in[i]); i++;
+ /* 8..15 */
+ s1 += fixmul31(win[i], in[i]); i++;
+ s2 += fixmul31(win[i], in[i]); i++;
+ s1 += fixmul31(win[i], in[i]); i++;
+ s2 += fixmul31(win[i], in[i]); i++;
+ s1 += fixmul31(win[i], in[i]); i++;
+ s2 += fixmul31(win[i], in[i]); i++;
+ s1 += fixmul31(win[i], in[i]); i++;
+ s2 += fixmul31(win[i], in[i]); i++;
+ /* 16..23 */
+ s1 += fixmul31(win[i], in[i]); i++;
+ s2 += fixmul31(win[i], in[i]); i++;
+ s1 += fixmul31(win[i], in[i]); i++;
+ s2 += fixmul31(win[i], in[i]); i++;
+ s1 += fixmul31(win[i], in[i]); i++;
+ s2 += fixmul31(win[i], in[i]); i++;
+ s1 += fixmul31(win[i], in[i]); i++;
+ s2 += fixmul31(win[i], in[i]); i++;
+ /* 24..31 */
+ s1 += fixmul31(win[i], in[i]); i++;
+ s2 += fixmul31(win[i], in[i]); i++;
+ s1 += fixmul31(win[i], in[i]); i++;
+ s2 += fixmul31(win[i], in[i]); i++;
+ s1 += fixmul31(win[i], in[i]); i++;
+ s2 += fixmul31(win[i], in[i]); i++;
+ s1 += fixmul31(win[i], in[i]); i++;
+ s2 += fixmul31(win[i], in[i]); i++;
+ /* 32..39 */
+ s1 += fixmul31(win[i], in[i]); i++;
+ s2 += fixmul31(win[i], in[i]); i++;
+ s1 += fixmul31(win[i], in[i]); i++;
+ s2 += fixmul31(win[i], in[i]); i++;
+ s1 += fixmul31(win[i], in[i]); i++;
+ s2 += fixmul31(win[i], in[i]); i++;
+ s1 += fixmul31(win[i], in[i]); i++;
+ s2 += fixmul31(win[i], in[i]); i++;
+ /* 40..47 */
+ s1 += fixmul31(win[i], in[i]); i++;
+ s2 += fixmul31(win[i], in[i]); i++;
+ s1 += fixmul31(win[i], in[i]); i++;
+ s2 += fixmul31(win[i], in[i]); i++;
+ s1 += fixmul31(win[i], in[i]); i++;
+ s2 += fixmul31(win[i], in[i]); i++;
+ s1 += fixmul31(win[i], in[i]); i++;
+ s2 += fixmul31(win[i], in[i]);
+
out[0] = s2;
out[1] = s1;

@@ -313,8 +374,8 @@
* @param pOut decoded band spectrum
* @return outSubbands subband counter, fix for broken specification/files
*/
-
-static int decodeSpectrum (GetBitContext *gb, int32_t *pOut)
+int decodeSpectrum (GetBitContext *gb, int32_t *pOut) ICODE_ATTR;
+int decodeSpectrum (GetBitContext *gb, int32_t *pOut)
{
int numSubbands, codingMode, cnt, first, last, subbWidth, *pIn;
int subband_vlc_index[32], SF_idxs[32];