summaryrefslogtreecommitdiff
path: root/libavcodec/lpc.c
diff options
context:
space:
mode:
authorVitor Sessak <vitor1001@gmail.com>2008-09-04 11:03:14 +0000
committerVitor Sessak <vitor1001@gmail.com>2008-09-04 11:03:14 +0000
commit1be0fc2909fbcefd800d20cfff1420234fd0715b (patch)
tree5e947eaeb7845f55f3c6f09b81e67393d8fb74be /libavcodec/lpc.c
parent287ba997b5a4df061a0f6efb1cc7e2ae67831f7e (diff)
downloadffmpeg-1be0fc2909fbcefd800d20cfff1420234fd0715b.tar.gz
Avoid duplicating compute_lpc_coefs() function in both the RA288 and AAC decoders.
Originally committed as revision 15193 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/lpc.c')
-rw-r--r--libavcodec/lpc.c48
1 files changed, 8 insertions, 40 deletions
diff --git a/libavcodec/lpc.c b/libavcodec/lpc.c
index 253267c5aa..dd145ca875 100644
--- a/libavcodec/lpc.c
+++ b/libavcodec/lpc.c
@@ -21,45 +21,10 @@
#include "libavutil/lls.h"
#include "dsputil.h"
-#include "lpc.h"
-
-
-/**
- * Levinson-Durbin recursion.
- * Produces LPC coefficients from autocorrelation data.
- */
-static void compute_lpc_coefs(const double *autoc, int max_order,
- double lpc[][MAX_LPC_ORDER], double *ref)
-{
- int i, j;
- double err = autoc[0];
- double lpc_tmp[MAX_LPC_ORDER];
-
- for(i=0; i<max_order; i++) {
- double r = -autoc[i+1];
-
- for(j=0; j<i; j++)
- r -= lpc_tmp[j] * autoc[i-j];
- r /= err;
- ref[i] = fabs(r);
-
- err *= 1.0 - (r * r);
-
- lpc_tmp[i] = r;
- for(j=0; j < i>>1; j++) {
- double tmp = lpc_tmp[j];
- lpc_tmp[j] += r * lpc_tmp[i-1-j];
- lpc_tmp[i-1-j] += r * tmp;
- }
-
- if(i & 1)
- lpc_tmp[j] += lpc_tmp[j] * r;
+#define LPC_USE_DOUBLE
+#include "lpc.h"
- for(j=0; j<=i; j++)
- lpc[i][j] = -lpc_tmp[j];
- }
-}
/**
* Quantize LPC coefficients
@@ -106,7 +71,7 @@ static void quantize_lpc_coefs(double *lpc_in, int order, int precision,
/* output quantized coefficients and level shift */
error=0;
for(i=0; i<order; i++) {
- error += lpc_in[i] * (1 << sh);
+ error -= lpc_in[i] * (1 << sh);
lpc_out[i] = av_clip(lrintf(error), -qmax, qmax);
error -= lpc_out[i];
}
@@ -147,7 +112,10 @@ int ff_lpc_calc_coefs(DSPContext *s,
if(use_lpc == 1){
s->flac_compute_autocorr(samples, blocksize, max_order, autoc);
- compute_lpc_coefs(autoc, max_order, lpc, ref);
+ compute_lpc_coefs(autoc, max_order, &lpc[0][0], MAX_LPC_ORDER, 0, 1);
+
+ for(i=0; i<max_order; i++)
+ ref[i] = fabs(lpc[i][i]);
}else{
LLSModel m[2];
double var[MAX_LPC_ORDER+1], weight;
@@ -179,7 +147,7 @@ int ff_lpc_calc_coefs(DSPContext *s,
for(i=0; i<max_order; i++){
for(j=0; j<max_order; j++)
- lpc[i][j]= m[(pass-1)&1].coeff[i][j];
+ lpc[i][j]=-m[(pass-1)&1].coeff[i][j];
ref[i]= sqrt(m[(pass-1)&1].variance[i] / weight) * (blocksize - max_order) / 4000;
}
for(i=max_order-1; i>0; i--)