1 /* 2 * Copyright (c) 2011 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 * entropy_coding.h 13 * 14 * This header file contains all of the functions used to arithmetically 15 * encode the iSAC bistream 16 * 17 */ 18 19 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ENTROPY_CODING_H_ 20 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ENTROPY_CODING_H_ 21 22 #include "structs.h" 23 24 /* decode complex spectrum (return number of bytes in stream) */ 25 int WebRtcIsacfix_DecodeSpec(Bitstr_dec *streamdata, 26 int16_t *frQ7, 27 int16_t *fiQ7, 28 int16_t AvgPitchGain_Q12); 29 30 /* encode complex spectrum */ 31 int WebRtcIsacfix_EncodeSpec(const int16_t *fr, 32 const int16_t *fi, 33 Bitstr_enc *streamdata, 34 int16_t AvgPitchGain_Q12); 35 36 37 /* decode & dequantize LPC Coef */ 38 int WebRtcIsacfix_DecodeLpcCoef(Bitstr_dec *streamdata, 39 int32_t *LPCCoefQ17, 40 int32_t *gain_lo_hiQ17, 41 int16_t *outmodel); 42 43 int WebRtcIsacfix_DecodeLpc(int32_t *gain_lo_hiQ17, 44 int16_t *LPCCoef_loQ15, 45 int16_t *LPCCoef_hiQ15, 46 Bitstr_dec *streamdata, 47 int16_t *outmodel); 48 49 /* quantize & code LPC Coef */ 50 int WebRtcIsacfix_EncodeLpc(int32_t *gain_lo_hiQ17, 51 int16_t *LPCCoef_loQ15, 52 int16_t *LPCCoef_hiQ15, 53 int16_t *model, 54 int32_t *sizeQ11, 55 Bitstr_enc *streamdata, 56 IsacSaveEncoderData* encData, 57 transcode_obj *transcodeParam); 58 59 int WebRtcIsacfix_EstCodeLpcGain(int32_t *gain_lo_hiQ17, 60 Bitstr_enc *streamdata, 61 IsacSaveEncoderData* encData); 62 /* decode & dequantize RC */ 63 int WebRtcIsacfix_DecodeRcCoef(Bitstr_dec *streamdata, 64 int16_t *RCQ15); 65 66 /* quantize & code RC */ 67 int WebRtcIsacfix_EncodeRcCoef(int16_t *RCQ15, 68 Bitstr_enc *streamdata); 69 70 /* decode & dequantize squared Gain */ 71 int WebRtcIsacfix_DecodeGain2(Bitstr_dec *streamdata, 72 int32_t *Gain2); 73 74 /* quantize & code squared Gain (input is squared gain) */ 75 int WebRtcIsacfix_EncodeGain2(int32_t *gain2, 76 Bitstr_enc *streamdata); 77 78 int WebRtcIsacfix_EncodePitchGain(int16_t *PitchGains_Q12, 79 Bitstr_enc *streamdata, 80 IsacSaveEncoderData* encData); 81 82 int WebRtcIsacfix_EncodePitchLag(int16_t *PitchLagQ7, 83 int16_t *PitchGain_Q12, 84 Bitstr_enc *streamdata, 85 IsacSaveEncoderData* encData); 86 87 int WebRtcIsacfix_DecodePitchGain(Bitstr_dec *streamdata, 88 int16_t *PitchGain_Q12); 89 90 int WebRtcIsacfix_DecodePitchLag(Bitstr_dec *streamdata, 91 int16_t *PitchGain_Q12, 92 int16_t *PitchLagQ7); 93 94 int WebRtcIsacfix_DecodeFrameLen(Bitstr_dec *streamdata, 95 size_t *framelength); 96 97 98 int WebRtcIsacfix_EncodeFrameLen(int16_t framelength, 99 Bitstr_enc *streamdata); 100 101 int WebRtcIsacfix_DecodeSendBandwidth(Bitstr_dec *streamdata, 102 int16_t *BWno); 103 104 105 int WebRtcIsacfix_EncodeReceiveBandwidth(int16_t *BWno, 106 Bitstr_enc *streamdata); 107 108 void WebRtcIsacfix_TranscodeLpcCoef(int32_t *tmpcoeffs_gQ6, 109 int16_t *index_gQQ); 110 111 // Pointer functions for LPC transforms. 112 113 typedef void (*MatrixProduct1)(const int16_t matrix0[], 114 const int32_t matrix1[], 115 int32_t matrix_product[], 116 const int matrix1_index_factor1, 117 const int matrix0_index_factor1, 118 const int matrix1_index_init_case, 119 const int matrix1_index_step, 120 const int matrix0_index_step, 121 const int inner_loop_count, 122 const int mid_loop_count, 123 const int shift); 124 typedef void (*MatrixProduct2)(const int16_t matrix0[], 125 const int32_t matrix1[], 126 int32_t matrix_product[], 127 const int matrix0_index_factor, 128 const int matrix0_index_step); 129 130 extern MatrixProduct1 WebRtcIsacfix_MatrixProduct1; 131 extern MatrixProduct2 WebRtcIsacfix_MatrixProduct2; 132 133 void WebRtcIsacfix_MatrixProduct1C(const int16_t matrix0[], 134 const int32_t matrix1[], 135 int32_t matrix_product[], 136 const int matrix1_index_factor1, 137 const int matrix0_index_factor1, 138 const int matrix1_index_init_case, 139 const int matrix1_index_step, 140 const int matrix0_index_step, 141 const int inner_loop_count, 142 const int mid_loop_count, 143 const int shift); 144 void WebRtcIsacfix_MatrixProduct2C(const int16_t matrix0[], 145 const int32_t matrix1[], 146 int32_t matrix_product[], 147 const int matrix0_index_factor, 148 const int matrix0_index_step); 149 150 #if (defined WEBRTC_DETECT_NEON) || (defined WEBRTC_HAS_NEON) 151 void WebRtcIsacfix_MatrixProduct1Neon(const int16_t matrix0[], 152 const int32_t matrix1[], 153 int32_t matrix_product[], 154 const int matrix1_index_factor1, 155 const int matrix0_index_factor1, 156 const int matrix1_index_init_case, 157 const int matrix1_index_step, 158 const int matrix0_index_step, 159 const int inner_loop_count, 160 const int mid_loop_count, 161 const int shift); 162 void WebRtcIsacfix_MatrixProduct2Neon(const int16_t matrix0[], 163 const int32_t matrix1[], 164 int32_t matrix_product[], 165 const int matrix0_index_factor, 166 const int matrix0_index_step); 167 #endif 168 169 #if defined(MIPS32_LE) 170 void WebRtcIsacfix_MatrixProduct1MIPS(const int16_t matrix0[], 171 const int32_t matrix1[], 172 int32_t matrix_product[], 173 const int matrix1_index_factor1, 174 const int matrix0_index_factor1, 175 const int matrix1_index_init_case, 176 const int matrix1_index_step, 177 const int matrix0_index_step, 178 const int inner_loop_count, 179 const int mid_loop_count, 180 const int shift); 181 182 void WebRtcIsacfix_MatrixProduct2MIPS(const int16_t matrix0[], 183 const int32_t matrix1[], 184 int32_t matrix_product[], 185 const int matrix0_index_factor, 186 const int matrix0_index_step); 187 #endif 188 189 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ENTROPY_CODING_H_ 190