[FFmpeg-cvslog] lpc: correctly apply windowing to the samples in the float-only lpc

Rostislav Pehlivanov git at videolan.org
Sat Sep 19 17:26:50 CEST 2015


ffmpeg | branch: master | Rostislav Pehlivanov <atomnuker at gmail.com> | Sat Sep 19 16:25:58 2015 +0100| [0cfdaf45c41ab62bef7f74c12950d755a26a301b] | committer: Rostislav Pehlivanov

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 at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0cfdaf45c41ab62bef7f74c12950d755a26a301b
---

 libavcodec/lpc.c   |   10 ++++++----
 tests/fate/aac.mak |    2 +-
 2 files changed, 7 insertions(+), 5 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];
diff --git a/tests/fate/aac.mak b/tests/fate/aac.mak
index 72fc59d..f30d4db 100644
--- a/tests/fate/aac.mak
+++ b/tests/fate/aac.mak
@@ -181,7 +181,7 @@ fate-aac-tns-encode: CMD = enc_dec_pcm adts wav s16le $(TARGET_SAMPLES)/audio-re
 fate-aac-tns-encode: CMP = stddev
 fate-aac-tns-encode: REF = $(SAMPLES)/audio-reference/luckynight_2ch_44kHz_s16.wav
 fate-aac-tns-encode: CMP_SHIFT = -4096
-fate-aac-tns-encode: CMP_TARGET = 650.28
+fate-aac-tns-encode: CMP_TARGET = 650.37
 fate-aac-tns-encode: FUZZ = 2.8
 fate-aac-tns-encode: SIZE_TOLERANCE = 3560
 



More information about the ffmpeg-cvslog mailing list