- float *work=alloca((look->ln+look->n)*sizeof(float));
- float amp;
- long bits=0;
- long val=0;
- static int seq=0;
-
-#ifdef TRAIN_LSP
- FILE *of;
- FILE *ef;
- char buffer[80];
-
-#if 1
- sprintf(buffer,"lsp0coeff_%d.vqd",vb->mode);
- of=fopen(buffer,"a");
-#endif
-
- sprintf(buffer,"lsp0ent_%d.vqd",vb->mode);
- ef=fopen(buffer,"a");
-#endif
-
- /* our floor comes in on a linear scale; go to a [-Inf...0] dB
- scale. The curve has to be positive, so we offset it. */
-
- for(j=0;j<look->n;j++)
- work[j]=todB(in[j])+info->ampdB;
-
- /* use 'out' as temp storage */
- /* Convert our floor to a set of lpc coefficients */
- amp=sqrt(_curve_to_lpc(work,out,look));
-
- /* amp is in the range (0. to ampdB]. Encode that range using
- ampbits bits */
-
- {
- long maxval=(1L<<info->ampbits)-1;
-
- val=rint(amp/info->ampdB*maxval);
-
- if(val<0)val=0; /* likely */
- if(val>maxval)val=maxval; /* not bloody likely */
-
- /*oggpack_write(&vb->opb,val,info->ampbits);*/
- if(val>0)
- amp=(float)val/maxval*info->ampdB;
- else
- amp=0;
- }
-
- if(val){
-
- /* the spec supports using one of a number of codebooks. Right
- now, encode using this lib supports only one */
- backend_lookup_state *be=vb->vd->backend_state;
- codebook *b=be->fullbooks+info->books[0];
- bitbuf_write(vbb,0,_ilog(info->numbooks));
-
- /* LSP <-> LPC is orthogonal and LSP quantizes more stably */
- vorbis_lpc_to_lsp(out,out,look->m);
-
-#ifdef ANALYSIS
- {
- float *lspwork=alloca(look->m*sizeof(float));
- memcpy(lspwork,out,look->m*sizeof(float));
- vorbis_lsp_to_curve(work,look->linearmap,look->n,look->ln,
- lspwork,look->m,amp,info->ampdB);
- _analysis_output("prefit",seq,work,look->n,0,1);