Browse code

lavc/lpc: exploit even symmetry of window function

Yields 2x improvement in function performance, and boosts aac encoding
speed by ~ 4% overall. Sample benchmark (Haswell+GCC under -march=native):
after:
ffmpeg -i sin.flac -acodec aac -y sin_new.aac 5.22s user 0.03s system 105% cpu 4.970 total

before:
ffmpeg -i sin.flac -acodec aac -y sin_new.aac 5.40s user 0.05s system 105% cpu 5.162 total

Reviewed-by: Rostislav Pehlivanov <atomnuker@gmail.com>
Signed-off-by: Ganesh Ajjanagadde <gajjanag@gmail.com>

Ganesh Ajjanagadde authored on 2016/03/09 12:08:29
Showing 1 changed files
... ...
@@ -176,9 +176,10 @@ double ff_lpc_calc_ref_coefs_f(LPCContext *s, const float *samples, int len,
176 176
     const double a = 0.5f, b = 1.0f - a;
177 177
 
178 178
     /* Apply windowing */
179
-    for (i = 0; i < len; i++) {
179
+    for (i = 0; i <= len / 2; i++) {
180 180
         double weight = a - b*cos((2*M_PI*i)/(len - 1));
181 181
         s->windowed_samples[i] = weight*samples[i];
182
+        s->windowed_samples[len-1-i] = weight*samples[len-1-i];
182 183
     }
183 184
 
184 185
     s->lpc_compute_autocorr(s->windowed_samples, len, order, autoc);