andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 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 | |
kma@webrtc.org | 27fe999 | 2012-11-14 18:44:24 | [diff] [blame] | 24 | #ifdef __cplusplus |
| 25 | extern "C" { |
| 26 | #endif |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 27 | |
kma@webrtc.org | 178f013 | 2013-01-24 01:37:33 | [diff] [blame] | 28 | int WebRtcIsacfix_EstimateBandwidth(BwEstimatorstr* bwest_str, |
| 29 | Bitstr_dec* streamdata, |
pbos@webrtc.org | fbda0fc | 2013-04-09 00:28:06 | [diff] [blame] | 30 | int32_t packet_size, |
| 31 | uint16_t rtp_seq_number, |
| 32 | uint32_t send_ts, |
| 33 | uint32_t arr_ts); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 34 | |
pbos@webrtc.org | fbda0fc | 2013-04-09 00:28:06 | [diff] [blame] | 35 | int16_t WebRtcIsacfix_DecodeImpl(int16_t* signal_out16, |
pbos@webrtc.org | 3791d7e | 2014-12-17 15:23:29 | [diff] [blame^] | 36 | IsacFixDecoderInstance* ISACdec_obj, |
pbos@webrtc.org | fbda0fc | 2013-04-09 00:28:06 | [diff] [blame] | 37 | int16_t* current_framesamples); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 38 | |
pbos@webrtc.org | fbda0fc | 2013-04-09 00:28:06 | [diff] [blame] | 39 | int16_t WebRtcIsacfix_DecodePlcImpl(int16_t* decoded, |
pbos@webrtc.org | 3791d7e | 2014-12-17 15:23:29 | [diff] [blame^] | 40 | IsacFixDecoderInstance* ISACdec_obj, |
pbos@webrtc.org | fbda0fc | 2013-04-09 00:28:06 | [diff] [blame] | 41 | int16_t* current_framesample ); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 42 | |
pbos@webrtc.org | fbda0fc | 2013-04-09 00:28:06 | [diff] [blame] | 43 | int WebRtcIsacfix_EncodeImpl(int16_t* in, |
pbos@webrtc.org | 3791d7e | 2014-12-17 15:23:29 | [diff] [blame^] | 44 | IsacFixEncoderInstance* ISACenc_obj, |
kma@webrtc.org | 178f013 | 2013-01-24 01:37:33 | [diff] [blame] | 45 | BwEstimatorstr* bw_estimatordata, |
pbos@webrtc.org | fbda0fc | 2013-04-09 00:28:06 | [diff] [blame] | 46 | int16_t CodingMode); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 47 | |
pbos@webrtc.org | 3791d7e | 2014-12-17 15:23:29 | [diff] [blame^] | 48 | int WebRtcIsacfix_EncodeStoredData(IsacFixEncoderInstance* ISACenc_obj, |
kma@webrtc.org | 178f013 | 2013-01-24 01:37:33 | [diff] [blame] | 49 | int BWnumber, |
| 50 | float scale); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 51 | |
| 52 | /* initialization functions */ |
| 53 | |
kma@webrtc.org | 178f013 | 2013-01-24 01:37:33 | [diff] [blame] | 54 | void WebRtcIsacfix_InitMaskingEnc(MaskFiltstr_enc* maskdata); |
| 55 | void WebRtcIsacfix_InitMaskingDec(MaskFiltstr_dec* maskdata); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 56 | |
kma@webrtc.org | 178f013 | 2013-01-24 01:37:33 | [diff] [blame] | 57 | void WebRtcIsacfix_InitPreFilterbank(PreFiltBankstr* prefiltdata); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 58 | |
kma@webrtc.org | 178f013 | 2013-01-24 01:37:33 | [diff] [blame] | 59 | void WebRtcIsacfix_InitPostFilterbank(PostFiltBankstr* postfiltdata); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 60 | |
kma@webrtc.org | 178f013 | 2013-01-24 01:37:33 | [diff] [blame] | 61 | void WebRtcIsacfix_InitPitchFilter(PitchFiltstr* pitchfiltdata); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 62 | |
kma@webrtc.org | 178f013 | 2013-01-24 01:37:33 | [diff] [blame] | 63 | void WebRtcIsacfix_InitPitchAnalysis(PitchAnalysisStruct* State); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 64 | |
kma@webrtc.org | 178f013 | 2013-01-24 01:37:33 | [diff] [blame] | 65 | void WebRtcIsacfix_InitPlc(PLCstr* State); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 66 | |
| 67 | |
| 68 | /* transform functions */ |
| 69 | |
| 70 | void WebRtcIsacfix_InitTransform(); |
| 71 | |
pbos@webrtc.org | fbda0fc | 2013-04-09 00:28:06 | [diff] [blame] | 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); |
kma@webrtc.org | 178f013 | 2013-01-24 01:37:33 | [diff] [blame] | 80 | |
| 81 | extern Time2Spec WebRtcIsacfix_Time2Spec; |
kma@webrtc.org | 3c37468 | 2012-12-12 23:00:52 | [diff] [blame] | 82 | extern Spec2Time WebRtcIsacfix_Spec2Time; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 83 | |
pbos@webrtc.org | fbda0fc | 2013-04-09 00:28:06 | [diff] [blame] | 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); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 92 | |
kma@webrtc.org | 3c37468 | 2012-12-12 23:00:52 | [diff] [blame] | 93 | #if (defined WEBRTC_DETECT_ARM_NEON) || (defined WEBRTC_ARCH_ARM_NEON) |
pbos@webrtc.org | fbda0fc | 2013-04-09 00:28:06 | [diff] [blame] | 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); |
kma@webrtc.org | 3c37468 | 2012-12-12 23:00:52 | [diff] [blame] | 102 | #endif |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 103 | |
andrew@webrtc.org | e4834e0 | 2014-07-21 16:43:13 | [diff] [blame] | 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 |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 114 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 115 | /* filterbank functions */ |
| 116 | |
pbos@webrtc.org | fbda0fc | 2013-04-09 00:28:06 | [diff] [blame] | 117 | void WebRtcIsacfix_SplitAndFilter1(int16_t* in, |
| 118 | int16_t* LP16, |
| 119 | int16_t* HP16, |
kma@webrtc.org | 178f013 | 2013-01-24 01:37:33 | [diff] [blame] | 120 | PreFiltBankstr* prefiltdata); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 121 | |
pbos@webrtc.org | fbda0fc | 2013-04-09 00:28:06 | [diff] [blame] | 122 | void WebRtcIsacfix_FilterAndCombine1(int16_t* tempin_ch1, |
| 123 | int16_t* tempin_ch2, |
| 124 | int16_t* out16, |
kma@webrtc.org | 178f013 | 2013-01-24 01:37:33 | [diff] [blame] | 125 | PostFiltBankstr* postfiltdata); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 126 | |
| 127 | #ifdef WEBRTC_ISAC_FIX_NB_CALLS_ENABLED |
| 128 | |
pbos@webrtc.org | fbda0fc | 2013-04-09 00:28:06 | [diff] [blame] | 129 | void WebRtcIsacfix_SplitAndFilter2(int16_t* in, |
| 130 | int16_t* LP16, |
| 131 | int16_t* HP16, |
kma@webrtc.org | 178f013 | 2013-01-24 01:37:33 | [diff] [blame] | 132 | PreFiltBankstr* prefiltdata); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 133 | |
pbos@webrtc.org | fbda0fc | 2013-04-09 00:28:06 | [diff] [blame] | 134 | void WebRtcIsacfix_FilterAndCombine2(int16_t* tempin_ch1, |
| 135 | int16_t* tempin_ch2, |
| 136 | int16_t* out16, |
kma@webrtc.org | 178f013 | 2013-01-24 01:37:33 | [diff] [blame] | 137 | PostFiltBankstr* postfiltdata, |
pbos@webrtc.org | fbda0fc | 2013-04-09 00:28:06 | [diff] [blame] | 138 | int16_t len); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 139 | |
| 140 | #endif |
| 141 | |
| 142 | /* normalized lattice filters */ |
| 143 | |
pbos@webrtc.org | fbda0fc | 2013-04-09 00:28:06 | [diff] [blame] | 144 | void WebRtcIsacfix_NormLatticeFilterMa(int16_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); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 151 | |
pbos@webrtc.org | fbda0fc | 2013-04-09 00:28:06 | [diff] [blame] | 152 | void WebRtcIsacfix_NormLatticeFilterAr(int16_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); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 159 | |
| 160 | /* TODO(kma): Remove the following functions into individual header files. */ |
| 161 | |
| 162 | /* Internal functions in both C and ARM Neon versions */ |
| 163 | |
pbos@webrtc.org | fbda0fc | 2013-04-09 00:28:06 | [diff] [blame] | 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); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 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_ARM_NEON) || (defined WEBRTC_ARCH_ARM_NEON) |
pbos@webrtc.org | fbda0fc | 2013-04-09 00:28:06 | [diff] [blame] | 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); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 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 | |
andrew@webrtc.org | bc9c195 | 2014-06-10 18:13:15 | [diff] [blame] | 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 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 207 | /* Function pointers associated with the above functions. */ |
| 208 | |
pbos@webrtc.org | fbda0fc | 2013-04-09 00:28:06 | [diff] [blame] | 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); |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 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 | |
kma@webrtc.org | 27fe999 | 2012-11-14 18:44:24 | [diff] [blame] | 224 | #ifdef __cplusplus |
| 225 | } // extern "C" |
| 226 | #endif |
| 227 | |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 | [diff] [blame] | 228 | #endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_CODEC_H_ */ |