summaryrefslogtreecommitdiffstats
path: root/libavcodec/lpc.c
diff options
context:
space:
mode:
authorRostislav Pehlivanov <atomnuker@gmail.com>2015-09-19 16:25:58 +0100
committerRostislav Pehlivanov <atomnuker@gmail.com>2015-09-19 16:25:58 +0100
commit0cfdaf45c41ab62bef7f74c12950d755a26a301b (patch)
tree4346ca43272afb40b964141c521c742754fe9599 /libavcodec/lpc.c
parent9db6c8815d9dc2f18b1a996372ec71900adb3638 (diff)
downloadffmpeg-streaming-0cfdaf45c41ab62bef7f74c12950d755a26a301b.zip
ffmpeg-streaming-0cfdaf45c41ab62bef7f74c12950d755a26a301b.tar.gz
lpc: correctly apply windowing to the samples in the float-only lpc
Also change the window to Hamming (using coefficient which make it a Hanning). Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Diffstat (limited to 'libavcodec/lpc.c')
-rw-r--r--libavcodec/lpc.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/libavcodec/lpc.c b/libavcodec/lpc.c
index 5cda779..3839119 100644
--- a/libavcodec/lpc.c
+++ b/libavcodec/lpc.c
@@ -173,11 +173,13 @@ double ff_lpc_calc_ref_coefs_f(LPCContext *s, const float *samples, int len,
int i;
double signal = 0.0f, avg_err = 0.0f;
double autoc[MAX_LPC_ORDER+1] = {0}, error[MAX_LPC_ORDER+1] = {0};
- const double c = (len - 1)/2.0f;
+ const double a = 0.5f, b = 1.0f - a;
- /* Welch window */
- for (i = 0; i < len; i++)
- s->windowed_samples[i] = 1.0f - ((samples[i]-c)/c)*((samples[i]-c)/c);
+ /* Apply windowing */
+ for (i = 0; i < len; i++) {
+ double weight = a - b*cos((2*M_PI*i)/(len - 1));
+ s->windowed_samples[i] = weight*samples[i];
+ }
s->lpc_compute_autocorr(s->windowed_samples, len, order, autoc);
signal = autoc[0];
OpenPOWER on IntegriCloud