Miscellaneous changes split from https://codereview.webrtc.org/1230503003 .
These are mostly trivial changes and are separated out just to reduce the diff on that change to the minimum possible. Note explanatory comments on patch set 1. BUG=none TEST=none Review URL: https://codereview.webrtc.org/1235643003 Cr-Commit-Position: refs/heads/master@{#9617}
This commit is contained in:
@ -120,7 +120,7 @@ complex<float> ConjugateDotProduct(const ComplexMatrix<float>& lhs,
|
||||
|
||||
// Works for positive numbers only.
|
||||
int Round(float x) {
|
||||
return std::floor(x + 0.5f);
|
||||
return static_cast<int>(std::floor(x + 0.5f));
|
||||
}
|
||||
|
||||
// Calculates the sum of absolute values of a complex matrix.
|
||||
@ -464,9 +464,9 @@ void NonlinearBeamformer::ApplyMaskFrequencySmoothing() {
|
||||
final_mask_[i] = kMaskFrequencySmoothAlpha * final_mask_[i] +
|
||||
(1 - kMaskFrequencySmoothAlpha) * final_mask_[i - 1];
|
||||
}
|
||||
for (int i = high_mean_end_bin_; i >= 0; --i) {
|
||||
final_mask_[i] = kMaskFrequencySmoothAlpha * final_mask_[i] +
|
||||
(1 - kMaskFrequencySmoothAlpha) * final_mask_[i + 1];
|
||||
for (int i = high_mean_end_bin_ + 1; i > 0; --i) {
|
||||
final_mask_[i - 1] = kMaskFrequencySmoothAlpha * final_mask_[i - 1] +
|
||||
(1 - kMaskFrequencySmoothAlpha) * final_mask_[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -31,7 +31,6 @@ namespace webrtc {
|
||||
|
||||
namespace {
|
||||
|
||||
const int kErbResolution = 2;
|
||||
const int kWindowSizeMs = 2;
|
||||
const int kChunkSizeMs = 10; // Size provided by APM.
|
||||
const float kClipFreq = 200.0f;
|
||||
@ -132,7 +131,7 @@ IntelligibilityEnhancer::IntelligibilityEnhancer(int erb_resolution,
|
||||
float freqs_khz = kClipFreq / 1000.0f;
|
||||
int erb_index = static_cast<int>(ceilf(
|
||||
11.17f * logf((freqs_khz + 0.312f) / (freqs_khz + 14.6575f)) + 43.0f));
|
||||
start_freq_ = max(1, erb_index * kErbResolution);
|
||||
start_freq_ = std::max(1, erb_index * erb_resolution);
|
||||
|
||||
WindowGenerator::KaiserBesselDerived(kKbdAlpha, window_size_,
|
||||
kbd_window_.get());
|
||||
|
||||
@ -73,11 +73,11 @@ class IntelligibilityEnhancer {
|
||||
|
||||
// All in frequency domain, receives input |in_block|, applies
|
||||
// intelligibility enhancement, and writes result to |out_block|.
|
||||
virtual void ProcessAudioBlock(const std::complex<float>* const* in_block,
|
||||
int in_channels,
|
||||
int frames,
|
||||
int out_channels,
|
||||
std::complex<float>* const* out_block);
|
||||
void ProcessAudioBlock(const std::complex<float>* const* in_block,
|
||||
int in_channels,
|
||||
int frames,
|
||||
int out_channels,
|
||||
std::complex<float>* const* out_block) override;
|
||||
|
||||
private:
|
||||
IntelligibilityEnhancer* parent_;
|
||||
|
||||
@ -137,9 +137,9 @@ void VarianceArray::InfiniteStep(const complex<float>* data, bool skip_fudge) {
|
||||
.real();
|
||||
variance_[i] =
|
||||
conj_sum_[i] / (count_ - 1); // + fudge[fudge_index].real();
|
||||
if (skip_fudge && false) {
|
||||
// variance_[i] -= fudge[fudge_index].real();
|
||||
}
|
||||
// if (skip_fudge) {
|
||||
// variance_[i] -= fudge[fudge_index].real();
|
||||
// }
|
||||
}
|
||||
array_mean_ += (variance_[i] - array_mean_) / (i + 1);
|
||||
}
|
||||
|
||||
@ -33,9 +33,11 @@
|
||||
using std::complex;
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
||||
using webrtc::RealFourier;
|
||||
using webrtc::IntelligibilityEnhancer;
|
||||
bool ValidateClearWindow(const char* flagname, int32_t value) {
|
||||
return value > 0;
|
||||
}
|
||||
|
||||
DEFINE_int32(clear_type,
|
||||
webrtc::intelligibility::VarianceArray::kStepInfinite,
|
||||
@ -44,6 +46,8 @@ DEFINE_double(clear_alpha, 0.9, "Variance decay factor for clear data.");
|
||||
DEFINE_int32(clear_window,
|
||||
475,
|
||||
"Window size for windowed variance for clear data.");
|
||||
const bool clear_window_dummy =
|
||||
google::RegisterFlagValidator(&FLAGS_clear_window, &ValidateClearWindow);
|
||||
DEFINE_int32(sample_rate,
|
||||
16000,
|
||||
"Audio sample rate used in the input and output files.");
|
||||
@ -137,6 +141,7 @@ void void_main(int argc, char* argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace webrtc
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
Reference in New Issue
Block a user