[xiph-cvs] cvs commit: vorbis/lib envelope.c iir.c iir.h
Monty
xiphmont at xiph.org
Sat Nov 4 02:24:16 PST 2000
xiphmont 00/11/04 02:24:16
Modified: lib Tag: branch_beta3 envelope.c iir.c iir.h
Log:
Clamp IIR highpass in envelope code to zero below a threshhold to
avoid underflow.
Revision Changes Path
No revision
No revision
1.23.2.4 +2 -1 vorbis/lib/envelope.c
Index: envelope.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/envelope.c,v
retrieving revision 1.23.2.3
retrieving revision 1.23.2.4
diff -u -r1.23.2.3 -r1.23.2.4
--- envelope.c 2000/11/04 06:43:49 1.23.2.3
+++ envelope.c 2000/11/04 10:24:15 1.23.2.4
@@ -12,7 +12,7 @@
********************************************************************
function: PCM data envelope analysis and manipulation
- last mod: $Id: envelope.c,v 1.23.2.3 2000/11/04 06:43:49 xiphmont Exp $
+ last mod: $Id: envelope.c,v 1.23.2.4 2000/11/04 10:24:15 xiphmont Exp $
Preecho calculation.
@@ -174,6 +174,7 @@
float *filtered=ve->filtered[i];
float *pcm=v->pcm[i];
IIR_state *iir=ve->iir+i;
+ IIR_clamp(iir,9e-15);
for(j=ve->current;j<v->pcm_current;j++)
filtered[j]=IIR_filter(iir,pcm[j]);
1.2.2.3 +12 -3 vorbis/lib/iir.c
Index: iir.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/iir.c,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -u -r1.2.2.2 -r1.2.2.3
--- iir.c 2000/11/04 06:43:50 1.2.2.2
+++ iir.c 2000/11/04 10:24:15 1.2.2.3
@@ -12,7 +12,7 @@
********************************************************************
function: Direct Form I, II IIR filters, plus some specializations
- last mod: $Id: iir.c,v 1.2.2.2 2000/11/04 06:43:50 xiphmont Exp $
+ last mod: $Id: iir.c,v 1.2.2.3 2000/11/04 10:24:15 xiphmont Exp $
********************************************************************/
@@ -32,7 +32,6 @@
s->coeff_A=_ogg_malloc(stages*sizeof(float));
s->coeff_B=_ogg_malloc((stages+1)*sizeof(float));
s->z_A=_ogg_calloc(stages*2,sizeof(float));
- s->z_B=_ogg_calloc(stages*2,sizeof(float));
memcpy(s->coeff_A,A,stages*sizeof(float));
memcpy(s->coeff_B,B,(stages+1)*sizeof(float));
@@ -43,7 +42,6 @@
free(s->coeff_A);
free(s->coeff_B);
free(s->z_A);
- free(s->z_B);
memset(s,0,sizeof(IIR_state));
}
}
@@ -65,6 +63,17 @@
if(++s->ring>=stages)s->ring=0;
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
1.2.2.2 +6 -6 vorbis/lib/iir.h
Index: iir.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/iir.h,v
retrieving revision 1.2.2.1
retrieving revision 1.2.2.2
diff -u -r1.2.2.1 -r1.2.2.2
--- iir.h 2000/11/04 06:21:44 1.2.2.1
+++ iir.h 2000/11/04 10:24:15 1.2.2.2
@@ -12,7 +12,7 @@
********************************************************************
function: Direct Form I, II IIR filters, plus some specializations
- last mod: $Id: iir.h,v 1.2.2.1 2000/11/04 06:21:44 xiphmont Exp $
+ last mod: $Id: iir.h,v 1.2.2.2 2000/11/04 10:24:15 xiphmont Exp $
********************************************************************/
@@ -24,14 +24,14 @@
float *coeff_A;
float *coeff_B;
float *z_A;
- float *z_B;
int ring;
float gain;
} IIR_state;
-void IIR_init(IIR_state *s,int stages,float gain, float *A, float *B);
-void IIR_clear(IIR_state *s);
-float IIR_filter(IIR_state *s,float in);
-float IIR_filter_ChebBand(IIR_state *s,float in);
+extern void IIR_init(IIR_state *s,int stages,float gain, float *A, float *B);
+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);
#endif
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list