From cab576ec9b4451954bc318e37412a14b74c1cee7 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Tue, 12 Feb 2008 17:21:14 +1100 Subject: [PATCH] Updating only the L-best entries in alg_quant() that are useful. --- libcelt/vq.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/libcelt/vq.c b/libcelt/vq.c index 388df6b2..ee55ae9c 100644 --- a/libcelt/vq.c +++ b/libcelt/vq.c @@ -92,18 +92,20 @@ void alg_quant(float *x, float *W, int N, int K, float *p, float alpha, ec_enc * while (pulsesLeft > 0) { int pulsesAtOnce=1; + int Lupdate = L; int L2 = L; - if (L>maxL) + pulsesAtOnce = pulsesLeft/N; + if (pulsesAtOnce<1) + pulsesAtOnce = 1; + if (pulsesLeft-pulsesAtOnce > 3 || N > 30) + Lupdate = 1; + //printf ("%d %d %d/%d %d\n", Lupdate, pulsesAtOnce, pulsesLeft, K, N); + L2 = Lupdate; + if (L2>maxL) { L2 = maxL; maxL *= N; } - if (pulsesLeft > 5) - L2 = 1; - - pulsesAtOnce = pulsesLeft/N; - if (pulsesAtOnce<1) - pulsesAtOnce = 1; for (m=0;mbest_scores[L-1]) + if (score>best_scores[Lupdate-1]) { int k, n; - int id = L-1; + int id = Lupdate-1; float *tmp_ny; int *tmp_iny; - tmp_ny = ny[L-1]; - tmp_iny = iny[L-1]; + tmp_ny = ny[Lupdate-1]; + tmp_iny = iny[Lupdate-1]; while (id > 0 && score > best_scores[id-1]) id--; - for (k=L-1;k>id;k--) + for (k=Lupdate-1;k>id;k--) { nxy[k] = nxy[k-1]; nyy[k] = nyy[k-1]; @@ -181,7 +183,7 @@ void alg_quant(float *x, float *W, int N, int K, float *p, float alpha, ec_enc * } int k; - for (k=0;k