Fixed a serious algorithmic bug in unpack that was spotted by routine
[platform/upstream/libvorbis.git] / lib / floor1.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: floor backend 1 implementation
14  last mod: $Id: floor1.c,v 1.3 2001/06/05 23:54:25 xiphmont Exp $
15
16  ********************************************************************/
17
18 #include <stdlib.h>
19 #include <string.h>
20 #include <math.h>
21 #include <ogg/ogg.h>
22 #include "vorbis/codec.h"
23 #include "codec_internal.h"
24 #include "registry.h"
25 #include "codebook.h"
26 #include "misc.h"
27 #include "scales.h"
28
29 #include <stdio.h>
30
31 #define floor1_rangedB 140 /* floor 1 fixed at -140dB to 0dB range */
32
33 typedef struct {
34   int sorted_index[VIF_POSIT+2];
35   int forward_index[VIF_POSIT+2];
36   int reverse_index[VIF_POSIT+2];
37   
38   int hineighbor[VIF_POSIT];
39   int loneighbor[VIF_POSIT];
40   int posts;
41
42   int n;
43   int quant_q;
44   vorbis_info_floor1 *vi;
45
46
47   long seq;
48   long postbits;
49   long classbits;
50   long subbits;
51   float mse;
52 } vorbis_look_floor1;
53
54 typedef struct lsfit_acc{
55   long x0;
56   long x1;
57
58   long xa;
59   long ya;
60   long x2a;
61   long y2a;
62   long xya; 
63   long n;
64   long an;
65   long un;
66   long edgey0;
67   long edgey1;
68 } lsfit_acc;
69
70 /***********************************************/
71  
72 static vorbis_info_floor *floor1_copy_info (vorbis_info_floor *i){
73   vorbis_info_floor1 *info=(vorbis_info_floor1 *)i;
74   vorbis_info_floor1 *ret=_ogg_malloc(sizeof(vorbis_info_floor1));
75   memcpy(ret,info,sizeof(vorbis_info_floor1));
76   return(ret);
77 }
78
79 static void floor1_free_info(vorbis_info_floor *i){
80   if(i){
81     memset(i,0,sizeof(vorbis_info_floor1));
82     _ogg_free(i);
83   }
84 }
85
86 static void floor1_free_look(vorbis_look_floor *i){
87   vorbis_look_floor1 *look=(vorbis_look_floor1 *)i;
88   if(i){
89     fprintf(stderr,"floor 1 bit usage: %ld:%ld:%ld (%ld/frame), mse:%gdB\n",
90             look->postbits/look->seq,look->classbits/look->seq,look->subbits/look->seq,
91             (look->postbits+look->subbits+look->classbits)/look->seq,
92             sqrt(look->mse/look->seq));
93
94     memset(look,0,sizeof(vorbis_look_floor1));
95     free(i);
96   }
97 }
98
99 static int ilog(unsigned int v){
100   int ret=0;
101   while(v){
102     ret++;
103     v>>=1;
104   }
105   return(ret);
106 }
107
108 static int ilog2(unsigned int v){
109   int ret=0;
110   while(v>1){
111     ret++;
112     v>>=1;
113   }
114   return(ret);
115 }
116
117 static void floor1_pack (vorbis_info_floor *i,oggpack_buffer *opb){
118   vorbis_info_floor1 *info=(vorbis_info_floor1 *)i;
119   int j,k;
120   int count=0;
121   int rangebits;
122   int maxposit=info->postlist[1];
123   int maxclass=-1;
124
125   /* save out partitions */
126   oggpack_write(opb,info->partitions,5); /* only 0 to 31 legal */
127   for(j=0;j<info->partitions;j++){
128     oggpack_write(opb,info->partitionclass[j],4); /* only 0 to 15 legal */
129     if(maxclass<info->partitionclass[j])maxclass=info->partitionclass[j];
130   }
131
132   /* save out partition classes */
133   for(j=0;j<maxclass+1;j++){
134     oggpack_write(opb,info->class_dim[j]-1,3); /* 1 to 8 */
135     oggpack_write(opb,info->class_subs[j],2); /* 0 to 3 */
136     if(info->class_subs[j])oggpack_write(opb,info->class_book[j],8);
137     for(k=0;k<(1<<info->class_subs[j]);k++)
138       oggpack_write(opb,info->class_subbook[j][k]+1,8);
139   }
140
141   /* save out the post list */
142   oggpack_write(opb,info->mult-1,2);     /* only 1,2,3,4 legal now */ 
143   oggpack_write(opb,ilog2(maxposit),4);
144   rangebits=ilog2(maxposit);
145
146   for(j=0,k=0;j<info->partitions;j++){
147     count+=info->class_dim[info->partitionclass[j]]; 
148     for(;k<count;k++)
149       oggpack_write(opb,info->postlist[k+2],rangebits);
150   }
151 }
152
153
154 static vorbis_info_floor *floor1_unpack (vorbis_info *vi,oggpack_buffer *opb){
155   codec_setup_info     *ci=vi->codec_setup;
156   int j,k,count=0,maxclass=-1,rangebits;
157
158   vorbis_info_floor1 *info=_ogg_calloc(1,sizeof(vorbis_info_floor1));
159   /* read partitions */
160   info->partitions=oggpack_read(opb,5); /* only 0 to 31 legal */
161   for(j=0;j<info->partitions;j++){
162     info->partitionclass[j]=oggpack_read(opb,4); /* only 0 to 15 legal */
163     if(maxclass<info->partitionclass[j])maxclass=info->partitionclass[j];
164   }
165
166   /* read partition classes */
167   for(j=0;j<maxclass+1;j++){
168     info->class_dim[j]=oggpack_read(opb,3)+1; /* 1 to 8 */
169     info->class_subs[j]=oggpack_read(opb,2); /* 0,1,2,3 bits */
170     if(info->class_subs[j]<0)
171       goto err_out;
172     if(info->class_subs[j])info->class_book[j]=oggpack_read(opb,8);
173     if(info->class_book[j]<0 || info->class_book[j]>=ci->books)
174       goto err_out;
175     for(k=0;k<(1<<info->class_subs[j]);k++){
176       info->class_subbook[j][k]=oggpack_read(opb,8)-1;
177       if(info->class_subbook[j][k]<-1 || info->class_subbook[j][k]>=ci->books)
178         goto err_out;
179     }
180   }
181
182   /* read the post list */
183   info->mult=oggpack_read(opb,2)+1;     /* only 1,2,3,4 legal now */ 
184   rangebits=oggpack_read(opb,4);
185
186   for(j=0,k=0;j<info->partitions;j++){
187     count+=info->class_dim[info->partitionclass[j]]; 
188     for(;k<count;k++){
189       int t=info->postlist[k+2]=oggpack_read(opb,rangebits);
190       if(t<0 || t>=(1<<rangebits))
191         goto err_out;
192     }
193   }
194   info->postlist[0]=0;
195   info->postlist[1]=1<<rangebits;
196
197   return(info);
198   
199  err_out:
200   floor1_free_info(info);
201   return(NULL);
202 }
203
204 static int icomp(const void *a,const void *b){
205   return(**(int **)a-**(int **)b);
206 }
207
208 static vorbis_look_floor *floor1_look(vorbis_dsp_state *vd,vorbis_info_mode *mi,
209                               vorbis_info_floor *in){
210
211   int *sortpointer[VIF_POSIT+2];
212   vorbis_info_floor1 *info=(vorbis_info_floor1 *)in;
213   vorbis_look_floor1 *look=_ogg_calloc(1,sizeof(vorbis_look_floor1));
214   int i,j,n=0;
215
216   look->vi=info;
217   look->n=info->postlist[1];
218  
219   /* we drop each position value in-between already decoded values,
220      and use linear interpolation to predict each new value past the
221      edges.  The positions are read in the order of the position
222      list... we precompute the bounding positions in the lookup.  Of
223      course, the neighbors can change (if a position is declined), but
224      this is an initial mapping */
225
226   for(i=0;i<info->partitions;i++)n+=info->class_dim[info->partitionclass[i]];
227   n+=2;
228   look->posts=n;
229
230   /* also store a sorted position index */
231   for(i=0;i<n;i++)sortpointer[i]=info->postlist+i;
232   qsort(sortpointer,n,sizeof(int),icomp);
233
234   /* points from sort order back to range number */
235   for(i=0;i<n;i++)look->forward_index[i]=sortpointer[i]-info->postlist;
236   /* points from range order to sorted position */
237   for(i=0;i<n;i++)look->reverse_index[look->forward_index[i]]=i;
238   /* we actually need the post values too */
239   for(i=0;i<n;i++)look->sorted_index[i]=info->postlist[look->forward_index[i]];
240   
241   /* quantize values to multiplier spec */
242   switch(info->mult){
243   case 1: /* 1024 -> 256 */
244     look->quant_q=256;
245     break;
246   case 2: /* 1024 -> 128 */
247     look->quant_q=128;
248     break;
249   case 3: /* 1024 -> 86 */
250     look->quant_q=86;
251     break;
252   case 4: /* 1024 -> 64 */
253     look->quant_q=64;
254     break;
255   }
256
257   /* discover our neighbors for decode where we don't use fit flags
258      (that would push the neighbors outward) */
259   for(i=0;i<n-2;i++){
260     int lo=0;
261     int hi=1;
262     int lx=0;
263     int hx=look->n;
264     int currentx=info->postlist[i+2];
265     for(j=0;j<i+2;j++){
266       int x=info->postlist[j];
267       if(x>lx && x<currentx){
268         lo=j;
269         lx=x;
270       }
271       if(x<hx && x>currentx){
272         hi=j;
273         hx=x;
274       }
275     }
276     look->loneighbor[i]=lo;
277     look->hineighbor[i]=hi;
278   }
279
280   return(look);
281 }
282
283 static int render_point(int x0,int x1,int y0,int y1,int x){
284   y0&=0x7fff; /* mask off flag */
285   y1&=0x7fff;
286     
287   {
288     int dy=y1-y0;
289     int adx=x1-x0;
290     int ady=abs(dy);
291     int err=ady*(x-x0);
292     
293     int off=err/adx;
294     if(dy<0)return(y0-off);
295     return(y0+off);
296   }
297 }
298
299 static int vorbis_dBquant(const float *x){
300   int i= *x*7.3142857f+1023.5f;
301   if(i>1023)return(1023);
302   if(i<0)return(0);
303   return i;
304 }
305
306 static float FLOOR_fromdB_LOOKUP[256]={
307         1.0649863e-07F, 1.1341951e-07F, 1.2079015e-07F, 1.2863978e-07F, 
308         1.3699951e-07F, 1.4590251e-07F, 1.5538408e-07F, 1.6548181e-07F, 
309         1.7623575e-07F, 1.8768855e-07F, 1.9988561e-07F, 2.128753e-07F, 
310         2.2670913e-07F, 2.4144197e-07F, 2.5713223e-07F, 2.7384213e-07F, 
311         2.9163793e-07F, 3.1059021e-07F, 3.3077411e-07F, 3.5226968e-07F, 
312         3.7516214e-07F, 3.9954229e-07F, 4.2550680e-07F, 4.5315863e-07F, 
313         4.8260743e-07F, 5.1396998e-07F, 5.4737065e-07F, 5.8294187e-07F, 
314         6.2082472e-07F, 6.6116941e-07F, 7.0413592e-07F, 7.4989464e-07F, 
315         7.9862701e-07F, 8.5052630e-07F, 9.0579828e-07F, 9.6466216e-07F, 
316         1.0273513e-06F, 1.0941144e-06F, 1.1652161e-06F, 1.2409384e-06F, 
317         1.3215816e-06F, 1.4074654e-06F, 1.4989305e-06F, 1.5963394e-06F, 
318         1.7000785e-06F, 1.8105592e-06F, 1.9282195e-06F, 2.0535261e-06F, 
319         2.1869758e-06F, 2.3290978e-06F, 2.4804557e-06F, 2.6416497e-06F, 
320         2.8133190e-06F, 2.9961443e-06F, 3.1908506e-06F, 3.3982101e-06F, 
321         3.6190449e-06F, 3.8542308e-06F, 4.1047004e-06F, 4.3714470e-06F, 
322         4.6555282e-06F, 4.9580707e-06F, 5.2802740e-06F, 5.6234160e-06F, 
323         5.9888572e-06F, 6.3780469e-06F, 6.7925283e-06F, 7.2339451e-06F, 
324         7.7040476e-06F, 8.2047000e-06F, 8.7378876e-06F, 9.3057248e-06F, 
325         9.9104632e-06F, 1.0554501e-05F, 1.1240392e-05F, 1.1970856e-05F, 
326         1.2748789e-05F, 1.3577278e-05F, 1.4459606e-05F, 1.5399272e-05F, 
327         1.6400004e-05F, 1.7465768e-05F, 1.8600792e-05F, 1.9809576e-05F, 
328         2.1096914e-05F, 2.2467911e-05F, 2.3928002e-05F, 2.5482978e-05F, 
329         2.7139006e-05F, 2.8902651e-05F, 3.0780908e-05F, 3.2781225e-05F, 
330         3.4911534e-05F, 3.7180282e-05F, 3.9596466e-05F, 4.2169667e-05F, 
331         4.4910090e-05F, 4.7828601e-05F, 5.0936773e-05F, 5.4246931e-05F, 
332         5.7772202e-05F, 6.1526565e-05F, 6.5524908e-05F, 6.9783085e-05F, 
333         7.4317983e-05F, 7.9147585e-05F, 8.4291040e-05F, 8.9768747e-05F, 
334         9.5602426e-05F, 0.00010181521F, 0.00010843174F, 0.00011547824F, 
335         0.00012298267F, 0.00013097477F, 0.00013948625F, 0.00014855085F, 
336         0.00015820453F, 0.00016848555F, 0.00017943469F, 0.00019109536F, 
337         0.00020351382F, 0.00021673929F, 0.00023082423F, 0.00024582449F, 
338         0.00026179955F, 0.00027881276F, 0.00029693158F, 0.00031622787F, 
339         0.00033677814F, 0.00035866388F, 0.00038197188F, 0.00040679456F, 
340         0.00043323036F, 0.00046138411F, 0.00049136745F, 0.00052329927F, 
341         0.00055730621F, 0.00059352311F, 0.00063209358F, 0.00067317058F, 
342         0.00071691700F, 0.00076350630F, 0.00081312324F, 0.00086596457F, 
343         0.00092223983F, 0.00098217216F, 0.0010459992F, 0.0011139742F, 
344         0.0011863665F, 0.0012634633F, 0.0013455702F, 0.0014330129F, 
345         0.0015261382F, 0.0016253153F, 0.0017309374F, 0.0018434235F, 
346         0.0019632195F, 0.0020908006F, 0.0022266726F, 0.0023713743F, 
347         0.0025254795F, 0.0026895994F, 0.0028643847F, 0.0030505286F, 
348         0.0032487691F, 0.0034598925F, 0.0036847358F, 0.0039241906F, 
349         0.0041792066F, 0.0044507950F, 0.0047400328F, 0.0050480668F, 
350         0.0053761186F, 0.0057254891F, 0.0060975636F, 0.0064938176F, 
351         0.0069158225F, 0.0073652516F, 0.0078438871F, 0.0083536271F, 
352         0.0088964928F, 0.009474637F, 0.010090352F, 0.010746080F, 
353         0.011444421F, 0.012188144F, 0.012980198F, 0.013823725F, 
354         0.014722068F, 0.015678791F, 0.016697687F, 0.017782797F, 
355         0.018938423F, 0.020169149F, 0.021479854F, 0.022875735F, 
356         0.024362330F, 0.025945531F, 0.027631618F, 0.029427276F, 
357         0.031339626F, 0.033376252F, 0.035545228F, 0.037855157F, 
358         0.040315199F, 0.042935108F, 0.045725273F, 0.048696758F, 
359         0.051861348F, 0.055231591F, 0.058820850F, 0.062643361F, 
360         0.066714279F, 0.071049749F, 0.075666962F, 0.080584227F, 
361         0.085821044F, 0.091398179F, 0.097337747F, 0.10366330F, 
362         0.11039993F, 0.11757434F, 0.12521498F, 0.13335215F, 
363         0.14201813F, 0.15124727F, 0.16107617F, 0.17154380F, 
364         0.18269168F, 0.19456402F, 0.20720788F, 0.22067342F, 
365         0.23501402F, 0.25028656F, 0.26655159F, 0.28387361F, 
366         0.30232132F, 0.32196786F, 0.34289114F, 0.36517414F, 
367         0.38890521F, 0.41417847F, 0.44109412F, 0.46975890F, 
368         0.50028648F, 0.53279791F, 0.56742212F, 0.60429640F, 
369         0.64356699F, 0.68538959F, 0.72993007F, 0.77736504F, 
370         0.82788260F, 0.88168307F, 0.9389798F, 1.F, 
371 };
372
373 static void render_line(int x0,int x1,int y0,int y1,float *d){
374   int dy=y1-y0;
375   int adx=x1-x0;
376   int ady=abs(dy);
377   int base=dy/adx;
378   int sy=(dy<0?base-1:base+1);
379   int x=x0;
380   int y=y0;
381   int err=0;
382
383   ady-=abs(base*adx);
384
385   d[x]=FLOOR_fromdB_LOOKUP[y];
386   while(++x<x1){
387     err=err+ady;
388     if(err>=adx){
389       err-=adx;
390       y+=sy;
391     }else{
392       y+=base;
393     }
394     d[x]=FLOOR_fromdB_LOOKUP[y];
395   }
396 }
397
398 /* the floor has already been filtered to only include relevant sections */
399 static int accumulate_fit(const float *flr,const float *mdct,
400                           int x0, int x1,lsfit_acc *a,
401                           int n,vorbis_info_floor1 *info){
402   long i;
403   int quantized=vorbis_dBquant(flr);
404
405   long xa=0,ya=0,x2a=0,y2a=0,xya=0,na=0, xb=0,yb=0,x2b=0,y2b=0,xyb=0,nb=0;
406
407   memset(a,0,sizeof(lsfit_acc));
408   a->x0=x0;
409   a->x1=x1;
410   a->edgey0=quantized;
411   if(x1>n)x1=n;
412
413   for(i=x0;i<x1;i++){
414     int quantized=vorbis_dBquant(flr+i);
415     if(quantized){
416       if(mdct[i]+info->twofitatten>=flr[i]){
417         xa  += i;
418         ya  += quantized;
419         x2a += i*i;
420         y2a += quantized*quantized;
421         xya += i*quantized;
422         na++;
423       }else{
424         xb  += i;
425         yb  += quantized;
426         x2b += i*i;
427         y2b += quantized*quantized;
428         xyb += i*quantized;
429         nb++;
430       }
431     }
432   }
433
434   xb+=xa;
435   yb+=ya;
436   x2b+=x2a;
437   y2b+=y2a;
438   xyb+=xya;
439   nb+=na;
440
441   /* weight toward the actually used frequencies if we meet the threshhold */
442   {
443     int weight;
444     if(nb<info->twofitminsize || na<info->twofitminused){
445       weight=0;
446     }else{
447       weight=nb*info->twofitweight/na;
448     }
449     a->xa=xa*weight+xb;
450     a->ya=ya*weight+yb;
451     a->x2a=x2a*weight+x2b;
452     a->y2a=y2a*weight+y2b;
453     a->xya=xya*weight+xyb;
454     a->an=na*weight+nb;
455     a->n=nb;
456     a->un=na;
457     if(nb>=info->unusedminsize)a->un++;
458   }
459
460   a->edgey1=-200;
461   if(x1<n){
462     int quantized=vorbis_dBquant(flr+i);
463     a->edgey1=quantized;
464   }
465   return(a->n);
466 }
467
468 /* returns < 0 on too few points to fit, >=0 (meansq error) on success */
469 static int fit_line(lsfit_acc *a,int fits,int *y0,int *y1){
470   long x=0,y=0,x2=0,y2=0,xy=0,n=0,an=0,i;
471   long x0=a[0].x0;
472   long x1=a[fits-1].x1;
473
474   for(i=0;i<fits;i++){
475     if(a[i].un){
476       x+=a[i].xa;
477       y+=a[i].ya;
478       x2+=a[i].x2a;
479       y2+=a[i].y2a;
480       xy+=a[i].xya;
481       n+=a[i].n;
482       an+=a[i].an;
483     }
484   }
485
486   if(*y0>=0){  /* hint used to break degenerate cases */
487     x+=   x0;
488     y+=  *y0;
489     x2+=  x0 *  x0;
490     y2+= *y0 * *y0;
491     xy+= *y0 *  x0;
492     n++;
493     an++;
494   }
495
496   if(*y1>=0){  /* hint used to break degenerate cases */
497     x+=   x1;
498     y+=  *y1;
499     x2+=  x1 *  x1;
500     y2+= *y1 * *y1;
501     xy+= *y1 *  x1;
502     n++;
503     an++;
504   }
505
506   if(n<2)return(n-2);
507   
508   {
509     /* need 64 bit multiplies, which C doesn't give portably as int */
510     double fx=x;
511     double fy=y;
512     double fx2=x2;
513     double fy2=y2;
514     double fxy=xy;
515     double denom=1./(an*fx2-fx*fx);
516     double a=(fy*fx2-fxy*fx)*denom;
517     double b=(an*fxy-fx*fy)*denom;
518     *y0=rint(a+b*x0);
519     *y1=rint(a+b*x1);
520
521     /* limit to our range! */
522     if(*y0>1023)*y0=1023;
523     if(*y1>1023)*y1=1023;
524     if(*y0<0)*y0=0;
525     if(*y1<0)*y1=0;
526
527     return(0);
528   }
529 }
530
531 static void fit_line_point(lsfit_acc *a,int fits,int *y0,int *y1){
532   long y=0;
533   int i;
534
535   for(i=0;i<fits && y==0;i++)
536     y+=a[i].ya;
537   
538   *y0=*y1=y;
539 }
540
541 static int inspect_error(int x0,int x1,int y0,int y1,const float *mask,
542                          const float *mdct,
543                          vorbis_info_floor1 *info){
544   int dy=y1-y0;
545   int adx=x1-x0;
546   int ady=abs(dy);
547   int base=dy/adx;
548   int sy=(dy<0?base-1:base+1);
549   int x=x0;
550   int y=y0;
551   int err=0;
552   int val=vorbis_dBquant(mask+x);
553   int mse=0;
554   int n=0;
555
556   ady-=abs(base*adx);
557   
558   if(mdct[x]+info->twofitatten>=mask[x]){
559     if(y+info->maxover<val)return(1);
560     if(y-info->maxunder>val)return(1);
561     mse=(y-val);
562     mse*=mse;
563     n++;
564   }
565
566   while(++x<x1){
567     err=err+ady;
568     if(err>=adx){
569       err-=adx;
570       y+=sy;
571     }else{
572       y+=base;
573     }
574
575     if(mdct[x]+info->twofitatten>=mask[x]){
576       val=vorbis_dBquant(mask+x);
577       if(val){
578         if(y+info->maxover<val)return(1);
579         if(y-info->maxunder>val)return(1);
580         mse+=((y-val)*(y-val));
581         n++;
582       }
583     }
584   }
585   
586   if(n){
587     if(info->maxover*info->maxover/n>info->maxerr)return(0);
588     if(info->maxunder*info->maxunder/n>info->maxerr)return(0);
589     if(mse/n>info->maxerr)return(1);
590   }
591   return(0);
592 }
593
594 static int post_Y(int *A,int *B,int pos){
595   if(A[pos]<0)
596     return B[pos];
597   if(B[pos]<0)
598     return A[pos];
599   return (A[pos]+B[pos])>>1;
600 }
601
602 static int floor1_forward(vorbis_block *vb,vorbis_look_floor *in,
603                           const float *mdct, const float *logmdct,   /* in */
604                           const float *logmask, const float *logmax, /* in */
605                           float *residue, float *codedflr){          /* out */
606   static int seq=0;
607   long i,j,k,l;
608   vorbis_look_floor1 *look=(vorbis_look_floor1 *)in;
609   vorbis_info_floor1 *info=look->vi;
610   long n=look->n;
611   long posts=look->posts;
612   long nonzero=0;
613   lsfit_acc fits[VIF_POSIT+1];
614   int fit_valueA[VIF_POSIT+2]; /* index by range list position */
615   int fit_valueB[VIF_POSIT+2]; /* index by range list position */
616   int fit_flag[VIF_POSIT+2];
617
618   int loneighbor[VIF_POSIT+2]; /* sorted index of range list position (+2) */
619   int hineighbor[VIF_POSIT+2]; 
620   int memo[VIF_POSIT+2];
621   codec_setup_info *ci=vb->vd->vi->codec_setup;
622   static_codebook **sbooks=ci->book_param;
623   codebook *books=((backend_lookup_state *)(vb->vd->backend_state))->
624     fullbooks;   
625
626   memset(fit_flag,0,sizeof(fit_flag));
627   for(i=0;i<posts;i++)loneighbor[i]=0; /* 0 for the implicit 0 post */
628   for(i=0;i<posts;i++)hineighbor[i]=1; /* 1 for the implicit post at n */
629   for(i=0;i<posts;i++)memo[i]=-1;      /* no neighbor yet */
630
631   /* Scan back from high edge to first 'used' frequency */
632   for(;n>info->unusedmin_n;n--)
633     if(logmdct[n-1]>-floor1_rangedB && 
634        logmdct[n-1]+info->twofitatten>logmask[n-1])break;
635
636   /* quantize the relevant floor points and collect them into line fit
637      structures (one per minimal division) at the same time */
638   if(posts==0){
639     nonzero+=accumulate_fit(logmask,logmax,0,n,fits,n,info);
640   }else{
641     for(i=0;i<posts-1;i++)
642       nonzero+=accumulate_fit(logmask,logmax,look->sorted_index[i],
643                               look->sorted_index[i+1],fits+i,
644                               n,info);
645   }
646   
647   if(nonzero){
648     /* start by fitting the implicit base case.... */
649     int y0=-200;
650     int y1=-200;
651     int mse=fit_line(fits,posts-1,&y0,&y1);
652     if(mse<0){
653       /* Only a single nonzero point */
654       y0=-200;
655       y1=0;
656       fit_line(fits,posts-1,&y0,&y1);
657     }
658
659     look->seq++;
660
661     fit_flag[0]=1;
662     fit_flag[1]=1;
663     fit_valueA[0]=y0;
664     fit_valueB[0]=y0;
665     fit_valueB[1]=y1;
666     fit_valueA[1]=y1;
667
668     if(mse>=0){
669       /* Non degenerate case */
670       /* start progressive splitting.  This is a greedy, non-optimal
671          algorithm, but simple and close enough to the best
672          answer. */
673       for(i=2;i<posts;i++){
674         int sortpos=look->reverse_index[i];
675         int ln=loneighbor[sortpos];
676         int hn=hineighbor[sortpos];
677
678         /* eliminate repeat searches of a particular range with a memo */
679         if(memo[ln]!=hn){
680           /* haven't performed this error search yet */
681           int lsortpos=look->reverse_index[ln];
682           int hsortpos=look->reverse_index[hn];
683           memo[ln]=hn;
684
685           /* if this is an empty segment, its endpoints don't matter.
686              Mark as such */
687           for(j=lsortpos;j<hsortpos;j++)
688             if(fits[j].un)break;
689           if(j==hsortpos){
690             /* empty segment; important to note that this does not
691                break 0/n post case */
692             fit_valueB[ln]=-200;
693             if(fit_valueA[ln]<0)
694               fit_flag[ln]=0;
695             fit_valueA[hn]=-200;
696             if(fit_valueB[hn]<0)
697               fit_flag[hn]=0;
698  
699           }else{
700             /* A note: we want to bound/minimize *local*, not global, error */
701             int lx=info->postlist[ln];
702             int hx=info->postlist[hn];    
703             int ly=post_Y(fit_valueA,fit_valueB,ln);
704             int hy=post_Y(fit_valueA,fit_valueB,hn);
705             
706             if(inspect_error(lx,hx,ly,hy,logmask,logmdct,info)){
707               /* outside error bounds/begin search area.  Split it. */
708               int ly0=-200;
709               int ly1=-200;
710               int hy0=-200;
711               int hy1=-200;
712               int lmse=fit_line(fits+lsortpos,sortpos-lsortpos,&ly0,&ly1);
713               int hmse=fit_line(fits+sortpos,hsortpos-sortpos,&hy0,&hy1);
714               
715               /* the boundary/sparsity cases are the hard part.  They
716                  don't happen often given that we use the full mask
717                  curve (weighted) now, but when they do happen they
718                  can go boom. Pay them detailed attention */
719               /* cases for a segment:
720                  >=0) normal fit (>=2 unique points)
721                  -1) one point on x0;
722                  one point on x1; <-- disallowed by fit_line
723                  -2) one point in between x0 and x1
724                  -3) no points */
725
726               switch(lmse){ 
727               case -2:  
728                 /* no points in the low segment */
729                 break;
730               case -1:
731                 ly0=fits[lsortpos].edgey0;
732                 break;
733               default:
734               }
735
736               switch(hmse){ 
737               case -2:  
738                 /* no points in the hi segment */
739                 break;
740               case -1:
741                 hy0=fits[sortpos].edgey0;
742                 break;
743               }
744
745               /* store new edge values */
746               fit_valueB[ln]=ly0;
747               if(ln==0 && ly0>=0)fit_valueA[ln]=ly0;
748               fit_valueA[i]=ly1;
749               fit_valueB[i]=hy0;
750               fit_valueA[hn]=hy1;
751               if(hn==1 && hy1>=0)fit_valueB[hn]=hy1;
752
753               if(ly0<0 && fit_valueA[ln]<0)
754                 fit_flag[ln]=0;
755               if(hy1<0 && fit_valueB[hn]<0)
756                 fit_flag[hn]=0;
757
758               if(ly1>=0 || hy0>=0){
759                 /* store new neighbor values */
760                 for(j=sortpos-1;j>=0;j--)
761                   if(hineighbor[j]==hn)
762                   hineighbor[j]=i;
763                   else
764                     break;
765                 for(j=sortpos+1;j<posts;j++)
766                   if(loneighbor[j]==ln)
767                     loneighbor[j]=i;
768                   else
769                     break;
770                 
771                 /* store flag (set) */
772                 fit_flag[i]=1;
773               }
774             }
775           }
776         }
777       }
778     }
779
780     /* quantize values to multiplier spec */
781     switch(info->mult){
782     case 1: /* 1024 -> 256 */
783       for(i=0;i<posts;i++)
784         if(fit_flag[i])
785           fit_valueA[i]=post_Y(fit_valueA,fit_valueB,i)>>2;
786       break;
787     case 2: /* 1024 -> 128 */
788       for(i=0;i<posts;i++)
789         if(fit_flag[i])
790           fit_valueA[i]=post_Y(fit_valueA,fit_valueB,i)>>3;
791       break;
792     case 3: /* 1024 -> 86 */
793       for(i=0;i<posts;i++)
794         if(fit_flag[i])
795           fit_valueA[i]=post_Y(fit_valueA,fit_valueB,i)/12;
796       break;
797     case 4: /* 1024 -> 64 */
798       for(i=0;i<posts;i++)
799         if(fit_flag[i])
800           fit_valueA[i]=post_Y(fit_valueA,fit_valueB,i)>>4;
801       break;
802     }
803
804     /* find prediction values for each post and subtract them */
805     for(i=2;i<posts;i++){
806       int sp=look->reverse_index[i];
807       int ln=look->loneighbor[i-2];
808       int hn=look->hineighbor[i-2];
809       int x0=info->postlist[ln];
810       int x1=info->postlist[hn];
811       int y0=fit_valueA[ln];
812       int y1=fit_valueA[hn];
813         
814       int predicted=render_point(x0,x1,y0,y1,info->postlist[i]);
815         
816       if(fit_flag[i]){
817         int headroom=(look->quant_q-predicted<predicted?
818                       look->quant_q-predicted:predicted);
819         
820         int val=fit_valueA[i]-predicted;
821         
822         /* at this point the 'deviation' value is in the range +/- max
823            range, but the real, unique range can always be mapped to
824            only [0-maxrange).  So we want to wrap the deviation into
825            this limited range, but do it in the way that least screws
826            an essentially gaussian probability distribution. */
827         
828         if(val<0)
829           if(val<-headroom)
830             val=headroom-val-1;
831           else
832             val=-1-(val<<1);
833         else
834           if(val>=headroom)
835             val= val+headroom;
836           else
837             val<<=1;
838         
839         fit_valueB[i]=val;
840         
841         /* unroll the neighbor arrays */
842         for(j=sp+1;j<posts;j++)
843           if(loneighbor[j]==i)
844             loneighbor[j]=loneighbor[sp];
845           else
846             break;
847         for(j=sp-1;j>=0;j--)
848           if(hineighbor[j]==i)
849             hineighbor[j]=hineighbor[sp];
850           else
851             break;
852         
853       }else{
854         fit_valueA[i]=predicted;
855         fit_valueB[i]=0;
856       }
857       if(fit_valueB[i]==0)
858         fit_valueA[i]|=0x8000;
859       else{
860         fit_valueA[look->loneighbor[i-2]]&=0x7fff;
861         fit_valueA[look->hineighbor[i-2]]&=0x7fff;
862       }
863     }
864
865     /* we have everything we need. pack it out */
866     /* mark nontrivial floor */
867     oggpack_write(&vb->opb,1,1);
868
869     /* beginning/end post */
870     look->postbits+=ilog(look->quant_q-1)*2;
871     oggpack_write(&vb->opb,fit_valueA[0],ilog(look->quant_q-1));
872     oggpack_write(&vb->opb,fit_valueA[1],ilog(look->quant_q-1));
873
874 #ifdef TRAIN_FLOOR1
875     {
876       FILE *of;
877       char buffer[80];
878       sprintf(buffer,"line%d_full.vqd",vb->mode);
879       of=fopen(buffer,"a");
880       for(j=2;j<posts;j++)
881         fprintf(of,"%d\n",fit_valueB[j]);
882       fclose(of);
883     }
884 #endif
885
886     
887     /* partition by partition */
888     for(i=0,j=2;i<info->partitions;i++){
889       int class=info->partitionclass[i];
890       int cdim=info->class_dim[class];
891       int csubbits=info->class_subs[class];
892       int csub=1<<csubbits;
893       int bookas[8]={0,0,0,0,0,0,0,0};
894       int cval=0;
895       int cshift=0;
896
897       /* generate the partition's first stage cascade value */
898       if(csubbits){
899         int maxval[8];
900         for(k=0;k<csub;k++){
901           int booknum=info->class_subbook[class][k];
902           if(booknum<0){
903             maxval[k]=1;
904           }else{
905             maxval[k]=sbooks[info->class_subbook[class][k]]->entries;
906           }
907         }
908         for(k=0;k<cdim;k++){
909           for(l=0;l<csub;l++){
910             int val=fit_valueB[j+k];
911             if(val<maxval[l]){
912               bookas[k]=l;
913               break;
914             }
915           }
916           cval|= bookas[k]<<cshift;
917           cshift+=csubbits;
918         }
919         /* write it */
920         look->classbits+=vorbis_book_encode(books+info->class_book[class],cval,&vb->opb);
921
922 #ifdef TRAIN_FLOOR1
923         {
924           FILE *of;
925           char buffer[80];
926           sprintf(buffer,"line%d_class%d.vqd",vb->mode,class);
927           of=fopen(buffer,"a");
928           fprintf(of,"%d\n",cval);
929           fclose(of);
930         }
931 #endif
932       }
933       
934       /* write post values */
935       for(k=0;k<cdim;k++){
936         int book=info->class_subbook[class][bookas[k]];
937         if(book>=0){
938           look->subbits+=vorbis_book_encode(books+book,
939                              fit_valueB[j+k],&vb->opb);
940
941 #ifdef TRAIN_FLOOR1
942           {
943             FILE *of;
944             char buffer[80];
945             sprintf(buffer,"line%d_%dsub%d.vqd",vb->mode,class,bookas[k]);
946             of=fopen(buffer,"a");
947             fprintf(of,"%d\n",fit_valueB[j+k]);
948             fclose(of);
949           }
950 #endif
951         }
952       }
953       j+=cdim;
954     }
955     
956     {
957       /* generate quantized floor equivalent to what we'd unpack in decode */
958       int hx;
959       int lx=0;
960       int ly=fit_valueA[0]*info->mult;
961       for(j=1;j<posts;j++){
962         int current=look->forward_index[j];
963         if(!(fit_valueA[current]&0x8000)){
964           int hy=(fit_valueA[current]&0x7fff)*info->mult;
965           hx=info->postlist[current];
966           
967           render_line(lx,hx,ly,hy,codedflr);
968           
969           lx=hx;
970           ly=hy;
971         }
972       }
973       for(j=hx;j<look->n;j++)codedflr[j]=codedflr[j-1]; /* be certain */
974
975       /* use it to create residue vector.  Eliminate residue elements
976          that were below the error training attenuation relative to
977          the original mask.  This avoids portions of the floor fit
978          that were considered 'unused' in fitting from being used in
979          coding residue if the unfit values are significantly below
980          the original input mask */
981       for(j=0;j<n;j++)
982         if(logmdct[j]+info->twofitatten<logmask[j])
983           residue[j]=0.f;
984         else
985           residue[j]=mdct[j]/codedflr[j];
986       for(j=n;j<look->n;j++)residue[j]=0.f;
987
988     }    
989
990   }else{
991     oggpack_write(&vb->opb,0,1);
992     memset(codedflr,0,n*sizeof(float));
993   }
994   seq++;
995   return(nonzero);
996 }
997
998 static int floor1_inverse(vorbis_block *vb,vorbis_look_floor *in,float *out){
999   vorbis_look_floor1 *look=(vorbis_look_floor1 *)in;
1000   vorbis_info_floor1 *info=look->vi;
1001
1002   codec_setup_info   *ci=vb->vd->vi->codec_setup;
1003   int                  n=ci->blocksizes[vb->mode]/2;
1004   int i,j,k;
1005   codebook *books=((backend_lookup_state *)(vb->vd->backend_state))->
1006     fullbooks;   
1007
1008   /* unpack wrapped/predicted values from stream */
1009   if(oggpack_read(&vb->opb,1)==1){
1010     int fit_value[VIF_POSIT+2];
1011
1012     fit_value[0]=oggpack_read(&vb->opb,ilog(look->quant_q-1));
1013     fit_value[1]=oggpack_read(&vb->opb,ilog(look->quant_q-1));
1014
1015     /* partition by partition */
1016     /* partition by partition */
1017     for(i=0,j=2;i<info->partitions;i++){
1018       int class=info->partitionclass[i];
1019       int cdim=info->class_dim[class];
1020       int csubbits=info->class_subs[class];
1021       int csub=1<<csubbits;
1022       int cval=0;
1023
1024       /* decode the partition's first stage cascade value */
1025       if(csubbits){
1026         cval=vorbis_book_decode(books+info->class_book[class],&vb->opb);
1027
1028         if(cval==-1)goto eop;
1029       }
1030
1031       for(k=0;k<cdim;k++){
1032         int book=info->class_subbook[class][cval&(csub-1)];
1033         cval>>=csubbits;
1034         if(book>=0){
1035           if((fit_value[j+k]=vorbis_book_decode(books+book,&vb->opb))==-1)
1036             goto eop;
1037         }else{
1038           fit_value[j+k]=0;
1039         }
1040       }
1041       j+=cdim;
1042     }
1043
1044     /* unwrap positive values and reconsitute via linear interpolation */
1045     for(i=2;i<look->posts;i++){
1046       int predicted=render_point(info->postlist[look->loneighbor[i-2]],
1047                                  info->postlist[look->hineighbor[i-2]],
1048                                  fit_value[look->loneighbor[i-2]],
1049                                  fit_value[look->hineighbor[i-2]],
1050                                  info->postlist[i]);
1051       int hiroom=look->quant_q-predicted;
1052       int loroom=predicted;
1053       int room=(hiroom<loroom?hiroom:loroom)<<1;
1054       int val=fit_value[i];
1055
1056       if(val){
1057         if(val>=room){
1058           if(hiroom>loroom){
1059             val = val-loroom;
1060           }else{
1061           val = -1-(val-hiroom);
1062           }
1063         }else{
1064           if(val&1){
1065             val= -((val+1)>>1);
1066           }else{
1067             val>>=1;
1068           }
1069         }
1070
1071         fit_value[i]=val+predicted;
1072         fit_value[look->loneighbor[i-2]]&=0x7fff;
1073         fit_value[look->hineighbor[i-2]]&=0x7fff;
1074
1075       }else{
1076         fit_value[i]=predicted|0x8000;
1077       }
1078         
1079     }
1080
1081     /* render the lines */
1082     {
1083       int hx;
1084       int lx=0;
1085       int ly=fit_value[0]*info->mult;
1086       for(j=1;j<look->posts;j++){
1087         int current=look->forward_index[j];
1088         int hy=fit_value[current]&0x7fff;
1089         if(hy==fit_value[current]){
1090
1091           hy*=info->mult;
1092           hx=info->postlist[current];
1093           
1094           render_line(lx,hx,ly,hy,out);
1095           
1096           lx=hx;
1097           ly=hy;
1098         }
1099       }
1100       for(j=hx;j<n;j++)out[j]=out[j-1]; /* be certain */
1101     }    
1102     return(1);
1103   }
1104
1105   /* fall through */
1106  eop:
1107   memset(out,0,sizeof(float)*n);
1108   return(0);
1109 }
1110
1111 /* export hooks */
1112 vorbis_func_floor floor1_exportbundle={
1113   &floor1_pack,&floor1_unpack,&floor1_look,&floor1_copy_info,&floor1_free_info,
1114   &floor1_free_look,&floor1_forward,&floor1_inverse
1115 };
1116
1117 #if 0
1118 static float test_mask[]={
1119   -44.5606,
1120   -52.1648,
1121   -64.1442,
1122   -81.206,
1123   -92.407,
1124   -92.5,
1125   -92.5,
1126   -88.7254,
1127   -84.746,
1128   -80.643,
1129   -67.643,
1130   -63.643,
1131   -56.1236,
1132   -48.643,
1133   -48.643,
1134 -48.643,
1135 -51.643,
1136 -50.643,
1137 -51.643,
1138 -51.643,
1139 -51.643,
1140 -51.643,
1141 -50.643,
1142 -50.643,
1143 -49.643,
1144 -51.643,
1145 -51.643,
1146 -50.1648,
1147 -49.3369,
1148 -49.3369,
1149 -49.3369,
1150 -49.3369,
1151 -55.1005,
1152 -56.3369,
1153 -56.3369,
1154 -56.3369,
1155 -57.143,
1156 -57.143,
1157 -57.143,
1158 -58.3369,
1159 -56.1236,
1160 -55.1005,
1161 -55.1005,
1162 -55.1005,
1163 -55.1005,
1164 -55.1005,
1165 -60.643,
1166 -62.6005,
1167 -62.6005,
1168 -63.143,
1169 -63.143,
1170 -64.643,
1171 -64.643,
1172 -64.643,
1173 -64.643,
1174 -64.643,
1175 -65.643,
1176 -65.643,
1177 -65.643,
1178 -65.643,
1179 -65.643,
1180 -67.143,
1181 -67.143,
1182 -67.143,
1183 -67.143,
1184 -67.143,
1185 -69.5167,
1186 -69.5167,
1187 -69.1624,
1188 -69.1624,
1189 -69.1624,
1190 -69.1624,
1191 -69.1624,
1192 -69.1624,
1193 -69.1624,
1194 -69.1624,
1195 -69.1624,
1196 -69.3452,
1197 -71,
1198 -71,
1199 -71,
1200 -69.9889,
1201 -68.1854,
1202 -68.1854,
1203 -68.1854,
1204 -68.1854,
1205 -68,
1206 -67.5,
1207 -66.5,
1208 -66.5,
1209 -65,
1210 -64,
1211 -64,
1212 -65,
1213 -64,
1214 -64,
1215 -64,
1216 -64,
1217 -64,
1218 -64,
1219 -64,
1220 -64,
1221 -64,
1222 -63,
1223 -62,
1224 -63,
1225 -63,
1226 -63,
1227 -63,
1228 -63,
1229 -63,
1230 -63,
1231 -61.5,
1232 -61.5,
1233 -61.5,
1234 -60.5,
1235 -60.5,
1236 -60.5,
1237 -60.5,
1238 -60.5,
1239 -60.5,
1240 -59.5,
1241 -59.5,
1242 -59,
1243 -59,
1244 -59,
1245 -59,
1246 -59,
1247 -59,
1248 -59,
1249 -59,
1250 -58,
1251 -58,
1252 -58,
1253 -58,
1254 -58,
1255 -58,
1256 -58,
1257 -58,
1258 -58,
1259 -58,
1260 -58,
1261 -58,
1262 -58,
1263 -58,
1264 -58,
1265 -58,
1266 -58,
1267 -58,
1268 -58,
1269 -58,
1270 -58,
1271 -58,
1272 -58,
1273 -58,
1274 -58,
1275 -58,
1276 -58,
1277 -59,
1278 -59,
1279 -59,
1280 -59.5,
1281 -59.5,
1282 -60.5,
1283 -60.5,
1284 -61.5,
1285 -61.5,
1286 -60.5,
1287 -60.5,
1288 -60.5,
1289 -61.5,
1290 -61.5,
1291 -61.5,
1292 -60.5,
1293 -60.5,
1294 -60.5,
1295 -60.5,
1296 -60.5,
1297 -60.5,
1298 -60.5,
1299 -60.5,
1300 -60.5,
1301 -60.5,
1302 -60.5,
1303 -60.5,
1304 -60.5,
1305 -60.5,
1306 -60.5,
1307 -60.5,
1308 -60.5,
1309 -60.5,
1310 -60.5,
1311 -61.5,
1312 -61.5,
1313 -61.5,
1314 -61.5,
1315 -61.5,
1316 -62.5,
1317 -62.5,
1318 -62.5,
1319 -62.5,
1320 -62.5,
1321 -63,
1322 -63,
1323 -65,
1324 -65,
1325 -66.5,
1326 -66.5,
1327 -66.5,
1328 -71.5,
1329 -71.5,
1330 -71.5,
1331 -71.5,
1332 -71.5,
1333 -71.5,
1334 -71.5,
1335 -79,
1336 -79,
1337 -79.5,
1338 -79,
1339 -79,
1340 -79,
1341 -79,
1342 -79,
1343 -79.5,
1344 -79.5,
1345 -79.5,
1346 -79.5,
1347 -79.5,
1348 -79.5,
1349 -79.5,
1350 -79.5,
1351 -79.5,
1352 -79,
1353 -79,
1354 -79,
1355 -77.5,
1356 -77.5,
1357 -77.5,
1358 -77.5,
1359 -77.5,
1360 -77.5,
1361 -77,
1362 -77,
1363 -77,
1364 -77,
1365 -77,
1366 -77,
1367 -77,
1368 -77,
1369 -77,
1370 -77,
1371 -77,
1372 -77,
1373 -77,
1374 -77,
1375 -77,
1376 -77,
1377 -77,
1378 -77,
1379 -77,
1380 -77,
1381 -77,
1382 -76.9913,
1383 -76.9803,
1384 -76.9695,
1385 -76.9586,
1386 -76.9478,
1387 -76.937,
1388 -76.9263,
1389 -76.9156,
1390 -76.905,
1391 -76.8944,
1392 -77.3838,
1393 -77.3733,
1394 -77.3628,
1395 -77.3523,
1396 -77.3419,
1397 -77.3315,
1398 -79.3212,
1399 -79.3109,
1400 -79.3006,
1401 -79.2904,
1402 -79.2802,
1403 -79.27,
1404 -79.2599,
1405 -79.2498,
1406 -79.2397,
1407 -79.2297,
1408 -79.2197,
1409 -79.2098,
1410 -79.1999,
1411 -78.69,
1412 -76.6802,
1413 -76.6703,
1414 -76.6606,
1415 -76.6508,
1416 -76.6411,
1417 -74.6314,
1418 -74.6218,
1419 -74.6122,
1420 -74.6026,
1421 -74.593,
1422 -74.5835,
1423 -74.074,
1424 -74.0645,
1425 -73.5551,
1426 -72.0457,
1427 -71.0363,
1428 -71.027,
1429 -71.0177,
1430 -71.0084,
1431 -70.9992,
1432 -70.9899,
1433 -70.9808,
1434 -70.9716,
1435 -70.9625,
1436 -70.9534,
1437 -70.9443,
1438 -70.9352,
1439 -70.9262,
1440 -70.9172,
1441 -70.9083,
1442 -70.8993,
1443 -70.8904,
1444 -70.8816,
1445 -70.8727,
1446 -70.8639,
1447 -70.8551,
1448 -70.8463,
1449 -70.8376,
1450 -70.8289,
1451 -70.8202,
1452 -70.8115,
1453 -70.8029,
1454 -70.7943,
1455 -70.7857,
1456 -70.7771,
1457 -70.7686,
1458 -70.7601,
1459 -70.7516,
1460 -70.7431,
1461 -70.7347,
1462 -70.7263,
1463 -70.7179,
1464 -70.7095,
1465 -70.7012,
1466 -70.6928,
1467 -74.1846,
1468 -74.1763,
1469 -74.168,
1470 -74.1598,
1471 -74.1516,
1472 -75.1434,
1473 -75.1353,
1474 -75.1272,
1475 -76.1191,
1476 -76.111,
1477 -76.1029,
1478 -76.0949,
1479 -76.0869,
1480 -76.5789,
1481 -76.5709,
1482 -76.563,
1483 -76.555,
1484 -76.5471,
1485 -78.0392,
1486 -78.0314,
1487 -78.0235,
1488 -78.0157,
1489 -78.0079,
1490 -78.0002,
1491 -78,
1492 -78,
1493 -79,
1494 -79,
1495 -79,
1496 -79,
1497 -79,
1498 -79,
1499 -80.5,
1500 -80.5,
1501 -80.5,
1502 -80.5,
1503 -80.5,
1504 -80.5,
1505 -81,
1506 -81,
1507 -81,
1508 -81,
1509 -81,
1510 -81,
1511 -81,
1512 -81,
1513 -83,
1514 -83,
1515 -83,
1516 -83,
1517 -83,
1518 -83,
1519 -83,
1520 -83,
1521 -83,
1522 -83,
1523 -83,
1524 -83,
1525 -85.5,
1526 -85.5,
1527 -85.5,
1528 -84,
1529 -84,
1530 -85.5,
1531 -85.5,
1532 -84,
1533 -85.5,
1534 -84,
1535 -84,
1536 -84,
1537 -84,
1538 -84,
1539 -84,
1540 -84,
1541 -84,
1542 -84,
1543 -84,
1544 -84,
1545 -84,
1546 -84,
1547 -84,
1548 -84,
1549 -84,
1550 -84,
1551 -84,
1552 -84,
1553 -84,
1554 -84.5,
1555 -84.5,
1556 -84.5,
1557 -84.5,
1558 -84,
1559 -84,
1560 -84,
1561 -84,
1562 -84,
1563 -84,
1564 -84,
1565 -84,
1566 -84,
1567 -84,
1568 -84,
1569 -84,
1570 -84,
1571 -84,
1572 -84.5,
1573 -84.5,
1574 -84.5,
1575 -84.5,
1576 -84.5,
1577 -84.5,
1578 -85,
1579 -85,
1580 -85,
1581 -85,
1582 -85,
1583 -85,
1584 -85,
1585 -85,
1586 -85,
1587 -85,
1588 -85,
1589 -85,
1590 -85,
1591 -85,
1592 -85,
1593 -85,
1594 -85,
1595 -85,
1596 -85,
1597 -85,
1598 -85,
1599 -85,
1600 -85.5,
1601 -85.5,
1602 -85.5,
1603 -85.5,
1604 -85.5,
1605 -85.5,
1606 -85.5,
1607 -85.5,
1608 -85.5,
1609 -85.5,
1610 -86.5,
1611 -86.5,
1612 -86.5,
1613 -86.5,
1614 -86.5,
1615 -86.5,
1616 -86.5,
1617 -86.5,
1618 -86.5,
1619 -86.5,
1620 -86.5,
1621 -86.5,
1622 -86.5,
1623 -87,
1624 -87,
1625 -87,
1626 -87,
1627 -87,
1628 -88.4276,
1629 -88.4276,
1630 -88.4276,
1631 -88.4276,
1632 -88.4276,
1633 -88.4276,
1634 -88.4276,
1635 -88.4276,
1636 -89.4276,
1637 -89.4276,
1638 -89.4276,
1639 -89.4276,
1640 -89.4276,
1641 -89.4276,
1642 -91.5,
1643 -91.5,
1644 -91.5,
1645 -91.5,
1646 -91,
1647 -91,
1648 -90.5,
1649 -90.5,
1650 -90,
1651 -90,
1652 -90,
1653 -90,
1654 -90,
1655 -90,
1656 -90,
1657 -90,
1658 -90,
1659 -90,
1660 -90,
1661 -90,
1662 -90,
1663 -90,
1664 -90,
1665 -90,
1666 -90,
1667 -90,
1668 -90,
1669 -90,
1670 -90,
1671 -90,
1672 -90,
1673 -90,
1674 -90,
1675 -90,
1676 -90,
1677 -90,
1678 -90,
1679 -90,
1680 -90,
1681 -90,
1682 -90,
1683 -90,
1684 -90,
1685 -90,
1686 -90,
1687 -90,
1688 -90,
1689 -90,
1690 -90,
1691 -90,
1692 -90,
1693 -90,
1694 -90,
1695 -90,
1696 -90,
1697 -90,
1698 -90,
1699 -90,
1700 -90,
1701 -89,
1702 -89,
1703 -89,
1704 -89,
1705 -89,
1706 -89,
1707 -89,
1708 -90,
1709 -90,
1710 -90,
1711 -90,
1712 -90,
1713 -90,
1714 -90,
1715 -90,
1716 -90,
1717 -90,
1718 -90,
1719 -90,
1720 -90,
1721 -90,
1722 -90,
1723 -90,
1724 -90,
1725 -90,
1726 -90,
1727 -90,
1728 -90,
1729 -90,
1730 -89,
1731 -89,
1732 -89,
1733 -90,
1734 -90,
1735 -90,
1736 -90,
1737 -90,
1738 -90,
1739 -90,
1740 -90,
1741 -90,
1742 -90,
1743 -90,
1744 -90,
1745 -90,
1746 -90,
1747 -90,
1748 -90,
1749 -90,
1750 -90,
1751 -89,
1752 -89,
1753 -89,
1754 -89,
1755 -89,
1756 -89,
1757 -89,
1758 -90,
1759 -90,
1760 -90,
1761 -90,
1762 -90,
1763 -90,
1764 -90,
1765 -90,
1766 -90,
1767 -90,
1768 -90,
1769 -90,
1770 -90,
1771 -90,
1772 -90,
1773 -90,
1774 -90.5,
1775 -90.5,
1776 -90.5,
1777 -90.5,
1778 -90.5,
1779 -90.5,
1780 -90.5,
1781 -90.5,
1782 -90.5,
1783 -90.5,
1784 -90.5,
1785 -90.5,
1786 -90.5,
1787 -90.5,
1788 -90.5,
1789 -90.5,
1790 -90.5223,
1791 -90.5223,
1792 -90.5223,
1793 -90.5223,
1794 -90.5223,
1795 -90.5,
1796 -90.5,
1797 -90.5,
1798 -90.5,
1799 -90.5,
1800 -90.5,
1801 -90.5,
1802 -90.5,
1803 -90.5,
1804 -90.5,
1805 -90.5,
1806 -90.5,
1807 -90.5,
1808 -90.5,
1809 -90.5,
1810 -90.5,
1811 -90,
1812 -90,
1813 -90,
1814 -90,
1815 -90,
1816 -90,
1817 -90,
1818 -90,
1819 -90,
1820 -90,
1821 -89,
1822 -89,
1823 -89,
1824 -89,
1825 -89,
1826 -89,
1827 -90,
1828 -90,
1829 -90,
1830 -90,
1831 -90,
1832 -90,
1833 -89,
1834 -87.5429,
1835 -87.5429,
1836 -87.5429,
1837 -87.5429,
1838 -87.5429,
1839 -87.5429,
1840 -87.5429,
1841 -87.5429,
1842 -87.5429,
1843 -87.5429,
1844 -87.5429,
1845 -87.5429,
1846 -87.5429,
1847 -87.5429,
1848 -87.5429,
1849 -87.5429,
1850 -87.5429,
1851 -87.5429,
1852 -87.5429,
1853 -87.5429,
1854 -87.5429,
1855 -87.5429,
1856 -87.5429,
1857 -87.5429,
1858 -87.5429,
1859 -87.5429,
1860 -87.5429,
1861 -87.5429,
1862 -87.5429,
1863 -87.5429,
1864 -87.5429,
1865 -87.5429,
1866 -87.5429,
1867 -87.5429,
1868 -87.4384,
1869 -87.3027,
1870 -87.1669,
1871 -87.0312,
1872 -86.8954,
1873 -86.7597,
1874 -86.6239,
1875 -86.4882,
1876 -86.3524,
1877 -86.2167,
1878 -86.081,
1879 -85.9452,
1880 -85.8095,
1881 -85.6737,
1882 -85.538,
1883 -85.4022,
1884 -85.2665,
1885 -85.1307,
1886 -84.995,
1887 -84.8592,
1888 -84.7235,
1889 -84.5878,
1890 -84.452,
1891 -84.3163,
1892 -84.1805,
1893 -84.0448,
1894 -83.909,
1895 -83.7733,
1896 -83.6375,
1897 -83.5018,
1898 -83.366,
1899 -83.2303,
1900 -83.0945,
1901 -82.9588,
1902 -82.8231,
1903 -82.6873,
1904 -82.5516,
1905 -82.4158,
1906 -82.2801,
1907 -82.1443,
1908 -82.0086,
1909 -81.8728,
1910 -81.7371,
1911 -81.6013,
1912 -81.4656,
1913 -81.3298,
1914 -81.1941,
1915 -81.0584,
1916 -76.3296,
1917 -76.3296,
1918 -76.3296,
1919 -76.3296,
1920 -76.3296,
1921 -76.3296,
1922 -76.3296,
1923 -76.3296,
1924 -76.3296,
1925 -76.3296,
1926 -76.3296,
1927 -76.3296,
1928 -76.3296,
1929 -76.3296,
1930 -76.3296,
1931 -76.3296,
1932 -76.3296,
1933 -76.3296,
1934 -76.3296,
1935 -76.3296,
1936 -76.3296,
1937 -76.3296,
1938 -76.3296,
1939 -76.3296,
1940 -76.3296,
1941 -76.3296,
1942 -76.3296,
1943 -76.3296,
1944 -76.3296,
1945 -76.3296,
1946 -76.3296,
1947 -76.3296,
1948 -76.3296,
1949 -76.3296,
1950 -76.3073,
1951 -76.1715,
1952 -76.0358,
1953 -75.9,
1954 -75.7643,
1955 -75.6285,
1956 -75.4928,
1957 -75.357,
1958 -75.2213,
1959 -75.0855,
1960 -74.9498,
1961 -74.814,
1962 -74.6783,
1963 -74.5425,
1964 -74.4068,
1965 -74.2711,
1966 -74.1353,
1967 -73.9996,
1968 -73.8638,
1969 -73.7281,
1970 -73.5923,
1971 -73.4566,
1972 -73.3208,
1973 -73.1851,
1974 -73.0493,
1975 -72.9136,
1976 -72.7778,
1977 -72.6421,
1978 -72.5064,
1979 -72.3706,
1980 -72.2349,
1981 -72.0991,
1982 -71.9634,
1983 -71.8276,
1984 -71.6919,
1985 -71.5561,
1986 -71.4204,
1987 -71.2846,
1988 -56.3296,
1989 -56.3296,
1990 -56.3296,
1991 -56.3296,
1992 -56.3296,
1993 -56.3296,
1994 -56.3296,
1995 -56.3296,
1996 -56.3296,
1997 -56.3296,
1998 -56.3296,
1999 -56.3296,
2000 -56.3296,
2001 -56.3296,
2002 -56.3296,
2003 -56.3296,
2004 -56.3296,
2005 -56.3296,
2006 -56.3296,
2007 -56.3296,
2008 -56.3296,
2009 -56.3296,
2010 -56.3296,
2011 -56.3296,
2012 -56.3296,
2013 -56.3296,
2014 -56.3296,
2015 -56.3296,
2016 -56.3296,
2017 -56.3296,
2018 -56.3296,
2019 -56.3296,
2020 -56.3296,
2021 -56.3296,
2022 -56.3296,
2023 -56.3296,
2024 -56.3296,
2025 -56.3296,
2026 -56.3296,
2027 -56.3296,
2028 -56.3296,
2029 -56.3296,
2030 -56.3296,
2031 -56.3296,
2032 -56.3296,
2033 -56.3296,
2034 -56.3296,
2035 -56.3296,
2036 -56.3296,
2037 -56.3296,
2038 -56.3296,
2039 -56.3296,
2040 -56.3296,
2041 -56.3296,
2042 -56.3296,
2043 -56.3296,
2044 -56.3296,
2045 -56.3296,
2046 -56.3296,
2047 -56.3296,
2048 -56.3296,
2049 -56.3296,
2050 -56.3296,
2051 -56.3296,
2052 -56.3296,
2053 -56.3296,
2054 -56.3296,
2055 -56.3296,
2056 -56.3296,
2057 -61.5223,
2058 -61.5223,
2059 -61.5109,
2060 -61.3752,
2061 -61.2394,
2062 -61.1037,
2063 -60.9679,
2064 -60.8322,
2065 -60.6965,
2066 -60.5606,
2067 -60.5606,
2068 -60.5606,
2069 -60.5606,
2070 -60.5606,
2071 -60.5606,
2072 -60.5606,
2073 -60.5606,
2074 -60.5606,
2075 -60.5606,
2076 -60.5606,
2077 -60.5606,
2078 -60.5606,
2079 -60.5606,
2080 -60.5606,
2081 -60.5606,
2082 -60.5606,
2083 -60.5606,
2084 -60.5606,
2085 -60.5606,
2086 -60.5606,
2087 -60.5606,
2088 -60.5606,
2089 -60.5606,
2090 -60.5606,
2091 -60.5606,
2092 -60.5606,
2093 -60.5606,
2094 -60.5606,
2095 -60.5606,
2096 -60.5606,
2097 -60.5606,
2098 -60.5606,
2099 -60.5606,
2100 -60.5606,
2101 -60.5606,
2102 -60.5606,
2103 -60.5606,
2104 -60.5606,
2105 -60.5606,
2106 -60.5606,
2107 -60.5606,
2108 -60.5606,
2109 -60.5606,
2110 -60.5606,
2111 -60.5606,
2112 -60.5606,
2113 -60.5606,
2114 -60.5606,
2115 -60.5606,
2116 -60.5606,
2117 -60.5606,
2118 -60.5606,
2119 -60.5606,
2120 -60.0713,
2121 -60.0713,
2122 -60.0713,
2123 -60.0713,
2124 -60.0713,
2125 -60.0713,
2126 -60.0713,
2127 -60.0713,
2128 -60.0713,
2129 -60.0713,
2130 -60.0713,
2131 -58.8284,
2132 -58.8284,
2133 -58.8284,
2134 -58.8284,
2135 -58.8284,
2136 -58.8284,
2137 -58.8284,
2138 -58.8284,
2139 -58.8284,
2140 -58.8284,
2141 -58.8284,
2142   -41.3296};
2143
2144 static float test_mdct[]={
2145 -25.2422,
2146 -47.1418,
2147 -47.1418,
2148 -64.2884,
2149 -72.2472,
2150 -75.5017,
2151 -70.309,
2152 -78.2678,
2153 -92.1125,
2154 -74.0507,
2155 -61.3658,
2156 -55.9889,
2157 -50.6636,
2158 -31.2628,
2159 -27.3369,
2160 -42.7048,
2161 -49.9683,
2162 -77.2448,
2163 -64.2884,
2164 -79.4276,
2165 -76.3296,
2166 -83.2654,
2167 -87.5429,
2168 -86.7872,
2169 -81.5223,
2170 -65.2035,
2171 -60.206,
2172 -58.2678,
2173 -25.8859,
2174 -36.6842,
2175 -52.2472,
2176 -52.2472,
2177 -58.2678,
2178 -74.0507,
2179 -77.2448,
2180 -77.2448,
2181 -68.7254,
2182 -70.309,
2183 -65.2035,
2184 -60.206,
2185 -54.1854,
2186 -43.9477,
2187 -35.1005,
2188 -41.1211,
2189 -48.7254,
2190 -66.2266,
2191 -71.2242,
2192 -62.0095,
2193 -74.0507,
2194 -82.3502,
2195 -79.4276,
2196 -84.2884,
2197 -86.7872,
2198 -88.3708,
2199 -77.2448,
2200 -66.2266,
2201 -50.6636,
2202 -71.2242,
2203 -78.2678,
2204 -74.0507,
2205 -77.2448,
2206 -89.2859,
2207 -70.309,
2208 -96.8902,
2209 -94.3914,
2210 -80.7666,
2211 -90.8696,
2212 -92.1125,
2213 -75.5017,
2214 -66.2266,
2215 -54.746,
2216 -100.412,
2217 -60.206,
2218 -60.206,
2219 -68.7254,
2220 -80.7666,
2221 -89.2859,
2222 -70.309,
2223 -74.746,
2224 -75.5017,
2225 -86.7872,
2226 -74.0507,
2227 -72.2472,
2228 -77.2448,
2229 -64.2884,
2230 -56.6842,
2231 -54.1854,
2232 -56.6842,
2233 -55.9889,
2234 -61.3658,
2235 -67.3864,
2236 -66.2266,
2237 -78.2678,
2238 -76.3296,
2239 -73.407,
2240 -78.2678,
2241 -70.309,
2242 -63.4605,
2243 -60.206,
2244 -98.8284,
2245 -59.1829,
2246 -60.206,
2247 -63.4605,
2248 -72.8078,
2249 -77.2448,
2250 -88.3708,
2251 -83.2654,
2252 -80.7666,
2253 -78.8284,
2254 -106.433,
2255 -71.2242,
2256 -66.7872,
2257 -62.7048,
2258 -72.2472,
2259 -60.7666,
2260 -59.1829,
2261 -63.4605,
2262 -67.3864,
2263 -77.2448,
2264 -72.2472,
2265 -84.2884,
2266 -80.7666,
2267 -90.309,
2268 -74.746,
2269 -84.2884,
2270 -71.2242,
2271 -60.7666,
2272 -64.2884,
2273 -57.4399,
2274 -59.1829,
2275 -63.4605,
2276 -62.7048,
2277 -60.7666,
2278 -57.4399,
2279 -62.0095,
2280 -60.206,
2281 -80.0713,
2282 -67.3864,
2283 -56.6842,
2284 -58.2678,
2285 -60.206,
2286 -58.2678,
2287 -55.9889,
2288 -53.1623,
2289 -54.746,
2290 -57.4399,
2291 -61.3658,
2292 -62.7048,
2293 -63.4605,
2294 -66.2266,
2295 -74.746,
2296 -75.5017,
2297 -88.3708,
2298 -71.2242,
2299 -63.4605,
2300 -68.0301,
2301 -61.3658,
2302 -118.474,
2303 -66.7872,
2304 -64.2884,
2305 -66.2266,
2306 -70.309,
2307 -76.3296,
2308 -70.309,
2309 -83.2654,
2310 -69.4811,
2311 -68.0301,
2312 -70.309,
2313 -74.0507,
2314 -63.4605,
2315 -82.3502,
2316 -59.1829,
2317 -59.1829,
2318 -64.2884,
2319 -64.2884,
2320 -73.407,
2321 -71.2242,
2322 -78.2678,
2323 -72.2472,
2324 -68.7254,
2325 -68.0301,
2326 -60.206,
2327 -60.7666,
2328 -74.746,
2329 -60.206,
2330 -84.2884,
2331 -62.7048,
2332 -60.206,
2333 -62.0095,
2334 -66.2266,
2335 -75.5017,
2336 -74.0507,
2337 -76.3296,
2338 -66.2266,
2339 -81.5223,
2340 -64.2884,
2341 -66.2266,
2342 -71.2242,
2343 -71.2242,
2344 -86.7872,
2345 -89.2859,
2346 -79.4276,
2347 -96.3296,
2348 -78.2678,
2349 -71.2242,
2350 -78.2678,
2351 -86.0919,
2352 -95.3065,
2353 -79.4276,
2354 -86.7872,
2355 -78.8284,
2356 -86.7872,
2357 -82.3502,
2358 -125.41,
2359 -87.5429,
2360 -91.4688,
2361 -93.5635,
2362 -89.2859,
2363 -107.348,
2364 -85.4482,
2365 -102.35,
2366 -99.5841,
2367 -100.412,
2368 -92.8078,
2369 -102.911,
2370 -93.5635,
2371 -89.2859,
2372 -84.849,
2373 -86.7872,
2374 -108.371,
2375 -86.7872,
2376 -79.4276,
2377 -86.7872,
2378 -92.1125,
2379 -106.433,
2380 -86.0919,
2381 -83.2654,
2382 -83.2654,
2383 -80.7666,
2384 -78.2678,
2385 -102.911,
2386 -78.8284,
2387 -105.605,
2388 -77.2448,
2389 -84.849,
2390 -84.849,
2391 -72.8078,
2392 -83.2654,
2393 -80.7666,
2394 -91.4688,
2395 -79.4276,
2396 -80.7666,
2397 -96.3296,
2398 -74.0507,
2399 -81.5223,
2400 -79.4276,
2401 -76.3296,
2402 -96.8902,
2403 -94.3914,
2404 -75.5017,
2405 -77.2448,
2406 -83.2654,
2407 -86.0919,
2408 -84.2884,
2409 -94.3914,
2410 -83.2654,
2411 -101.327,
2412 -75.5017,
2413 -95.3065,
2414 -78.8284,
2415 -86.7872,
2416 -84.2884,
2417 -83.2654,
2418 -78.8284,
2419 -85.4482,
2420 -89.2859,
2421 -84.2884,
2422 -88.3708,
2423 -86.0919,
2424 -99.5841,
2425 -98.1331,
2426 -83.2654,
2427 -90.8696,
2428 -119.389,
2429 -89.2859,
2430 -92.8078,
2431 -84.849,
2432 -90.309,
2433 -81.5223,
2434 -92.1125,
2435 -108.371,
2436 -92.1125,
2437 -87.5429,
2438 -84.2884,
2439 -86.7872,
2440 -92.1125,
2441 -76.3296,
2442 -79.4276,
2443 -96.8902,
2444 -89.2859,
2445 -78.8284,
2446 -82.3502,
2447 -80.7666,
2448 -78.8284,
2449 -86.0919,
2450 -82.3502,
2451 -80.0713,
2452 -80.7666,
2453 -76.3296,
2454 -82.3502,
2455 -80.0713,
2456 -73.407,
2457 -78.2678,
2458 -74.746,
2459 -76.3296,
2460 -87.5429,
2461 -74.746,
2462 -77.2448,
2463 -72.2472,
2464 -91.4688,
2465 -75.5017,
2466 -71.2242,
2467 -80.0713,
2468 -96.3296,
2469 -74.0507,
2470 -82.3502,
2471 -71.2242,
2472 -70.309,
2473 -70.309,
2474 -78.2678,
2475 -76.3296,
2476 -81.5223,
2477 -70.309,
2478 -69.4811,
2479 -80.7666,
2480 -75.5017,
2481 -74.746,
2482 -80.7666,
2483 -82.3502,
2484 -77.2448,
2485 -83.2654,
2486 -76.3296,
2487 -84.2884,
2488 -80.7666,
2489 -78.8284,
2490 -80.7666,
2491 -70.309,
2492 -78.8284,
2493 -81.5223,
2494 -81.5223,
2495 -86.7872,
2496 -86.7872,
2497 -77.2448,
2498 -88.3708,
2499 -75.5017,
2500 -102.35,
2501 -81.5223,
2502 -82.3502,
2503 -80.7666,
2504 -88.3708,
2505 -78.2678,
2506 -88.3708,
2507 -84.2884,
2508 -89.2859,
2509 -96.3296,
2510 -101.327,
2511 -78.2678,
2512 -88.3708,
2513 -74.746,
2514 -104.154,
2515 -84.2884,
2516 -94.3914,
2517 -88.3708,
2518 -102.35,
2519 -79.4276,
2520 -88.3708,
2521 -87.5429,
2522 -92.1125,
2523 -83.2654,
2524 -106.433,
2525 -91.4688,
2526 -81.5223,
2527 -102.911,
2528 -89.2859,
2529 -80.7666,
2530 -92.1125,
2531 -83.2654,
2532 -91.4688,
2533 -95.3065,
2534 -87.5429,
2535 -400,
2536 -83.2654,
2537 -90.309,
2538 -92.1125,
2539 -81.5223,
2540 -89.2859,
2541 -109.531,
2542 -90.8696,
2543 -89.2859,
2544 -91.4688,
2545 -87.5429,
2546 -88.3708,
2547 -91.4688,
2548 -106.433,
2549 -92.8078,
2550 -90.8696,
2551 -92.1125,
2552 -92.1125,
2553 -90.309,
2554 -98.1331,
2555 -112.453,
2556 -86.0919,
2557 -97.4894,
2558 -92.1125,
2559 -98.1331,
2560 -83.2654,
2561 -118.474,
2562 -91.4688,
2563 -109.531,
2564 -88.3708,
2565 -104.849,
2566 -91.4688,
2567 -94.3914,
2568 -109.531,
2569 -90.309,
2570 -113.368,
2571 -92.1125,
2572 -87.5429,
2573 -102.35,
2574 -84.2884,
2575 -86.7872,
2576 -90.8696,
2577 -87.5429,
2578 -84.2884,
2579 -86.7872,
2580 -84.2884,
2581 -400,
2582 -89.2859,
2583 -119.389,
2584 -88.3708,
2585 -81.5223,
2586 -108.931,
2587 -80.7666,
2588 -104.154,
2589 -115.551,
2590 -89.2859,
2591 -111.625,
2592 -93.5635,
2593 -104.154,
2594 -89.2859,
2595 -92.8078,
2596 -98.1331,
2597 -102.35,
2598 -85.4482,
2599 -86.0919,
2600 -90.8696,
2601 -83.2654,
2602 -96.8902,
2603 -89.2859,
2604 -89.2859,
2605 -100.412,
2606 -84.2884,
2607 -88.3708,
2608 -119.389,
2609 -92.8078,
2610 -84.849,
2611 -96.8902,
2612 -98.1331,
2613 -91.4688,
2614 -88.3708,
2615 -105.605,
2616 -89.2859,
2617 -99.5841,
2618 -126.993,
2619 -90.309,
2620 -95.3065,
2621 -130.515,
2622 -106.433,
2623 -123.667,
2624 -87.5429,
2625 -85.4482,
2626 -107.348,
2627 -85.4482,
2628 -91.4688,
2629 -86.7872,
2630 -95.3065,
2631 -90.8696,
2632 -102.35,
2633 -88.3708,
2634 -81.5223,
2635 -86.0919,
2636 -86.0919,
2637 -94.3914,
2638 -96.3296,
2639 -87.5429,
2640 -106.433,
2641 -94.3914,
2642 -120.412,
2643 -96.3296,
2644 -95.3065,
2645 -91.4688,
2646 -108.371,
2647 -98.8284,
2648 -95.3065,
2649 -108.931,
2650 -90.8696,
2651 -99.5841,
2652 -102.35,
2653 -110.174,
2654 -114.391,
2655 -98.8284,
2656 -107.348,
2657 -94.3914,
2658 -108.931,
2659 -94.3914,
2660 -93.5635,
2661 -103.51,
2662 -96.3296,
2663 -96.3296,
2664 -98.8284,
2665 -95.3065,
2666 -116.89,
2667 -95.3065,
2668 -102.911,
2669 -96.3296,
2670 -104.154,
2671 -106.433,
2672 -98.8284,
2673 -100.412,
2674 -97.4894,
2675 -92.8078,
2676 -92.8078,
2677 -95.3065,
2678 -97.4894,
2679 -102.35,
2680 -110.174,
2681 -92.8078,
2682 -109.531,
2683 -92.1125,
2684 -94.3914,
2685 -91.4688,
2686 -97.4894,
2687 -94.3914,
2688 -92.1125,
2689 -87.5429,
2690 -89.2859,
2691 -114.391,
2692 -90.309,
2693 -103.51,
2694 -90.8696,
2695 -94.3914,
2696 -90.309,
2697 -90.309,
2698 -98.8284,
2699 -100.412,
2700 -95.3065,
2701 -112.453,
2702 -92.1125,
2703 -107.348,
2704 -90.8696,
2705 -95.3065,
2706 -104.154,
2707 -103.51,
2708 -90.309,
2709 -90.8696,
2710 -101.327,
2711 -88.3708,
2712 -94.3914,
2713 -98.8284,
2714 -103.51,
2715 -96.3296,
2716 -90.309,
2717 -90.8696,
2718 -89.2859,
2719 -85.4482,
2720 -101.327,
2721 -98.8284,
2722 -96.3296,
2723 -95.3065,
2724 -134.952,
2725 -83.2654,
2726 -99.5841,
2727 -90.309,
2728 -103.51,
2729 -102.35,
2730 -105.605,
2731 -112.453,
2732 -94.3914,
2733 -98.1331,
2734 -92.1125,
2735 -98.8284,
2736 -94.3914,
2737 -92.8078,
2738 -112.453,
2739 -102.911,
2740 -86.0919,
2741 -90.309,
2742 -118.474,
2743 -94.3914,
2744 -104.154,
2745 -92.1125,
2746 -134.257,
2747 -95.3065,
2748 -89.2859,
2749 -93.5635,
2750 -101.327,
2751 -102.35,
2752 -113.368,
2753 -93.5635,
2754 -101.327,
2755 -93.5635,
2756 -94.3914,
2757 -99.5841,
2758 -110.174,
2759 -116.195,
2760 -91.4688,
2761 -87.5429,
2762 -93.5635,
2763 -92.1125,
2764 -87.5429,
2765 -107.348,
2766 -91.4688,
2767 -87.5429,
2768 -92.1125,
2769 -90.8696,
2770 -98.8284,
2771 -104.849,
2772 -90.309,
2773 -105.605,
2774 -120.412,
2775 -105.605,
2776 -100.412,
2777 -90.309,
2778 -99.5841,
2779 -92.1125,
2780 -89.2859,
2781 -98.1331,
2782 -94.3914,
2783 -102.35,
2784 -96.3296,
2785 -96.3296,
2786 -110.174,
2787 -91.4688,
2788 -101.327,
2789 -108.931,
2790 -96.8902,
2791 -93.5635,
2792 -97.4894,
2793 -90.8696,
2794 -85.4482,
2795 -108.371,
2796 -90.309,
2797 -99.5841,
2798 -92.1125,
2799 -94.3914,
2800 -93.5635,
2801 -400,
2802 -96.8902,
2803 -100.412,
2804 -97.4894,
2805 -92.1125,
2806 -86.0919,
2807 -102.35,
2808 -103.51,
2809 -101.327,
2810 -97.4894,
2811 -96.8902,
2812 -102.35,
2813 -92.8078,
2814 -99.5841,
2815 -120.412,
2816 -92.8078,
2817 -96.3296,
2818 -107.348,
2819 -101.327,
2820 -98.8284,
2821 -102.35,
2822 -96.3296,
2823 -106.433,
2824 -91.4688,
2825 -91.4688,
2826 -90.8696,
2827 -92.1125,
2828 -99.5841,
2829 -105.605,
2830 -90.8696,
2831 -114.952,
2832 -102.35,
2833 -92.8078,
2834 -98.1331,
2835 -99.5841,
2836 -96.3296,
2837 -96.3296,
2838 -98.8284,
2839 -107.348,
2840 -101.327,
2841 -86.7872,
2842 -86.7872,
2843 -90.8696,
2844 -98.8284,
2845 -102.35,
2846 -107.348,
2847 -113.368,
2848 -95.3065,
2849 -100.412,
2850 -96.3296,
2851 -95.3065,
2852 -90.309,
2853 -95.3065,
2854 -94.3914,
2855 -110.87,
2856 -93.5635,
2857 -90.309,
2858 -110.87,
2859 -97.4894,
2860 -120.412,
2861 -101.327,
2862 -95.3065,
2863 -93.5635,
2864 -89.2859,
2865 -92.1125,
2866 -95.3065,
2867 -87.5429,
2868 -89.2859,
2869 -90.8696,
2870 -98.1331,
2871 -99.5841,
2872 -109.531,
2873 -102.35,
2874 -102.35,
2875 -104.849,
2876 -96.3296,
2877 -107.348,
2878 -100.412,
2879 -91.4688,
2880 -109.531,
2881 -87.5429,
2882 -93.5635,
2883 -104.849,
2884 -95.3065,
2885 -118.474,
2886 -119.389,
2887 -96.3296,
2888 -92.1125,
2889 -90.309,
2890 -89.2859,
2891 -100.412,
2892 -92.1125,
2893 -123.667,
2894 -88.3708,
2895 -94.3914,
2896 -107.348,
2897 -122.216,
2898 -107.348,
2899 -108.371,
2900 -124.494,
2901 -96.3296,
2902 -107.348,
2903 -115.551,
2904 -96.3296,
2905 -97.4894,
2906 -90.8696,
2907 -98.8284,
2908 -96.8902,
2909 -89.2859,
2910 -104.154,
2911 -89.2859,
2912 -85.4482,
2913 -102.35,
2914 -96.3296,
2915 -112.453,
2916 -95.3065,
2917 -106.433,
2918 -92.1125,
2919 -108.931,
2920 -86.7872,
2921 -139.034,
2922 -95.3065,
2923 -108.371,
2924 -98.8284,
2925 -86.7872,
2926 -92.1125,
2927 -105.605,
2928 -90.309,
2929 -100.412,
2930 -93.5635,
2931 -108.371,
2932 -108.931,
2933 -105.605,
2934 -96.8902,
2935 -91.4688,
2936 -94.3914,
2937 -90.309,
2938 -96.8902,
2939 -101.327,
2940 -90.309,
2941 -100.412,
2942 -103.51,
2943 -128.236,
2944 -100.412,
2945 -90.309,
2946 -92.8078,
2947 -95.3065,
2948 -102.35,
2949 -93.5635,
2950 -84.2884,
2951 -96.8902,
2952 -103.51,
2953 -98.8284,
2954 -90.309,
2955 -86.7872,
2956 -93.5635,
2957 -93.5635,
2958 -103.51,
2959 -98.1331,
2960 -91.4688,
2961 -90.8696,
2962 -98.8284,
2963 -94.3914,
2964 -100.412,
2965 -96.8902,
2966 -85.4482,
2967 -100.412,
2968 -100.412,
2969 -96.3296,
2970 -82.3502,
2971 -83.2654,
2972 -79.4276,
2973 -86.7872,
2974 -92.8078,
2975 -85.4482,
2976 -100.412,
2977 -91.4688,
2978 -125.41,
2979 -90.309,
2980 -87.5429,
2981 -82.3502,
2982 -117.646,
2983 -92.1125,
2984 -83.2654,
2985 -104.849,
2986 -94.3914,
2987 -97.4894,
2988 -82.3502,
2989 -97.4894,
2990 -90.309,
2991 -86.7872,
2992 -114.952,
2993 -97.4894,
2994 -120.412,
2995 -115.551,
2996 -97.4894,
2997 -92.1125,
2998 -92.8078,
2999 -113.368,
3000 -109.531,
3001 -102.35,
3002 -107.348,
3003 -86.7872,
3004 -86.7872,
3005 -92.8078,
3006 -94.3914,
3007 -98.8284,
3008 -92.1125,
3009 -90.8696,
3010 -111.625,
3011 -92.8078,
3012 -100.412,
3013 -102.35,
3014 -89.2859,
3015 -93.5635,
3016 -96.3296,
3017 -86.0919,
3018 -96.8902,
3019 -111.625,
3020 -107.348,
3021 -131.43,
3022 -94.3914,
3023 -100.412,
3024 -92.1125,
3025 -91.4688,
3026 -93.5635,
3027 -120.412,
3028 -95.3065,
3029 -88.3708,
3030 -102.911,
3031 -90.309,
3032 -94.3914,
3033 -90.309,
3034 -89.2859,
3035 -90.309,
3036 -91.4688,
3037 -86.7872,
3038 -108.931,
3039 -98.1331,
3040 -107.348,
3041 -92.1125,
3042 -90.8696,
3043 -87.5429,
3044 -100.412,
3045 -96.8902,
3046 -101.327,
3047 -95.3065,
3048 -86.7872,
3049 -92.1125,
3050 -98.1331,
3051 -103.51,
3052 -98.8284,
3053 -95.3065,
3054 -94.3914,
3055 -102.35,
3056 -96.3296,
3057 -111.625,
3058 -91.4688,
3059 -103.51,
3060 -107.348,
3061 -98.1331,
3062 -90.309,
3063 -105.605,
3064 -95.3065,
3065 -92.1125,
3066 -90.309,
3067 -114.952,
3068 -102.35,
3069 -101.327,
3070 -97.4894,
3071 -104.849,
3072 -86.7872,
3073 -88.3708,
3074 -89.2859,
3075 -90.309,
3076 -92.1125,
3077 -99.5841,
3078 -98.8284,
3079 -91.4688,
3080 -100.412,
3081 -102.35,
3082 -94.3914,
3083 -96.8902,
3084 -94.3914,
3085 -102.35,
3086 -93.5635,
3087 -97.4894,
3088 -98.8284,
3089 -96.8902,
3090 -89.2859,
3091 -96.8902,
3092 -99.5841,
3093 -99.5841,
3094 -95.3065,
3095 -97.4894,
3096 -105.605,
3097 -112.453,
3098 -89.2859,
3099 -92.1125,
3100 -104.849,
3101 -91.4688,
3102 -104.849,
3103 -102.911,
3104 -101.327,
3105 -99.5841,
3106 -96.3296,
3107 -96.3296,
3108 -100.412,
3109 -94.3914,
3110 -107.348,
3111 -100.412,
3112 -102.35,
3113 -105.605,
3114 -98.8284,
3115 -95.3065,
3116 -104.849,
3117 -96.3296,
3118 -94.3914,
3119 -114.952,
3120 -96.3296,
3121 -103.51,
3122 -101.327,
3123 -96.3296,
3124 -97.4894,
3125 -95.3065,
3126 -93.5635,
3127 -102.911,
3128 -125.41,
3129 -110.174,
3130 -104.154,
3131 -100.412,
3132 -108.371,
3133 -91.4688,
3134 -106.433,
3135 -129.687,
3136 -121.572,
3137 -121.572,
3138 -98.8284,
3139 -101.327,
3140 -99.5841,
3141 -101.327,
3142 -95.3065,
3143 -97.4894,
3144 -105.605,
3145 -104.154,
3146 -97.4894,
3147 -92.8078,
3148 -102.35,
3149 -101.327,
3150 -106.433,
3151 -99.5841,
3152 -94.3914,
3153 -99.5841,
3154 -94.3914,
3155 -104.849,
3156 -92.1125,
3157 -100.412,
3158 -116.89,
3159 -123.667,
3160 -132.453,
3161 -97.4894,
3162 -99.5841,
3163 -94.3914,
3164 -105.605,
3165 -94.3914,
3166 -98.1331,
3167 -103.51,
3168 -109.531};
3169
3170 #include "../include/vorbis/vorbisenc.h"
3171 typedef struct {
3172   drft_lookup fft_look;
3173   vorbis_info_mode *mode;
3174   vorbis_info_mapping0 *map;
3175
3176   vorbis_look_time **time_look;
3177   vorbis_look_floor **floor_look;
3178
3179   vorbis_look_residue **residue_look;
3180   vorbis_look_psy *psy_look;
3181
3182   vorbis_func_time **time_func;
3183   vorbis_func_floor **floor_func;
3184   vorbis_func_residue **residue_func;
3185
3186   int ch;
3187   long lastframe; /* if a different mode is called, we need to 
3188                      invalidate decay */
3189 } vorbis_look_mapping0;
3190
3191 int main(){
3192   vorbis_info      vi; /* struct that stores all the static vorbis bitstream
3193                           settings */
3194   vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
3195   vorbis_block     vb; /* local working space for packet->PCM decode */
3196   backend_lookup_state *b;
3197   vorbis_look_mapping0  *m;
3198   float out[1024];
3199
3200   /* choose an encoding mode */
3201   /* (mode 0: 44kHz stereo uncoupled, roughly 128kbps VBR) */
3202   vorbis_info_init(&vi);
3203   vorbis_encode_init(&vi,2,44100, -1, 128000, -1);
3204
3205   /* set up the analysis state and auxiliary encoding storage */
3206   vorbis_analysis_init(&vd,&vi);
3207   vorbis_block_init(&vd,&vb);
3208   b=vd.backend_state;
3209   m=(vorbis_look_mapping0 *)(b->mode[1]);
3210
3211   floor1_forward(&vb,m->floor_look[0],
3212                  test_mdct, test_mdct,
3213                  test_mask, test_mdct,
3214                  test_mdct, out);
3215     
3216   _analysis_output("testout",0,out,1024,0,1);
3217 }
3218
3219 #endif