********************************************************************
function: PCM data envelope analysis and manipulation
- last mod: $Id: envelope.c,v 1.21 2000/08/15 09:09:42 xiphmont Exp $
+ last mod: $Id: envelope.c,v 1.22 2000/08/31 08:01:34 xiphmont Exp $
Preecho calculation.
Command line: /www/usr/fisher/helpers/mkfilter -Ch \
-6.0000000000e+00 -Bp -o 5 -a 1.3605442177e-01 3.1746031746e-01 -l */
+#if 0
static int cheb_bandpass_stages=10;
static double cheb_bandpass_gain=5.589612458e+01;
-/* z^-stage, z^-stage+1... */
static double cheb_bandpass_B[]={-1.,0.,5.,0.,-10.,0.,10.,0.,-5.,0.,1};
static double cheb_bandpass_A[]={
-0.1917409386,
0.0451493360,
-1.4471447397,
0.0303413711};
+#endif
static int cheb_highpass_stages=10;
static double cheb_highpass_gain= 5.291963434e+01;
2.3920318913};
void _ve_envelope_init(envelope_lookup *e,vorbis_info *vi){
- long rate=vi->rate;
int ch=vi->channels;
int window=vi->envelopesa;
int i;
memset(e,0,sizeof(envelope_lookup));
}
-/*static int frameno=0;*/
-
-static void smooth_noise(long n,double *f,double *noise){
- long i;
- long lo=0,hi=0;
- double acc=0.;
-
- for(i=0;i<n;i++){
- long newhi=i*1.0442718740+5;
- long newlo=i*.8781245150-5;
- if(newhi>n)newhi=n;
-
- for(;lo<newlo;lo++)
- acc-=f[lo]*f[lo];
- for(;hi<newhi;hi++)
- acc+=f[hi]*f[hi];
- noise[i]=todB(sqrt(acc/(hi-lo)));
- }
-}
-
static double _ve_deltai(envelope_lookup *ve,IIR_state *iir,
double *pre,double *post){
- long no=ve->winlength/3; /* past the highpass rollon! */
long n2=ve->winlength*2;
long n=ve->winlength;
********************************************************************
function: floor backend 0 implementation
- last mod: $Id: floor0.c,v 1.23 2000/08/23 10:16:56 xiphmont Exp $
+ last mod: $Id: floor0.c,v 1.24 2000/08/31 08:01:34 xiphmont Exp $
********************************************************************/
double *workfit,
int cursor){
int dim=book->dim;
- double norm,base=0.,err=0.;
+ double norm,base=0.;
int i,best=0;
double *lsp=workfit+cursor;
return vorbis_lpc_from_curve(work,lpc,&(l->lpclook));
}
-/* generate the whole freq response curve of an LPC IIR filter */
+/* generate the whole freq response curve of an LSP IIR filter */
void _lsp_to_curve(double *curve,double *lsp,double amp,
vorbis_look_floor0 *l,char *name,long frameno){
/* 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++){
- double val=todB(in[j])+info->ampdB;
- if(val<1.)
- work[j]=1.;
- else
- work[j]=val;
- }
+ 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,seq));
-
+
/* amp is in the range (0. to ampdB]. Encode that range using
ampbits bits */
********************************************************************
function: psychoacoustics not including preecho
- last mod: $Id: psy.c,v 1.26 2000/08/23 06:38:49 xiphmont Exp $
+ last mod: $Id: psy.c,v 1.27 2000/08/31 08:01:34 xiphmont Exp $
********************************************************************/
double decscale=fromdB(p->vi->decay_coeff*n);
double attscale=1./fromdB(p->vi->attack_coeff);
- static int frameno=0;
-
for(i=10;i<n;i++){
double pre=decay[i];
if(decay[i]){
double acc=0.,val,del=0.;
double *norm=alloca(n*sizeof(double));
- double normacc=0;
memset(noise,0,n*sizeof(double));
memset(norm,0,n*sizeof(double));
{
long ilo=i-lo;
long hii=hi-i;
- long hilo=hi-lo;
for(;i<n;i++){
val=todB(f[i]*f[i])+400.;
}
}
-/* stability doesn't matter */
-static int comp(const void *a,const void *b){
- if(fabs(**(double **)a)<fabs(**(double **)b))
- return(1);
- else
- return(-1);
-}
-
-static int frameno=0;
void _vp_compute_mask(vorbis_look_psy *p,double *f,
double *flr,
double *decay){
}
- frameno++;
+ /* doing this here is clean, but we need to find a faster way to do
+ it than to just tack it on */
+
+ for(i=0;i<n;i++)if(2.*f[i]>flr[i] || -2.*f[i]>flr[i])break;
+ if(i==n)memset(flr,0,sizeof(double)*n);
+
}
/* f and flr are *linear* scale, not dB */
void _vp_apply_floor(vorbis_look_psy *p,double *f, double *flr){
double *work=alloca(p->n*sizeof(double));
- int i,j,addcount=0;
+ int j;
/* subtract the floor */
for(j=0;j<p->n;j++){
********************************************************************
function: basic shared codebook operations
- last mod: $Id: sharedbook.c,v 1.7 2000/07/19 18:10:46 xiphmont Exp $
+ last mod: $Id: sharedbook.c,v 1.8 2000/08/31 08:01:34 xiphmont Exp $
********************************************************************/
encode_aux_pigeonhole *pt=book->c->pigeon_tree;
int dim=book->dim;
int ptr=0,k,o;
- int savebest=-1;
- double saverr;
+ /*int savebest=-1;
+ double saverr;*/
/* do we have a threshhold encode hint? */
if(tt){