summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/codecs/Tremor/asm_mcf5249.h44
-rw-r--r--apps/codecs/Tremor/bitwise.c2
-rw-r--r--apps/codecs/Tremor/codebook.c13
-rw-r--r--apps/codecs/Tremor/floor1.c19
-rw-r--r--apps/codecs/Tremor/framing.c2
-rw-r--r--apps/codecs/Tremor/mapping0.c55
-rw-r--r--apps/codecs/Tremor/mdct.c72
-rw-r--r--apps/codecs/Tremor/mdct_lookup.h2
-rw-r--r--apps/codecs/Tremor/res012.c4
-rw-r--r--apps/codecs/Tremor/synthesis.c27
-rw-r--r--apps/codecs/Tremor/window_lookup.h2
11 files changed, 110 insertions, 132 deletions
diff --git a/apps/codecs/Tremor/asm_mcf5249.h b/apps/codecs/Tremor/asm_mcf5249.h
index 09c74671bc..933d6bb1fc 100644
--- a/apps/codecs/Tremor/asm_mcf5249.h
+++ b/apps/codecs/Tremor/asm_mcf5249.h
@@ -49,13 +49,12 @@ static inline ogg_int32_t MULT32(ogg_int32_t x, ogg_int32_t y) {
49} 49}
50 50
51static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) { 51static inline ogg_int32_t MULT31(ogg_int32_t x, ogg_int32_t y) {
52 ogg_int32_t r;
53 asm volatile ("mac.l %[x], %[y], %%acc0;" // multiply 52 asm volatile ("mac.l %[x], %[y], %%acc0;" // multiply
54 "movclr.l %%acc0, %[r];" // move and clear 53 "movclr.l %%acc0, %[x];" // move and clear
55 : [r] "=r" (r) 54 : [x] "+&r" (x)
56 : [x] "r" (x), [y] "r" (y) 55 : [y] "r" (y)
57 : "cc"); 56 : "cc");
58 return r; 57 return x;
59} 58}
60 59
61 60
@@ -64,11 +63,11 @@ static inline ogg_int32_t MULT31_SHIFT15(ogg_int32_t x, ogg_int32_t y) {
64 asm volatile ("mac.l %[x], %[y], %%acc0;" // multiply 63 asm volatile ("mac.l %[x], %[y], %%acc0;" // multiply
65 "movclr.l %%acc0, %[r];" // get higher half 64 "movclr.l %%acc0, %[r];" // get higher half
66 "mulu.l %[y], %[x];" // get lower half 65 "mulu.l %[y], %[x];" // get lower half
67 "asl.l #8, %[r];" // hi << 17 66 "asl.l #8, %[r];" // hi << 17
68 "asl.l #8, %[r];" 67 "asl.l #8, %[r];"
69 "lsr.l #8, %[x];" // (unsigned)lo >> 15 68 "lsr.l #8, %[x];" // (unsigned)lo >> 15
70 "lsr.l #7, %[x];" 69 "lsr.l #7, %[x];"
71 "or.l %[x], %[r];" // or 70 "or.l %[x], %[r];" // or
72 : [r] "=&d" (r), [x] "+d" (x) 71 : [r] "=&d" (r), [x] "+d" (x)
73 : [y] "d" (y) 72 : [y] "d" (y)
74 : "cc"); 73 : "cc");
@@ -81,18 +80,17 @@ void XPROD31(ogg_int32_t a, ogg_int32_t b,
81 ogg_int32_t t, ogg_int32_t v, 80 ogg_int32_t t, ogg_int32_t v,
82 ogg_int32_t *x, ogg_int32_t *y) 81 ogg_int32_t *x, ogg_int32_t *y)
83{ 82{
84 ogg_int32_t r;
85 asm volatile ("mac.l %[a], %[t], %%acc0;" 83 asm volatile ("mac.l %[a], %[t], %%acc0;"
86 "mac.l %[b], %[v], %%acc0;" 84 "mac.l %[b], %[v], %%acc0;"
87 "mac.l %[b], %[t], %%acc1;" 85 "mac.l %[b], %[t], %%acc1;"
88 "msac.l %[a], %[v], %%acc1;" 86 "msac.l %[a], %[v], %%acc1;"
89 "movclr.l %%acc0, %[r];" 87 "movclr.l %%acc0, %[a];"
90 "move.l %[r], (%[x]);" 88 "move.l %[a], (%[x]);"
91 "movclr.l %%acc1, %[r];" 89 "movclr.l %%acc1, %[a];"
92 "move.l %[r], (%[y]);" 90 "move.l %[a], (%[y]);"
93 : [r] "=&r" (r) 91 : [a] "+&r" (a)
94 : [x] "a" (x), [y] "a" (y), 92 : [x] "a" (x), [y] "a" (y),
95 [a] "r" (a), [b] "r" (b), [t] "r" (t), [v] "r" (v) 93 [b] "r" (b), [t] "r" (t), [v] "r" (v)
96 : "cc", "memory"); 94 : "cc", "memory");
97} 95}
98 96
@@ -102,23 +100,23 @@ void XNPROD31(ogg_int32_t a, ogg_int32_t b,
102 ogg_int32_t t, ogg_int32_t v, 100 ogg_int32_t t, ogg_int32_t v,
103 ogg_int32_t *x, ogg_int32_t *y) 101 ogg_int32_t *x, ogg_int32_t *y)
104{ 102{
105 ogg_int32_t r;
106 asm volatile ("mac.l %[a], %[t], %%acc0;" 103 asm volatile ("mac.l %[a], %[t], %%acc0;"
107 "msac.l %[b], %[v], %%acc0;" 104 "msac.l %[b], %[v], %%acc0;"
108 "mac.l %[b], %[t], %%acc1;" 105 "mac.l %[b], %[t], %%acc1;"
109 "mac.l %[a], %[v], %%acc1;" 106 "mac.l %[a], %[v], %%acc1;"
110 "movclr.l %%acc0, %[r];" 107 "movclr.l %%acc0, %[a];"
111 "move.l %[r], (%[x]);" 108 "move.l %[a], (%[x]);"
112 "movclr.l %%acc1, %[r];" 109 "movclr.l %%acc1, %[a];"
113 "move.l %[r], (%[y]);" 110 "move.l %[a], (%[y]);"
114 : [r] "=&r" (r) 111 : [a] "+&r" (a)
115 : [x] "a" (x), [y] "a" (y), 112 : [x] "a" (x), [y] "a" (y),
116 [a] "r" (a), [b] "r" (b), [t] "r" (t), [v] "r" (v) 113 [b] "r" (b), [t] "r" (t), [v] "r" (v)
117 : "cc", "memory"); 114 : "cc", "memory");
118} 115}
119 116
120 117
121/* no faster way of doing this using the MAC? */ 118
119/* is there no better way of doing this using the MAC? */
122#define XPROD32(_a, _b, _t, _v, _x, _y) \ 120#define XPROD32(_a, _b, _t, _v, _x, _y) \
123 { (_x)=MULT32(_a,_t)+MULT32(_b,_v); \ 121 { (_x)=MULT32(_a,_t)+MULT32(_b,_v); \
124 (_y)=MULT32(_b,_t)-MULT32(_a,_v); } 122 (_y)=MULT32(_b,_t)-MULT32(_a,_v); }
diff --git a/apps/codecs/Tremor/bitwise.c b/apps/codecs/Tremor/bitwise.c
index fa9dcd6eff..bf8c7ec163 100644
--- a/apps/codecs/Tremor/bitwise.c
+++ b/apps/codecs/Tremor/bitwise.c
@@ -22,7 +22,7 @@
22#include <string.h> 22#include <string.h>
23#include "ogg.h" 23#include "ogg.h"
24 24
25static const unsigned long mask[] IDATA_ATTR = 25static const unsigned long mask[] =
26{0x00000000,0x00000001,0x00000003,0x00000007,0x0000000f, 26{0x00000000,0x00000001,0x00000003,0x00000007,0x0000000f,
27 0x0000001f,0x0000003f,0x0000007f,0x000000ff,0x000001ff, 27 0x0000001f,0x0000003f,0x0000007f,0x000000ff,0x000001ff,
28 0x000003ff,0x000007ff,0x00000fff,0x00001fff,0x00003fff, 28 0x000003ff,0x000007ff,0x00000fff,0x00001fff,0x00003fff,
diff --git a/apps/codecs/Tremor/codebook.c b/apps/codecs/Tremor/codebook.c
index 4da7641553..f03b5efb04 100644
--- a/apps/codecs/Tremor/codebook.c
+++ b/apps/codecs/Tremor/codebook.c
@@ -140,7 +140,7 @@ int vorbis_staticbook_unpack(oggpack_buffer *opb,static_codebook *s){
140 be. The first-stage decode table catches most words so that 140 be. The first-stage decode table catches most words so that
141 bitreverse is not in the main execution path. */ 141 bitreverse is not in the main execution path. */
142 142
143static ogg_uint32_t bitreverse(ogg_uint32_t x){ 143static inline ogg_uint32_t bitreverse(register ogg_uint32_t x){
144 x= ((x>>16)&0x0000ffff) | ((x<<16)&0xffff0000); 144 x= ((x>>16)&0x0000ffff) | ((x<<16)&0xffff0000);
145 x= ((x>> 8)&0x00ff00ff) | ((x<< 8)&0xff00ff00); 145 x= ((x>> 8)&0x00ff00ff) | ((x<< 8)&0xff00ff00);
146 x= ((x>> 4)&0x0f0f0f0f) | ((x<< 4)&0xf0f0f0f0); 146 x= ((x>> 4)&0x0f0f0f0f) | ((x<< 4)&0xf0f0f0f0);
@@ -265,12 +265,13 @@ long vorbis_book_decodev_add(codebook *book,ogg_int32_t *a,
265 a[i++]+=t[j++]>>shift; 265 a[i++]+=t[j++]>>shift;
266 } 266 }
267 }else{ 267 }else{
268 shift = -shift;
268 for(i=0;i<n;){ 269 for(i=0;i<n;){
269 entry = decode_packed_entry_number(book,b); 270 entry = decode_packed_entry_number(book,b);
270 if(entry==-1)return(-1); 271 if(entry==-1)return(-1);
271 t = book->valuelist+entry*book->dim; 272 t = book->valuelist+entry*book->dim;
272 for (j=0;j<book->dim;) 273 for (j=0;j<book->dim;)
273 a[i++]+=t[j++]<<-shift; 274 a[i++]+=t[j++]<<shift;
274 } 275 }
275 } 276 }
276 return(0); 277 return(0);
@@ -293,13 +294,13 @@ long vorbis_book_decodev_set(codebook *book,ogg_int32_t *a,
293 } 294 }
294 } 295 }
295 }else{ 296 }else{
296 297 shift = -shift;
297 for(i=0;i<n;){ 298 for(i=0;i<n;){
298 entry = decode_packed_entry_number(book,b); 299 entry = decode_packed_entry_number(book,b);
299 if(entry==-1)return(-1); 300 if(entry==-1)return(-1);
300 t = book->valuelist+entry*book->dim; 301 t = book->valuelist+entry*book->dim;
301 for (j=0;j<book->dim;){ 302 for (j=0;j<book->dim;){
302 a[i++]=t[j++]<<-shift; 303 a[i++]=t[j++]<<shift;
303 } 304 }
304 } 305 }
305 } 306 }
@@ -330,14 +331,14 @@ long vorbis_book_decodevv_add(codebook *book,ogg_int32_t **a,
330 } 331 }
331 } 332 }
332 }else{ 333 }else{
333 334 shift = -shift;
334 for(i=offset;i<offset+n;){ 335 for(i=offset;i<offset+n;){
335 entry = decode_packed_entry_number(book,b); 336 entry = decode_packed_entry_number(book,b);
336 if(entry==-1)return(-1); 337 if(entry==-1)return(-1);
337 { 338 {
338 const ogg_int32_t *t = book->valuelist+entry*book->dim; 339 const ogg_int32_t *t = book->valuelist+entry*book->dim;
339 for (j=0;j<book->dim;j++){ 340 for (j=0;j<book->dim;j++){
340 a[chptr++][i]+=t[j]<<-shift; 341 a[chptr++][i]+=t[j]<<shift;
341 if(chptr==ch){ 342 if(chptr==ch){
342 chptr=0; 343 chptr=0;
343 i++; 344 i++;
diff --git a/apps/codecs/Tremor/floor1.c b/apps/codecs/Tremor/floor1.c
index 7f54aa76ea..9632dee9b0 100644
--- a/apps/codecs/Tremor/floor1.c
+++ b/apps/codecs/Tremor/floor1.c
@@ -45,7 +45,7 @@ typedef struct {
45static void floor1_free_info(vorbis_info_floor *i){ 45static void floor1_free_info(vorbis_info_floor *i){
46 vorbis_info_floor1 *info=(vorbis_info_floor1 *)i; 46 vorbis_info_floor1 *info=(vorbis_info_floor1 *)i;
47 if(info){ 47 if(info){
48 memset(info,0,sizeof(*info)); 48 //memset(info,0,sizeof(*info));
49 _ogg_free(info); 49 _ogg_free(info);
50 } 50 }
51} 51}
@@ -53,13 +53,13 @@ static void floor1_free_info(vorbis_info_floor *i){
53static void floor1_free_look(vorbis_look_floor *i){ 53static void floor1_free_look(vorbis_look_floor *i){
54 vorbis_look_floor1 *look=(vorbis_look_floor1 *)i; 54 vorbis_look_floor1 *look=(vorbis_look_floor1 *)i;
55 if(look){ 55 if(look){
56 memset(look,0,sizeof(*look)); 56 //memset(look,0,sizeof(*look));
57 _ogg_free(look); 57 _ogg_free(look);
58 } 58 }
59} 59}
60 60
61static int ilog(unsigned int v){ 61static inline int ilog(register unsigned int v){
62 int ret=0; 62 register int ret=0;
63 while(v){ 63 while(v){
64 ret++; 64 ret++;
65 v>>=1; 65 v>>=1;
@@ -124,7 +124,7 @@ static int icomp(const void *a,const void *b){
124static vorbis_look_floor *floor1_look(vorbis_dsp_state *vd,vorbis_info_mode *mi, 124static vorbis_look_floor *floor1_look(vorbis_dsp_state *vd,vorbis_info_mode *mi,
125 vorbis_info_floor *in){ 125 vorbis_info_floor *in){
126 126
127 static int *sortpointer[VIF_POSIT+2] IDATA_ATTR; 127 int *sortpointer[VIF_POSIT+2];
128 vorbis_info_floor1 *info=(vorbis_info_floor1 *)in; 128 vorbis_info_floor1 *info=(vorbis_info_floor1 *)in;
129 vorbis_look_floor1 *look=(vorbis_look_floor1 *)_ogg_calloc(1,sizeof(*look)); 129 vorbis_look_floor1 *look=(vorbis_look_floor1 *)_ogg_calloc(1,sizeof(*look));
130 int i,j,n=0; 130 int i,j,n=0;
@@ -216,7 +216,7 @@ static int render_point(int x0,int x1,int y0,int y1,int x){
216# define XdB(n) (n) 216# define XdB(n) (n)
217#endif 217#endif
218 218
219static ogg_int32_t FLOOR_fromdB_LOOKUP[256] IDATA_ATTR ={ 219static ogg_int32_t FLOOR_fromdB_LOOKUP[256] ={
220 XdB(0x000000e5), XdB(0x000000f4), XdB(0x00000103), XdB(0x00000114), 220 XdB(0x000000e5), XdB(0x000000f4), XdB(0x00000103), XdB(0x00000114),
221 XdB(0x00000126), XdB(0x00000139), XdB(0x0000014e), XdB(0x00000163), 221 XdB(0x00000126), XdB(0x00000139), XdB(0x0000014e), XdB(0x00000163),
222 XdB(0x0000017a), XdB(0x00000193), XdB(0x000001ad), XdB(0x000001c9), 222 XdB(0x0000017a), XdB(0x00000193), XdB(0x000001ad), XdB(0x000001c9),
@@ -313,16 +313,15 @@ static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in){
313 vorbis_look_floor1 *look=(vorbis_look_floor1 *)in; 313 vorbis_look_floor1 *look=(vorbis_look_floor1 *)in;
314 vorbis_info_floor1 *info=look->vi; 314 vorbis_info_floor1 *info=look->vi;
315 codec_setup_info *ci=(codec_setup_info *)vb->vd->vi->codec_setup; 315 codec_setup_info *ci=(codec_setup_info *)vb->vd->vi->codec_setup;
316
317 int i,j,k; 316 int i,j,k;
318 codebook *books=ci->fullbooks; 317 codebook *books=ci->fullbooks;
319 318
320 /* unpack wrapped/predicted values from stream */ 319 /* unpack wrapped/predicted values from stream */
321 if(oggpack_read(&vb->opb,1)==1){ 320 if(oggpack_read(&vb->opb,1)==1){
322 int *fit_value=(int *)_vorbis_block_alloc(vb,(look->posts)*sizeof(*fit_value)); 321 int *fit_value=(int *)_vorbis_block_alloc(vb,(look->posts)*sizeof(*fit_value));
323 322 int ilg = ilog(look->quant_q-1);
324 fit_value[0]=oggpack_read(&vb->opb,ilog(look->quant_q-1)); 323 fit_value[0]=oggpack_read(&vb->opb,ilg);
325 fit_value[1]=oggpack_read(&vb->opb,ilog(look->quant_q-1)); 324 fit_value[1]=oggpack_read(&vb->opb,ilg);
326 325
327 /* partition by partition */ 326 /* partition by partition */
328 /* partition by partition */ 327 /* partition by partition */
diff --git a/apps/codecs/Tremor/framing.c b/apps/codecs/Tremor/framing.c
index 9133333bda..7358986946 100644
--- a/apps/codecs/Tremor/framing.c
+++ b/apps/codecs/Tremor/framing.c
@@ -501,7 +501,7 @@ int ogg_page_packets(ogg_page *og){
501/* Static CRC calculation table. See older code in CVS for dead 501/* Static CRC calculation table. See older code in CVS for dead
502 run-time initialization code. */ 502 run-time initialization code. */
503 503
504static ogg_uint32_t crc_lookup[256] IDATA_ATTR = { 504static ogg_uint32_t crc_lookup[256] = {
505 0x00000000,0x04c11db7,0x09823b6e,0x0d4326d9, 505 0x00000000,0x04c11db7,0x09823b6e,0x0d4326d9,
506 0x130476dc,0x17c56b6b,0x1a864db2,0x1e475005, 506 0x130476dc,0x17c56b6b,0x1a864db2,0x1e475005,
507 0x2608edb8,0x22c9f00f,0x2f8ad6d6,0x2b4bcb61, 507 0x2608edb8,0x22c9f00f,0x2f8ad6d6,0x2b4bcb61,
diff --git a/apps/codecs/Tremor/mapping0.c b/apps/codecs/Tremor/mapping0.c
index 26d6289d4e..c88f072706 100644
--- a/apps/codecs/Tremor/mapping0.c
+++ b/apps/codecs/Tremor/mapping0.c
@@ -180,12 +180,6 @@ static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb)
180} 180}
181 181
182 182
183/* IRAM buffer keep the pcm data; only for windows size upto 2048
184 for space restrictions. No real compromise, larger window sizes
185 are only used for very low quality settings (q<0?) */
186#define IRAM_PCM_SIZE 2048
187static ogg_int32_t pcm_iram[IRAM_PCM_SIZE] IDATA_ATTR;
188
189static int seq = 0; 183static int seq = 0;
190 184
191#define CHANNELS 2 /* max 2 channels on the ihp-1xx (stereo) */ 185#define CHANNELS 2 /* max 2 channels on the ihp-1xx (stereo) */
@@ -201,11 +195,12 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
201 int i,j; 195 int i,j;
202 long n=vb->pcmend=ci->blocksizes[vb->W]; 196 long n=vb->pcmend=ci->blocksizes[vb->W];
203 197
204 /* statically allocate mapping structures in IRAM */ 198 /* bounded mapping arrays instead of using alloca();
205 static ogg_int32_t *pcmbundle[CHANNELS] IDATA_ATTR; 199 avoids memory leak; we can only deal with stereo anyway */
206 static int zerobundle[CHANNELS] IDATA_ATTR; 200 ogg_int32_t *pcmbundle[CHANNELS];
207 static int nonzero[CHANNELS] IDATA_ATTR; 201 int zerobundle[CHANNELS];
208 static void *floormemo[CHANNELS] IDATA_ATTR; 202 int nonzero[CHANNELS];
203 void *floormemo[CHANNELS];
209 204
210 /* test for too many channels; 205 /* test for too many channels;
211 (maybe this is can be checked at the stream level?) */ 206 (maybe this is can be checked at the stream level?) */
@@ -249,7 +244,7 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
249 pcmbundle[ch_in_bundle++]=vb->pcm[j]; 244 pcmbundle[ch_in_bundle++]=vb->pcm[j];
250 } 245 }
251 } 246 }
252 247
253 look->residue_func[i]->inverse(vb,look->residue_look[i], 248 look->residue_func[i]->inverse(vb,look->residue_look[i],
254 pcmbundle,zerobundle,ch_in_bundle); 249 pcmbundle,zerobundle,ch_in_bundle);
255 } 250 }
@@ -286,13 +281,10 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
286 } 281 }
287 } 282 }
288 283
284
289 //for(j=0;j<vi->channels;j++) 285 //for(j=0;j<vi->channels;j++)
290 //_analysis_output("residue",seq+j,vb->pcm[j],-8,n/2,0,0); 286 //_analysis_output("residue",seq+j,vb->pcm[j],-8,n/2,0,0);
291 287
292
293/* pbv: removed this loop by fusion with the following one
294 to avoid recopying data to/from the IRAM */
295#if 0
296 /* compute and apply spectral envelope */ 288 /* compute and apply spectral envelope */
297 for(i=0;i<vi->channels;i++){ 289 for(i=0;i<vi->channels;i++){
298 ogg_int32_t *pcm=vb->pcm[i]; 290 ogg_int32_t *pcm=vb->pcm[i];
@@ -300,7 +292,6 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
300 look->floor_func[submap]-> 292 look->floor_func[submap]->
301 inverse2(vb,look->floor_look[submap],floormemo[i],pcm); 293 inverse2(vb,look->floor_look[submap],floormemo[i],pcm);
302 } 294 }
303#endif
304 295
305 //for(j=0;j<vi->channels;j++) 296 //for(j=0;j<vi->channels;j++)
306 //_analysis_output("mdct",seq+j,vb->pcm[j],-24,n/2,0,1); 297 //_analysis_output("mdct",seq+j,vb->pcm[j],-24,n/2,0,1);
@@ -308,32 +299,9 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
308 /* transform the PCM data; takes PCM vector, vb; modifies PCM vector */ 299 /* transform the PCM data; takes PCM vector, vb; modifies PCM vector */
309 /* only MDCT right now.... */ 300 /* only MDCT right now.... */
310 301
311 /* check if we can do this in IRAM */ 302 for(i=0;i<vi->channels;i++){
312 if(n <= IRAM_PCM_SIZE) { /* normal window size: yes */ 303 ogg_int32_t *pcm=vb->pcm[i];
313 for(i=0;i<vi->channels;i++){ 304
314 ogg_int32_t *pcm=vb->pcm[i];
315 int submap=info->chmuxlist[i];
316
317 if(nonzero[i]) {
318 memcpy(pcm_iram, pcm, sizeof(ogg_int32_t)*n);
319 look->floor_func[submap]->
320 inverse2(vb,look->floor_look[submap],floormemo[i],pcm_iram);
321 mdct_backward(n, pcm_iram, pcm_iram);
322 /* window the data */
323 _vorbis_apply_window(pcm_iram,b->window,ci->blocksizes,vb->lW,vb->W,vb->nW);
324 memcpy(pcm, pcm_iram, sizeof(ogg_int32_t)*n);
325 }
326 else
327 memset(pcm, 0, sizeof(ogg_int32_t)*n);
328 }
329 }
330 else { /* large window: no, do it in the normal memory */
331 for(i=0;i<vi->channels;i++){
332 ogg_int32_t *pcm=vb->pcm[i];
333 int submap=info->chmuxlist[i];
334
335 look->floor_func[submap]->
336 inverse2(vb,look->floor_look[submap],floormemo[i],pcm);
337 if(nonzero[i]) { 305 if(nonzero[i]) {
338 mdct_backward(n, pcm, pcm); 306 mdct_backward(n, pcm, pcm);
339 /* window the data */ 307 /* window the data */
@@ -341,7 +309,6 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
341 } 309 }
342 else 310 else
343 memset(pcm, 0, sizeof(ogg_int32_t)*n); 311 memset(pcm, 0, sizeof(ogg_int32_t)*n);
344 }
345 } 312 }
346 313
347 //for(j=0;j<vi->channels;j++) 314 //for(j=0;j<vi->channels;j++)
diff --git a/apps/codecs/Tremor/mdct.c b/apps/codecs/Tremor/mdct.c
index 2d2564f196..53d1ed4f0c 100644
--- a/apps/codecs/Tremor/mdct.c
+++ b/apps/codecs/Tremor/mdct.c
@@ -41,7 +41,6 @@
41 41
42/* 8 point butterfly (in place) */ 42/* 8 point butterfly (in place) */
43STIN void mdct_butterfly_8(DATA_TYPE *x){ 43STIN void mdct_butterfly_8(DATA_TYPE *x){
44
45 REG_TYPE r0 = x[4] + x[0]; 44 REG_TYPE r0 = x[4] + x[0];
46 REG_TYPE r1 = x[4] - x[0]; 45 REG_TYPE r1 = x[4] - x[0];
47 REG_TYPE r2 = x[5] + x[1]; 46 REG_TYPE r2 = x[5] + x[1];
@@ -144,88 +143,81 @@ STIN void mdct_butterfly_32(DATA_TYPE *x){
144 mdct_butterfly_16(x+16); 143 mdct_butterfly_16(x+16);
145} 144}
146 145
147/* N/stage point generic N stage butterfly (in place, 2 register) */ 146/* N/stage point generic N stage butterfly (in place, 4 register) */
148STIN void mdct_butterfly_generic(DATA_TYPE *x,int points,int step){ 147void mdct_butterfly_generic(DATA_TYPE *x,int points, int step){
149
150 LOOKUP_T *T = sincos_lookup0; 148 LOOKUP_T *T = sincos_lookup0;
151 DATA_TYPE *x1 = x + points - 8; 149 DATA_TYPE *x1 = x + points - 8;
152 DATA_TYPE *x2 = x + (points>>1) - 8; 150 DATA_TYPE *x2 = x + (points>>1) - 8;
153 REG_TYPE r0; 151 REG_TYPE r0;
154 REG_TYPE r1; 152 REG_TYPE r1;
153 REG_TYPE r2;
154 REG_TYPE r3;
155 155
156 do{ 156 do{
157 r0 = x1[6] - x2[6]; x1[6] += x2[6]; 157 r0 = x1[6] - x2[6]; x1[6] += x2[6];
158 r1 = x2[7] - x1[7]; x1[7] += x2[7]; 158 r1 = x2[7] - x1[7]; x1[7] += x2[7];
159 r2 = x1[4] - x2[4]; x1[4] += x2[4];
160 r3 = x2[5] - x1[5]; x1[5] += x2[5];
159 XPROD31( r1, r0, T[0], T[1], &x2[6], &x2[7] ); T+=step; 161 XPROD31( r1, r0, T[0], T[1], &x2[6], &x2[7] ); T+=step;
160 162 XPROD31( r3, r2, T[0], T[1], &x2[4], &x2[5] ); T+=step;
161 r0 = x1[4] - x2[4]; x1[4] += x2[4]; 163
162 r1 = x2[5] - x1[5]; x1[5] += x2[5];
163 XPROD31( r1, r0, T[0], T[1], &x2[4], &x2[5] ); T+=step;
164
165 r0 = x1[2] - x2[2]; x1[2] += x2[2]; 164 r0 = x1[2] - x2[2]; x1[2] += x2[2];
166 r1 = x2[3] - x1[3]; x1[3] += x2[3]; 165 r1 = x2[3] - x1[3]; x1[3] += x2[3];
166 r2 = x1[0] - x2[0]; x1[0] += x2[0];
167 r3 = x2[1] - x1[1]; x1[1] += x2[1];
167 XPROD31( r1, r0, T[0], T[1], &x2[2], &x2[3] ); T+=step; 168 XPROD31( r1, r0, T[0], T[1], &x2[2], &x2[3] ); T+=step;
168 169 XPROD31( r3, r2, T[0], T[1], &x2[0], &x2[1] ); T+=step;
169 r0 = x1[0] - x2[0]; x1[0] += x2[0]; 170
170 r1 = x2[1] - x1[1]; x1[1] += x2[1];
171 XPROD31( r1, r0, T[0], T[1], &x2[0], &x2[1] ); T+=step;
172
173 x1-=8; x2-=8; 171 x1-=8; x2-=8;
174 }while(T<sincos_lookup0+1024); 172 }while(T<sincos_lookup0+1024);
175 do{ 173 do{
176 r0 = x1[6] - x2[6]; x1[6] += x2[6]; 174 r0 = x1[6] - x2[6]; x1[6] += x2[6];
177 r1 = x1[7] - x2[7]; x1[7] += x2[7]; 175 r1 = x1[7] - x2[7]; x1[7] += x2[7];
176 r2 = x1[4] - x2[4]; x1[4] += x2[4];
177 r3 = x1[5] - x2[5]; x1[5] += x2[5];
178 XNPROD31( r0, r1, T[0], T[1], &x2[6], &x2[7] ); T-=step; 178 XNPROD31( r0, r1, T[0], T[1], &x2[6], &x2[7] ); T-=step;
179 XNPROD31( r2, r3, T[0], T[1], &x2[4], &x2[5] ); T-=step;
179 180
180 r0 = x1[4] - x2[4]; x1[4] += x2[4];
181 r1 = x1[5] - x2[5]; x1[5] += x2[5];
182 XNPROD31( r0, r1, T[0], T[1], &x2[4], &x2[5] ); T-=step;
183
184 r0 = x1[2] - x2[2]; x1[2] += x2[2]; 181 r0 = x1[2] - x2[2]; x1[2] += x2[2];
185 r1 = x1[3] - x2[3]; x1[3] += x2[3]; 182 r1 = x1[3] - x2[3]; x1[3] += x2[3];
183 r2 = x1[0] - x2[0]; x1[0] += x2[0];
184 r3 = x1[1] - x2[1]; x1[1] += x2[1];
186 XNPROD31( r0, r1, T[0], T[1], &x2[2], &x2[3] ); T-=step; 185 XNPROD31( r0, r1, T[0], T[1], &x2[2], &x2[3] ); T-=step;
187 186 XNPROD31( r2, r3, T[0], T[1], &x2[0], &x2[1] ); T-=step;
188 r0 = x1[0] - x2[0]; x1[0] += x2[0];
189 r1 = x1[1] - x2[1]; x1[1] += x2[1];
190 XNPROD31( r0, r1, T[0], T[1], &x2[0], &x2[1] ); T-=step;
191 187
192 x1-=8; x2-=8; 188 x1-=8; x2-=8;
193 }while(T>sincos_lookup0); 189 }while(T>sincos_lookup0);
194 do{ 190 do{
195 r0 = x2[6] - x1[6]; x1[6] += x2[6]; 191 r0 = x2[6] - x1[6]; x1[6] += x2[6];
196 r1 = x2[7] - x1[7]; x1[7] += x2[7]; 192 r1 = x2[7] - x1[7]; x1[7] += x2[7];
193 r2 = x2[4] - x1[4]; x1[4] += x2[4];
194 r3 = x2[5] - x1[5]; x1[5] += x2[5];
197 XPROD31( r0, r1, T[0], T[1], &x2[6], &x2[7] ); T+=step; 195 XPROD31( r0, r1, T[0], T[1], &x2[6], &x2[7] ); T+=step;
198 196 XPROD31( r2, r3, T[0], T[1], &x2[4], &x2[5] ); T+=step;
199 r0 = x2[4] - x1[4]; x1[4] += x2[4];
200 r1 = x2[5] - x1[5]; x1[5] += x2[5];
201 XPROD31( r0, r1, T[0], T[1], &x2[4], &x2[5] ); T+=step;
202 197
203 r0 = x2[2] - x1[2]; x1[2] += x2[2]; 198 r0 = x2[2] - x1[2]; x1[2] += x2[2];
204 r1 = x2[3] - x1[3]; x1[3] += x2[3]; 199 r1 = x2[3] - x1[3]; x1[3] += x2[3];
200 r2 = x2[0] - x1[0]; x1[0] += x2[0];
201 r3 = x2[1] - x1[1]; x1[1] += x2[1];
205 XPROD31( r0, r1, T[0], T[1], &x2[2], &x2[3] ); T+=step; 202 XPROD31( r0, r1, T[0], T[1], &x2[2], &x2[3] ); T+=step;
206 203 XPROD31( r2, r3, T[0], T[1], &x2[0], &x2[1] ); T+=step;
207 r0 = x2[0] - x1[0]; x1[0] += x2[0];
208 r1 = x2[1] - x1[1]; x1[1] += x2[1];
209 XPROD31( r0, r1, T[0], T[1], &x2[0], &x2[1] ); T+=step;
210 204
211 x1-=8; x2-=8; 205 x1-=8; x2-=8;
212 }while(T<sincos_lookup0+1024); 206 }while(T<sincos_lookup0+1024);
213 do{ 207 do{
214 r0 = x1[6] - x2[6]; x1[6] += x2[6]; 208 r0 = x1[6] - x2[6]; x1[6] += x2[6];
215 r1 = x2[7] - x1[7]; x1[7] += x2[7]; 209 r1 = x2[7] - x1[7]; x1[7] += x2[7];
210 r2 = x1[4] - x2[4]; x1[4] += x2[4];
211 r3 = x2[5] - x1[5]; x1[5] += x2[5];
216 XNPROD31( r1, r0, T[0], T[1], &x2[6], &x2[7] ); T-=step; 212 XNPROD31( r1, r0, T[0], T[1], &x2[6], &x2[7] ); T-=step;
217 213 XNPROD31( r3, r2, T[0], T[1], &x2[4], &x2[5] ); T-=step;
218 r0 = x1[4] - x2[4]; x1[4] += x2[4];
219 r1 = x2[5] - x1[5]; x1[5] += x2[5];
220 XNPROD31( r1, r0, T[0], T[1], &x2[4], &x2[5] ); T-=step;
221 214
222 r0 = x1[2] - x2[2]; x1[2] += x2[2]; 215 r0 = x1[2] - x2[2]; x1[2] += x2[2];
223 r1 = x2[3] - x1[3]; x1[3] += x2[3]; 216 r1 = x2[3] - x1[3]; x1[3] += x2[3];
217 r2 = x1[0] - x2[0]; x1[0] += x2[0];
218 r3 = x2[1] - x1[1]; x1[1] += x2[1];
224 XNPROD31( r1, r0, T[0], T[1], &x2[2], &x2[3] ); T-=step; 219 XNPROD31( r1, r0, T[0], T[1], &x2[2], &x2[3] ); T-=step;
225 220 XNPROD31( r3, r2, T[0], T[1], &x2[0], &x2[1] ); T-=step;
226 r0 = x1[0] - x2[0]; x1[0] += x2[0];
227 r1 = x2[1] - x1[1]; x1[1] += x2[1];
228 XNPROD31( r1, r0, T[0], T[1], &x2[0], &x2[1] ); T-=step;
229 221
230 x1-=8; x2-=8; 222 x1-=8; x2-=8;
231 }while(T>sincos_lookup0); 223 }while(T>sincos_lookup0);
@@ -246,8 +238,8 @@ STIN void mdct_butterflies(DATA_TYPE *x,int points,int shift) {
246} 238}
247 239
248 240
249static const unsigned char bitrev[16] 241static const unsigned char bitrev[16] IDATA_ATTR =
250 IDATA_ATTR = {0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15}; 242 {0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15};
251 243
252STIN int bitrev12(int x){ 244STIN int bitrev12(int x){
253 return bitrev[x>>8]|(bitrev[(x&0x0f0)>>4]<<4)|(((int)bitrev[x&0x00f])<<8); 245 return bitrev[x>>8]|(bitrev[(x&0x0f0)>>4]<<4)|(((int)bitrev[x&0x00f])<<8);
diff --git a/apps/codecs/Tremor/mdct_lookup.h b/apps/codecs/Tremor/mdct_lookup.h
index 8a88997376..63e0775ef7 100644
--- a/apps/codecs/Tremor/mdct_lookup.h
+++ b/apps/codecs/Tremor/mdct_lookup.h
@@ -281,7 +281,7 @@ static LOOKUP_T sincos_lookup0[1026] IDATA_ATTR = {
281 }; 281 };
282 282
283 /* {sin((2*i+1)*PI/4096), cos((2*i+1)*PI/4096)}, with i = 0 to 511 */ 283 /* {sin((2*i+1)*PI/4096), cos((2*i+1)*PI/4096)}, with i = 0 to 511 */
284static LOOKUP_T sincos_lookup1[1024] IDATA_ATTR = { 284static LOOKUP_T sincos_lookup1[1024] = {
285 X(0x001921fb), X(0x7ffffd88), X(0x004b65ee), X(0x7fffe9cb), 285 X(0x001921fb), X(0x7ffffd88), X(0x004b65ee), X(0x7fffe9cb),
286 X(0x007da9d4), X(0x7fffc251), X(0x00afeda8), X(0x7fff8719), 286 X(0x007da9d4), X(0x7fffc251), X(0x00afeda8), X(0x7fff8719),
287 X(0x00e23160), X(0x7fff3824), X(0x011474f6), X(0x7ffed572), 287 X(0x00e23160), X(0x7fff3824), X(0x011474f6), X(0x7ffed572),
diff --git a/apps/codecs/Tremor/res012.c b/apps/codecs/Tremor/res012.c
index 3d69cee73b..66947ffe7e 100644
--- a/apps/codecs/Tremor/res012.c
+++ b/apps/codecs/Tremor/res012.c
@@ -172,6 +172,7 @@ vorbis_look_residue *res0_look(vorbis_dsp_state *vd,vorbis_info_mode *vm,
172 return(look); 172 return(look);
173} 173}
174 174
175#define CHANNELS 2
175 176
176/* a truncated packet here just means 'stop working'; it's not an error */ 177/* a truncated packet here just means 'stop working'; it's not an error */
177static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl, 178static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl,
@@ -254,6 +255,8 @@ int res1_inverse(vorbis_block *vb,vorbis_look_residue *vl,
254 return(0); 255 return(0);
255} 256}
256 257
258
259
257/* duplicate code here as speed is somewhat more important */ 260/* duplicate code here as speed is somewhat more important */
258int res2_inverse(vorbis_block *vb,vorbis_look_residue *vl, 261int res2_inverse(vorbis_block *vb,vorbis_look_residue *vl,
259 ogg_int32_t **in,int *nonzero,int ch){ 262 ogg_int32_t **in,int *nonzero,int ch){
@@ -291,7 +294,6 @@ int res2_inverse(vorbis_block *vb,vorbis_look_residue *vl,
291 for(k=0;k<partitions_per_word && i<partvals;k++,i++) 294 for(k=0;k<partitions_per_word && i<partvals;k++,i++)
292 if(info->secondstages[partword[l][k]]&(1<<s)){ 295 if(info->secondstages[partword[l][k]]&(1<<s)){
293 codebook *stagebook=look->partbooks[partword[l][k]][s]; 296 codebook *stagebook=look->partbooks[partword[l][k]][s];
294
295 if(stagebook){ 297 if(stagebook){
296 if(vorbis_book_decodevv_add(stagebook,in, 298 if(vorbis_book_decodevv_add(stagebook,in,
297 i*samples_per_partition+beginoff,ch, 299 i*samples_per_partition+beginoff,ch,
diff --git a/apps/codecs/Tremor/synthesis.c b/apps/codecs/Tremor/synthesis.c
index 0b93fee0ac..35c09f8ddb 100644
--- a/apps/codecs/Tremor/synthesis.c
+++ b/apps/codecs/Tremor/synthesis.c
@@ -24,6 +24,17 @@
24#include "misc.h" 24#include "misc.h"
25#include "os.h" 25#include "os.h"
26 26
27
28/* IRAM buffer keep the block pcm data; only for windows size upto 2048
29 for space restrictions. No real compromise, larger window sizes
30 are only used for very low quality settings (q<0?) */
31/* max 2 channels on the ihp-1xx (stereo), 2048 samples (2*2048*4=16Kb) */
32#define IRAM_PCM_END 2048
33#define CHANNELS 2
34
35static ogg_int32_t *ipcm_vect[CHANNELS] IDATA_ATTR;
36static ogg_int32_t ipcm_buff[CHANNELS*IRAM_PCM_END] IDATA_ATTR;
37
27int vorbis_synthesis(vorbis_block *vb,ogg_packet *op,int decodep){ 38int vorbis_synthesis(vorbis_block *vb,ogg_packet *op,int decodep){
28 vorbis_dsp_state *vd=vb->vd; 39 vorbis_dsp_state *vd=vb->vd;
29 private_state *b=(private_state *)vd->backend_state; 40 private_state *b=(private_state *)vd->backend_state;
@@ -65,10 +76,18 @@ int vorbis_synthesis(vorbis_block *vb,ogg_packet *op,int decodep){
65 if(decodep){ 76 if(decodep){
66 /* alloc pcm passback storage */ 77 /* alloc pcm passback storage */
67 vb->pcmend=ci->blocksizes[vb->W]; 78 vb->pcmend=ci->blocksizes[vb->W];
68 vb->pcm=(ogg_int32_t **)_vorbis_block_alloc(vb,sizeof(*vb->pcm)*vi->channels); 79 if (vi->channels <= CHANNELS && vb->pcmend<=IRAM_PCM_END) {
69 for(i=0;i<vi->channels;i++) 80 /* use statically allocated iram buffer */
70 vb->pcm[i]=(ogg_int32_t *)_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i])); 81 vb->pcm = ipcm_vect;
71 82 for(i=0; i<CHANNELS; i++)
83 vb->pcm[i] = &ipcm_buff[i*IRAM_PCM_END];
84 } else {
85 /* dynamic allocation (slower) */
86 vb->pcm=(ogg_int32_t **)_vorbis_block_alloc(vb,sizeof(*vb->pcm)*vi->channels);
87 for(i=0;i<vi->channels;i++)
88 vb->pcm[i]=(ogg_int32_t *)_vorbis_block_alloc(vb,vb->pcmend*sizeof(*vb->pcm[i]));
89 }
90
72 /* unpack_header enforces range checking */ 91 /* unpack_header enforces range checking */
73 type=ci->map_type[ci->mode_param[mode]->mapping]; 92 type=ci->map_type[ci->mode_param[mode]->mapping];
74 93
diff --git a/apps/codecs/Tremor/window_lookup.h b/apps/codecs/Tremor/window_lookup.h
index f9452e1b42..fdc099b741 100644
--- a/apps/codecs/Tremor/window_lookup.h
+++ b/apps/codecs/Tremor/window_lookup.h
@@ -18,7 +18,7 @@
18 18
19#include "os_types.h" 19#include "os_types.h"
20 20
21/* keep small window table in fast IRAM */ 21/* keep small window tables in fast IRAM */
22static LOOKUP_T vwin64[32] IDATA_ATTR = { 22static LOOKUP_T vwin64[32] IDATA_ATTR = {
23 X(0x001f0003), X(0x01168c98), X(0x030333c8), X(0x05dfe3a4), 23 X(0x001f0003), X(0x01168c98), X(0x030333c8), X(0x05dfe3a4),
24 X(0x09a49562), X(0x0e45df18), X(0x13b47ef2), X(0x19dcf676), 24 X(0x09a49562), X(0x0e45df18), X(0x13b47ef2), X(0x19dcf676),