-/* less efficient than the decode side (written for clarity). We're
- not bottlenecked here anyway */
-
-double _curve_to_lpc(double *curve,double *lpc,
- vorbis_look_floor0 *l,long frameno){
- /* map the input curve to a bark-scale curve for encoding */
-
- int mapped=l->ln;
- double *work=alloca(sizeof(double)*mapped);
- int i,j,last=0;
- int bark=0;
-
- memset(work,0,sizeof(double)*mapped);
-
- /* Only the decode side is behavior-specced; for now in the encoder,
- we select the maximum value of each band as representative (this
- helps make sure peaks don't go out of range. In error terms,
- selecting min would make more sense, but the codebook is trained
- numerically, so we don't actually lose. We'd still want to
- use the original curve for error and noise estimation */
-
- for(i=0;i<l->n;i++){
- bark=l->linearmap[i];
- if(work[bark]<curve[i])work[bark]=curve[i];
- if(bark>last+1){
- /* If the bark scale is climbing rapidly, some bins may end up
- going unused. This isn't a waste actually; it keeps the
- scale resolution even so that the LPC generator has an easy
- time. However, if we leave the bins empty we lose energy.
- So, fill 'em in. The decoder does not do anything with he
- unused bins, so we can fill them anyway we like to end up
- with a better spectral curve */
-
- /* we'll always have a bin zero, so we don't need to guard init */
- long span=bark-last;
- for(j=1;j<span;j++){
- double del=(double)j/span;
- work[j+last]=work[bark]*del+work[last]*(1.-del);
- }
- }
- last=bark;
- }
-
- /* If we're over-ranged to avoid edge effects, fill in the end of spectrum gap */
- for(i=bark+1;i<mapped;i++)
- work[i]=work[i-1];
-
-#if 0
- { /******************/
- FILE *of;
- char buffer[80];
- int i;
-
- sprintf(buffer,"Fmask_%d.m",frameno);
- of=fopen(buffer,"w");
- for(i=0;i<mapped;i++)
- fprintf(of,"%g\n",work[i]);
- fclose(of);
- }
-#endif
-
- return vorbis_lpc_from_curve(work,lpc,&(l->lpclook));
-}
-
-/* generate the whole freq response curve of an LPC IIR filter */