1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
Index: apps/codecs/libatrac/atrac3data.h
===================================================================
--- apps/codecs/libatrac/atrac3data.h  (revision 24645)
+++ apps/codecs/libatrac/atrac3data.h  (working copy)
@@ -32,63 +32,63 @@

 /* VLC tables */

-static const uint8_t huffcode1[9] = {
+static const uint8_t huffcode1[9] ICONST_ATTR = {
   0x0,0x4,0x5,0xC,0xD,0x1C,0x1D,0x1E,0x1F,
 };

-static const uint8_t huffbits1[9] = {
+static const uint8_t huffbits1[9] ICONST_ATTR = {
   1,3,3,4,4,5,5,5,5,
 };

-static const uint8_t huffcode2[5] = {
+static const uint8_t huffcode2[5] ICONST_ATTR = {
   0x0,0x4,0x5,0x6,0x7,
 };

-static const uint8_t huffbits2[5] = {
+static const uint8_t huffbits2[5] ICONST_ATTR = {
   1,3,3,3,3,
 };

-static const uint8_t huffcode3[7] = {
+static const uint8_t huffcode3[7] ICONST_ATTR = {
 0x0,0x4,0x5,0xC,0xD,0xE,0xF,
 };

-static const uint8_t huffbits3[7] = {
+static const uint8_t huffbits3[7] ICONST_ATTR = {
   1,3,3,4,4,4,4,
 };

-static const uint8_t huffcode4[9] = {
+static const uint8_t huffcode4[9] ICONST_ATTR = {
   0x0,0x4,0x5,0xC,0xD,0x1C,0x1D,0x1E,0x1F,
 };

-static const uint8_t huffbits4[9] = {
+static const uint8_t huffbits4[9] ICONST_ATTR = {
   1,3,3,4,4,5,5,5,5,
 };

-static const uint8_t huffcode5[15] = {
+static const uint8_t huffcode5[15] ICONST_ATTR = {
   0x0,0x2,0x3,0x8,0x9,0xA,0xB,0x1C,0x1D,0x3C,0x3D,0x3E,0x3F,0xC,0xD,
 };

-static const uint8_t huffbits5[15] = {
+static const uint8_t huffbits5[15] ICONST_ATTR = {
   2,3,3,4,4,4,4,5,5,6,6,6,6,4,4
 };

-static const uint8_t huffcode6[31] = {
+static const uint8_t huffcode6[31] ICONST_ATTR = {
   0x0,0x2,0x3,0x4,0x5,0x6,0x7,0x14,0x15,0x16,0x17,0x18,0x19,0x34,0x35,
   0x36,0x37,0x38,0x39,0x3A,0x3B,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,0x8,0x9,
 };

-static const uint8_t huffbits6[31] = {
+static const uint8_t huffbits6[31] ICONST_ATTR  = {
   3,4,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,4,4
 };

-static const uint8_t huffcode7[63] = {
+static const uint8_t huffcode7[63] ICONST_ATTR = {
   0x0,0x8,0x9,0xA,0xB,0xC,0xD,0xE,0xF,0x10,0x11,0x24,0x25,0x26,0x27,0x28,
   0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x68,0x69,0x6A,0x6B,0x6C,
   0x6D,0x6E,0x6F,0x70,0x71,0x72,0x73,0x74,0x75,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,
   0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF,0x2,0x3,
 };

-static const uint8_t huffbits7[63] = {
+static const uint8_t huffbits7[63] ICONST_ATTR = {
   3,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,
   7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,4,4
 };
@@ -111,24 +111,24 @@

 /* selector tables */

-static const uint8_t CLCLengthTab[8] = {0, 4, 3, 3, 4, 4, 5, 6};
-static const int8_t seTab_0[4] = {0, 1, -2, -1};
-static const int8_t decTable1[18] = {0,0, 0,1, 0,-1, 1,0, -1,0, 1,1, 1,-1, -1,1, -1,-1};
+static const uint8_t CLCLengthTab[8] ICONST_ATTR = {0, 4, 3, 3, 4, 4, 5, 6};
+static const int8_t seTab_0[4]       ICONST_ATTR = {0, 1, -2, -1};
+static const int8_t decTable1[18]    ICONST_ATTR = {0,0, 0,1, 0,-1, 1,0, -1,0, 1,1, 1,-1, -1,1, -1,-1};


 /* 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
 };

 /* transform data */
-
+/* not needed anymore
 static const float qmf_48tap_half[24] = {
    -0.00001461907, -0.00009205479, -0.000056157569, 0.00030117269,
     0.0002422519,-0.00085293897, -0.0005205574, 0.0020340169,
@@ -137,8 +137,9 @@
    -0.007801671, -0.034090221, 0.01880949, 0.054326009,
    -0.043596379, -0.099384367, 0.13207909, 0.46424159
 };
-
+*/
 /* joint stereo related tables */
+/* not needed anymore
 static const float matrixCoeffs[8] = {0.0, 2.0, 2.0, 2.0, 0.0, 0.0, 1.0, 1.0};
-
+*/
 #endif /* AVCODEC_ATRAC3DATA_H */
Index: apps/codecs/libatrac/atrac3.c
===================================================================
--- apps/codecs/libatrac/atrac3.c  (revision 24645)
+++ apps/codecs/libatrac/atrac3.c  (working copy)
@@ -98,6 +98,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 +130,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;