From c93ccf5a4cca722b39f05e9f5660b4cb75bc1740 Mon Sep 17 00:00:00 2001 From: Loren Merritt Date: Sun, 16 Jun 2013 00:53:47 +0000 Subject: [PATCH] lpc: use levinson for the first pass of multipass cholesky Levinson is faster, and cholesky is only needed if we want to apply different weights to different samples, which doesn't happen on the first pass. Signed-off-by: Luca Barbato --- libavcodec/lpc.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/libavcodec/lpc.c b/libavcodec/lpc.c index 144bbede44..995e4e2ad4 100644 --- a/libavcodec/lpc.c +++ b/libavcodec/lpc.c @@ -176,7 +176,7 @@ int ff_lpc_calc_coefs(LPCContext *s, double autoc[MAX_LPC_ORDER+1]; double ref[MAX_LPC_ORDER]; double lpc[MAX_LPC_ORDER][MAX_LPC_ORDER]; - int i, j, pass; + int i, j, pass = 0; int opt_order; assert(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER && @@ -189,7 +189,7 @@ int ff_lpc_calc_coefs(LPCContext *s, ff_lpc_init(s, blocksize, max_order, lpc_type); } - if (lpc_type == FF_LPC_TYPE_LEVINSON) { + if (lpc_type == FF_LPC_TYPE_LEVINSON || (lpc_type == FF_LPC_TYPE_CHOLESKY && lpc_passes > 1)) { s->lpc_apply_welch_window(samples, blocksize, s->windowed_samples); s->lpc_compute_autocorr(s->windowed_samples, blocksize, max_order, autoc); @@ -198,13 +198,20 @@ int ff_lpc_calc_coefs(LPCContext *s, for(i=0; imax_order = max_order; s->lpc_type = lpc_type; - if (lpc_type == FF_LPC_TYPE_LEVINSON) { - s->windowed_buffer = av_mallocz((blocksize + 2 + FFALIGN(max_order, 4)) * - sizeof(*s->windowed_samples)); - if (!s->windowed_buffer) - return AVERROR(ENOMEM); - s->windowed_samples = s->windowed_buffer + FFALIGN(max_order, 4); - } else { - s->windowed_samples = NULL; - } + s->windowed_buffer = av_mallocz((blocksize + 2 + FFALIGN(max_order, 4)) * + sizeof(*s->windowed_samples)); + if (!s->windowed_buffer) + return AVERROR(ENOMEM); + s->windowed_samples = s->windowed_buffer + FFALIGN(max_order, 4); s->lpc_apply_welch_window = lpc_apply_welch_window_c; s->lpc_compute_autocorr = lpc_compute_autocorr_c;