Git init
[external/opencore-amr.git] / opencore / codecs_v2 / audio / gsm_amr / amr_wb / dec / src / qisf_ns.cpp
1 /* ------------------------------------------------------------------
2  * Copyright (C) 1998-2009 PacketVideo
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
13  * express or implied.
14  * See the License for the specific language governing permissions
15  * and limitations under the License.
16  * -------------------------------------------------------------------
17  */
18 /****************************************************************************************
19 Portions of this file are derived from the following 3GPP standard:
20
21     3GPP TS 26.173
22     ANSI-C code for the Adaptive Multi-Rate - Wideband (AMR-WB) speech codec
23     Available from http://www.3gpp.org
24
25 (C) 2007, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC)
26 Permission to distribute, modify and use this file under the standard license
27 terms listed above has been obtained from the copyright holder.
28 ****************************************************************************************/
29 /*
30 ------------------------------------------------------------------------------
31
32
33
34  Filename: qisf_ns.cpp
35
36 ------------------------------------------------------------------------------
37  INPUT AND OUTPUT DEFINITIONS
38
39      int16 indice[] : indices of the selected codebook entries
40      int16 isf[]    : quantized ISFs (in frequency domain)
41
42 ------------------------------------------------------------------------------
43  FUNCTION DESCRIPTION
44
45    Coding/Decoding of ISF parameters for background noise.
46
47    The ISF vector is quantized using VQ with split-by-5
48
49 ------------------------------------------------------------------------------
50  REQUIREMENTS
51
52
53 ------------------------------------------------------------------------------
54  REFERENCES
55
56 ------------------------------------------------------------------------------
57  PSEUDO-CODE
58
59 ------------------------------------------------------------------------------
60 */
61
62
63 /*----------------------------------------------------------------------------
64 ; INCLUDES
65 ----------------------------------------------------------------------------*/
66
67 #include "pv_amr_wb_type_defs.h"
68 #include "pvamrwbdecoder_basic_op.h"
69 #include "pvamrwbdecoder_acelp.h"
70 #include "qisf_ns.h"
71
72 /*----------------------------------------------------------------------------
73 ; MACROS
74 ; Define module specific macros here
75 ----------------------------------------------------------------------------*/
76
77
78 /*----------------------------------------------------------------------------
79 ; DEFINES
80 ; Include all pre-processor statements here. Include conditional
81 ; compile variables also.
82 ----------------------------------------------------------------------------*/
83
84 /*----------------------------------------------------------------------------
85 ; LOCAL FUNCTION DEFINITIONS
86 ; Function Prototype declaration
87 ----------------------------------------------------------------------------*/
88
89 /*----------------------------------------------------------------------------
90 ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
91 ; Variable declaration - defined here and used outside this module
92 ----------------------------------------------------------------------------*/
93
94 /*----------------------------------------------------------------------------
95 ; EXTERNAL FUNCTION REFERENCES
96 ; Declare functions defined elsewhere and referenced in this module
97 ----------------------------------------------------------------------------*/
98
99 /*----------------------------------------------------------------------------
100 ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
101 ; Declare variables used in this module but defined elsewhere
102 ----------------------------------------------------------------------------*/
103
104 /*----------------------------------------------------------------------------
105 ; FUNCTION CODE
106 ----------------------------------------------------------------------------*/
107
108 void Disf_ns(
109     int16 * indice,   /* input:  quantization indices               */
110     int16 * isf_q     /* input: ISF in the frequency domain (0..0.5)*/
111 )
112 {
113     int16 i;
114
115     isf_q[0] = dico1_isf_noise[(indice[0] << 1)];
116     isf_q[1] = dico1_isf_noise[(indice[0] << 1) + 1];
117
118     for (i = 0; i < 3; i++)
119     {
120         isf_q[i + 2] = dico2_isf_noise[(indice[1] << 1) + indice[1] + i];
121         isf_q[i + 5] = dico3_isf_noise[(indice[2] << 1) + indice[2] + i];
122     }
123
124     for (i = 0; i < 4; i++)
125     {
126         isf_q[i +  8] = dico4_isf_noise[(indice[3] << 2) + i];
127         isf_q[i + 12] = dico5_isf_noise[(indice[4] << 2) + i];
128     }
129
130     for (i = 0; i < ORDER; i++)
131     {
132         isf_q[i] = add_int16(isf_q[i], mean_isf_noise[i]);
133     }
134
135     Reorder_isf(isf_q, ISF_GAP, ORDER);
136
137 }