Rename VectorBuffer->SpectrumBuffer, MatrixBuffer->BlockBuffer, BlockBuffer->Aec2BlockBuffer

The VectorBuffer and MatrixBuffer names are too generic for their use case.

Bug: webrtc:10913
Change-Id: Ideecd0d27e07487a85a61dc6474e69733d07dcd6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/151602
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29076}
This commit is contained in:
Sam Zackrisson 2019-09-05 11:30:49 +02:00 committed by Commit Bot
parent 77c71d1488
commit f3f6159114
23 changed files with 90 additions and 90 deletions

View File

@ -154,25 +154,25 @@ __inline static float MulIm(float aRe, float aIm, float bRe, float bIm) {
PowerLevel::PowerLevel()
: framelevel(kSubCountLen + 1), averagelevel(kCountLen + 1) {}
BlockBuffer::BlockBuffer() {
Aec2BlockBuffer::Aec2BlockBuffer() {
buffer_ = WebRtc_CreateBuffer(kBufferSizeBlocks, sizeof(float) * PART_LEN);
RTC_CHECK(buffer_);
ReInit();
}
BlockBuffer::~BlockBuffer() {
Aec2BlockBuffer::~Aec2BlockBuffer() {
WebRtc_FreeBuffer(buffer_);
}
void BlockBuffer::ReInit() {
void Aec2BlockBuffer::ReInit() {
WebRtc_InitBuffer(buffer_);
}
void BlockBuffer::Insert(const float block[PART_LEN]) {
void Aec2BlockBuffer::Insert(const float block[PART_LEN]) {
WebRtc_WriteBuffer(buffer_, block, 1);
}
void BlockBuffer::ExtractExtendedBlock(float extended_block[PART_LEN2]) {
void Aec2BlockBuffer::ExtractExtendedBlock(float extended_block[PART_LEN2]) {
float* block_ptr = NULL;
RTC_DCHECK_LT(0, AvaliableSpace());
@ -197,15 +197,15 @@ void BlockBuffer::ExtractExtendedBlock(float extended_block[PART_LEN2]) {
}
}
int BlockBuffer::AdjustSize(int buffer_size_decrease) {
int Aec2BlockBuffer::AdjustSize(int buffer_size_decrease) {
return WebRtc_MoveReadPtr(buffer_, buffer_size_decrease);
}
size_t BlockBuffer::Size() {
size_t Aec2BlockBuffer::Size() {
return static_cast<int>(WebRtc_available_read(buffer_));
}
size_t BlockBuffer::AvaliableSpace() {
size_t Aec2BlockBuffer::AvaliableSpace() {
return WebRtc_available_write(buffer_);
}

View File

@ -82,10 +82,10 @@ typedef struct PowerLevel {
float minlevel;
} PowerLevel;
class BlockBuffer {
class Aec2BlockBuffer {
public:
BlockBuffer();
~BlockBuffer();
Aec2BlockBuffer();
~Aec2BlockBuffer();
void ReInit();
void Insert(const float block[PART_LEN]);
void ExtractExtendedBlock(float extended_block[PART_LEN]);
@ -183,7 +183,7 @@ struct AecCore {
int xfBufBlockPos;
BlockBuffer farend_block_buffer_;
Aec2BlockBuffer farend_block_buffer_;
int system_delay; // Current system delay buffered in AEC.

View File

@ -22,6 +22,8 @@ rtc_static_library("aec3") {
"aec_state.h",
"api_call_jitter_metrics.cc",
"api_call_jitter_metrics.h",
"block_buffer.cc",
"block_buffer.h",
"block_delay_buffer.cc",
"block_delay_buffer.h",
"block_framer.cc",
@ -70,8 +72,6 @@ rtc_static_library("aec3") {
"matched_filter.h",
"matched_filter_lag_aggregator.cc",
"matched_filter_lag_aggregator.h",
"matrix_buffer.cc",
"matrix_buffer.h",
"moving_average.cc",
"moving_average.h",
"render_buffer.cc",
@ -100,6 +100,8 @@ rtc_static_library("aec3") {
"shadow_filter_update_gain.h",
"signal_dependent_erle_estimator.cc",
"signal_dependent_erle_estimator.h",
"spectrum_buffer.cc",
"spectrum_buffer.h",
"stationarity_estimator.cc",
"stationarity_estimator.h",
"subband_erle_estimator.cc",
@ -114,8 +116,6 @@ rtc_static_library("aec3") {
"suppression_filter.h",
"suppression_gain.cc",
"suppression_gain.h",
"vector_buffer.cc",
"vector_buffer.h",
"vector_math.h",
]

View File

@ -8,16 +8,16 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/audio_processing/aec3/matrix_buffer.h"
#include "modules/audio_processing/aec3/block_buffer.h"
#include <algorithm>
namespace webrtc {
MatrixBuffer::MatrixBuffer(size_t size,
size_t num_bands,
size_t num_channels,
size_t frame_length)
BlockBuffer::BlockBuffer(size_t size,
size_t num_bands,
size_t num_channels,
size_t frame_length)
: size(static_cast<int>(size)),
buffer(size,
std::vector<std::vector<std::vector<float>>>(
@ -34,6 +34,6 @@ MatrixBuffer::MatrixBuffer(size_t size,
}
}
MatrixBuffer::~MatrixBuffer() = default;
BlockBuffer::~BlockBuffer() = default;
} // namespace webrtc

View File

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_AUDIO_PROCESSING_AEC3_MATRIX_BUFFER_H_
#define MODULES_AUDIO_PROCESSING_AEC3_MATRIX_BUFFER_H_
#ifndef MODULES_AUDIO_PROCESSING_AEC3_BLOCK_BUFFER_H_
#define MODULES_AUDIO_PROCESSING_AEC3_BLOCK_BUFFER_H_
#include <stddef.h>
@ -22,12 +22,12 @@ namespace webrtc {
// Struct for bundling a circular buffer of two dimensional vector objects
// together with the read and write indices.
// TODO(peah): Change name of this class to be more specific to what it does.
struct MatrixBuffer {
MatrixBuffer(size_t size,
size_t num_bands,
size_t num_channels,
size_t frame_length);
~MatrixBuffer();
struct BlockBuffer {
BlockBuffer(size_t size,
size_t num_bands,
size_t num_channels,
size_t frame_length);
~BlockBuffer();
int IncIndex(int index) const {
RTC_DCHECK_EQ(buffer.size(), static_cast<size_t>(size));
@ -60,4 +60,4 @@ struct MatrixBuffer {
} // namespace webrtc
#endif // MODULES_AUDIO_PROCESSING_AEC3_MATRIX_BUFFER_H_
#endif // MODULES_AUDIO_PROCESSING_AEC3_BLOCK_BUFFER_H_

View File

@ -16,9 +16,9 @@
#include <vector>
#include "api/array_view.h"
#include "modules/audio_processing/aec3/matrix_buffer.h"
#include "modules/audio_processing/aec3/block_buffer.h"
#include "modules/audio_processing/aec3/spectrum_buffer.h"
#include "modules/audio_processing/aec3/stationarity_estimator.h"
#include "modules/audio_processing/aec3/vector_buffer.h"
namespace webrtc {
@ -54,7 +54,7 @@ void EchoAudibility::UpdateRenderStationarityFlags(
const RenderBuffer& render_buffer,
rtc::ArrayView<const float> render_reverb_contribution_spectrum,
int delay_blocks) {
const VectorBuffer& spectrum_buffer = render_buffer.GetSpectrumBuffer();
const SpectrumBuffer& spectrum_buffer = render_buffer.GetSpectrumBuffer();
int idx_at_delay =
spectrum_buffer.OffsetIndex(spectrum_buffer.read, delay_blocks);
@ -67,8 +67,8 @@ void EchoAudibility::UpdateRenderStationarityFlags(
}
void EchoAudibility::UpdateRenderNoiseEstimator(
const VectorBuffer& spectrum_buffer,
const MatrixBuffer& block_buffer,
const SpectrumBuffer& spectrum_buffer,
const BlockBuffer& block_buffer,
bool external_delay_seen) {
if (!render_spectrum_write_prev_) {
render_spectrum_write_prev_ = spectrum_buffer.write;
@ -90,7 +90,7 @@ void EchoAudibility::UpdateRenderNoiseEstimator(
render_spectrum_write_prev_ = render_spectrum_write_current;
}
bool EchoAudibility::IsRenderTooLow(const MatrixBuffer& block_buffer) {
bool EchoAudibility::IsRenderTooLow(const BlockBuffer& block_buffer) {
bool too_low = false;
const int render_block_write_current = block_buffer.write;
if (render_block_write_current == render_block_write_prev_) {

View File

@ -15,10 +15,10 @@
#include "absl/types/optional.h"
#include "api/array_view.h"
#include "modules/audio_processing/aec3/matrix_buffer.h"
#include "modules/audio_processing/aec3/block_buffer.h"
#include "modules/audio_processing/aec3/render_buffer.h"
#include "modules/audio_processing/aec3/spectrum_buffer.h"
#include "modules/audio_processing/aec3/stationarity_estimator.h"
#include "modules/audio_processing/aec3/vector_buffer.h"
#include "rtc_base/constructor_magic.h"
namespace webrtc {
@ -64,13 +64,13 @@ class EchoAudibility {
// Updates the noise estimator with the new render data since the previous
// call to this method.
void UpdateRenderNoiseEstimator(const VectorBuffer& spectrum_buffer,
const MatrixBuffer& block_buffer,
void UpdateRenderNoiseEstimator(const SpectrumBuffer& spectrum_buffer,
const BlockBuffer& block_buffer,
bool external_delay_seen);
// Returns a bool being true if the render signal contains just close to zero
// values.
bool IsRenderTooLow(const MatrixBuffer& block_buffer);
bool IsRenderTooLow(const BlockBuffer& block_buffer);
absl::optional<int> render_spectrum_write_prev_;
int render_block_write_prev_;

View File

@ -14,7 +14,7 @@
#include "api/array_view.h"
#include "modules/audio_processing/aec3/render_delay_buffer.h"
#include "modules/audio_processing/aec3/vector_buffer.h"
#include "modules/audio_processing/aec3/spectrum_buffer.h"
#include "rtc_base/random.h"
#include "test/gtest.h"

View File

@ -48,8 +48,8 @@ class MockRenderDelayBuffer : public RenderDelayBuffer {
const DownsampledRenderBuffer& FakeGetDownsampledRenderBuffer() const {
return downsampled_render_buffer_;
}
MatrixBuffer block_buffer_;
VectorBuffer spectrum_buffer_;
BlockBuffer block_buffer_;
SpectrumBuffer spectrum_buffer_;
FftBuffer fft_buffer_;
RenderBuffer render_buffer_;
DownsampledRenderBuffer downsampled_render_buffer_;

View File

@ -18,8 +18,8 @@
namespace webrtc {
RenderBuffer::RenderBuffer(MatrixBuffer* block_buffer,
VectorBuffer* spectrum_buffer,
RenderBuffer::RenderBuffer(BlockBuffer* block_buffer,
SpectrumBuffer* spectrum_buffer,
FftBuffer* fft_buffer)
: block_buffer_(block_buffer),
spectrum_buffer_(spectrum_buffer),

View File

@ -18,10 +18,10 @@
#include "api/array_view.h"
#include "modules/audio_processing/aec3/aec3_common.h"
#include "modules/audio_processing/aec3/block_buffer.h"
#include "modules/audio_processing/aec3/fft_buffer.h"
#include "modules/audio_processing/aec3/fft_data.h"
#include "modules/audio_processing/aec3/matrix_buffer.h"
#include "modules/audio_processing/aec3/vector_buffer.h"
#include "modules/audio_processing/aec3/spectrum_buffer.h"
#include "rtc_base/checks.h"
#include "rtc_base/constructor_magic.h"
@ -30,8 +30,8 @@ namespace webrtc {
// Provides a buffer of the render data for the echo remover.
class RenderBuffer {
public:
RenderBuffer(MatrixBuffer* block_buffer,
VectorBuffer* spectrum_buffer,
RenderBuffer(BlockBuffer* block_buffer,
SpectrumBuffer* spectrum_buffer,
FftBuffer* fft_buffer);
~RenderBuffer();
@ -95,14 +95,14 @@ class RenderBuffer {
}
// Returns a reference to the spectrum buffer.
const VectorBuffer& GetSpectrumBuffer() const { return *spectrum_buffer_; }
const SpectrumBuffer& GetSpectrumBuffer() const { return *spectrum_buffer_; }
// Returns a reference to the block buffer.
const MatrixBuffer& GetBlockBuffer() const { return *block_buffer_; }
const BlockBuffer& GetBlockBuffer() const { return *block_buffer_; }
private:
const MatrixBuffer* const block_buffer_;
const VectorBuffer* const spectrum_buffer_;
const BlockBuffer* const block_buffer_;
const SpectrumBuffer* const spectrum_buffer_;
const FftBuffer* const fft_buffer_;
bool render_activity_ = false;
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RenderBuffer);

View File

@ -22,22 +22,22 @@ namespace webrtc {
// Verifies the check for non-null fft buffer.
TEST(RenderBuffer, NullExternalFftBuffer) {
MatrixBuffer block_buffer(10, 3, 1, kBlockSize);
VectorBuffer spectrum_buffer(10, 1, kFftLengthBy2Plus1);
BlockBuffer block_buffer(10, 3, 1, kBlockSize);
SpectrumBuffer spectrum_buffer(10, 1, kFftLengthBy2Plus1);
EXPECT_DEATH(RenderBuffer(&block_buffer, &spectrum_buffer, nullptr), "");
}
// Verifies the check for non-null spectrum buffer.
TEST(RenderBuffer, NullExternalSpectrumBuffer) {
FftBuffer fft_buffer(10);
MatrixBuffer block_buffer(10, 3, 1, kBlockSize);
BlockBuffer block_buffer(10, 3, 1, kBlockSize);
EXPECT_DEATH(RenderBuffer(&block_buffer, nullptr, &fft_buffer), "");
}
// Verifies the check for non-null block buffer.
TEST(RenderBuffer, NullExternalBlockBuffer) {
FftBuffer fft_buffer(10);
VectorBuffer spectrum_buffer(10, 1, kFftLengthBy2Plus1);
SpectrumBuffer spectrum_buffer(10, 1, kFftLengthBy2Plus1);
EXPECT_DEATH(RenderBuffer(nullptr, &spectrum_buffer, &fft_buffer), "");
}

View File

@ -22,13 +22,13 @@
#include "api/audio/echo_canceller3_config.h"
#include "modules/audio_processing/aec3/aec3_common.h"
#include "modules/audio_processing/aec3/aec3_fft.h"
#include "modules/audio_processing/aec3/block_buffer.h"
#include "modules/audio_processing/aec3/decimator.h"
#include "modules/audio_processing/aec3/downsampled_render_buffer.h"
#include "modules/audio_processing/aec3/fft_buffer.h"
#include "modules/audio_processing/aec3/fft_data.h"
#include "modules/audio_processing/aec3/matrix_buffer.h"
#include "modules/audio_processing/aec3/render_buffer.h"
#include "modules/audio_processing/aec3/vector_buffer.h"
#include "modules/audio_processing/aec3/spectrum_buffer.h"
#include "modules/audio_processing/logging/apm_data_dumper.h"
#include "rtc_base/atomic_ops.h"
#include "rtc_base/checks.h"
@ -72,8 +72,8 @@ class RenderDelayBufferImpl final : public RenderDelayBuffer {
const EchoCanceller3Config config_;
size_t down_sampling_factor_;
const int sub_block_size_;
MatrixBuffer blocks_;
VectorBuffer spectra_;
BlockBuffer blocks_;
SpectrumBuffer spectra_;
FftBuffer ffts_;
absl::optional<size_t> delay_;
RenderBuffer echo_remover_buffer_;

View File

@ -27,7 +27,7 @@ void RenderReverbModel::Reset() {
render_reverb_.Reset();
}
void RenderReverbModel::Apply(const VectorBuffer& spectrum_buffer,
void RenderReverbModel::Apply(const SpectrumBuffer& spectrum_buffer,
int delay_blocks,
float reverb_decay,
rtc::ArrayView<float> reverb_power_spectrum) {

View File

@ -13,7 +13,7 @@
#include "api/array_view.h"
#include "modules/audio_processing/aec3/reverb_model.h"
#include "modules/audio_processing/aec3/vector_buffer.h"
#include "modules/audio_processing/aec3/spectrum_buffer.h"
namespace webrtc {
@ -29,7 +29,7 @@ class RenderReverbModel {
// Applies the reverberation model over the render spectrum. It also returns
// the reverberation render power spectrum in the array reverb_power_spectrum.
void Apply(const VectorBuffer& spectrum_buffer,
void Apply(const SpectrumBuffer& spectrum_buffer,
int delay_blocks,
float reverb_decay,
rtc::ArrayView<float> reverb_power_spectrum);

View File

@ -25,7 +25,7 @@ namespace {
// Computes the indexes that will be used for computing spectral power over
// the blocks surrounding the delay.
void GetRenderIndexesToAnalyze(
const VectorBuffer& spectrum_buffer,
const SpectrumBuffer& spectrum_buffer,
const EchoCanceller3Config::EchoModel& echo_model,
int filter_delay_blocks,
int* idx_start,
@ -160,7 +160,7 @@ void ResidualEchoEstimator::NonLinearEstimate(
}
void ResidualEchoEstimator::EchoGeneratingPower(
const VectorBuffer& spectrum_buffer,
const SpectrumBuffer& spectrum_buffer,
const EchoCanceller3Config::EchoModel& echo_model,
int filter_delay_blocks,
bool apply_noise_gating,

View File

@ -20,7 +20,7 @@
#include "modules/audio_processing/aec3/aec_state.h"
#include "modules/audio_processing/aec3/render_buffer.h"
#include "modules/audio_processing/aec3/reverb_model.h"
#include "modules/audio_processing/aec3/vector_buffer.h"
#include "modules/audio_processing/aec3/spectrum_buffer.h"
#include "rtc_base/checks.h"
#include "rtc_base/constructor_magic.h"
@ -61,7 +61,7 @@ class ResidualEchoEstimator {
// Estimates the echo generating signal power as gated maximal power over a
// time window.
void EchoGeneratingPower(const VectorBuffer& spectrum_buffer,
void EchoGeneratingPower(const SpectrumBuffer& spectrum_buffer,
const EchoCanceller3Config::EchoModel& echo_model,
int filter_delay_blocks,
bool apply_noise_gating,

View File

@ -14,7 +14,7 @@
#include <functional>
#include <numeric>
#include "modules/audio_processing/aec3/vector_buffer.h"
#include "modules/audio_processing/aec3/spectrum_buffer.h"
#include "rtc_base/numerics/safe_minmax.h"
namespace webrtc {
@ -314,7 +314,7 @@ void SignalDependentErleEstimator::ComputeEchoEstimatePerFilterSection(
const RenderBuffer& render_buffer,
const std::vector<std::array<float, kFftLengthBy2Plus1>>&
filter_frequency_response) {
const VectorBuffer& spectrum_render_buffer =
const SpectrumBuffer& spectrum_render_buffer =
render_buffer.GetSpectrumBuffer();
RTC_DCHECK_EQ(S2_section_accum_.size() + 1,

View File

@ -95,7 +95,7 @@ void TestInputs::Update() {
}
void TestInputs::UpdateCurrentPowerSpectra() {
const VectorBuffer& spectrum_render_buffer =
const SpectrumBuffer& spectrum_render_buffer =
render_buffer_->GetSpectrumBuffer();
size_t idx = render_buffer_->Position();
size_t prev_idx = spectrum_render_buffer.OffsetIndex(idx, 1);

View File

@ -8,15 +8,15 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/audio_processing/aec3/vector_buffer.h"
#include "modules/audio_processing/aec3/spectrum_buffer.h"
#include <algorithm>
namespace webrtc {
VectorBuffer::VectorBuffer(size_t size,
size_t num_channels,
size_t spectrum_length)
SpectrumBuffer::SpectrumBuffer(size_t size,
size_t num_channels,
size_t spectrum_length)
: size(static_cast<int>(size)),
buffer(size,
std::vector<std::vector<float>>(
@ -29,6 +29,6 @@ VectorBuffer::VectorBuffer(size_t size,
}
}
VectorBuffer::~VectorBuffer() = default;
SpectrumBuffer::~SpectrumBuffer() = default;
} // namespace webrtc

View File

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef MODULES_AUDIO_PROCESSING_AEC3_VECTOR_BUFFER_H_
#define MODULES_AUDIO_PROCESSING_AEC3_VECTOR_BUFFER_H_
#ifndef MODULES_AUDIO_PROCESSING_AEC3_SPECTRUM_BUFFER_H_
#define MODULES_AUDIO_PROCESSING_AEC3_SPECTRUM_BUFFER_H_
#include <stddef.h>
@ -22,9 +22,9 @@ namespace webrtc {
// Struct for bundling a circular buffer of one dimensional vector objects
// together with the read and write indices.
// TODO(peah): Change name of this class to be more specific to what it does.
struct VectorBuffer {
VectorBuffer(size_t size, size_t num_channels, size_t spectrum_length);
~VectorBuffer();
struct SpectrumBuffer {
SpectrumBuffer(size_t size, size_t num_channels, size_t spectrum_length);
~SpectrumBuffer();
int IncIndex(int index) const {
RTC_DCHECK_EQ(buffer.size(), static_cast<size_t>(size));
@ -58,4 +58,4 @@ struct VectorBuffer {
} // namespace webrtc
#endif // MODULES_AUDIO_PROCESSING_AEC3_VECTOR_BUFFER_H_
#endif // MODULES_AUDIO_PROCESSING_AEC3_SPECTRUM_BUFFER_H_

View File

@ -16,7 +16,7 @@
#include "api/array_view.h"
#include "modules/audio_processing/aec3/aec3_common.h"
#include "modules/audio_processing/aec3/vector_buffer.h"
#include "modules/audio_processing/aec3/spectrum_buffer.h"
#include "modules/audio_processing/logging/apm_data_dumper.h"
#include "rtc_base/atomic_ops.h"
@ -53,7 +53,7 @@ void StationarityEstimator::UpdateNoiseEstimator(
}
void StationarityEstimator::UpdateStationarityFlags(
const VectorBuffer& spectrum_buffer,
const SpectrumBuffer& spectrum_buffer,
rtc::ArrayView<const float> render_reverb_contribution_spectrum,
int idx_current,
int num_lookahead) {
@ -98,7 +98,7 @@ bool StationarityEstimator::IsBlockStationary() const {
}
bool StationarityEstimator::EstimateBandStationarity(
const VectorBuffer& spectrum_buffer,
const SpectrumBuffer& spectrum_buffer,
rtc::ArrayView<const float> reverb,
const std::array<int, kWindowLength>& indexes,
size_t band) const {

View File

@ -24,7 +24,7 @@
namespace webrtc {
class ApmDataDumper;
struct VectorBuffer;
struct SpectrumBuffer;
class StationarityEstimator {
public:
@ -40,7 +40,7 @@ class StationarityEstimator {
// Update the flag indicating whether this current frame is stationary. For
// getting a more robust estimation, it looks at future and/or past frames.
void UpdateStationarityFlags(
const VectorBuffer& spectrum_buffer,
const SpectrumBuffer& spectrum_buffer,
rtc::ArrayView<const float> render_reverb_contribution_spectrum,
int idx_current,
int num_lookahead);
@ -60,7 +60,7 @@ class StationarityEstimator {
// Get an estimation of the stationarity for the current band by looking
// at the past/present/future available data.
bool EstimateBandStationarity(const VectorBuffer& spectrum_buffer,
bool EstimateBandStationarity(const SpectrumBuffer& spectrum_buffer,
rtc::ArrayView<const float> reverb,
const std::array<int, kWindowLength>& indexes,
size_t band) const;