********************************************************************
function: PCM data envelope analysis and manipulation
- last mod: $Id: envelope.c,v 1.24 2000/11/06 00:07:00 xiphmont Exp $
+ last mod: $Id: envelope.c,v 1.25 2000/11/07 09:51:42 xiphmont Exp $
Preecho calculation.
float *filtered=ve->filtered[i];
float *pcm=v->pcm[i];
IIR_state *iir=ve->iir+i;
- IIR_clamp(iir,9e-15);
+ int flag=1;
- for(j=ve->current;j<v->pcm_current;j++)
+ for(j=ve->current;j<v->pcm_current;j++){
filtered[j]=IIR_filter(iir,pcm[j]);
+ if(pcm[j])flag=0;
+ }
+ if(flag && ve->current+64<v->pcm_current)IIR_reset(iir);
}
+
ve->current=v->pcm_current;
/* Now search through our cached highpass data for breaking points */
********************************************************************
function: floor backend 0 implementation
- last mod: $Id: floor0.c,v 1.26 2000/11/06 00:07:00 xiphmont Exp $
+ last mod: $Id: floor0.c,v 1.27 2000/11/07 09:51:42 xiphmont Exp $
********************************************************************/
float *work=alloca((look->ln+look->n)*sizeof(float));
float amp;
long bits=0;
+ static int seq=0;
#ifdef TRAIN_LSP
FILE *of;
/* 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(lspwork,look->linearmap,look->n,look->ln,
+ work,look->m,amp,info->ampdB);
+ _analysis_output("prefit",seq,work,look->n,0,1);
+
+ }
+
+#endif
+
+
#if 1
#ifdef TRAIN_LSP
{
}
memset(out,0,sizeof(float)*look->n);
+ seq++;
return(0);
}
********************************************************************
function: Direct Form I, II IIR filters, plus some specializations
- last mod: $Id: iir.c,v 1.3 2000/11/06 00:07:00 xiphmont Exp $
+ last mod: $Id: iir.c,v 1.4 2000/11/07 09:51:43 xiphmont Exp $
********************************************************************/
}
}
+void IIR_reset(IIR_state *s){
+ memset(s->z_A,0,sizeof(float)*s->stages*2);
+}
+
float IIR_filter(IIR_state *s,float in){
int stages=s->stages,i;
float newA;
return(newB);
}
-/* prevents ringing down to underflow */
-void IIR_clamp(IIR_state *s,float thresh){
- float *zA=s->z_A+s->ring;
- int i;
- for(i=0;i<s->stages;i++)
- if(fabs(zA[i])>=thresh)break;
-
- if(i<s->stages)
- memset(s->z_A,0,sizeof(float)*s->stages*2);
-}
-
/* this assumes the symmetrical structure of the feed-forward stage of
a Chebyshev bandpass to save multiplies */
float IIR_filter_ChebBand(IIR_state *s,float in){
********************************************************************
function: Direct Form I, II IIR filters, plus some specializations
- last mod: $Id: iir.h,v 1.3 2000/11/06 00:07:00 xiphmont Exp $
+ last mod: $Id: iir.h,v 1.4 2000/11/07 09:51:43 xiphmont Exp $
********************************************************************/
extern void IIR_clear(IIR_state *s);
extern float IIR_filter(IIR_state *s,float in);
extern float IIR_filter_ChebBand(IIR_state *s,float in);
-extern void IIR_clamp(IIR_state *s,float thresh);
+extern void IIR_reset(IIR_state *s);
#endif
********************************************************************
function: channel mapping 0 implementation
- last mod: $Id: mapping0.c,v 1.17 2000/11/06 00:07:01 xiphmont Exp $
+ last mod: $Id: mapping0.c,v 1.18 2000/11/07 09:51:43 xiphmont Exp $
********************************************************************/
#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ogg/ogg.h>