Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/celt-0.7.0.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Marc Valin <jean-marc.valin@usherbrooke.ca>2009-10-20 15:13:35 +0400
committerJean-Marc Valin <jean-marc.valin@usherbrooke.ca>2009-10-20 15:13:35 +0400
commita3bba38b49a1d12d22f7949786a266e410aa884e (patch)
tree6b849f8b399f36bda6dde795c8fd2d3d4b0d7aca
parentbd5d54adb837b94ba648e9f7770b59bf64cb4e6c (diff)
This should prevent a rare divide-by-zero in the pitch gain code
-rw-r--r--libcelt/bands.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libcelt/bands.c b/libcelt/bands.c
index 231b2cd..d414b66 100644
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -262,12 +262,14 @@ int compute_pitch_gain(const CELTMode *m, const celt_sig *X, const celt_sig *P,
fact = QCONST16(1., 14);
num = Sxy;
den = EPSILON+Sxx+MULT16_32_Q15(QCONST16(.03,15),Syy);
- shift = celt_ilog2(Sxy)-16;
+ shift = celt_zlog2(Sxy)-16;
if (shift < 0)
shift = 0;
- g = DIV32(SHL32(SHR32(num,shift),14),SHR32(den,shift));
if (Sxy < MULT16_32_Q15(fact, MULT16_16(celt_sqrt(EPSILON+Sxx),celt_sqrt(EPSILON+Syy))))
g = 0;
+ else
+ g = DIV32(SHL32(SHR32(num,shift),14),ADD32(EPSILON,SHR32(den,shift)));
+
/* This MUST round down so that we don't over-estimate the gain */
*gain_id = EXTRACT16(SHR32(MULT16_16(20,(g-QCONST16(.5,14))),14));
}