digital_agc.h (2819B)
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 #ifndef MODULES_AUDIO_PROCESSING_AGC_LEGACY_DIGITAL_AGC_H_ 12 #define MODULES_AUDIO_PROCESSING_AGC_LEGACY_DIGITAL_AGC_H_ 13 14 #include <cstddef> 15 #include <cstdint> 16 17 namespace webrtc { 18 19 typedef struct { 20 int32_t downState[8]; 21 int16_t HPstate; 22 int16_t counter; 23 int16_t logRatio; // log( P(active) / P(inactive) ) (Q10) 24 int16_t meanLongTerm; // Q10 25 int32_t varianceLongTerm; // Q8 26 int16_t stdLongTerm; // Q10 27 int16_t meanShortTerm; // Q10 28 int32_t varianceShortTerm; // Q8 29 int16_t stdShortTerm; // Q10 30 } AgcVad; // total = 54 bytes 31 32 typedef struct { 33 int32_t capacitorSlow; 34 int32_t capacitorFast; 35 int32_t gain; 36 int32_t gainTable[32]; 37 int16_t gatePrevious; 38 int16_t agcMode; 39 AgcVad vadNearend; 40 AgcVad vadFarend; 41 } DigitalAgc; 42 43 int32_t WebRtcAgc_InitDigital(DigitalAgc* digitalAgcInst, int16_t agcMode); 44 45 int32_t WebRtcAgc_ComputeDigitalGains(DigitalAgc* digitalAgcInst, 46 const int16_t* const* inNear, 47 size_t num_bands, 48 uint32_t FS, 49 int16_t lowLevelSignal, 50 int32_t gains[11]); 51 52 int32_t WebRtcAgc_ApplyDigitalGains(const int32_t gains[11], 53 size_t num_bands, 54 uint32_t FS, 55 const int16_t* const* in_near, 56 int16_t* const* out); 57 58 int32_t WebRtcAgc_AddFarendToDigital(DigitalAgc* digitalAgcInst, 59 const int16_t* inFar, 60 size_t nrSamples); 61 62 void WebRtcAgc_InitVad(AgcVad* vadInst); 63 64 int16_t WebRtcAgc_ProcessVad(AgcVad* vadInst, // (i) VAD state 65 const int16_t* in, // (i) Speech signal 66 size_t nrSamples); // (i) number of samples 67 68 int32_t WebRtcAgc_CalculateGainTable(int32_t* gainTable, // Q16 69 int16_t compressionGaindB, // Q0 (in dB) 70 int16_t targetLevelDbfs, // Q0 (in dB) 71 uint8_t limiterEnable, 72 int16_t analogTarget); 73 74 } // namespace webrtc 75 76 #endif // MODULES_AUDIO_PROCESSING_AGC_LEGACY_DIGITAL_AGC_H_