Change name of files and class in agc/histogram* in order to avoid issue file-name clash in build files

The changes are done in several patches in order to make
the review easier.

NOTRY=True
BUG=webrtc:5949

Review-Url: https://codereview.webrtc.org/2051443002
Cr-Commit-Position: refs/heads/master@{#13068}
This commit is contained in:
peah 2016-06-08 06:42:02 -07:00 committed by Commit bot
parent 86f7afd44f
commit bbe423312d
9 changed files with 103 additions and 103 deletions

View File

@ -40,13 +40,13 @@ source_set("audio_processing") {
"agc/agc_manager_direct.cc",
"agc/agc_manager_direct.h",
"agc/gain_map_internal.h",
"agc/histogram.cc",
"agc/histogram.h",
"agc/legacy/analog_agc.c",
"agc/legacy/analog_agc.h",
"agc/legacy/digital_agc.c",
"agc/legacy/digital_agc.h",
"agc/legacy/gain_control.h",
"agc/loudness_histogram.cc",
"agc/loudness_histogram.h",
"agc/utility.cc",
"agc/utility.h",
"audio_buffer.cc",

View File

@ -17,7 +17,7 @@
#include <vector>
#include "webrtc/base/checks.h"
#include "webrtc/modules/audio_processing/agc/histogram.h"
#include "webrtc/modules/audio_processing/agc/loudness_histogram.h"
#include "webrtc/modules/audio_processing/agc/utility.h"
#include "webrtc/modules/include/module_common_types.h"
@ -33,9 +33,8 @@ const double kActivityThreshold = 0.3;
Agc::Agc()
: target_level_loudness_(Dbfs2Loudness(kDefaultLevelDbfs)),
target_level_dbfs_(kDefaultLevelDbfs),
histogram_(Histogram::Create(kNumAnalysisFrames)),
inactive_histogram_(Histogram::Create()) {
}
histogram_(LoudnessHistogram::Create(kNumAnalysisFrames)),
inactive_histogram_(LoudnessHistogram::Create()) {}
Agc::~Agc() {}

View File

@ -19,7 +19,7 @@
namespace webrtc {
class AudioFrame;
class Histogram;
class LoudnessHistogram;
class Agc {
public:
@ -49,8 +49,8 @@ class Agc {
private:
double target_level_loudness_;
int target_level_dbfs_;
std::unique_ptr<Histogram> histogram_;
std::unique_ptr<Histogram> inactive_histogram_;
std::unique_ptr<LoudnessHistogram> histogram_;
std::unique_ptr<LoudnessHistogram> inactive_histogram_;
VoiceActivityDetector vad_;
};

View File

@ -8,7 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "webrtc/modules/audio_processing/agc/histogram.h"
#include "webrtc/modules/audio_processing/agc/loudness_histogram.h"
#include <cmath>
#include <cstring>
@ -18,47 +18,47 @@
namespace webrtc {
static const double kHistBinCenters[] = {
7.59621091765857e-02, 9.02036021061016e-02, 1.07115112009343e-01,
1.27197217770508e-01, 1.51044347572047e-01, 1.79362373905283e-01,
2.12989507320644e-01, 2.52921107370304e-01, 3.00339145144454e-01,
3.56647189489147e-01, 4.23511952494003e-01, 5.02912623991786e-01,
5.97199455365749e-01, 7.09163326739184e-01, 8.42118356728544e-01,
1.00000000000000e+00, 1.18748153630660e+00, 1.41011239906908e+00,
1.67448243801153e+00, 1.98841697800836e+00, 2.36120844786349e+00,
2.80389143520905e+00, 3.32956930911896e+00, 3.95380207843188e+00,
4.69506696634852e+00, 5.57530533426190e+00, 6.62057214370769e+00,
7.86180718043869e+00, 9.33575086877358e+00, 1.10860317842269e+01,
1.31644580546776e+01, 1.56325508754123e+01, 1.85633655299256e+01,
2.20436538184971e+01, 2.61764319021997e+01, 3.10840295702492e+01,
3.69117111886792e+01, 4.38319755100383e+01, 5.20496616180135e+01,
6.18080121423973e+01, 7.33958732149108e+01, 8.71562442838066e+01,
1.03496430860848e+02, 1.22900100720889e+02, 1.45941600416277e+02,
1.73302955873365e+02, 2.05794060286978e+02, 2.44376646872353e+02,
2.90192756065437e+02, 3.44598539797631e+02, 4.09204403447902e+02,
4.85922673669740e+02, 5.77024203055553e+02, 6.85205587130498e+02,
8.13668983291589e+02, 9.66216894324125e+02, 1.14736472207740e+03,
1.36247442287647e+03, 1.61791322085579e+03, 1.92124207711260e+03,
2.28143949334655e+03, 2.70916727454970e+03, 3.21708611729384e+03,
3.82023036499473e+03, 4.53645302286906e+03, 5.38695420497926e+03,
6.39690865534207e+03, 7.59621091765857e+03, 9.02036021061016e+03,
1.07115112009343e+04, 1.27197217770508e+04, 1.51044347572047e+04,
1.79362373905283e+04, 2.12989507320644e+04, 2.52921107370304e+04,
3.00339145144454e+04, 3.56647189489147e+04};
7.59621091765857e-02, 9.02036021061016e-02, 1.07115112009343e-01,
1.27197217770508e-01, 1.51044347572047e-01, 1.79362373905283e-01,
2.12989507320644e-01, 2.52921107370304e-01, 3.00339145144454e-01,
3.56647189489147e-01, 4.23511952494003e-01, 5.02912623991786e-01,
5.97199455365749e-01, 7.09163326739184e-01, 8.42118356728544e-01,
1.00000000000000e+00, 1.18748153630660e+00, 1.41011239906908e+00,
1.67448243801153e+00, 1.98841697800836e+00, 2.36120844786349e+00,
2.80389143520905e+00, 3.32956930911896e+00, 3.95380207843188e+00,
4.69506696634852e+00, 5.57530533426190e+00, 6.62057214370769e+00,
7.86180718043869e+00, 9.33575086877358e+00, 1.10860317842269e+01,
1.31644580546776e+01, 1.56325508754123e+01, 1.85633655299256e+01,
2.20436538184971e+01, 2.61764319021997e+01, 3.10840295702492e+01,
3.69117111886792e+01, 4.38319755100383e+01, 5.20496616180135e+01,
6.18080121423973e+01, 7.33958732149108e+01, 8.71562442838066e+01,
1.03496430860848e+02, 1.22900100720889e+02, 1.45941600416277e+02,
1.73302955873365e+02, 2.05794060286978e+02, 2.44376646872353e+02,
2.90192756065437e+02, 3.44598539797631e+02, 4.09204403447902e+02,
4.85922673669740e+02, 5.77024203055553e+02, 6.85205587130498e+02,
8.13668983291589e+02, 9.66216894324125e+02, 1.14736472207740e+03,
1.36247442287647e+03, 1.61791322085579e+03, 1.92124207711260e+03,
2.28143949334655e+03, 2.70916727454970e+03, 3.21708611729384e+03,
3.82023036499473e+03, 4.53645302286906e+03, 5.38695420497926e+03,
6.39690865534207e+03, 7.59621091765857e+03, 9.02036021061016e+03,
1.07115112009343e+04, 1.27197217770508e+04, 1.51044347572047e+04,
1.79362373905283e+04, 2.12989507320644e+04, 2.52921107370304e+04,
3.00339145144454e+04, 3.56647189489147e+04};
static const double kProbQDomain = 1024.0;
// Loudness of -15 dB (smallest expected loudness) in log domain,
// loudness_db = 13.5 * log10(rms);
static const double kLogDomainMinBinCenter = -2.57752062648587;
// Loudness step of 1 dB in log domain
static const double kLogDomainStepSizeInverse = 5.81954605750359;
static const double kLogDomainStepSizeInverse = 5.81954605750359;
static const int kTransientWidthThreshold = 7;
static const double kLowProbabilityThreshold = 0.2;
static const int kLowProbThresholdQ10 = static_cast<int>(
kLowProbabilityThreshold * kProbQDomain);
static const int kLowProbThresholdQ10 =
static_cast<int>(kLowProbabilityThreshold * kProbQDomain);
Histogram::Histogram()
LoudnessHistogram::LoudnessHistogram()
: num_updates_(0),
audio_content_q10_(0),
bin_count_q10_(),
@ -73,7 +73,7 @@ Histogram::Histogram()
"histogram bin centers incorrect size");
}
Histogram::Histogram(int window_size)
LoudnessHistogram::LoudnessHistogram(int window_size)
: num_updates_(0),
audio_content_q10_(0),
bin_count_q10_(),
@ -84,9 +84,9 @@ Histogram::Histogram(int window_size)
len_circular_buffer_(window_size),
len_high_activity_(0) {}
Histogram::~Histogram() {}
LoudnessHistogram::~LoudnessHistogram() {}
void Histogram::Update(double rms, double activity_probaility) {
void LoudnessHistogram::Update(double rms, double activity_probaility) {
// If circular histogram is activated then remove the oldest entry.
if (len_circular_buffer_ > 0)
RemoveOldestEntryAndUpdate();
@ -94,13 +94,13 @@ void Histogram::Update(double rms, double activity_probaility) {
// Find the corresponding bin.
int hist_index = GetBinIndex(rms);
// To Q10 domain.
int prob_q10 = static_cast<int16_t>(floor(activity_probaility *
kProbQDomain));
int prob_q10 =
static_cast<int16_t>(floor(activity_probaility * kProbQDomain));
InsertNewestEntryAndUpdate(prob_q10, hist_index);
}
// Doing nothing if buffer is not full, yet.
void Histogram::RemoveOldestEntryAndUpdate() {
void LoudnessHistogram::RemoveOldestEntryAndUpdate() {
assert(len_circular_buffer_ > 0);
// Do nothing if circular buffer is not full.
if (!buffer_is_full_)
@ -111,12 +111,12 @@ void Histogram::RemoveOldestEntryAndUpdate() {
UpdateHist(-oldest_prob, oldest_hist_index);
}
void Histogram::RemoveTransient() {
void LoudnessHistogram::RemoveTransient() {
// Don't expect to be here if high-activity region is longer than
// |kTransientWidthThreshold| or there has not been any transient.
assert(len_high_activity_ <= kTransientWidthThreshold);
int index = (buffer_index_ > 0) ? (buffer_index_ - 1) :
len_circular_buffer_ - 1;
int index =
(buffer_index_ > 0) ? (buffer_index_ - 1) : len_circular_buffer_ - 1;
while (len_high_activity_ > 0) {
UpdateHist(-activity_probability_[index], hist_bin_index_[index]);
activity_probability_[index] = 0;
@ -125,8 +125,8 @@ void Histogram::RemoveTransient() {
}
}
void Histogram::InsertNewestEntryAndUpdate(int activity_prob_q10,
int hist_index) {
void LoudnessHistogram::InsertNewestEntryAndUpdate(int activity_prob_q10,
int hist_index) {
// Update the circular buffer if it is enabled.
if (len_circular_buffer_ > 0) {
// Removing transient.
@ -158,26 +158,26 @@ void Histogram::InsertNewestEntryAndUpdate(int activity_prob_q10,
UpdateHist(activity_prob_q10, hist_index);
}
void Histogram::UpdateHist(int activity_prob_q10, int hist_index) {
void LoudnessHistogram::UpdateHist(int activity_prob_q10, int hist_index) {
bin_count_q10_[hist_index] += activity_prob_q10;
audio_content_q10_ += activity_prob_q10;
}
double Histogram::AudioContent() const {
double LoudnessHistogram::AudioContent() const {
return audio_content_q10_ / kProbQDomain;
}
Histogram* Histogram::Create() {
return new Histogram;
LoudnessHistogram* LoudnessHistogram::Create() {
return new LoudnessHistogram;
}
Histogram* Histogram::Create(int window_size) {
LoudnessHistogram* LoudnessHistogram::Create(int window_size) {
if (window_size < 0)
return NULL;
return new Histogram(window_size);
return new LoudnessHistogram(window_size);
}
void Histogram::Reset() {
void LoudnessHistogram::Reset() {
// Reset the histogram, audio-content and number of updates.
memset(bin_count_q10_, 0, sizeof(bin_count_q10_));
audio_content_q10_ = 0;
@ -188,7 +188,7 @@ void Histogram::Reset() {
len_high_activity_ = 0;
}
int Histogram::GetBinIndex(double rms) {
int LoudnessHistogram::GetBinIndex(double rms) {
// First exclude overload cases.
if (rms <= kHistBinCenters[0]) {
return 0;
@ -199,8 +199,8 @@ int Histogram::GetBinIndex(double rms) {
// search in linear domain.
double rms_log = log(rms);
int index = static_cast<int>(floor((rms_log - kLogDomainMinBinCenter) *
kLogDomainStepSizeInverse));
int index = static_cast<int>(
floor((rms_log - kLogDomainMinBinCenter) * kLogDomainStepSizeInverse));
// The final decision is in linear domain.
double b = 0.5 * (kHistBinCenters[index] + kHistBinCenters[index + 1]);
if (rms > b) {
@ -210,7 +210,7 @@ int Histogram::GetBinIndex(double rms) {
}
}
double Histogram::CurrentRms() const {
double LoudnessHistogram::CurrentRms() const {
double p;
double mean_val = 0;
if (audio_content_q10_ > 0) {

View File

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AGC_HISTOGRAM_H_
#define WEBRTC_MODULES_AUDIO_PROCESSING_AGC_HISTOGRAM_H_
#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AGC_LOUDNESS_HISTOGRAM_H_
#define WEBRTC_MODULES_AUDIO_PROCESSING_AGC_LOUDNESS_HISTOGRAM_H_
#include <string.h>
@ -21,15 +21,15 @@ namespace webrtc {
// This class implements the histogram of loudness with circular buffers so that
// the histogram tracks the last T seconds of the loudness.
class Histogram {
class LoudnessHistogram {
public:
// Create a non-sliding Histogram.
static Histogram* Create();
// Create a non-sliding LoudnessHistogram.
static LoudnessHistogram* Create();
// Create a sliding Histogram, i.e. the histogram represents the last
// Create a sliding LoudnessHistogram, i.e. the histogram represents the last
// |window_size| samples.
static Histogram* Create(int window_size);
~Histogram();
static LoudnessHistogram* Create(int window_size);
~LoudnessHistogram();
// Insert RMS and the corresponding activity probability.
void Update(double rms, double activity_probability);
@ -48,8 +48,8 @@ class Histogram {
int num_updates() const { return num_updates_; }
private:
Histogram();
explicit Histogram(int window);
LoudnessHistogram();
explicit LoudnessHistogram(int window);
// Find the histogram bin associated with the given |rms|.
int GetBinIndex(double rms);
@ -68,9 +68,9 @@ class Histogram {
// |bin_count_q10_|.
int64_t audio_content_q10_;
// Histogram of input RMS in Q10 with |kHistSize_| bins. In each 'Update(),'
// we increment the associated histogram-bin with the given probability. The
// increment is implemented in Q10 to avoid rounding errors.
// LoudnessHistogram of input RMS in Q10 with |kHistSize_| bins. In each
// 'Update(),' we increment the associated histogram-bin with the given
// probability. The increment is implemented in Q10 to avoid rounding errors.
int64_t bin_count_q10_[kHistSize];
// Circular buffer for probabilities
@ -89,4 +89,4 @@ class Histogram {
} // namespace webrtc
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_AGC_HISTOGRAM_H_
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_AGC_LOUDNESS_HISTOGRAM_H_

View File

@ -10,9 +10,10 @@
// Use CreateHistUnittestFile.m to generate the input file.
#include "webrtc/modules/audio_processing/agc/histogram.h"
#include "webrtc/modules/audio_processing/agc/loudness_histogram.h"
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <memory>
@ -31,31 +32,31 @@ struct InputOutput {
const double kRelativeErrTol = 1e-10;
class HistogramTest : public ::testing::Test {
class LoudnessHistogramTest : public ::testing::Test {
protected:
void RunTest(bool enable_circular_buff,
const char* filename);
void RunTest(bool enable_circular_buff, const char* filename);
private:
void TestClean();
std::unique_ptr<Histogram> hist_;
std::unique_ptr<LoudnessHistogram> hist_;
};
void HistogramTest::TestClean() {
void LoudnessHistogramTest::TestClean() {
EXPECT_EQ(hist_->CurrentRms(), 7.59621091765857e-02);
EXPECT_EQ(hist_->AudioContent(), 0);
EXPECT_EQ(hist_->num_updates(), 0);
}
void HistogramTest::RunTest(bool enable_circular_buff, const char* filename) {
void LoudnessHistogramTest::RunTest(bool enable_circular_buff,
const char* filename) {
FILE* in_file = fopen(filename, "rb");
ASSERT_TRUE(in_file != NULL);
if (enable_circular_buff) {
int buffer_size;
EXPECT_EQ(fread(&buffer_size, sizeof(buffer_size), 1, in_file), 1u);
hist_.reset(Histogram::Create(buffer_size));
hist_.reset(LoudnessHistogram::Create(buffer_size));
} else {
hist_.reset(Histogram::Create());
hist_.reset(LoudnessHistogram::Create());
}
TestClean();
@ -78,28 +79,28 @@ void HistogramTest::RunTest(bool enable_circular_buff, const char* filename) {
EXPECT_EQ(hist_->num_updates(), num_updates);
double audio_content = hist_->AudioContent();
double abs_err = std::min(audio_content, io.audio_content) *
kRelativeErrTol;
double abs_err =
std::min(audio_content, io.audio_content) * kRelativeErrTol;
ASSERT_NEAR(audio_content, io.audio_content, abs_err);
double current_loudness = Linear2Loudness(hist_->CurrentRms());
abs_err = std::min(fabs(current_loudness), fabs(io.loudness)) *
kRelativeErrTol;
abs_err =
std::min(fabs(current_loudness), fabs(io.loudness)) * kRelativeErrTol;
ASSERT_NEAR(current_loudness, io.loudness, abs_err);
}
fclose(in_file);
}
TEST_F(HistogramTest, ActiveCircularBuffer) {
RunTest(true,
test::ResourcePath("audio_processing/agc/agc_with_circular_buffer",
"dat").c_str());
TEST_F(LoudnessHistogramTest, ActiveCircularBuffer) {
RunTest(true, test::ResourcePath(
"audio_processing/agc/agc_with_circular_buffer", "dat")
.c_str());
}
TEST_F(HistogramTest, InactiveCircularBuffer) {
RunTest(false,
test::ResourcePath("audio_processing/agc/agc_no_circular_buffer",
"dat").c_str());
TEST_F(LoudnessHistogramTest, InactiveCircularBuffer) {
RunTest(false, test::ResourcePath(
"audio_processing/agc/agc_no_circular_buffer", "dat")
.c_str());
}
} // namespace webrtc

View File

@ -51,8 +51,8 @@
'agc/agc_manager_direct.cc',
'agc/agc_manager_direct.h',
'agc/gain_map_internal.h',
'agc/histogram.cc',
'agc/histogram.h',
'agc/loudness_histogram.cc',
'agc/loudness_histogram.h',
'agc/legacy/analog_agc.c',
'agc/legacy/analog_agc.h',
'agc/legacy/digital_agc.c',

View File

@ -236,7 +236,7 @@
'audio_processing/agc/agc_manager_direct_unittest.cc',
# TODO(ajm): Fix to match new interface.
# 'audio_processing/agc/agc_unittest.cc',
'audio_processing/agc/histogram_unittest.cc',
'audio_processing/agc/loudness_histogram_unittest.cc',
'audio_processing/agc/mock_agc.h',
'audio_processing/beamformer/array_util_unittest.cc',
'audio_processing/beamformer/complex_matrix_unittest.cc',

View File

@ -19,7 +19,7 @@
#include "gflags/gflags.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/modules/audio_processing/agc/agc.h"
#include "webrtc/modules/audio_processing/agc/histogram.h"
#include "webrtc/modules/audio_processing/agc/loudness_histogram.h"
#include "webrtc/modules/audio_processing/agc/utility.h"
#include "webrtc/modules/audio_processing/vad/vad_audio_proc.h"
#include "webrtc/modules/audio_processing/vad/common.h"
@ -75,7 +75,7 @@ class AgcStat {
AgcStat()
: video_index_(0),
activity_threshold_(kDefaultActivityThreshold),
audio_content_(Histogram::Create(kAgcAnalWindowSamples)),
audio_content_(LoudnessHistogram::Create(kAgcAnalWindowSamples)),
audio_processing_(new VadAudioProc()),
vad_(new PitchBasedVad()),
standalone_vad_(StandaloneVad::Create()),
@ -155,7 +155,7 @@ class AgcStat {
int video_index_;
double activity_threshold_;
double video_vad_[kMaxNumFrames];
std::unique_ptr<Histogram> audio_content_;
std::unique_ptr<LoudnessHistogram> audio_content_;
std::unique_ptr<VadAudioProc> audio_processing_;
std::unique_ptr<PitchBasedVad> vad_;
std::unique_ptr<StandaloneVad> standalone_vad_;