[xiph-cvs] cvs commit: vorbis/lib floor0.c lpc.c lpc.h
Monty
xiphmont at xiph.org
Fri Mar 7 01:13:31 PST 2003
xiphmont 03/03/07 04:13:30
Modified: lib floor0.c lpc.c lpc.h
Log:
LPC filter generation (for pre- and post-extrapolation) requires
greater than float mantissa depth. Go to doubles for filter generation.
Revision Changes Path
1.54 +1 -12 vorbis/lib/floor0.c
Index: floor0.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/floor0.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- floor0.c 17 Jul 2002 21:34:31 -0000 1.53
+++ floor0.c 7 Mar 2003 09:13:30 -0000 1.54
@@ -11,7 +11,7 @@
********************************************************************
function: floor backend 0 implementation
- last mod: $Id: floor0.c,v 1.53 2002/07/17 21:34:31 xiphmont Exp $
+ last mod: $Id: floor0.c,v 1.54 2003/03/07 09:13:30 xiphmont Exp $
********************************************************************/
@@ -39,8 +39,6 @@
int n[2];
vorbis_info_floor0 *vi;
- lpc_lookup lpclook;
- float *lsp_look;
long bits;
long frames;
@@ -68,8 +66,6 @@
_ogg_free(look->linearmap);
}
- if(look->lsp_look)_ogg_free(look->lsp_look);
- lpc_clear(&look->lpclook);
memset(look,0,sizeof(*look));
_ogg_free(look);
}
@@ -154,14 +150,7 @@
look->ln=info->barkmap;
look->vi=info;
- if(vd->analysisp)
- lpc_init(&look->lpclook,look->ln,look->m);
-
look->linearmap=_ogg_calloc(2,sizeof(*look->linearmap));
-
- look->lsp_look=_ogg_malloc(look->ln*sizeof(*look->lsp_look));
- for(j=0;j<look->ln;j++)
- look->lsp_look[j]=2*cos(M_PI/look->ln*j);
return look;
}
<p><p>1.36 +13 -64 vorbis/lib/lpc.c
Index: lpc.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/lpc.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- lpc.c 11 Jul 2002 06:40:49 -0000 1.35
+++ lpc.c 7 Mar 2003 09:13:30 -0000 1.36
@@ -11,7 +11,7 @@
********************************************************************
function: LPC low level routines
- last mod: $Id: lpc.c,v 1.35 2002/07/11 06:40:49 xiphmont Exp $
+ last mod: $Id: lpc.c,v 1.36 2003/03/07 09:13:30 xiphmont Exp $
********************************************************************/
@@ -58,17 +58,17 @@
/* Input : n elements of time doamin data
Output: m lpc coefficients, excitation energy */
-float vorbis_lpc_from_data(float *data,float *lpc,int n,int m){
- float *aut=alloca(sizeof(*aut)*(m+1));
- float error;
+float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){
+ double *aut=alloca(sizeof(*aut)*(m+1));
+ double *lpc=alloca(sizeof(*lpc)*(m));
+ double error;
int i,j;
/* autocorrelation, p+1 lag coefficients */
-
j=m+1;
while(j--){
double d=0; /* double needed for accumulator depth */
- for(i=j;i<n;i++)d+=data[i]*data[i-j];
+ for(i=j;i<n;i++)d+=(double)data[i]*data[i-j];
aut[j]=d;
}
@@ -77,7 +77,7 @@
error=aut[0];
for(i=0;i<m;i++){
- float r= -aut[i+1];
+ double r= -aut[i+1];
if(error==0){
memset(lpc,0,m*sizeof(*lpc));
@@ -96,73 +96,22 @@
lpc[i]=r;
for(j=0;j<i/2;j++){
- float tmp=lpc[j];
+ double tmp=lpc[j];
+
lpc[j]+=r*lpc[i-1-j];
lpc[i-1-j]+=r*tmp;
}
if(i%2)lpc[j]+=lpc[j]*r;
-
+
error*=1.f-r*r;
}
-
+
+ for(j=0;j<m;j++)lpci[j]=(float)lpc[j];
+
/* we need the error value to know how big an impulse to hit the
filter with later */
return error;
-}
-
-/* Input : n element envelope spectral curve
- Output: m lpc coefficients, excitation energy */
-
-float vorbis_lpc_from_curve(float *curve,float *lpc,lpc_lookup *l){
- int n=l->ln;
- int m=l->m;
- float *work=alloca(sizeof(*work)*(n+n));
- float fscale=.5f/n;
- int i,j;
-
- /* input is a real curve. make it complex-real */
- /* This mixes phase, but the LPC generation doesn't care. */
- for(i=0;i<n;i++){
- work[i*2]=curve[i]*fscale;
- work[i*2+1]=0;
- }
- work[n*2-1]=curve[n-1]*fscale;
-
- n*=2;
- drft_backward(&l->fft,work);
-
- /* The autocorrelation will not be circular. Shift, else we lose
- most of the power in the edges. */
-
- for(i=0,j=n/2;i<n/2;){
- float temp=work[i];
- work[i++]=work[j];
- work[j++]=temp;
- }
-
- /* we *could* shave speed here by skimping on the edges (thus
- speeding up the autocorrelation in vorbis_lpc_from_data) but we
- don't right now. */
-
- return(vorbis_lpc_from_data(work,lpc,n,m));
-}
-
-void lpc_init(lpc_lookup *l,long mapped, int m){
- memset(l,0,sizeof(*l));
-
- l->ln=mapped;
- l->m=m;
-
- /* we cheat decoding the LPC spectrum via FFTs */
- drft_init(&l->fft,mapped*2);
-
-}
-
-void lpc_clear(lpc_lookup *l){
- if(l){
- drft_clear(&l->fft);
- }
}
void vorbis_lpc_predict(float *coeff,float *prime,int m,
<p><p>1.20 +1 -15 vorbis/lib/lpc.h
Index: lpc.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis/lib/lpc.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- lpc.h 11 Jul 2002 06:40:49 -0000 1.19
+++ lpc.h 7 Mar 2003 09:13:30 -0000 1.20
@@ -11,7 +11,7 @@
********************************************************************
function: LPC low level routines
- last mod: $Id: lpc.h,v 1.19 2002/07/11 06:40:49 xiphmont Exp $
+ last mod: $Id: lpc.h,v 1.20 2003/03/07 09:13:30 xiphmont Exp $
********************************************************************/
@@ -19,23 +19,9 @@
#define _V_LPC_H_
#include "vorbis/codec.h"
-#include "smallft.h"
-
-typedef struct lpclook{
- /* en/decode lookups */
- drft_lookup fft;
-
- int ln;
- int m;
-
-} lpc_lookup;
-
-extern void lpc_init(lpc_lookup *l,long mapped, int m);
-extern void lpc_clear(lpc_lookup *l);
/* simple linear scale LPC code */
extern float vorbis_lpc_from_data(float *data,float *lpc,int n,int m);
-extern float vorbis_lpc_from_curve(float *curve,float *lpc,lpc_lookup *l);
extern void vorbis_lpc_predict(float *coeff,float *prime,int m,
float *data,long n);
<p><p>--- >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