diff --git a/libcelt/arch.h b/libcelt/arch.h index 3e1af694..8534fc79 100644 --- a/libcelt/arch.h +++ b/libcelt/arch.h @@ -58,6 +58,7 @@ typedef celt_word16_t celt_pgain_t; typedef float celt_mask_t; #define Q15ONE 32767 +#define Q30ONE 1073741823 #define SIG_SCALING 16384.f #define SIG_SCALING_1 (1.f/16384.f) @@ -114,6 +115,7 @@ typedef float celt_pgain_t; typedef float celt_mask_t; #define Q15ONE 1.0f +#define Q30ONE 1.0f #define SIG_SCALING 1.f #define SIG_SCALING_1 1.f diff --git a/libcelt/quant_pitch.c b/libcelt/quant_pitch.c index 862425f2..f1a0247e 100644 --- a/libcelt/quant_pitch.c +++ b/libcelt/quant_pitch.c @@ -37,21 +37,28 @@ #include #include "pgain_table.h" #include "arch.h" +#include "mathops.h" + +#define PGAIN(codebook, i) ((celt_pgain_t)(Q15ONE*(codebook)[i])) + +#define Q1515ONE MULT16_16(Q15ONE,Q15ONE) /* Taken from Speex. Finds the index of the entry in a codebook that best matches the input*/ -int vq_index(float *in, const float *codebook, int len, int entries) +int vq_index(celt_pgain_t *in, const float *codebook, int len, int entries) { int i,j; - float min_dist=0; + int index = 0; + celt_word32_t min_dist=0; int best_index=0; for (i=0;i