chromium/third_party/webrtc/modules/audio_processing/agc/legacy/digital_agc.cc

/*
 *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#include "modules/audio_processing/agc/legacy/digital_agc.h"

#include <string.h>

#include "modules/audio_processing/agc/legacy/gain_control.h"
#include "rtc_base/checks.h"

namespace webrtc {

namespace {

// To generate the gaintable, copy&paste the following lines to a Matlab window:
// MaxGain = 6; MinGain = 0; CompRatio = 3; Knee = 1;
// zeros = 0:31; lvl = 2.^(1-zeros);
// A = -10*log10(lvl) * (CompRatio - 1) / CompRatio;
// B = MaxGain - MinGain;
// gains = round(2^16*10.^(0.05 * (MinGain + B * (
// log(exp(-Knee*A)+exp(-Knee*B)) - log(1+exp(-Knee*B)) ) /
// log(1/(1+exp(Knee*B))))));
// fprintf(1, '\t%i, %i, %i, %i,\n', gains);
// % Matlab code for plotting the gain and input/output level characteristic
// (copy/paste the following 3 lines):
// in = 10*log10(lvl); out = 20*log10(gains/65536);
// subplot(121); plot(in, out); axis([-30, 0, -5, 20]); grid on; xlabel('Input
// (dB)'); ylabel('Gain (dB)');
// subplot(122); plot(in, in+out); axis([-30, 0, -30, 5]); grid on;
// xlabel('Input (dB)'); ylabel('Output (dB)');
// zoom on;

// Generator table for y=log2(1+e^x) in Q8.
enum {};
static const uint16_t kGenFuncTable[kGenFuncTableSize] =;

static const int16_t kAvgDecayTime =;  // frames; < 3000

// the 32 most significant bits of A(19) * B(26) >> 13
#define AGC_MUL32(A, B)
// C + the 32 most significant bits of A * B
#define AGC_SCALEDIFF32(A, B, C)

}  // namespace

int32_t WebRtcAgc_CalculateGainTable(int32_t* gainTable,       // Q16
                                     int16_t digCompGaindB,    // Q0
                                     int16_t targetLevelDbfs,  // Q0
                                     uint8_t limiterEnable,
                                     int16_t analogTarget) {}

int32_t WebRtcAgc_InitDigital(DigitalAgc* stt, int16_t agcMode) {}

int32_t WebRtcAgc_AddFarendToDigital(DigitalAgc* stt,
                                     const int16_t* in_far,
                                     size_t nrSamples) {}

// Gains is an 11 element long array (one value per ms, incl start & end).
int32_t WebRtcAgc_ComputeDigitalGains(DigitalAgc* stt,
                                      const int16_t* const* in_near,
                                      size_t num_bands,
                                      uint32_t FS,
                                      int16_t lowlevelSignal,
                                      int32_t gains[11]) {}

int32_t WebRtcAgc_ApplyDigitalGains(const int32_t gains[11],
                                    size_t num_bands,
                                    uint32_t FS,
                                    const int16_t* const* in_near,
                                    int16_t* const* out) {}

void WebRtcAgc_InitVad(AgcVad* state) {}

int16_t WebRtcAgc_ProcessVad(AgcVad* state,       // (i) VAD state
                             const int16_t* in,   // (i) Speech signal
                             size_t nrSamples) {}

}  // namespace webrtc