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 MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ENTROPY_CODING_H_ 20 #define MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ENTROPY_CODING_H_ 21 22 #include "modules/audio_coding/codecs/isac/fix/source/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 /* decode & dequantize LPC Coef */ 37 int WebRtcIsacfix_DecodeLpcCoef(Bitstr_dec* streamdata, 38 int32_t* LPCCoefQ17, 39 int32_t* gain_lo_hiQ17, 40 int16_t* outmodel); 41 42 int WebRtcIsacfix_DecodeLpc(int32_t* gain_lo_hiQ17, 43 int16_t* LPCCoef_loQ15, 44 int16_t* LPCCoef_hiQ15, 45 Bitstr_dec* streamdata, 46 int16_t* outmodel); 47 48 /* quantize & code LPC Coef */ 49 int WebRtcIsacfix_EncodeLpc(int32_t* gain_lo_hiQ17, 50 int16_t* LPCCoef_loQ15, 51 int16_t* LPCCoef_hiQ15, 52 int16_t* model, 53 int32_t* sizeQ11, 54 Bitstr_enc* streamdata, 55 IsacSaveEncoderData* encData, 56 transcode_obj* transcodeParam); 57 58 int WebRtcIsacfix_EstCodeLpcGain(int32_t* gain_lo_hiQ17, 59 Bitstr_enc* streamdata, 60 IsacSaveEncoderData* encData); 61 /* decode & dequantize RC */ 62 int WebRtcIsacfix_DecodeRcCoef(Bitstr_dec* streamdata, int16_t* RCQ15); 63 64 /* quantize & code RC */ 65 int WebRtcIsacfix_EncodeRcCoef(int16_t* RCQ15, Bitstr_enc* streamdata); 66 67 /* decode & dequantize squared Gain */ 68 int WebRtcIsacfix_DecodeGain2(Bitstr_dec* streamdata, int32_t* Gain2); 69 70 /* quantize & code squared Gain (input is squared gain) */ 71 int WebRtcIsacfix_EncodeGain2(int32_t* gain2, Bitstr_enc* streamdata); 72 73 int WebRtcIsacfix_EncodePitchGain(int16_t* PitchGains_Q12, 74 Bitstr_enc* streamdata, 75 IsacSaveEncoderData* encData); 76 77 int WebRtcIsacfix_EncodePitchLag(int16_t* PitchLagQ7, 78 int16_t* PitchGain_Q12, 79 Bitstr_enc* streamdata, 80 IsacSaveEncoderData* encData); 81 82 int WebRtcIsacfix_DecodePitchGain(Bitstr_dec* streamdata, 83 int16_t* PitchGain_Q12); 84 85 int WebRtcIsacfix_DecodePitchLag(Bitstr_dec* streamdata, 86 int16_t* PitchGain_Q12, 87 int16_t* PitchLagQ7); 88 89 int WebRtcIsacfix_DecodeFrameLen(Bitstr_dec* streamdata, size_t* framelength); 90 91 int WebRtcIsacfix_EncodeFrameLen(int16_t framelength, Bitstr_enc* streamdata); 92 93 int WebRtcIsacfix_DecodeSendBandwidth(Bitstr_dec* streamdata, int16_t* BWno); 94 95 int WebRtcIsacfix_EncodeReceiveBandwidth(int16_t* BWno, Bitstr_enc* streamdata); 96 97 void WebRtcIsacfix_TranscodeLpcCoef(int32_t* tmpcoeffs_gQ6, int16_t* index_gQQ); 98 99 // Pointer functions for LPC transforms. 100 101 typedef void (*MatrixProduct1)(const int16_t matrix0[], 102 const int32_t matrix1[], 103 int32_t matrix_product[], 104 const int matrix1_index_factor1, 105 const int matrix0_index_factor1, 106 const int matrix1_index_init_case, 107 const int matrix1_index_step, 108 const int matrix0_index_step, 109 const int inner_loop_count, 110 const int mid_loop_count, 111 const int shift); 112 typedef void (*MatrixProduct2)(const int16_t matrix0[], 113 const int32_t matrix1[], 114 int32_t matrix_product[], 115 const int matrix0_index_factor, 116 const int matrix0_index_step); 117 118 extern MatrixProduct1 WebRtcIsacfix_MatrixProduct1; 119 extern MatrixProduct2 WebRtcIsacfix_MatrixProduct2; 120 121 void WebRtcIsacfix_MatrixProduct1C(const int16_t matrix0[], 122 const int32_t matrix1[], 123 int32_t matrix_product[], 124 const int matrix1_index_factor1, 125 const int matrix0_index_factor1, 126 const int matrix1_index_init_case, 127 const int matrix1_index_step, 128 const int matrix0_index_step, 129 const int inner_loop_count, 130 const int mid_loop_count, 131 const int shift); 132 void WebRtcIsacfix_MatrixProduct2C(const int16_t matrix0[], 133 const int32_t matrix1[], 134 int32_t matrix_product[], 135 const int matrix0_index_factor, 136 const int matrix0_index_step); 137 138 #if defined(WEBRTC_HAS_NEON) 139 void WebRtcIsacfix_MatrixProduct1Neon(const int16_t matrix0[], 140 const int32_t matrix1[], 141 int32_t matrix_product[], 142 const int matrix1_index_factor1, 143 const int matrix0_index_factor1, 144 const int matrix1_index_init_case, 145 const int matrix1_index_step, 146 const int matrix0_index_step, 147 const int inner_loop_count, 148 const int mid_loop_count, 149 const int shift); 150 void WebRtcIsacfix_MatrixProduct2Neon(const int16_t matrix0[], 151 const int32_t matrix1[], 152 int32_t matrix_product[], 153 const int matrix0_index_factor, 154 const int matrix0_index_step); 155 #endif 156 157 #if defined(MIPS32_LE) 158 void WebRtcIsacfix_MatrixProduct1MIPS(const int16_t matrix0[], 159 const int32_t matrix1[], 160 int32_t matrix_product[], 161 const int matrix1_index_factor1, 162 const int matrix0_index_factor1, 163 const int matrix1_index_init_case, 164 const int matrix1_index_step, 165 const int matrix0_index_step, 166 const int inner_loop_count, 167 const int mid_loop_count, 168 const int shift); 169 170 void WebRtcIsacfix_MatrixProduct2MIPS(const int16_t matrix0[], 171 const int32_t matrix1[], 172 int32_t matrix_product[], 173 const int matrix0_index_factor, 174 const int matrix0_index_step); 175 #endif 176 177 #endif // MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ENTROPY_CODING_H_ 178