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 * encode_lpc_swb.h 13 * 14 * This file contains declaration of functions used to 15 * encode LPC parameters (Shape & gain) of the upper band. 16 * 17 */ 18 19 #ifndef MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ENCODE_LPC_SWB_H_ 20 #define MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ENCODE_LPC_SWB_H_ 21 22 #include "modules/audio_coding/codecs/isac/main/source/settings.h" 23 #include "modules/audio_coding/codecs/isac/main/source/structs.h" 24 25 /****************************************************************************** 26 * WebRtcIsac_RemoveLarMean() 27 * 28 * Remove the means from LAR coefficients. 29 * 30 * Input: 31 * -lar : pointer to lar vectors. LAR vectors are 32 * concatenated. 33 * -bandwidth : indicates if the given LAR vectors belong 34 * to SWB-12kHz or SWB-16kHz. 35 * 36 * Output: 37 * -lar : pointer to mean-removed LAR:s. 38 * 39 * 40 */ 41 int16_t WebRtcIsac_RemoveLarMean(double* lar, int16_t bandwidth); 42 43 /****************************************************************************** 44 * WebRtcIsac_DecorrelateIntraVec() 45 * 46 * Remove the correlation amonge the components of LAR vectors. If LAR vectors 47 * of one frame are put in a matrix where each column is a LAR vector of a 48 * sub-frame, then this is equivalent to multiplying the LAR matrix with 49 * a decorrelting mtrix from left. 50 * 51 * Input: 52 * -inLar : pointer to mean-removed LAR vecrtors. 53 * -bandwidth : indicates if the given LAR vectors belong 54 * to SWB-12kHz or SWB-16kHz. 55 * 56 * Output: 57 * -out : decorrelated LAR vectors. 58 */ 59 int16_t WebRtcIsac_DecorrelateIntraVec(const double* inLAR, 60 double* out, 61 int16_t bandwidth); 62 63 /****************************************************************************** 64 * WebRtcIsac_DecorrelateInterVec() 65 * 66 * Remover the correlation among mean-removed LAR vectors. If LAR vectors 67 * of one frame are put in a matrix where each column is a LAR vector of a 68 * sub-frame, then this is equivalent to multiplying the LAR matrix with 69 * a decorrelting mtrix from right. 70 * 71 * Input: 72 * -data : pointer to matrix of LAR vectors. The matrix 73 * is stored column-wise. 74 * -bandwidth : indicates if the given LAR vectors belong 75 * to SWB-12kHz or SWB-16kHz. 76 * 77 * Output: 78 * -out : decorrelated LAR vectors. 79 */ 80 int16_t WebRtcIsac_DecorrelateInterVec(const double* data, 81 double* out, 82 int16_t bandwidth); 83 84 /****************************************************************************** 85 * WebRtcIsac_QuantizeUncorrLar() 86 * 87 * Quantize the uncorrelated parameters. 88 * 89 * Input: 90 * -data : uncorrelated LAR vectors. 91 * -bandwidth : indicates if the given LAR vectors belong 92 * to SWB-12kHz or SWB-16kHz. 93 * 94 * Output: 95 * -data : quantized version of the input. 96 * -idx : pointer to quantization indices. 97 */ 98 double WebRtcIsac_QuantizeUncorrLar(double* data, int* idx, int16_t bandwidth); 99 100 /****************************************************************************** 101 * WebRtcIsac_CorrelateIntraVec() 102 * 103 * This is the inverse of WebRtcIsac_DecorrelateIntraVec(). 104 * 105 * Input: 106 * -data : uncorrelated parameters. 107 * -bandwidth : indicates if the given LAR vectors belong 108 * to SWB-12kHz or SWB-16kHz. 109 * 110 * Output: 111 * -out : correlated parametrs. 112 */ 113 int16_t WebRtcIsac_CorrelateIntraVec(const double* data, 114 double* out, 115 int16_t bandwidth); 116 117 /****************************************************************************** 118 * WebRtcIsac_CorrelateInterVec() 119 * 120 * This is the inverse of WebRtcIsac_DecorrelateInterVec(). 121 * 122 * Input: 123 * -data 124 * -bandwidth : indicates if the given LAR vectors belong 125 * to SWB-12kHz or SWB-16kHz. 126 * 127 * Output: 128 * -out : correlated parametrs. 129 */ 130 int16_t WebRtcIsac_CorrelateInterVec(const double* data, 131 double* out, 132 int16_t bandwidth); 133 134 /****************************************************************************** 135 * WebRtcIsac_AddLarMean() 136 * 137 * This is the inverse of WebRtcIsac_RemoveLarMean() 138 * 139 * Input: 140 * -data : pointer to mean-removed LAR:s. 141 * -bandwidth : indicates if the given LAR vectors belong 142 * to SWB-12kHz or SWB-16kHz. 143 * 144 * Output: 145 * -data : pointer to LARs. 146 */ 147 int16_t WebRtcIsac_AddLarMean(double* data, int16_t bandwidth); 148 149 /****************************************************************************** 150 * WebRtcIsac_DequantizeLpcParam() 151 * 152 * Get the quantized value of uncorrelated LARs given the quantization indices. 153 * 154 * Input: 155 * -idx : pointer to quantiztion indices. 156 * -bandwidth : indicates if the given LAR vectors belong 157 * to SWB-12kHz or SWB-16kHz. 158 * 159 * Output: 160 * -out : pointer to quantized values. 161 */ 162 int16_t WebRtcIsac_DequantizeLpcParam(const int* idx, 163 double* out, 164 int16_t bandwidth); 165 166 /****************************************************************************** 167 * WebRtcIsac_ToLogDomainRemoveMean() 168 * 169 * Transform the LPC gain to log domain then remove the mean value. 170 * 171 * Input: 172 * -lpcGain : pointer to LPC Gain, expecting 6 LPC gains 173 * 174 * Output: 175 * -lpcGain : mean-removed in log domain. 176 */ 177 int16_t WebRtcIsac_ToLogDomainRemoveMean(double* lpGains); 178 179 /****************************************************************************** 180 * WebRtcIsac_DecorrelateLPGain() 181 * 182 * Decorrelate LPC gains. There are 6 LPC Gains per frame. This is like 183 * multiplying gain vector with decorrelating matrix. 184 * 185 * Input: 186 * -data : LPC gain in log-domain with mean removed. 187 * 188 * Output: 189 * -out : decorrelated parameters. 190 */ 191 int16_t WebRtcIsac_DecorrelateLPGain(const double* data, double* out); 192 193 /****************************************************************************** 194 * WebRtcIsac_QuantizeLpcGain() 195 * 196 * Quantize the decorrelated log-domain gains. 197 * 198 * Input: 199 * -lpcGain : uncorrelated LPC gains. 200 * 201 * Output: 202 * -idx : quantization indices 203 * -lpcGain : quantized value of the inpt. 204 */ 205 double WebRtcIsac_QuantizeLpcGain(double* lpGains, int* idx); 206 207 /****************************************************************************** 208 * WebRtcIsac_DequantizeLpcGain() 209 * 210 * Get the quantized values given the quantization indices. 211 * 212 * Input: 213 * -idx : pointer to quantization indices. 214 * 215 * Output: 216 * -lpcGains : quantized values of the given parametes. 217 */ 218 int16_t WebRtcIsac_DequantizeLpcGain(const int* idx, double* lpGains); 219 220 /****************************************************************************** 221 * WebRtcIsac_CorrelateLpcGain() 222 * 223 * This is the inverse of WebRtcIsac_DecorrelateLPGain(). 224 * 225 * Input: 226 * -data : decorrelated parameters. 227 * 228 * Output: 229 * -out : correlated parameters. 230 */ 231 int16_t WebRtcIsac_CorrelateLpcGain(const double* data, double* out); 232 233 /****************************************************************************** 234 * WebRtcIsac_AddMeanToLinearDomain() 235 * 236 * This is the inverse of WebRtcIsac_ToLogDomainRemoveMean(). 237 * 238 * Input: 239 * -lpcGain : LPC gain in log-domain & mean removed 240 * 241 * Output: 242 * -lpcGain : LPC gain in normal domain. 243 */ 244 int16_t WebRtcIsac_AddMeanToLinearDomain(double* lpcGains); 245 246 #endif // MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_SOURCE_ENCODE_LPC_SWB_H_ 247