Bringing rc2 (minus the modes it needs) onto mainline.
[platform/upstream/libvorbis.git] / lib / mapping0.c
1 /********************************************************************
2  *                                                                  *
3  * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
4  * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
5  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
7  *                                                                  *
8  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001             *
9  * by the XIPHOPHORUS Company http://www.xiph.org/                  *
10  *                                                                  *
11  ********************************************************************
12
13  function: channel mapping 0 implementation
14  last mod: $Id: mapping0.c,v 1.34 2001/08/13 01:36:57 xiphmont Exp $
15
16  ********************************************************************/
17
18 #include <stdlib.h>
19 #include <stdio.h>
20 #include <string.h>
21 #include <math.h>
22 #include <ogg/ogg.h>
23 #include "vorbis/codec.h"
24 #include "codec_internal.h"
25 #include "codebook.h"
26 #include "bitbuffer.h"
27 #include "registry.h"
28 #include "psy.h"
29 #include "misc.h"
30
31 /* simplistic, wasteful way of doing this (unique lookup for each
32    mode/submapping); there should be a central repository for
33    identical lookups.  That will require minor work, so I'm putting it
34    off as low priority.
35
36    Why a lookup for each backend in a given mode?  Because the
37    blocksize is set by the mode, and low backend lookups may require
38    parameters from other areas of the mode/mapping */
39
40 extern int analysis_noisy;
41
42 typedef struct {
43   drft_lookup fft_look;
44   vorbis_info_mode *mode;
45   vorbis_info_mapping0 *map;
46
47   vorbis_look_time **time_look;
48   vorbis_look_floor **floor_look;
49
50   vorbis_look_residue **residue_look;
51   vorbis_look_psy *psy_look[2];
52
53   vorbis_func_time **time_func;
54   vorbis_func_floor **floor_func;
55   vorbis_func_residue **residue_func;
56
57   int ch;
58   long lastframe; /* if a different mode is called, we need to 
59                      invalidate decay */
60 } vorbis_look_mapping0;
61
62 static vorbis_info_mapping *mapping0_copy_info(vorbis_info_mapping *vm){
63   vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)vm;
64   vorbis_info_mapping0 *ret=_ogg_malloc(sizeof(vorbis_info_mapping0));
65   memcpy(ret,info,sizeof(vorbis_info_mapping0));
66   return(ret);
67 }
68
69 static void mapping0_free_info(vorbis_info_mapping *i){
70   if(i){
71     memset(i,0,sizeof(vorbis_info_mapping0));
72     _ogg_free(i);
73   }
74 }
75
76 static void mapping0_free_look(vorbis_look_mapping *look){
77   int i;
78   vorbis_look_mapping0 *l=(vorbis_look_mapping0 *)look;
79   if(l){
80     drft_clear(&l->fft_look);
81
82     for(i=0;i<l->map->submaps;i++){
83       l->time_func[i]->free_look(l->time_look[i]);
84       l->floor_func[i]->free_look(l->floor_look[i]);
85       l->residue_func[i]->free_look(l->residue_look[i]);
86     }
87     if(l->psy_look[1] && l->psy_look[1]!=l->psy_look[0]){
88       _vp_psy_clear(l->psy_look[1]);
89       _ogg_free(l->psy_look[1]);
90     }
91     if(l->psy_look[0]){
92       _vp_psy_clear(l->psy_look[0]);
93       _ogg_free(l->psy_look[0]);
94     }
95     _ogg_free(l->time_func);
96     _ogg_free(l->floor_func);
97     _ogg_free(l->residue_func);
98     _ogg_free(l->time_look);
99     _ogg_free(l->floor_look);
100     _ogg_free(l->residue_look);
101     memset(l,0,sizeof(vorbis_look_mapping0));
102     _ogg_free(l);
103   }
104 }
105
106 static vorbis_look_mapping *mapping0_look(vorbis_dsp_state *vd,vorbis_info_mode *vm,
107                           vorbis_info_mapping *m){
108   int i;
109   vorbis_info          *vi=vd->vi;
110   codec_setup_info     *ci=vi->codec_setup;
111   vorbis_look_mapping0 *look=_ogg_calloc(1,sizeof(vorbis_look_mapping0));
112   vorbis_info_mapping0 *info=look->map=(vorbis_info_mapping0 *)m;
113   look->mode=vm;
114   
115   look->time_look=_ogg_calloc(info->submaps,sizeof(vorbis_look_time *));
116   look->floor_look=_ogg_calloc(info->submaps,sizeof(vorbis_look_floor *));
117
118   look->residue_look=_ogg_calloc(info->submaps,sizeof(vorbis_look_residue *));
119
120   look->time_func=_ogg_calloc(info->submaps,sizeof(vorbis_func_time *));
121   look->floor_func=_ogg_calloc(info->submaps,sizeof(vorbis_func_floor *));
122   look->residue_func=_ogg_calloc(info->submaps,sizeof(vorbis_func_residue *));
123   
124   for(i=0;i<info->submaps;i++){
125     int timenum=info->timesubmap[i];
126     int floornum=info->floorsubmap[i];
127     int resnum=info->residuesubmap[i];
128
129     look->time_func[i]=_time_P[ci->time_type[timenum]];
130     look->time_look[i]=look->time_func[i]->
131       look(vd,vm,ci->time_param[timenum]);
132     look->floor_func[i]=_floor_P[ci->floor_type[floornum]];
133     look->floor_look[i]=look->floor_func[i]->
134       look(vd,vm,ci->floor_param[floornum]);
135     look->residue_func[i]=_residue_P[ci->residue_type[resnum]];
136     look->residue_look[i]=look->residue_func[i]->
137       look(vd,vm,ci->residue_param[resnum]);
138     
139   }
140   if(ci->psys && vd->analysisp){
141     if(info->psy[0] != info->psy[1]){
142
143       int psynum=info->psy[0];
144       look->psy_look[0]=_ogg_calloc(1,sizeof(vorbis_look_psy));      
145       _vp_psy_init(look->psy_look[0],ci->psy_param[psynum],
146                    ci->psy_g_param,
147                    ci->blocksizes[vm->blockflag]/2,vi->rate);
148
149       psynum=info->psy[1];
150       look->psy_look[1]=_ogg_calloc(1,sizeof(vorbis_look_psy));      
151       _vp_psy_init(look->psy_look[1],ci->psy_param[psynum],
152                    ci->psy_g_param,
153                    ci->blocksizes[vm->blockflag]/2,vi->rate);
154     }else{
155
156       int psynum=info->psy[0];
157       look->psy_look[0]=_ogg_calloc(1,sizeof(vorbis_look_psy));      
158       look->psy_look[1]=look->psy_look[0];
159       _vp_psy_init(look->psy_look[0],ci->psy_param[psynum],
160                    ci->psy_g_param,
161                    ci->blocksizes[vm->blockflag]/2,vi->rate);
162
163     }
164   }
165
166   look->ch=vi->channels;
167
168   if(vd->analysisp)drft_init(&look->fft_look,ci->blocksizes[vm->blockflag]);
169   return(look);
170 }
171
172 static int ilog2(unsigned int v){
173   int ret=0;
174   while(v>1){
175     ret++;
176     v>>=1;
177   }
178   return(ret);
179 }
180
181 static void mapping0_pack(vorbis_info *vi,vorbis_info_mapping *vm,oggpack_buffer *opb){
182   int i;
183   vorbis_info_mapping0 *info=(vorbis_info_mapping0 *)vm;
184
185   /* another 'we meant to do it this way' hack...  up to beta 4, we
186      packed 4 binary zeros here to signify one submapping in use.  We
187      now redefine that to mean four bitflags that indicate use of
188      deeper features; bit0:submappings, bit1:coupling,
189      bit2,3:reserved. This is backward compatable with all actual uses
190      of the beta code. */
191
192   if(info->submaps>1){
193     oggpack_write(opb,1,1);
194     oggpack_write(opb,info->submaps-1,4);
195   }else
196     oggpack_write(opb,0,1);
197
198   if(info->coupling_steps>0){
199     oggpack_write(opb,1,1);
200     oggpack_write(opb,info->coupling_steps-1,8);
201     
202     for(i=0;i<info->coupling_steps;i++){
203       oggpack_write(opb,info->coupling_mag[i],ilog2(vi->channels));
204       oggpack_write(opb,info->coupling_ang[i],ilog2(vi->channels));
205     }
206   }else
207     oggpack_write(opb,0,1);
208   
209   oggpack_write(opb,0,2); /* 2,3:reserved */
210
211   /* we don't write the channel submappings if we only have one... */
212   if(info->submaps>1){
213     for(i=0;i<vi->channels;i++)
214       oggpack_write(opb,info->chmuxlist[i],4);
215   }
216   for(i=0;i<info->submaps;i++){
217     oggpack_write(opb,info->timesubmap[i],8);
218     oggpack_write(opb,info->floorsubmap[i],8);
219     oggpack_write(opb,info->residuesubmap[i],8);
220   }
221 }
222
223 /* also responsible for range checking */
224 static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb){
225   int i;
226   vorbis_info_mapping0 *info=_ogg_calloc(1,sizeof(vorbis_info_mapping0));
227   codec_setup_info     *ci=vi->codec_setup;
228   memset(info,0,sizeof(vorbis_info_mapping0));
229
230   if(oggpack_read(opb,1))
231     info->submaps=oggpack_read(opb,4)+1;
232   else
233     info->submaps=1;
234
235   if(oggpack_read(opb,1)){
236     info->coupling_steps=oggpack_read(opb,8)+1;
237
238     for(i=0;i<info->coupling_steps;i++){
239       int testM=info->coupling_mag[i]=oggpack_read(opb,ilog2(vi->channels));
240       int testA=info->coupling_ang[i]=oggpack_read(opb,ilog2(vi->channels));
241
242       if(testM<0 || 
243          testA<0 || 
244          testM==testA || 
245          testM>=vi->channels ||
246          testA>=vi->channels) goto err_out;
247     }
248
249   }
250
251   if(oggpack_read(opb,2)>0)goto err_out; /* 2,3:reserved */
252     
253   if(info->submaps>1){
254     for(i=0;i<vi->channels;i++){
255       info->chmuxlist[i]=oggpack_read(opb,4);
256       if(info->chmuxlist[i]>=info->submaps)goto err_out;
257     }
258   }
259   for(i=0;i<info->submaps;i++){
260     info->timesubmap[i]=oggpack_read(opb,8);
261     if(info->timesubmap[i]>=ci->times)goto err_out;
262     info->floorsubmap[i]=oggpack_read(opb,8);
263     if(info->floorsubmap[i]>=ci->floors)goto err_out;
264     info->residuesubmap[i]=oggpack_read(opb,8);
265     if(info->residuesubmap[i]>=ci->residues)goto err_out;
266   }
267
268   return info;
269
270  err_out:
271   mapping0_free_info(info);
272   return(NULL);
273 }
274
275 #include "os.h"
276 #include "lpc.h"
277 #include "lsp.h"
278 #include "envelope.h"
279 #include "mdct.h"
280 #include "psy.h"
281 #include "scales.h"
282
283 /* no time mapping implementation for now */
284 static long seq=0;
285 static int mapping0_forward(vorbis_block *vb,vorbis_look_mapping *l){
286   vorbis_dsp_state      *vd=vb->vd;
287   vorbis_info           *vi=vd->vi;
288   codec_setup_info      *ci=vi->codec_setup;
289   backend_lookup_state  *b=vb->vd->backend_state;
290   vorbis_look_mapping0  *look=(vorbis_look_mapping0 *)l;
291   vorbis_info_mapping0  *info=look->map;
292   vorbis_info_mode      *mode=look->mode;
293   vorbis_block_internal *vbi=(vorbis_block_internal *)vb->internal;
294   int                    n=vb->pcmend;
295   int i,j;
296   float *window=b->window[vb->W][vb->lW][vb->nW][mode->windowtype];
297   int   *nonzero=alloca(sizeof(int)*vi->channels);
298
299   float *work=_vorbis_block_alloc(vb,n*sizeof(float));
300
301   float global_ampmax=vbi->ampmax;
302   float *local_ampmax=alloca(sizeof(float)*vi->channels);
303   int blocktype;
304
305   /* we differentiate between short and long block types to help the
306      masking engine; the window shapes also matter.
307      impulse block (a short block in which an impulse occurs)
308      padding block (a short block that pads between a transitional 
309           long block and an impulse block, or vice versa)
310      transition block (the wqeird one; a long block with the transition 
311           window; affects bass/midrange response and that must be 
312           accounted for in masking) 
313      long block (run of the mill long block)
314   */
315
316   if(vb->W){
317     if(!vb->lW || !vb->nW)
318       blocktype=BLOCKTYPE_TRANSITION;
319     else
320       blocktype=BLOCKTYPE_LONG;
321   }else{
322     /* right now we're missing the infrastructure to distingush the
323        two short types */
324     blocktype=BLOCKTYPE_IMPULSE;
325   }
326
327   for(i=0;i<vi->channels;i++){
328     float scale=4.f/n;
329
330     /* the following makes things clearer to *me* anyway */
331     float *pcm     =vb->pcm[i]; 
332     float *fft     =work;
333     float *logfft  =pcm+n/2;
334
335     /*float *res     =pcm;
336     float *mdct    =pcm;
337     float *codedflr=pcm+n/2;
338     float *logmax  =work;
339     float *logmask =work+n/2;*/
340
341     /* window the PCM data */
342     for(j=0;j<n;j++)
343       fft[j]=pcm[j]*=window[j];
344     
345     /* transform the PCM data */
346     /* only MDCT right now.... */
347     mdct_forward(b->transform[vb->W][0],pcm,pcm);
348     
349     /* FFT yields more accurate tonal estimation (not phase sensitive) */
350     drft_forward(&look->fft_look,fft);
351     fft[0]*=scale;
352     logfft[0]=todB(fft);
353     local_ampmax[i]=logfft[0];
354     for(j=1;j<n-1;j+=2){
355       float temp=scale*FAST_HYPOT(fft[j],fft[j+1]);
356       temp=logfft[(j+1)>>1]=todB(&temp);
357       if(temp>local_ampmax[i])local_ampmax[i]=temp;
358     }
359     if(local_ampmax[i]>global_ampmax)global_ampmax=local_ampmax[i];
360
361     _analysis_output("fft",seq+i,logfft,n/2,1,0);
362   }
363
364   for(i=0;i<vi->channels;i++){
365     int submap=info->chmuxlist[i];
366
367     /* the following makes things clearer to *me* anyway */
368     float *mdct    =vb->pcm[i]; 
369     float *res     =mdct;
370     float *codedflr=mdct+n/2;
371     float *logfft  =mdct+n/2;
372
373     float *logmdct =work;
374     float *logmax  =mdct+n/2;
375     float *logmask =work+n/2;
376
377     for(j=0;j<n/2;j++)
378       logmdct[j]=todB(mdct+j);
379     _analysis_output("mdct",seq+i,logmdct,n/2,1,0);
380
381
382     /* perform psychoacoustics; do masking */
383     _vp_compute_mask(look->psy_look[blocktype],
384                      b->psy_g_look,
385                      i,
386                      logfft, /* -> logmax */
387                      logmdct,
388                      logmask,
389                      global_ampmax,
390                      local_ampmax[i],
391                      ci->blocksizes[vb->lW]/2);
392
393     _analysis_output("mask",seq+i,logmask,n/2,1,0);
394     
395     /* perform floor encoding */
396     nonzero[i]=look->floor_func[submap]->
397       forward(vb,look->floor_look[submap],
398               mdct,
399               logmdct,
400               logmask,
401               logmax,
402
403               codedflr);
404
405
406     _analysis_output("mdct2",seq+i,mdct,n/2,1,1);
407     _vp_remove_floor(look->psy_look[blocktype],
408                      b->psy_g_look,
409                      logmdct,
410                      mdct,
411                      codedflr,
412                      res,
413                      local_ampmax[i]);
414
415     for(j=0;j<n/2;j++)
416       if(fabs(res[j])>1200){
417         analysis_noisy=1;
418         /*fprintf(stderr,"%ld ",seq+i);*/
419       }
420
421     _analysis_output("res",seq+i,res,n/2,1,0);
422     _analysis_output("codedflr",seq+i,codedflr,n/2,1,1);
423       
424   }
425
426   vbi->ampmax=global_ampmax;
427
428   /* partition based prequantization and channel coupling */
429   /* Steps in prequant and coupling:
430      
431      down-couple/down-quantize from perfect residue ->  quantized vector 
432      classify by this first quantized vector
433      
434      do{ 
435         encode quantized vector; add encoded values to 'so-far' vector
436         more? [not yet at bitrate/not yet at target]
437           yes{
438               down-couple/down-quantize from perfect-'so-far' -> 
439                 quantized vector; when subtracting coupling, 
440                 account for +/- out-of-phase component
441           }no{  
442               break
443           }
444      }
445      done.
446
447      quantization in each iteration is done (after circular normalization 
448      in coupling) using a by-iteration quantization granule value.
449   */
450    
451   {
452     float  **pcm=vb->pcm;
453     float  **quantized=alloca(sizeof(float*)*vi->channels);
454     float  **sofar=alloca(sizeof(float*)*vi->channels);
455
456     long  ***classifications=alloca(sizeof(long**)*info->submaps);
457     float ***pcmbundle=alloca(sizeof(float **)*info->submaps);
458     float ***sobundle=alloca(sizeof(float **)*info->submaps);
459     int    **zerobundle=alloca(sizeof(int *)*info->submaps);
460     int     *chbundle=alloca(sizeof(int)*info->submaps);
461     int      chcounter=0;
462
463     /* play a little loose with this abstraction */
464     int   quant_passes=look->psy_look[blocktype]->vi->coupling_passes;
465     int   stopflag=0;
466
467     for(i=0;i<vi->channels;i++){
468       quantized[i]=pcm[i]+n/2;
469       sofar[i]=_vorbis_block_alloc(vb,n/2*sizeof(float));
470       memset(sofar[i],0,sizeof(float)*n/2);
471     }
472
473     pcmbundle[0]=alloca(sizeof(float *)*vi->channels);
474     sobundle[0]=alloca(sizeof(float *)*vi->channels);
475     zerobundle[0]=alloca(sizeof(int)*vi->channels);
476
477     /* initial down-quantized coupling */
478     _vp_quantize_couple(look->psy_look[blocktype],
479                         info,
480                         pcm,
481                         sofar,
482                         quantized,
483                         nonzero,
484                         0);
485
486     for(i=0;i<vi->channels;i++)
487       _analysis_output("quant",seq+i,quantized[i],n/2,1,0);
488
489   
490     /* classify, by submap */
491
492     for(i=0;i<info->submaps;i++){
493       int ch_in_bundle=0;
494       pcmbundle[i]=pcmbundle[0]+chcounter;
495       sobundle[i]=sobundle[0]+chcounter;
496       zerobundle[i]=zerobundle[0]+chcounter;
497
498       for(j=0;j<vi->channels;j++){
499         if(info->chmuxlist[j]==i){
500           if(nonzero[j])
501             zerobundle[i][ch_in_bundle]=1;
502           else
503             zerobundle[i][ch_in_bundle]=0;
504           pcmbundle[i][ch_in_bundle]=quantized[j];
505           sobundle[i][ch_in_bundle++]=sofar[j];
506         }
507       }
508       chbundle[i]=ch_in_bundle;
509       chcounter+=ch_in_bundle;
510
511       classifications[i]=look->residue_func[i]->
512         class(vb,look->residue_look[i],pcmbundle[i],zerobundle[i],chbundle[i]);
513     }
514
515     /* actual encoding loop */
516     for(i=0;!stopflag;){
517
518       /* perform residue encoding of this pass's quantized residue
519          vector, according residue mapping */
520     
521       for(j=0;j<info->submaps;j++)
522         look->residue_func[j]->
523           forward(vb,look->residue_look[j],
524                   pcmbundle[j],sobundle[j],zerobundle[j],chbundle[j],
525                   i,classifications[j]);
526       i++;
527       
528       /* bitrate management decision hook; the following if() is where
529          we tell progressive encoding to halt, right now it just
530          avoids falling off the edge */
531       if(i>=quant_passes /* || yadda yadda */)stopflag=1;
532
533       if(!stopflag){
534         /* down-couple/down-quantize from perfect-'so-far' -> 
535            new quantized vector */
536         _vp_quantize_couple(look->psy_look[blocktype],
537                             info,
538                             pcm,
539                             sofar,
540                             quantized,
541                             nonzero,
542                             i);
543       }
544       /* steady as she goes */
545     }
546     seq+=vi->channels;
547   }
548   
549   look->lastframe=vb->sequence;
550   return(0);
551 }
552
553 static int mapping0_inverse(vorbis_block *vb,vorbis_look_mapping *l){
554   vorbis_dsp_state     *vd=vb->vd;
555   vorbis_info          *vi=vd->vi;
556   codec_setup_info     *ci=vi->codec_setup;
557   backend_lookup_state *b=vd->backend_state;
558   vorbis_look_mapping0 *look=(vorbis_look_mapping0 *)l;
559   vorbis_info_mapping0 *info=look->map;
560   vorbis_info_mode     *mode=look->mode;
561   int                   i,j;
562   long                  n=vb->pcmend=ci->blocksizes[vb->W];
563
564   float *window=b->window[vb->W][vb->lW][vb->nW][mode->windowtype];
565   float **pcmbundle=alloca(sizeof(float *)*vi->channels);
566   int    *zerobundle=alloca(sizeof(int)*vi->channels);
567
568   int   *nonzero  =alloca(sizeof(int)*vi->channels);
569   void **floormemo=alloca(sizeof(void *)*vi->channels);
570   
571   /* time domain information decode (note that applying the
572      information would have to happen later; we'll probably add a
573      function entry to the harness for that later */
574   /* NOT IMPLEMENTED */
575
576   /* recover the spectral envelope; store it in the PCM vector for now */
577   for(i=0;i<vi->channels;i++){
578     int submap=info->chmuxlist[i];
579     floormemo[i]=look->floor_func[submap]->
580       inverse1(vb,look->floor_look[submap]);
581     if(floormemo[i])
582       nonzero[i]=1;
583     else
584       nonzero[i]=0;      
585     memset(vb->pcm[i],0,sizeof(float)*n/2);
586   }
587
588   /* channel coupling can 'dirty' the nonzero listing */
589   for(i=0;i<info->coupling_steps;i++){
590     if(nonzero[info->coupling_mag[i]] ||
591        nonzero[info->coupling_ang[i]]){
592       nonzero[info->coupling_mag[i]]=1; 
593       nonzero[info->coupling_ang[i]]=1; 
594     }
595   }
596
597   /* recover the residue into our working vectors */
598   for(i=0;i<info->submaps;i++){
599     int ch_in_bundle=0;
600     for(j=0;j<vi->channels;j++){
601       if(info->chmuxlist[j]==i){
602         if(nonzero[j])
603           zerobundle[ch_in_bundle]=1;
604         else
605           zerobundle[ch_in_bundle]=0;
606         pcmbundle[ch_in_bundle++]=vb->pcm[j];
607       }
608     }
609     
610     look->residue_func[i]->inverse(vb,look->residue_look[i],
611                                    pcmbundle,zerobundle,ch_in_bundle);
612   }
613
614   /* channel coupling */
615   for(i=info->coupling_steps-1;i>=0;i--){
616     float *pcmM=vb->pcm[info->coupling_mag[i]];
617     float *pcmA=vb->pcm[info->coupling_ang[i]];
618
619     for(j=0;j<n/2;j++){
620       float mag=pcmM[j];
621       float ang=pcmA[j];
622
623       if(mag>0)
624         if(ang>0){
625           pcmM[j]=mag;
626           pcmA[j]=mag-ang;
627         }else{
628           pcmA[j]=mag;
629           pcmM[j]=mag+ang;
630         }
631       else
632         if(ang>0){
633           pcmM[j]=mag;
634           pcmA[j]=mag+ang;
635         }else{
636           pcmA[j]=mag;
637           pcmM[j]=mag-ang;
638         }
639     }
640   }
641
642   /* compute and apply spectral envelope */
643   for(i=0;i<vi->channels;i++){
644     float *pcm=vb->pcm[i];
645     int submap=info->chmuxlist[i];
646     look->floor_func[submap]->
647       inverse2(vb,look->floor_look[submap],floormemo[i],pcm);
648   }
649
650   /* transform the PCM data; takes PCM vector, vb; modifies PCM vector */
651   /* only MDCT right now.... */
652   for(i=0;i<vi->channels;i++){
653     float *pcm=vb->pcm[i];
654     _analysis_output("out",seq+i,pcm,n/2,1,1);
655     mdct_backward(b->transform[vb->W][0],pcm,pcm);
656   }
657
658   /* window the data */
659   for(i=0;i<vi->channels;i++){
660     float *pcm=vb->pcm[i];
661     if(nonzero[i])
662       for(j=0;j<n;j++)
663         pcm[j]*=window[j];
664     else
665       for(j=0;j<n;j++)
666         pcm[j]=0.f;
667     _analysis_output("final",seq++,pcm,n,0,0);
668   }
669             
670   /* now apply the decoded post-window time information */
671   /* NOT IMPLEMENTED */
672
673   /* all done! */
674   return(0);
675 }
676
677 /* export hooks */
678 vorbis_func_mapping mapping0_exportbundle={
679   &mapping0_pack,
680   &mapping0_unpack,
681   &mapping0_look,
682   &mapping0_copy_info,
683   &mapping0_free_info,
684   &mapping0_free_look,
685   &mapping0_forward,
686   &mapping0_inverse
687 };