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

/*
 *  Copyright (c) 2012 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.
 */

/*
 *
 * Using a feedback system, determines an appropriate analog volume level
 * given an input signal and current volume level. Targets a conservative
 * signal level and is intended for use with a digital AGC to apply
 * additional gain.
 *
 */

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

#include <stdlib.h>

#include "rtc_base/checks.h"

namespace webrtc {

namespace {

// Errors
#define AGC_UNSPECIFIED_ERROR
#define AGC_UNINITIALIZED_ERROR
#define AGC_NULL_POINTER_ERROR
#define AGC_BAD_PARAMETER_ERROR

/* The slope of in Q13*/
static const int16_t kSlope1[8] =;

/* The offset in Q14 */
static const int16_t kOffset1[8] =;

/* The slope of in Q13*/
static const int16_t kSlope2[8] =;

/* The offset in Q14 */
static const int16_t kOffset2[8] =;

static const int16_t kMuteGuardTimeMs =;
static const int16_t kInitCheck =;
static const size_t kNumSubframes =;

/* Default settings if config is not used */
#define AGC_DEFAULT_TARGET_LEVEL
#define AGC_DEFAULT_COMP_GAIN
/* This is the target level for the analog part in ENV scale. To convert to RMS
 * scale you
 * have to add OFFSET_ENV_TO_RMS.
 */
#define ANALOG_TARGET_LEVEL
#define ANALOG_TARGET_LEVEL_2
/* Offset between RMS scale (analog part) and ENV scale (digital part). This
 * value actually
 * varies with the FIXED_ANALOG_TARGET_LEVEL, hence we should in the future
 * replace it with
 * a table.
 */
#define OFFSET_ENV_TO_RMS
/* The reference input level at which the digital part gives an output of
 * targetLevelDbfs
 * (desired level) if we have no compression gain. This level should be set high
 * enough not
 * to compress the peaks due to the dynamics.
 */
#define DIGITAL_REF_AT_0_COMP_GAIN
/* Speed of reference level decrease.
 */
#define DIFF_REF_TO_ANALOG

/* Size of analog gain table */
#define GAIN_TBL_LEN
/* Matlab code:
 * fprintf(1, '\t%i, %i, %i, %i,\n', round(10.^(linspace(0,10,32)/20) * 2^12));
 */
/* Q12 */
static const uint16_t kGainTableAnalog[GAIN_TBL_LEN] =;

/* Gain/Suppression tables for virtual Mic (in Q10) */
static const uint16_t kGainTableVirtualMic[128] =;
static const uint16_t kSuppressionTableVirtualMic[128] =;

/* Table for target energy levels. Values in Q(-7)
 * Matlab code
 * targetLevelTable = fprintf('%d,\t%d,\t%d,\t%d,\n',
 * round((32767*10.^(-(0:63)'/20)).^2*16/2^7) */

static const int32_t kTargetLevelTable[64] =;

}  // namespace

int WebRtcAgc_AddMic(void* state,
                     int16_t* const* in_mic,
                     size_t num_bands,
                     size_t samples) {}

int WebRtcAgc_AddFarend(void* state, const int16_t* in_far, size_t samples) {}

int WebRtcAgc_GetAddFarendError(void* state, size_t samples) {}

int WebRtcAgc_VirtualMic(void* agcInst,
                         int16_t* const* in_near,
                         size_t num_bands,
                         size_t samples,
                         int32_t micLevelIn,
                         int32_t* micLevelOut) {}

void WebRtcAgc_UpdateAgcThresholds(LegacyAgc* stt) {}

void WebRtcAgc_SaturationCtrl(LegacyAgc* stt,
                              uint8_t* saturated,
                              int32_t* env) {}

void WebRtcAgc_ZeroCtrl(LegacyAgc* stt, int32_t* inMicLevel, int32_t* env) {}

void WebRtcAgc_SpeakerInactiveCtrl(LegacyAgc* stt) {}

void WebRtcAgc_ExpCurve(int16_t volume, int16_t* index) {}

int32_t WebRtcAgc_ProcessAnalog(void* state,
                                int32_t inMicLevel,
                                int32_t* outMicLevel,
                                int16_t vadLogRatio,
                                int16_t echo,
                                uint8_t* saturationWarning) {}

int WebRtcAgc_Analyze(void* agcInst,
                      const int16_t* const* in_near,
                      size_t num_bands,
                      size_t samples,
                      int32_t inMicLevel,
                      int32_t* outMicLevel,
                      int16_t echo,
                      uint8_t* saturationWarning,
                      int32_t gains[11]) {}

int WebRtcAgc_Process(const void* agcInst,
                      const int32_t gains[11],
                      const int16_t* const* in_near,
                      size_t num_bands,
                      int16_t* const* out) {}

int WebRtcAgc_set_config(void* agcInst, WebRtcAgcConfig agcConfig) {}

int WebRtcAgc_get_config(void* agcInst, WebRtcAgcConfig* config) {}

void* WebRtcAgc_Create() {}

void WebRtcAgc_Free(void* state) {}

/* minLevel     - Minimum volume level
 * maxLevel     - Maximum volume level
 */
int WebRtcAgc_Init(void* agcInst,
                   int32_t minLevel,
                   int32_t maxLevel,
                   int16_t agcMode,
                   uint32_t fs) {}

}  // namespace webrtc