projects
/
platform
/
upstream
/
libvorbis.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix the compiling errors on msvc ARM64 configuration.
[platform/upstream/libvorbis.git]
/
lib
/
lpc.c
diff --git
a/lib/lpc.c
b/lib/lpc.c
index
cb41d2d
..
798f4cf
100644
(file)
--- a/
lib/lpc.c
+++ b/
lib/lpc.c
@@
-5,13
+5,12
@@
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
* *
- * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-200
2
*
- * by the X
IPHOPHORUS Company
http://www.xiph.org/ *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-200
9
*
+ * by the X
iph.Org Foundation
http://www.xiph.org/ *
* *
********************************************************************
function: LPC low level routines
* *
********************************************************************
function: LPC low level routines
- last mod: $Id: lpc.c,v 1.36 2003/03/07 09:13:30 xiphmont Exp $
********************************************************************/
********************************************************************/
@@
-62,6
+61,7
@@
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;
double *aut=alloca(sizeof(*aut)*(m+1));
double *lpc=alloca(sizeof(*lpc)*(m));
double error;
+ double epsilon;
int i,j;
/* autocorrelation, p+1 lag coefficients */
int i,j;
/* autocorrelation, p+1 lag coefficients */
@@
-71,17
+71,19
@@
float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){
for(i=j;i<n;i++)d+=(double)data[i]*data[i-j];
aut[j]=d;
}
for(i=j;i<n;i++)d+=(double)data[i]*data[i-j];
aut[j]=d;
}
-
+
/* Generate lpc coefficients from autocorr values */
/* Generate lpc coefficients from autocorr values */
- error=aut[0];
-
+ /* set our noise floor to about -100dB */
+ error=aut[0] * (1. + 1e-10);
+ epsilon=1e-9*aut[0]+1e-10;
+
for(i=0;i<m;i++){
double r= -aut[i+1];
for(i=0;i<m;i++){
double r= -aut[i+1];
- if(error
==0
){
- memset(lpc
,0,m
*sizeof(*lpc));
-
return 0
;
+ if(error
<epsilon
){
+ memset(lpc
+i,0,(m-i)
*sizeof(*lpc));
+
goto done
;
}
/* Sum up this iteration's reflection coefficient; note that in
}
/* Sum up this iteration's reflection coefficient; note that in
@@
-90,10
+92,10
@@
float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){
each iteration. */
for(j=0;j<i;j++)r-=lpc[j]*aut[i-j];
each iteration. */
for(j=0;j<i;j++)r-=lpc[j]*aut[i-j];
- r/=error;
+ r/=error;
/* Update LPC coefficients and total error */
/* Update LPC coefficients and total error */
-
+
lpc[i]=r;
for(j=0;j<i/2;j++){
double tmp=lpc[j];
lpc[i]=r;
for(j=0;j<i/2;j++){
double tmp=lpc[j];
@@
-101,23
+103,36
@@
float vorbis_lpc_from_data(float *data,float *lpci,int n,int m){
lpc[j]+=r*lpc[i-1-j];
lpc[i-1-j]+=r*tmp;
}
lpc[j]+=r*lpc[i-1-j];
lpc[i-1-j]+=r*tmp;
}
- if(i%2)lpc[j]+=lpc[j]*r;
+ if(i&1)lpc[j]+=lpc[j]*r;
+
+ error*=1.-r*r;
- error*=1.f-r*r;
+ }
+
+ done:
+
+ /* slightly damp the filter */
+ {
+ double g = .99;
+ double damp = g;
+ for(j=0;j<m;j++){
+ lpc[j]*=damp;
+ damp*=g;
+ }
}
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 */
}
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;
}
void vorbis_lpc_predict(float *coeff,float *prime,int m,
float *data,long n){
return error;
}
void vorbis_lpc_predict(float *coeff,float *prime,int m,
float *data,long n){
- /* in: coeff[0...m-1] LPC coefficients
+ /* in: coeff[0...m-1] LPC coefficients
prime[0...m-1] initial values (allocated size of n+m-1)
out: data[0...n-1] data samples */
prime[0...m-1] initial values (allocated size of n+m-1)
out: data[0...n-1] data samples */
@@
-138,12
+153,7
@@
void vorbis_lpc_predict(float *coeff,float *prime,int m,
p=m;
for(j=0;j<m;j++)
y-=work[o++]*coeff[--p];
p=m;
for(j=0;j<m;j++)
y-=work[o++]*coeff[--p];
-
+
data[i]=work[o]=y;
}
}
data[i]=work[o]=y;
}
}
-
-
-
-
-