1 /*
2  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 /*
12  * codec.h
13  *
14  * This header file contains the calls to the internal encoder
15  * and decoder functions.
16  *
17  */
18 
19 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_CODEC_H_
20 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_CODEC_H_
21 
22 #include "structs.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 int WebRtcIsacfix_EstimateBandwidth(BwEstimatorstr* bwest_str,
29                                     Bitstr_dec* streamdata,
30                                     size_t packet_size,
31                                     uint16_t rtp_seq_number,
32                                     uint32_t send_ts,
33                                     uint32_t arr_ts);
34 
35 int WebRtcIsacfix_DecodeImpl(int16_t* signal_out16,
36                              IsacFixDecoderInstance* ISACdec_obj,
37                              size_t* current_framesamples);
38 
39 void WebRtcIsacfix_DecodePlcImpl(int16_t* decoded,
40                                  IsacFixDecoderInstance* ISACdec_obj,
41                                  size_t* current_framesample );
42 
43 int WebRtcIsacfix_EncodeImpl(int16_t* in,
44                              IsacFixEncoderInstance* ISACenc_obj,
45                              BwEstimatorstr* bw_estimatordata,
46                              int16_t CodingMode);
47 
48 int WebRtcIsacfix_EncodeStoredData(IsacFixEncoderInstance* ISACenc_obj,
49                                    int BWnumber,
50                                    float scale);
51 
52 /* initialization functions */
53 
54 void WebRtcIsacfix_InitMaskingEnc(MaskFiltstr_enc* maskdata);
55 void WebRtcIsacfix_InitMaskingDec(MaskFiltstr_dec* maskdata);
56 
57 void WebRtcIsacfix_InitPreFilterbank(PreFiltBankstr* prefiltdata);
58 
59 void WebRtcIsacfix_InitPostFilterbank(PostFiltBankstr* postfiltdata);
60 
61 void WebRtcIsacfix_InitPitchFilter(PitchFiltstr* pitchfiltdata);
62 
63 void WebRtcIsacfix_InitPitchAnalysis(PitchAnalysisStruct* State);
64 
65 void WebRtcIsacfix_InitPlc(PLCstr* State);
66 
67 
68 /* transform functions */
69 
70 void WebRtcIsacfix_InitTransform();
71 
72 typedef void (*Time2Spec)(int16_t* inre1Q9,
73                           int16_t* inre2Q9,
74                           int16_t* outre,
75                           int16_t* outim);
76 typedef void (*Spec2Time)(int16_t* inreQ7,
77                           int16_t* inimQ7,
78                           int32_t* outre1Q16,
79                           int32_t* outre2Q16);
80 
81 extern Time2Spec WebRtcIsacfix_Time2Spec;
82 extern Spec2Time WebRtcIsacfix_Spec2Time;
83 
84 void WebRtcIsacfix_Time2SpecC(int16_t* inre1Q9,
85                               int16_t* inre2Q9,
86                               int16_t* outre,
87                               int16_t* outim);
88 void WebRtcIsacfix_Spec2TimeC(int16_t* inreQ7,
89                               int16_t* inimQ7,
90                               int32_t* outre1Q16,
91                               int32_t* outre2Q16);
92 
93 #if (defined WEBRTC_DETECT_NEON) || (defined WEBRTC_HAS_NEON)
94 void WebRtcIsacfix_Time2SpecNeon(int16_t* inre1Q9,
95                                  int16_t* inre2Q9,
96                                  int16_t* outre,
97                                  int16_t* outim);
98 void WebRtcIsacfix_Spec2TimeNeon(int16_t* inreQ7,
99                                  int16_t* inimQ7,
100                                  int32_t* outre1Q16,
101                                  int32_t* outre2Q16);
102 #endif
103 
104 #if defined(MIPS32_LE)
105 void WebRtcIsacfix_Time2SpecMIPS(int16_t* inre1Q9,
106                                  int16_t* inre2Q9,
107                                  int16_t* outre,
108                                  int16_t* outim);
109 void WebRtcIsacfix_Spec2TimeMIPS(int16_t* inreQ7,
110                                  int16_t* inimQ7,
111                                  int32_t* outre1Q16,
112                                  int32_t* outre2Q16);
113 #endif
114 
115 /* filterbank functions */
116 
117 void WebRtcIsacfix_SplitAndFilter1(int16_t* in,
118                                    int16_t* LP16,
119                                    int16_t* HP16,
120                                    PreFiltBankstr* prefiltdata);
121 
122 void WebRtcIsacfix_FilterAndCombine1(int16_t* tempin_ch1,
123                                      int16_t* tempin_ch2,
124                                      int16_t* out16,
125                                      PostFiltBankstr* postfiltdata);
126 
127 #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
128 
129 void WebRtcIsacfix_SplitAndFilter2(int16_t* in,
130                                    int16_t* LP16,
131                                    int16_t* HP16,
132                                    PreFiltBankstr* prefiltdata);
133 
134 void WebRtcIsacfix_FilterAndCombine2(int16_t* tempin_ch1,
135                                      int16_t* tempin_ch2,
136                                      int16_t* out16,
137                                      PostFiltBankstr* postfiltdata,
138                                      int16_t len);
139 
140 #endif
141 
142 /* normalized lattice filters */
143 
144 void WebRtcIsacfix_NormLatticeFilterMa(size_t orderCoef,
145                                        int32_t* stateGQ15,
146                                        int16_t* lat_inQ0,
147                                        int16_t* filt_coefQ15,
148                                        int32_t* gain_lo_hiQ17,
149                                        int16_t lo_hi,
150                                        int16_t* lat_outQ9);
151 
152 void WebRtcIsacfix_NormLatticeFilterAr(size_t orderCoef,
153                                        int16_t* stateGQ0,
154                                        int32_t* lat_inQ25,
155                                        int16_t* filt_coefQ15,
156                                        int32_t* gain_lo_hiQ17,
157                                        int16_t lo_hi,
158                                        int16_t* lat_outQ0);
159 
160 /* TODO(kma): Remove the following functions into individual header files. */
161 
162 /* Internal functions in both C and ARM Neon versions */
163 
164 int WebRtcIsacfix_AutocorrC(int32_t* __restrict r,
165                             const int16_t* __restrict x,
166                             int16_t N,
167                             int16_t order,
168                             int16_t* __restrict scale);
169 
170 void WebRtcIsacfix_FilterMaLoopC(int16_t input0,
171                                  int16_t input1,
172                                  int32_t input2,
173                                  int32_t* ptr0,
174                                  int32_t* ptr1,
175                                  int32_t* ptr2);
176 
177 #if (defined WEBRTC_DETECT_NEON) || (defined WEBRTC_HAS_NEON)
178 int WebRtcIsacfix_AutocorrNeon(int32_t* __restrict r,
179                                const int16_t* __restrict x,
180                                int16_t N,
181                                int16_t order,
182                                int16_t* __restrict scale);
183 
184 void WebRtcIsacfix_FilterMaLoopNeon(int16_t input0,
185                                     int16_t input1,
186                                     int32_t input2,
187                                     int32_t* ptr0,
188                                     int32_t* ptr1,
189                                     int32_t* ptr2);
190 #endif
191 
192 #if defined(MIPS32_LE)
193 int WebRtcIsacfix_AutocorrMIPS(int32_t* __restrict r,
194                                const int16_t* __restrict x,
195                                int16_t N,
196                                int16_t order,
197                                int16_t* __restrict scale);
198 
199 void WebRtcIsacfix_FilterMaLoopMIPS(int16_t input0,
200                                     int16_t input1,
201                                     int32_t input2,
202                                     int32_t* ptr0,
203                                     int32_t* ptr1,
204                                     int32_t* ptr2);
205 #endif
206 
207 /* Function pointers associated with the above functions. */
208 
209 typedef int (*AutocorrFix)(int32_t* __restrict r,
210                            const int16_t* __restrict x,
211                            int16_t N,
212                            int16_t order,
213                            int16_t* __restrict scale);
214 extern AutocorrFix WebRtcIsacfix_AutocorrFix;
215 
216 typedef void (*FilterMaLoopFix)(int16_t input0,
217                                 int16_t input1,
218                                 int32_t input2,
219                                 int32_t* ptr0,
220                                 int32_t* ptr1,
221                                 int32_t* ptr2);
222 extern FilterMaLoopFix WebRtcIsacfix_FilterMaLoopFix;
223 
224 #ifdef __cplusplus
225 }  // extern "C"
226 #endif
227 
228 #endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_CODEC_H_ */
229