1 /*
2 ** Copyright 2003-2010, VisualOn, Inc.
3 **
4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
7 **
8 ** http://www.apache.org/licenses/LICENSE-2.0
9 **
10 ** Unless required by applicable law or agreed to in writing, software
11 ** distributed under the License is distributed on an "AS IS" BASIS,
12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ** See the License for the specific language governing permissions and
14 ** limitations under the License.
15 */
16
17 /***************************************************************************
18 * File: qisf_ns.c *
19 * *
20 * Description: Coding/Decoding of ISF parameters for background noise.*
21 * The ISF vector is quantized using VQ with split-by-5 *
22 * *
23 ****************************************************************************/
24
25 #include "typedef.h"
26 #include "basic_op.h"
27 #include "acelp.h"
28 #include "qisf_ns.tab" /* Codebooks of ISFs */
29
30 /*------------------------------------------------------------------*
31 * routine: Qisf_ns() *
32 * ~~~~~~~~~ *
33 *------------------------------------------------------------------*/
34
Qisf_ns(Word16 * isf1,Word16 * isf_q,Word16 * indice)35 void Qisf_ns(
36 Word16 * isf1, /* input : ISF in the frequency domain (0..0.5) */
37 Word16 * isf_q, /* output: quantized ISF */
38 Word16 * indice /* output: quantization indices */
39 )
40 {
41 Word16 i;
42 Word32 tmp;
43
44 for (i = 0; i < ORDER; i++)
45 {
46 isf_q[i] = sub(isf1[i], mean_isf_noise[i]);
47 }
48
49 indice[0] = Sub_VQ(&isf_q[0], dico1_isf_noise, 2, SIZE_BK_NOISE1, &tmp);
50 indice[1] = Sub_VQ(&isf_q[2], dico2_isf_noise, 3, SIZE_BK_NOISE2, &tmp);
51 indice[2] = Sub_VQ(&isf_q[5], dico3_isf_noise, 3, SIZE_BK_NOISE3, &tmp);
52 indice[3] = Sub_VQ(&isf_q[8], dico4_isf_noise, 4, SIZE_BK_NOISE4, &tmp);
53 indice[4] = Sub_VQ(&isf_q[12], dico5_isf_noise, 4, SIZE_BK_NOISE5, &tmp);
54
55 /* decoding the ISFs */
56
57 Disf_ns(indice, isf_q);
58
59 return;
60 }
61
62 /********************************************************************
63 * Function: Disf_ns() *
64 * ~~~~~~~~~ *
65 * Decoding of ISF parameters *
66 *-------------------------------------------------------------------*
67 * Arguments: *
68 * indice[] : indices of the selected codebook entries *
69 * isf[] : quantized ISFs (in frequency domain) *
70 *********************************************************************/
71
Disf_ns(Word16 * indice,Word16 * isf_q)72 void Disf_ns(
73 Word16 * indice, /* input: quantization indices */
74 Word16 * isf_q /* input : ISF in the frequency domain (0..0.5) */
75 )
76 {
77 Word16 i;
78
79 for (i = 0; i < 2; i++)
80 {
81 isf_q[i] = dico1_isf_noise[indice[0] * 2 + i];
82 }
83 for (i = 0; i < 3; i++)
84 {
85 isf_q[i + 2] = dico2_isf_noise[indice[1] * 3 + i];
86 }
87 for (i = 0; i < 3; i++)
88 {
89 isf_q[i + 5] = dico3_isf_noise[indice[2] * 3 + i];
90 }
91 for (i = 0; i < 4; i++)
92 {
93 isf_q[i + 8] = dico4_isf_noise[indice[3] * 4 + i];
94 }
95 for (i = 0; i < 4; i++)
96 {
97 isf_q[i + 12] = dico5_isf_noise[indice[4] * 4 + i];
98 }
99
100 for (i = 0; i < ORDER; i++)
101 {
102 isf_q[i] = add(isf_q[i], mean_isf_noise[i]);
103 }
104
105 Reorder_isf(isf_q, ISF_GAP, ORDER);
106
107 return;
108 }
109
110
111
112