5 /******************************************************************
7 iLBC Speech Coder ANSI-C Source Code
15 ******************************************************************/
19 #include "iLBC_define.h"
20 #include "gainquant.h"
23 /*----------------------------------------------------------------*
24 * Convert the codebook indexes to make the search easier
25 *---------------------------------------------------------------*/
28 int *index
/* (i/o) Codebook indexes */
32 for (k
=1; k
<CB_NSTAGES
; k
++) {
34 if ((index
[k
]>=108)&&(index
[k
]<172)) {
36 } else if (index
[k
]>=236) {
45 int *index
/* (i/o) Codebook indexes */
49 for (k
=1; k
<CB_NSTAGES
; k
++) {
51 if ((index
[k
]>=44)&&(index
[k
]<108)) {
53 } else if ((index
[k
]>=108)&&(index
[k
]<128)) {
64 /*----------------------------------------------------------------*
65 * Construct decoded vector from codebook and gains.
66 *---------------------------------------------------------------*/
69 float *decvector
, /* (o) Decoded vector */
70 int *index
, /* (i) Codebook indices */
71 int *gain_index
,/* (i) Gain quantization indices */
72 float *mem
, /* (i) Buffer for codevector construction */
73 int lMem
, /* (i) Length of buffer */
74 int veclen
, /* (i) Length of vector */
75 int nStages
/* (i) Number of codebook stages */
78 float gain
[CB_NSTAGES
];
81 /* gain de-quantization */
83 gain
[0] = gaindequant(gain_index
[0], 1.0, 32);
85 gain
[1] = gaindequant(gain_index
[1],
86 (float)fabs(gain
[0]), 16);
89 gain
[2] = gaindequant(gain_index
[2],
90 (float)fabs(gain
[1]), 8);
93 /* codebook vector construction and construction of
96 getCBvec(cbvec
, mem
, index
[0], lMem
, veclen
);
97 for (j
=0;j
<veclen
;j
++){
98 decvector
[j
] = gain
[0]*cbvec
[j
];
101 for (k
=1; k
<nStages
; k
++) {
102 getCBvec(cbvec
, mem
, index
[k
], lMem
, veclen
);
103 for (j
=0;j
<veclen
;j
++) {
104 decvector
[j
] += gain
[k
]*cbvec
[j
];