summaryrefslogtreecommitdiff
path: root/apps/codecs/Tremor/mapping0.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/Tremor/mapping0.c')
-rw-r--r--apps/codecs/Tremor/mapping0.c90
1 files changed, 67 insertions, 23 deletions
diff --git a/apps/codecs/Tremor/mapping0.c b/apps/codecs/Tremor/mapping0.c
index d4ab3a6a29..26d6289d4e 100644
--- a/apps/codecs/Tremor/mapping0.c
+++ b/apps/codecs/Tremor/mapping0.c
@@ -28,6 +28,8 @@
28#include "registry.h" 28#include "registry.h"
29#include "misc.h" 29#include "misc.h"
30 30
31
32
31/* simplistic, wasteful way of doing this (unique lookup for each 33/* simplistic, wasteful way of doing this (unique lookup for each
32 mode/submapping); there should be a central repository for 34 mode/submapping); there should be a central repository for
33 identical lookups. That will require minor work, so I'm putting it 35 identical lookups. That will require minor work, so I'm putting it
@@ -124,6 +126,7 @@ static int ilog(unsigned int v){
124 return(ret); 126 return(ret);
125} 127}
126 128
129
127/* also responsible for range checking */ 130/* also responsible for range checking */
128static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb){ 131static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb){
129 int i; 132 int i;
@@ -176,7 +179,17 @@ static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb)
176 return(NULL); 179 return(NULL);
177} 180}
178 181
179static int seq=0; 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;
190
191#define CHANNELS 2 /* max 2 channels on the ihp-1xx (stereo) */
192
180static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){ 193static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
181 vorbis_dsp_state *vd=vb->vd; 194 vorbis_dsp_state *vd=vb->vd;
182 vorbis_info *vi=vd->vi; 195 vorbis_info *vi=vd->vi;
@@ -188,12 +201,16 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
188 int i,j; 201 int i,j;
189 long n=vb->pcmend=ci->blocksizes[vb->W]; 202 long n=vb->pcmend=ci->blocksizes[vb->W];
190 203
191 ogg_int32_t **pcmbundle=(ogg_int32_t **)alloca(sizeof(*pcmbundle)*vi->channels); 204 /* statically allocate mapping structures in IRAM */
192 int *zerobundle=(int *)alloca(sizeof(*zerobundle)*vi->channels); 205 static ogg_int32_t *pcmbundle[CHANNELS] IDATA_ATTR;
193 206 static int zerobundle[CHANNELS] IDATA_ATTR;
194 int *nonzero =(int *)alloca(sizeof(*nonzero)*vi->channels); 207 static int nonzero[CHANNELS] IDATA_ATTR;
195 void **floormemo=(void **)alloca(sizeof(*floormemo)*vi->channels); 208 static void *floormemo[CHANNELS] IDATA_ATTR;
196 209
210 /* test for too many channels;
211 (maybe this is can be checked at the stream level?) */
212 if (vi->channels > CHANNELS) return (-1);
213
197 /* time domain information decode (note that applying the 214 /* time domain information decode (note that applying the
198 information would have to happen later; we'll probably add a 215 information would have to happen later; we'll probably add a
199 function entry to the harness for that later */ 216 function entry to the harness for that later */
@@ -272,38 +289,64 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
272 //for(j=0;j<vi->channels;j++) 289 //for(j=0;j<vi->channels;j++)
273 //_analysis_output("residue",seq+j,vb->pcm[j],-8,n/2,0,0); 290 //_analysis_output("residue",seq+j,vb->pcm[j],-8,n/2,0,0);
274 291
292
293/* pbv: removed this loop by fusion with the following one
294 to avoid recopying data to/from the IRAM */
295#if 0
275 /* compute and apply spectral envelope */ 296 /* compute and apply spectral envelope */
276 for(i=0;i<vi->channels;i++){ 297 for(i=0;i<vi->channels;i++){
277 ogg_int32_t *pcm=vb->pcm[i]; 298 ogg_int32_t *pcm=vb->pcm[i];
278 int submap=info->chmuxlist[i]; 299 int submap=info->chmuxlist[i];
279 look->floor_func[submap]-> 300 look->floor_func[submap]->
280 inverse2(vb,look->floor_look[submap],floormemo[i],pcm); 301 inverse2(vb,look->floor_look[submap],floormemo[i],pcm);
281 } 302 }
303#endif
282 304
283 //for(j=0;j<vi->channels;j++) 305 //for(j=0;j<vi->channels;j++)
284 //_analysis_output("mdct",seq+j,vb->pcm[j],-24,n/2,0,1); 306 //_analysis_output("mdct",seq+j,vb->pcm[j],-24,n/2,0,1);
285 307
286 /* transform the PCM data; takes PCM vector, vb; modifies PCM vector */ 308 /* transform the PCM data; takes PCM vector, vb; modifies PCM vector */
287 /* only MDCT right now.... */ 309 /* only MDCT right now.... */
288 for(i=0;i<vi->channels;i++){ 310
289 ogg_int32_t *pcm=vb->pcm[i]; 311 /* check if we can do this in IRAM */
290 mdct_backward(n,pcm,pcm); 312 if(n <= IRAM_PCM_SIZE) { /* normal window size: yes */
313 for(i=0;i<vi->channels;i++){
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]) {
338 mdct_backward(n, pcm, pcm);
339 /* window the data */
340 _vorbis_apply_window(pcm,b->window,ci->blocksizes,vb->lW,vb->W,vb->nW);
341 }
342 else
343 memset(pcm, 0, sizeof(ogg_int32_t)*n);
344 }
291 } 345 }
292 346
293 //for(j=0;j<vi->channels;j++) 347 //for(j=0;j<vi->channels;j++)
294 //_analysis_output("imdct",seq+j,vb->pcm[j],-24,n,0,0); 348 //_analysis_output("imdct",seq+j,vb->pcm[j],-24,n,0,0);
295 349
296 /* window the data */
297 for(i=0;i<vi->channels;i++){
298 ogg_int32_t *pcm=vb->pcm[i];
299 if(nonzero[i])
300 _vorbis_apply_window(pcm,b->window,ci->blocksizes,vb->lW,vb->W,vb->nW);
301 else
302 for(j=0;j<n;j++)
303 pcm[j]=0;
304
305 }
306
307 //for(j=0;j<vi->channels;j++) 350 //for(j=0;j<vi->channels;j++)
308 //_analysis_output("window",seq+j,vb->pcm[j],-24,n,0,0); 351 //_analysis_output("window",seq+j,vb->pcm[j],-24,n,0,0);
309 352
@@ -313,10 +356,11 @@ static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
313} 356}
314 357
315/* export hooks */ 358/* export hooks */
316vorbis_func_mapping mapping0_exportbundle={ 359vorbis_func_mapping mapping0_exportbundle ={
317 &mapping0_unpack, 360 &mapping0_unpack,
318 &mapping0_look, 361 &mapping0_look,
319 &mapping0_free_info, 362 &mapping0_free_info,
320 &mapping0_free_look, 363 &mapping0_free_look,
321 &mapping0_inverse 364 &mapping0_inverse
322}; 365};
366