From d4018c3a22d3eee203b018ba751ae00fd3549182 Mon Sep 17 00:00:00 2001
From: Jean-Marc Valin
Date: Wed, 27 Feb 2008 10:09:48 +1100
Subject: [PATCH] Reduced code duplication in vq.c by adding
mix_pitch_and_residual() which is used by both by the encoding and decoding
functions.
---
libcelt/vq.c | 128 +++++++++++++++++++++++------------------------------------
1 file changed, 50 insertions(+), 78 deletions(-)
diff --git a/libcelt/vq.c b/libcelt/vq.c
index 33c920bc..ff877bb0 100644
--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -59,6 +59,50 @@ static inline float approx_inv(float x)
#define approx_inv(x) (1.f/(x))
#endif
+/** Takes the pitch vector and the decoded residual vector (non-compressed),
+ applies the compression in the pitch direction, computes the gain that will
+ give ||p+g*y||=1 and mixes the residual with the pitch. */
+static void mix_pitch_and_residual(int *iy, celt_norm_t *X, int N, celt_norm_t *P, float alpha)
+{
+ int i;
+ float Rpp=0, Ryp=0, Ryy=0;
+ float g;
+ VARDECL(float *y);
+ VARDECL(float *x);
+ VARDECL(float *p);
+
+ ALLOC(y, N, float);
+ ALLOC(x, N, float);
+ ALLOC(p, N, float);
+
+ for (i=0;igain*y[0][i];
/* Sanity checks, don't bother */
if (0) {
+ for (i=0;igain*y[0][i];
float E=1e-15;
int ABS = 0;
for (i=0;i