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
25int WebRtcIsacfix_EstimateBandwidth(BwEstimatorstr   *bwest_str,
26                                    Bitstr_dec       *streamdata,
27                                    WebRtc_Word32      packet_size,
28                                    WebRtc_UWord16     rtp_seq_number,
29                                    WebRtc_UWord32     send_ts,
30                                    WebRtc_UWord32     arr_ts);
31
32WebRtc_Word16 WebRtcIsacfix_DecodeImpl(WebRtc_Word16   *signal_out16,
33                                       ISACFIX_DecInst_t  *ISACdec_obj,
34                                       WebRtc_Word16        *current_framesamples);
35
36WebRtc_Word16 WebRtcIsacfix_DecodePlcImpl(WebRtc_Word16       *decoded,
37                                          ISACFIX_DecInst_t *ISACdec_obj,
38                                          WebRtc_Word16       *current_framesample );
39
40int WebRtcIsacfix_EncodeImpl(WebRtc_Word16      *in,
41                             ISACFIX_EncInst_t  *ISACenc_obj,
42                             BwEstimatorstr      *bw_estimatordata,
43                             WebRtc_Word16         CodingMode);
44
45int WebRtcIsacfix_EncodeStoredData(ISACFIX_EncInst_t  *ISACenc_obj,
46                                   int     BWnumber,
47                                   float              scale);
48
49/* initialization functions */
50
51void WebRtcIsacfix_InitMaskingEnc(MaskFiltstr_enc *maskdata);
52void WebRtcIsacfix_InitMaskingDec(MaskFiltstr_dec *maskdata);
53
54void WebRtcIsacfix_InitPreFilterbank(PreFiltBankstr *prefiltdata);
55
56void WebRtcIsacfix_InitPostFilterbank(PostFiltBankstr *postfiltdata);
57
58void WebRtcIsacfix_InitPitchFilter(PitchFiltstr *pitchfiltdata);
59
60void WebRtcIsacfix_InitPitchAnalysis(PitchAnalysisStruct *State);
61
62void WebRtcIsacfix_InitPlc( PLCstr *State );
63
64
65/* transform functions */
66
67void WebRtcIsacfix_InitTransform();
68
69
70void WebRtcIsacfix_Time2Spec(WebRtc_Word16 *inre1Q9,
71                             WebRtc_Word16 *inre2Q9,
72                             WebRtc_Word16 *outre,
73                             WebRtc_Word16 *outim);
74
75
76
77void WebRtcIsacfix_Spec2Time(WebRtc_Word16 *inreQ7,
78                             WebRtc_Word16 *inimQ7,
79                             WebRtc_Word32 *outre1Q16,
80                             WebRtc_Word32 *outre2Q16);
81
82
83
84
85/* filterbank functions */
86
87void WebRtcIsacfix_SplitAndFilter1(WebRtc_Word16    *in,
88                                   WebRtc_Word16    *LP16,
89                                   WebRtc_Word16    *HP16,
90                                   PreFiltBankstr *prefiltdata);
91
92void WebRtcIsacfix_FilterAndCombine1(WebRtc_Word16     *tempin_ch1,
93                                     WebRtc_Word16     *tempin_ch2,
94                                     WebRtc_Word16     *out16,
95                                     PostFiltBankstr *postfiltdata);
96
97#ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED
98
99void WebRtcIsacfix_SplitAndFilter2(WebRtc_Word16    *in,
100                                   WebRtc_Word16    *LP16,
101                                   WebRtc_Word16    *HP16,
102                                   PreFiltBankstr *prefiltdata);
103
104void WebRtcIsacfix_FilterAndCombine2(WebRtc_Word16     *tempin_ch1,
105                                     WebRtc_Word16     *tempin_ch2,
106                                     WebRtc_Word16     *out16,
107                                     PostFiltBankstr *postfiltdata,
108                                     WebRtc_Word16     len);
109
110#endif
111
112/* normalized lattice filters */
113
114void WebRtcIsacfix_NormLatticeFilterMa(WebRtc_Word16 orderCoef,
115                                       WebRtc_Word32 *stateGQ15,
116                                       WebRtc_Word16 *lat_inQ0,
117                                       WebRtc_Word16 *filt_coefQ15,
118                                       WebRtc_Word32 *gain_lo_hiQ17,
119                                       WebRtc_Word16 lo_hi,
120                                       WebRtc_Word16 *lat_outQ9);
121
122void WebRtcIsacfix_NormLatticeFilterAr(WebRtc_Word16 orderCoef,
123                                       WebRtc_Word16 *stateGQ0,
124                                       WebRtc_Word32 *lat_inQ25,
125                                       WebRtc_Word16 *filt_coefQ15,
126                                       WebRtc_Word32 *gain_lo_hiQ17,
127                                       WebRtc_Word16 lo_hi,
128                                       WebRtc_Word16 *lat_outQ0);
129
130/* TODO(kma): Remove the following functions into individual header files. */
131
132/* Internal functions in both C and ARM Neon versions */
133
134int WebRtcIsacfix_AutocorrC(WebRtc_Word32* __restrict r,
135                            const WebRtc_Word16* __restrict x,
136                            WebRtc_Word16 N,
137                            WebRtc_Word16 order,
138                            WebRtc_Word16* __restrict scale);
139
140void WebRtcIsacfix_FilterMaLoopC(int16_t input0,
141                                 int16_t input1,
142                                 int32_t input2,
143                                 int32_t* ptr0,
144                                 int32_t* ptr1,
145                                 int32_t* ptr2);
146
147#if (defined WEBRTC_DETECT_ARM_NEON) || (defined WEBRTC_ARCH_ARM_NEON)
148int WebRtcIsacfix_AutocorrNeon(WebRtc_Word32* __restrict r,
149                               const WebRtc_Word16* __restrict x,
150                               WebRtc_Word16 N,
151                               WebRtc_Word16 order,
152                               WebRtc_Word16* __restrict scale);
153
154void WebRtcIsacfix_FilterMaLoopNeon(int16_t input0,
155                                    int16_t input1,
156                                    int32_t input2,
157                                    int32_t* ptr0,
158                                    int32_t* ptr1,
159                                    int32_t* ptr2);
160#endif
161
162/* Function pointers associated with the above functions. */
163
164typedef int (*AutocorrFix)(WebRtc_Word32* __restrict r,
165                           const WebRtc_Word16* __restrict x,
166                           WebRtc_Word16 N,
167                           WebRtc_Word16 order,
168                           WebRtc_Word16* __restrict scale);
169extern AutocorrFix WebRtcIsacfix_AutocorrFix;
170
171typedef void (*FilterMaLoopFix)(int16_t input0,
172                                int16_t input1,
173                                int32_t input2,
174                                int32_t* ptr0,
175                                int32_t* ptr1,
176                                int32_t* ptr2);
177extern FilterMaLoopFix WebRtcIsacfix_FilterMaLoopFix;
178
179#endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_CODEC_H_ */
180