Optional: Use nullopt and implicit construction in /modules/audio_processing
Changes places where we explicitly construct an Optional to instead use nullopt or the requisite value type only. This CL was uploaded by git cl split. R=henrik.lundin@webrtc.org Bug: None Change-Id: I733a83f702fe11884d229a1713cfac952727bde8 Reviewed-on: https://webrtc-review.googlesource.com/23601 Commit-Queue: Oskar Sundbom <ossu@webrtc.org> Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20786}
This commit is contained in:

committed by
Commit Bot

parent
28dfeb7f24
commit
aa8b67da9d
@ -365,9 +365,8 @@ TEST(AdaptiveFirFilter, FilterAndAdapt) {
|
||||
filter.Adapt(render_buffer, G);
|
||||
aec_state.HandleEchoPathChange(EchoPathVariability(false, false));
|
||||
aec_state.Update(filter.FilterFrequencyResponse(),
|
||||
filter.FilterImpulseResponse(), true,
|
||||
rtc::Optional<size_t>(), render_buffer, E2_main, Y2,
|
||||
x[0], s, false);
|
||||
filter.FilterImpulseResponse(), true, rtc::nullopt,
|
||||
render_buffer, E2_main, Y2, x[0], s, false);
|
||||
}
|
||||
// Verify that the filter is able to perform well.
|
||||
EXPECT_LT(1000 * std::inner_product(e.begin(), e.end(), e.begin(), 0.f),
|
||||
|
@ -113,12 +113,11 @@ void AecState::Update(const std::vector<std::array<float, kFftLengthBy2Plus1>>&
|
||||
force_zero_gain_ = (++force_zero_gain_counter_) < kNumBlocksPerSecond / 5;
|
||||
|
||||
// Estimate delays.
|
||||
filter_delay_ = rtc::Optional<size_t>(
|
||||
EstimateFilterDelay(adaptive_filter_frequency_response));
|
||||
filter_delay_ = EstimateFilterDelay(adaptive_filter_frequency_response);
|
||||
external_delay_ =
|
||||
external_delay_samples
|
||||
? rtc::Optional<size_t>(*external_delay_samples / kBlockSize)
|
||||
: rtc::Optional<size_t>();
|
||||
: rtc::nullopt;
|
||||
|
||||
// Update the ERL and ERLE measures.
|
||||
if (converged_filter && capture_block_counter_ >= 2 * kNumBlocksPerSecond) {
|
||||
|
@ -44,51 +44,44 @@ TEST(AecState, NormalUsage) {
|
||||
// Verify that linear AEC usability is false when the filter is diverged and
|
||||
// there is no external delay reported.
|
||||
state.Update(diverged_filter_frequency_response, impulse_response, true,
|
||||
rtc::Optional<size_t>(), render_buffer, E2_main, Y2, x[0], s,
|
||||
false);
|
||||
rtc::nullopt, render_buffer, E2_main, Y2, x[0], s, false);
|
||||
EXPECT_FALSE(state.UsableLinearEstimate());
|
||||
|
||||
// Verify that linear AEC usability is true when the filter is converged
|
||||
std::fill(x[0].begin(), x[0].end(), 101.f);
|
||||
for (int k = 0; k < 3000; ++k) {
|
||||
state.Update(converged_filter_frequency_response, impulse_response, true,
|
||||
rtc::Optional<size_t>(2), render_buffer, E2_main, Y2, x[0], s,
|
||||
false);
|
||||
state.Update(converged_filter_frequency_response, impulse_response, true, 2,
|
||||
render_buffer, E2_main, Y2, x[0], s, false);
|
||||
}
|
||||
EXPECT_TRUE(state.UsableLinearEstimate());
|
||||
|
||||
// Verify that linear AEC usability becomes false after an echo path change is
|
||||
// reported
|
||||
state.HandleEchoPathChange(EchoPathVariability(true, false));
|
||||
state.Update(converged_filter_frequency_response, impulse_response, true,
|
||||
rtc::Optional<size_t>(2), render_buffer, E2_main, Y2, x[0], s,
|
||||
false);
|
||||
state.Update(converged_filter_frequency_response, impulse_response, true, 2,
|
||||
render_buffer, E2_main, Y2, x[0], s, false);
|
||||
EXPECT_FALSE(state.UsableLinearEstimate());
|
||||
|
||||
// Verify that the active render detection works as intended.
|
||||
std::fill(x[0].begin(), x[0].end(), 101.f);
|
||||
state.HandleEchoPathChange(EchoPathVariability(true, true));
|
||||
state.Update(converged_filter_frequency_response, impulse_response, true,
|
||||
rtc::Optional<size_t>(2), render_buffer, E2_main, Y2, x[0], s,
|
||||
false);
|
||||
state.Update(converged_filter_frequency_response, impulse_response, true, 2,
|
||||
render_buffer, E2_main, Y2, x[0], s, false);
|
||||
EXPECT_FALSE(state.ActiveRender());
|
||||
|
||||
for (int k = 0; k < 1000; ++k) {
|
||||
state.Update(converged_filter_frequency_response, impulse_response, true,
|
||||
rtc::Optional<size_t>(2), render_buffer, E2_main, Y2, x[0], s,
|
||||
false);
|
||||
state.Update(converged_filter_frequency_response, impulse_response, true, 2,
|
||||
render_buffer, E2_main, Y2, x[0], s, false);
|
||||
}
|
||||
EXPECT_TRUE(state.ActiveRender());
|
||||
|
||||
// Verify that echo leakage is properly reported.
|
||||
state.Update(converged_filter_frequency_response, impulse_response, true,
|
||||
rtc::Optional<size_t>(2), render_buffer, E2_main, Y2, x[0], s,
|
||||
false);
|
||||
state.Update(converged_filter_frequency_response, impulse_response, true, 2,
|
||||
render_buffer, E2_main, Y2, x[0], s, false);
|
||||
EXPECT_FALSE(state.EchoLeakageDetected());
|
||||
|
||||
state.Update(converged_filter_frequency_response, impulse_response, true,
|
||||
rtc::Optional<size_t>(2), render_buffer, E2_main, Y2, x[0], s,
|
||||
true);
|
||||
state.Update(converged_filter_frequency_response, impulse_response, true, 2,
|
||||
render_buffer, E2_main, Y2, x[0], s, true);
|
||||
EXPECT_TRUE(state.EchoLeakageDetected());
|
||||
|
||||
// Verify that the ERL is properly estimated
|
||||
@ -103,9 +96,8 @@ TEST(AecState, NormalUsage) {
|
||||
|
||||
Y2.fill(10.f * 10000.f * 10000.f);
|
||||
for (size_t k = 0; k < 1000; ++k) {
|
||||
state.Update(converged_filter_frequency_response, impulse_response, true,
|
||||
rtc::Optional<size_t>(2), render_buffer, E2_main, Y2, x[0], s,
|
||||
false);
|
||||
state.Update(converged_filter_frequency_response, impulse_response, true, 2,
|
||||
render_buffer, E2_main, Y2, x[0], s, false);
|
||||
}
|
||||
|
||||
ASSERT_TRUE(state.UsableLinearEstimate());
|
||||
@ -120,9 +112,8 @@ TEST(AecState, NormalUsage) {
|
||||
E2_main.fill(1.f * 10000.f * 10000.f);
|
||||
Y2.fill(10.f * E2_main[0]);
|
||||
for (size_t k = 0; k < 1000; ++k) {
|
||||
state.Update(converged_filter_frequency_response, impulse_response, true,
|
||||
rtc::Optional<size_t>(2), render_buffer, E2_main, Y2, x[0], s,
|
||||
false);
|
||||
state.Update(converged_filter_frequency_response, impulse_response, true, 2,
|
||||
render_buffer, E2_main, Y2, x[0], s, false);
|
||||
}
|
||||
ASSERT_TRUE(state.UsableLinearEstimate());
|
||||
{
|
||||
@ -141,9 +132,8 @@ TEST(AecState, NormalUsage) {
|
||||
E2_main.fill(1.f * 10000.f * 10000.f);
|
||||
Y2.fill(5.f * E2_main[0]);
|
||||
for (size_t k = 0; k < 1000; ++k) {
|
||||
state.Update(converged_filter_frequency_response, impulse_response, true,
|
||||
rtc::Optional<size_t>(2), render_buffer, E2_main, Y2, x[0], s,
|
||||
false);
|
||||
state.Update(converged_filter_frequency_response, impulse_response, true, 2,
|
||||
render_buffer, E2_main, Y2, x[0], s, false);
|
||||
}
|
||||
|
||||
ASSERT_TRUE(state.UsableLinearEstimate());
|
||||
@ -189,9 +179,8 @@ TEST(AecState, ConvergedFilterDelay) {
|
||||
frequency_response[k].fill(100.f);
|
||||
frequency_response[k][0] = 0.f;
|
||||
state.HandleEchoPathChange(echo_path_variability);
|
||||
state.Update(frequency_response, impulse_response, true,
|
||||
rtc::Optional<size_t>(), render_buffer, E2_main, Y2, x, s,
|
||||
false);
|
||||
state.Update(frequency_response, impulse_response, true, rtc::nullopt,
|
||||
render_buffer, E2_main, Y2, x, s, false);
|
||||
EXPECT_TRUE(k == (kFilterLength - 1) || state.FilterDelay());
|
||||
if (k != (kFilterLength - 1)) {
|
||||
EXPECT_EQ(k, state.FilterDelay());
|
||||
@ -225,9 +214,8 @@ TEST(AecState, ExternalDelay) {
|
||||
|
||||
for (size_t k = 0; k < frequency_response.size() - 1; ++k) {
|
||||
state.HandleEchoPathChange(EchoPathVariability(false, false));
|
||||
state.Update(frequency_response, impulse_response, true,
|
||||
rtc::Optional<size_t>(k * kBlockSize + 5), render_buffer,
|
||||
E2_main, Y2, x, s, false);
|
||||
state.Update(frequency_response, impulse_response, true, k * kBlockSize + 5,
|
||||
render_buffer, E2_main, Y2, x, s, false);
|
||||
EXPECT_TRUE(state.ExternalDelay());
|
||||
EXPECT_EQ(k, state.ExternalDelay());
|
||||
}
|
||||
@ -235,9 +223,8 @@ TEST(AecState, ExternalDelay) {
|
||||
// Verify that the externally reported delay is properly unset when it is no
|
||||
// longer present.
|
||||
state.HandleEchoPathChange(EchoPathVariability(false, false));
|
||||
state.Update(frequency_response, impulse_response, true,
|
||||
rtc::Optional<size_t>(), render_buffer, E2_main, Y2, x, s,
|
||||
false);
|
||||
state.Update(frequency_response, impulse_response, true, rtc::nullopt,
|
||||
render_buffer, E2_main, Y2, x, s, false);
|
||||
EXPECT_FALSE(state.ExternalDelay());
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ rtc::Optional<size_t> EchoPathDelayEstimator::EstimateDelay(
|
||||
return aggregated_matched_filter_lag
|
||||
? rtc::Optional<size_t>(*aggregated_matched_filter_lag *
|
||||
down_sampling_factor_)
|
||||
: rtc::Optional<size_t>();
|
||||
: rtc::nullopt;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -64,7 +64,7 @@ TEST(EchoRemover, BasicApiCalls) {
|
||||
k % 5 == 0 ? true : false);
|
||||
rtc::Optional<size_t> echo_path_delay_samples =
|
||||
(k % 6 == 0 ? rtc::Optional<size_t>(k * 10)
|
||||
: rtc::Optional<size_t>());
|
||||
: rtc::nullopt);
|
||||
render_buffer->Insert(render);
|
||||
render_buffer->UpdateBuffers();
|
||||
remover->ProcessCapture(echo_path_delay_samples, echo_path_variability,
|
||||
@ -198,8 +198,7 @@ TEST(EchoRemover, BasicEchoRemoval) {
|
||||
render_buffer->Insert(x);
|
||||
render_buffer->UpdateBuffers();
|
||||
|
||||
remover->ProcessCapture(rtc::Optional<size_t>(delay_samples),
|
||||
echo_path_variability, false,
|
||||
remover->ProcessCapture(delay_samples, echo_path_variability, false,
|
||||
render_buffer->GetRenderBuffer(), &y);
|
||||
|
||||
if (k > kNumBlocksToProcess / 2) {
|
||||
|
@ -135,9 +135,8 @@ void RunFilterUpdateTest(int num_blocks_to_process,
|
||||
// Update the delay.
|
||||
aec_state.HandleEchoPathChange(EchoPathVariability(false, false));
|
||||
aec_state.Update(main_filter.FilterFrequencyResponse(),
|
||||
main_filter.FilterImpulseResponse(), true,
|
||||
rtc::Optional<size_t>(), render_buffer, E2_main, Y2, x[0],
|
||||
s, false);
|
||||
main_filter.FilterImpulseResponse(), true, rtc::nullopt,
|
||||
render_buffer, E2_main, Y2, x[0], s, false);
|
||||
}
|
||||
|
||||
std::copy(e_main.begin(), e_main.end(), e_last_block->begin());
|
||||
|
@ -67,10 +67,10 @@ rtc::Optional<size_t> MatchedFilterLagAggregator::Aggregate(
|
||||
std::max_element(histogram_.begin(), histogram_.end()));
|
||||
|
||||
if (histogram_[candidate] > 25) {
|
||||
return rtc::Optional<size_t>(candidate);
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return rtc::Optional<size_t>();
|
||||
return rtc::nullopt;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -183,8 +183,7 @@ TEST(MatchedFilter, LagEstimation) {
|
||||
if ((alignment_shift_sub_blocks + 3 * kWindowSizeSubBlocks / 4) *
|
||||
sub_block_size >
|
||||
delay_samples) {
|
||||
expected_most_accurate_lag_estimate =
|
||||
rtc::Optional<size_t>(k > 0 ? k - 1 : 0);
|
||||
expected_most_accurate_lag_estimate = k > 0 ? k - 1 : 0;
|
||||
break;
|
||||
}
|
||||
alignment_shift_sub_blocks += kAlignmentShiftSubBlocks;
|
||||
|
@ -96,7 +96,7 @@ void RenderDelayControllerImpl::Reset() {
|
||||
blocks_since_last_delay_estimate_ = 300000;
|
||||
echo_path_delay_samples_ = delay_ * kBlockSize;
|
||||
align_call_counter_ = 0;
|
||||
headroom_samples_ = rtc::Optional<size_t>();
|
||||
headroom_samples_ = rtc::nullopt;
|
||||
std::fill(capture_delay_buffer_.begin(), capture_delay_buffer_.end(), 0.f);
|
||||
delay_estimator_.Reset();
|
||||
}
|
||||
@ -150,15 +150,15 @@ size_t RenderDelayControllerImpl::GetDelay(
|
||||
if (echo_path_delay_samples_corrected >= 0) {
|
||||
const int headroom = echo_path_delay_samples_ - delay_ * kBlockSize;
|
||||
RTC_DCHECK_LE(0, headroom);
|
||||
headroom_samples_ = rtc::Optional<size_t>(headroom);
|
||||
headroom_samples_ = headroom;
|
||||
} else {
|
||||
headroom_samples_ = rtc::Optional<size_t>();
|
||||
headroom_samples_ = rtc::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
metrics_.Update(rtc::Optional<size_t>(echo_path_delay_samples_), delay_);
|
||||
metrics_.Update(echo_path_delay_samples_, delay_);
|
||||
} else {
|
||||
metrics_.Update(rtc::Optional<size_t>(), delay_);
|
||||
metrics_.Update(rtc::nullopt, delay_);
|
||||
}
|
||||
|
||||
data_dumper_->DumpRaw("aec3_render_delay_controller_delay", 1,
|
||||
|
@ -22,10 +22,10 @@ TEST(RenderDelayControllerMetrics, NormalUsage) {
|
||||
|
||||
for (int j = 0; j < 3; ++j) {
|
||||
for (int k = 0; k < kMetricsReportingIntervalBlocks - 1; ++k) {
|
||||
metrics.Update(rtc::Optional<size_t>(), 0);
|
||||
metrics.Update(rtc::nullopt, 0);
|
||||
EXPECT_FALSE(metrics.MetricsReported());
|
||||
}
|
||||
metrics.Update(rtc::Optional<size_t>(), 0);
|
||||
metrics.Update(rtc::nullopt, 0);
|
||||
EXPECT_TRUE(metrics.MetricsReported());
|
||||
}
|
||||
}
|
||||
|
@ -77,11 +77,11 @@ void IdentifyStrongNarrowBandComponent(const RenderBuffer& render_buffer,
|
||||
// Detect whether the spectal peak has as strong narrowband nature.
|
||||
if (peak_bin > 6 && max_abs > 100 &&
|
||||
X2_latest[peak_bin] > 100 * non_peak_power) {
|
||||
*narrow_peak_band = rtc::Optional<int>(peak_bin);
|
||||
*narrow_peak_band = peak_bin;
|
||||
*narrow_peak_counter = 0;
|
||||
} else {
|
||||
if (*narrow_peak_band && ++(*narrow_peak_counter) > 7) {
|
||||
*narrow_peak_band = rtc::Optional<int>();
|
||||
*narrow_peak_band = rtc::nullopt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ TEST(RenderSignalAnalyzer, NoFalseDetectionOfNarrowBands) {
|
||||
RandomizeSampleVector(&random_generator, x[0]);
|
||||
fft.PaddedFft(x[0], x_old, &X);
|
||||
render_buffer.Insert(x);
|
||||
analyzer.Update(render_buffer, rtc::Optional<size_t>(0));
|
||||
analyzer.Update(render_buffer, 0);
|
||||
}
|
||||
|
||||
mask.fill(1.f);
|
||||
@ -99,7 +99,7 @@ TEST(RenderSignalAnalyzer, NarrowBandDetection) {
|
||||
&sample_counter, x[0]);
|
||||
render_buffer.Insert(x);
|
||||
analyzer.Update(render_buffer, known_delay ? rtc::Optional<size_t>(0)
|
||||
: rtc::Optional<size_t>());
|
||||
: rtc::nullopt);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -83,8 +83,8 @@ TEST(ResidualEchoEstimator, BasicTest) {
|
||||
render_buffer.Insert(x);
|
||||
|
||||
aec_state.HandleEchoPathChange(echo_path_variability);
|
||||
aec_state.Update(H2, h, true, rtc::Optional<size_t>(2), render_buffer,
|
||||
E2_main, Y2, x[0], s, false);
|
||||
aec_state.Update(H2, h, true, 2, render_buffer, E2_main, Y2, x[0], s,
|
||||
false);
|
||||
|
||||
estimator.Estimate(aec_state, render_buffer, S2_linear, Y2, &R2);
|
||||
}
|
||||
|
@ -68,8 +68,7 @@ void RunFilterUpdateTest(int num_blocks_to_process,
|
||||
RandomizeSampleVector(&random_generator, x[0]);
|
||||
delay_buffer.Delay(x[0], y);
|
||||
render_buffer.Insert(x);
|
||||
render_signal_analyzer.Update(
|
||||
render_buffer, rtc::Optional<size_t>(delay_samples / kBlockSize));
|
||||
render_signal_analyzer.Update(render_buffer, delay_samples / kBlockSize);
|
||||
|
||||
shadow_filter.Filter(render_buffer, &S);
|
||||
fft.Ifft(S, &s);
|
||||
|
@ -69,8 +69,7 @@ float RunSubtractorTest(int num_blocks_to_process,
|
||||
aec_state.HandleEchoPathChange(EchoPathVariability(false, false));
|
||||
aec_state.Update(subtractor.FilterFrequencyResponse(),
|
||||
subtractor.FilterImpulseResponse(),
|
||||
subtractor.ConvergedFilter(),
|
||||
rtc::Optional<size_t>(delay_samples / kBlockSize),
|
||||
subtractor.ConvergedFilter(), delay_samples / kBlockSize,
|
||||
render_buffer, E2_main, Y2, x[0], output.s_main, false);
|
||||
}
|
||||
|
||||
|
@ -70,10 +70,9 @@ TEST(SuppressionGain, BasicGainComputation) {
|
||||
R2.fill(10000000000000.f);
|
||||
N2.fill(0.f);
|
||||
s.fill(10.f);
|
||||
aec_state.Update(subtractor.FilterFrequencyResponse(),
|
||||
subtractor.FilterImpulseResponse(),
|
||||
subtractor.ConvergedFilter(), rtc::Optional<size_t>(10),
|
||||
render_buffer, E2, Y2, x[0], s, false);
|
||||
aec_state.Update(
|
||||
subtractor.FilterFrequencyResponse(), subtractor.FilterImpulseResponse(),
|
||||
subtractor.ConvergedFilter(), 10, render_buffer, E2, Y2, x[0], s, false);
|
||||
suppression_gain.GetGain(E2, R2, N2, analyzer, aec_state, x, &high_bands_gain,
|
||||
&g);
|
||||
std::for_each(g.begin(), g.end(), [](float a) { EXPECT_FLOAT_EQ(0.f, a); });
|
||||
@ -88,15 +87,15 @@ TEST(SuppressionGain, BasicGainComputation) {
|
||||
for (int k = 0; k <= kNumBlocksPerSecond / 5 + 1; ++k) {
|
||||
aec_state.Update(subtractor.FilterFrequencyResponse(),
|
||||
subtractor.FilterImpulseResponse(),
|
||||
subtractor.ConvergedFilter(), rtc::Optional<size_t>(10),
|
||||
render_buffer, E2, Y2, x[0], s, false);
|
||||
subtractor.ConvergedFilter(), 10, render_buffer, E2, Y2,
|
||||
x[0], s, false);
|
||||
}
|
||||
|
||||
for (int k = 0; k < 100; ++k) {
|
||||
aec_state.Update(subtractor.FilterFrequencyResponse(),
|
||||
subtractor.FilterImpulseResponse(),
|
||||
subtractor.ConvergedFilter(), rtc::Optional<size_t>(10),
|
||||
render_buffer, E2, Y2, x[0], s, false);
|
||||
subtractor.ConvergedFilter(), 10, render_buffer, E2, Y2,
|
||||
x[0], s, false);
|
||||
suppression_gain.GetGain(E2, R2, N2, analyzer, aec_state, x,
|
||||
&high_bands_gain, &g);
|
||||
}
|
||||
@ -111,8 +110,8 @@ TEST(SuppressionGain, BasicGainComputation) {
|
||||
for (int k = 0; k < 100; ++k) {
|
||||
aec_state.Update(subtractor.FilterFrequencyResponse(),
|
||||
subtractor.FilterImpulseResponse(),
|
||||
subtractor.ConvergedFilter(), rtc::Optional<size_t>(10),
|
||||
render_buffer, E2, Y2, x[0], s, false);
|
||||
subtractor.ConvergedFilter(), 10, render_buffer, E2, Y2,
|
||||
x[0], s, false);
|
||||
suppression_gain.GetGain(E2, R2, N2, analyzer, aec_state, x,
|
||||
&high_bands_gain, &g);
|
||||
}
|
||||
|
@ -65,10 +65,10 @@ rtc::Optional<Point> GetDirectionIfLinear(
|
||||
const Point pair_direction =
|
||||
PairDirection(array_geometry[i - 1], array_geometry[i]);
|
||||
if (!AreParallel(first_pair_direction, pair_direction)) {
|
||||
return rtc::Optional<Point>();
|
||||
return rtc::nullopt;
|
||||
}
|
||||
}
|
||||
return rtc::Optional<Point>(first_pair_direction);
|
||||
return first_pair_direction;
|
||||
}
|
||||
|
||||
rtc::Optional<Point> GetNormalIfPlanar(
|
||||
@ -86,30 +86,30 @@ rtc::Optional<Point> GetNormalIfPlanar(
|
||||
}
|
||||
}
|
||||
if (is_linear) {
|
||||
return rtc::Optional<Point>();
|
||||
return rtc::nullopt;
|
||||
}
|
||||
const Point normal_direction =
|
||||
CrossProduct(first_pair_direction, pair_direction);
|
||||
for (; i < array_geometry.size(); ++i) {
|
||||
pair_direction = PairDirection(array_geometry[i - 1], array_geometry[i]);
|
||||
if (!ArePerpendicular(normal_direction, pair_direction)) {
|
||||
return rtc::Optional<Point>();
|
||||
return rtc::nullopt;
|
||||
}
|
||||
}
|
||||
return rtc::Optional<Point>(normal_direction);
|
||||
return normal_direction;
|
||||
}
|
||||
|
||||
rtc::Optional<Point> GetArrayNormalIfExists(
|
||||
const std::vector<Point>& array_geometry) {
|
||||
const rtc::Optional<Point> direction = GetDirectionIfLinear(array_geometry);
|
||||
if (direction) {
|
||||
return rtc::Optional<Point>(Point(direction->y(), -direction->x(), 0.f));
|
||||
return Point(direction->y(), -direction->x(), 0.f);
|
||||
}
|
||||
const rtc::Optional<Point> normal = GetNormalIfPlanar(array_geometry);
|
||||
if (normal && normal->z() < kMaxDotProduct) {
|
||||
return normal;
|
||||
}
|
||||
return rtc::Optional<Point>();
|
||||
return rtc::nullopt;
|
||||
}
|
||||
|
||||
Point AzimuthToPoint(float azimuth) {
|
||||
|
@ -30,14 +30,14 @@ void CircularBuffer::Push(float value) {
|
||||
|
||||
rtc::Optional<float> CircularBuffer::Pop() {
|
||||
if (nr_elements_in_buffer_ == 0) {
|
||||
return rtc::Optional<float>();
|
||||
return rtc::nullopt;
|
||||
}
|
||||
const size_t index =
|
||||
(buffer_.size() + next_insertion_index_ - nr_elements_in_buffer_) %
|
||||
buffer_.size();
|
||||
RTC_DCHECK_LT(index, buffer_.size());
|
||||
--nr_elements_in_buffer_;
|
||||
return rtc::Optional<float>(buffer_[index]);
|
||||
return buffer_[index];
|
||||
}
|
||||
|
||||
void CircularBuffer::Clear() {
|
||||
|
@ -17,8 +17,8 @@ TEST(CircularBufferTests, LessThanMaxTest) {
|
||||
CircularBuffer test_buffer(3);
|
||||
test_buffer.Push(1.f);
|
||||
test_buffer.Push(2.f);
|
||||
EXPECT_EQ(rtc::Optional<float>(1.f), test_buffer.Pop());
|
||||
EXPECT_EQ(rtc::Optional<float>(2.f), test_buffer.Pop());
|
||||
EXPECT_EQ(1.f, test_buffer.Pop());
|
||||
EXPECT_EQ(2.f, test_buffer.Pop());
|
||||
}
|
||||
|
||||
TEST(CircularBufferTests, FillTest) {
|
||||
@ -26,9 +26,9 @@ TEST(CircularBufferTests, FillTest) {
|
||||
test_buffer.Push(1.f);
|
||||
test_buffer.Push(2.f);
|
||||
test_buffer.Push(3.f);
|
||||
EXPECT_EQ(rtc::Optional<float>(1.f), test_buffer.Pop());
|
||||
EXPECT_EQ(rtc::Optional<float>(2.f), test_buffer.Pop());
|
||||
EXPECT_EQ(rtc::Optional<float>(3.f), test_buffer.Pop());
|
||||
EXPECT_EQ(1.f, test_buffer.Pop());
|
||||
EXPECT_EQ(2.f, test_buffer.Pop());
|
||||
EXPECT_EQ(3.f, test_buffer.Pop());
|
||||
}
|
||||
|
||||
TEST(CircularBufferTests, OverflowTest) {
|
||||
@ -39,14 +39,14 @@ TEST(CircularBufferTests, OverflowTest) {
|
||||
test_buffer.Push(4.f);
|
||||
// Because the circular buffer has a size of 3, the first insert should have
|
||||
// been forgotten.
|
||||
EXPECT_EQ(rtc::Optional<float>(2.f), test_buffer.Pop());
|
||||
EXPECT_EQ(rtc::Optional<float>(3.f), test_buffer.Pop());
|
||||
EXPECT_EQ(rtc::Optional<float>(4.f), test_buffer.Pop());
|
||||
EXPECT_EQ(2.f, test_buffer.Pop());
|
||||
EXPECT_EQ(3.f, test_buffer.Pop());
|
||||
EXPECT_EQ(4.f, test_buffer.Pop());
|
||||
}
|
||||
|
||||
TEST(CircularBufferTests, ReadFromEmpty) {
|
||||
CircularBuffer test_buffer(3);
|
||||
EXPECT_EQ(rtc::Optional<float>(), test_buffer.Pop());
|
||||
EXPECT_EQ(rtc::nullopt, test_buffer.Pop());
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -68,7 +68,7 @@ class GainControlImpl::GainController {
|
||||
}
|
||||
|
||||
void set_capture_level(int capture_level) {
|
||||
capture_level_ = rtc::Optional<int>(capture_level);
|
||||
capture_level_ = capture_level;
|
||||
}
|
||||
|
||||
int get_capture_level() {
|
||||
@ -394,8 +394,8 @@ void GainControlImpl::Initialize(size_t num_proc_channels, int sample_rate_hz) {
|
||||
rtc::CritScope cs_capture(crit_capture_);
|
||||
data_dumper_->InitiateNewSetOfRecordings();
|
||||
|
||||
num_proc_channels_ = rtc::Optional<size_t>(num_proc_channels);
|
||||
sample_rate_hz_ = rtc::Optional<int>(sample_rate_hz);
|
||||
num_proc_channels_ = num_proc_channels;
|
||||
sample_rate_hz_ = sample_rate_hz;
|
||||
|
||||
if (!enabled_) {
|
||||
return;
|
||||
|
@ -202,7 +202,7 @@ void LevelController::Initialize(int sample_rate_hz) {
|
||||
metrics_.Initialize(sample_rate_hz);
|
||||
|
||||
last_gain_ = 1.0f;
|
||||
sample_rate_hz_ = rtc::Optional<int>(sample_rate_hz);
|
||||
sample_rate_hz_ = sample_rate_hz;
|
||||
dc_forgetting_factor_ = 0.01f * sample_rate_hz / 48000.f;
|
||||
std::fill(dc_level_, dc_level_ + arraysize(dc_level_), 0.f);
|
||||
}
|
||||
|
@ -90,20 +90,20 @@ TEST(LevelControllerConfig, ToString) {
|
||||
|
||||
TEST(LevelControlBitExactnessTest, Mono8kHz) {
|
||||
const float kOutputReference[] = {-0.013939f, -0.012154f, -0.009054f};
|
||||
RunBitexactnessTest(AudioProcessing::kSampleRate8kHz, 1,
|
||||
rtc::Optional<float>(), kOutputReference);
|
||||
RunBitexactnessTest(AudioProcessing::kSampleRate8kHz, 1, rtc::nullopt,
|
||||
kOutputReference);
|
||||
}
|
||||
|
||||
TEST(LevelControlBitExactnessTest, Mono16kHz) {
|
||||
const float kOutputReference[] = {-0.013706f, -0.013215f, -0.013018f};
|
||||
RunBitexactnessTest(AudioProcessing::kSampleRate16kHz, 1,
|
||||
rtc::Optional<float>(), kOutputReference);
|
||||
RunBitexactnessTest(AudioProcessing::kSampleRate16kHz, 1, rtc::nullopt,
|
||||
kOutputReference);
|
||||
}
|
||||
|
||||
TEST(LevelControlBitExactnessTest, Mono32kHz) {
|
||||
const float kOutputReference[] = {-0.014495f, -0.016425f, -0.016085f};
|
||||
RunBitexactnessTest(AudioProcessing::kSampleRate32kHz, 1,
|
||||
rtc::Optional<float>(), kOutputReference);
|
||||
RunBitexactnessTest(AudioProcessing::kSampleRate32kHz, 1, rtc::nullopt,
|
||||
kOutputReference);
|
||||
}
|
||||
|
||||
// TODO(peah): Investigate why this particular testcase differ between Android
|
||||
@ -115,42 +115,42 @@ TEST(LevelControlBitExactnessTest, Mono48kHz) {
|
||||
#else
|
||||
const float kOutputReference[] = {-0.014306f, -0.015209f, -0.017466f};
|
||||
#endif
|
||||
RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 1,
|
||||
rtc::Optional<float>(), kOutputReference);
|
||||
RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 1, rtc::nullopt,
|
||||
kOutputReference);
|
||||
}
|
||||
|
||||
TEST(LevelControlBitExactnessTest, Stereo8kHz) {
|
||||
const float kOutputReference[] = {-0.014063f, -0.008450f, -0.012159f,
|
||||
-0.051967f, -0.023202f, -0.047858f};
|
||||
RunBitexactnessTest(AudioProcessing::kSampleRate8kHz, 2,
|
||||
rtc::Optional<float>(), kOutputReference);
|
||||
RunBitexactnessTest(AudioProcessing::kSampleRate8kHz, 2, rtc::nullopt,
|
||||
kOutputReference);
|
||||
}
|
||||
|
||||
TEST(LevelControlBitExactnessTest, Stereo16kHz) {
|
||||
const float kOutputReference[] = {-0.012714f, -0.005896f, -0.012220f,
|
||||
-0.053306f, -0.024549f, -0.051527f};
|
||||
RunBitexactnessTest(AudioProcessing::kSampleRate16kHz, 2,
|
||||
rtc::Optional<float>(), kOutputReference);
|
||||
RunBitexactnessTest(AudioProcessing::kSampleRate16kHz, 2, rtc::nullopt,
|
||||
kOutputReference);
|
||||
}
|
||||
|
||||
TEST(LevelControlBitExactnessTest, Stereo32kHz) {
|
||||
const float kOutputReference[] = {-0.011764f, -0.007044f, -0.013472f,
|
||||
-0.053537f, -0.026322f, -0.056253f};
|
||||
RunBitexactnessTest(AudioProcessing::kSampleRate32kHz, 2,
|
||||
rtc::Optional<float>(), kOutputReference);
|
||||
RunBitexactnessTest(AudioProcessing::kSampleRate32kHz, 2, rtc::nullopt,
|
||||
kOutputReference);
|
||||
}
|
||||
|
||||
TEST(LevelControlBitExactnessTest, Stereo48kHz) {
|
||||
const float kOutputReference[] = {-0.010643f, -0.006334f, -0.011377f,
|
||||
-0.049088f, -0.023600f, -0.050465f};
|
||||
RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 2,
|
||||
rtc::Optional<float>(), kOutputReference);
|
||||
RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 2, rtc::nullopt,
|
||||
kOutputReference);
|
||||
}
|
||||
|
||||
TEST(LevelControlBitExactnessTest, MonoInitial48kHz) {
|
||||
const float kOutputReference[] = {-0.013884f, -0.014761f, -0.016951f};
|
||||
RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 1,
|
||||
rtc::Optional<float>(-50), kOutputReference);
|
||||
RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 1, -50,
|
||||
kOutputReference);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -54,7 +54,7 @@ void RmsLevel::Reset() {
|
||||
sum_square_ = 0.f;
|
||||
sample_count_ = 0;
|
||||
max_sum_square_ = 0.f;
|
||||
block_size_ = rtc::Optional<size_t>();
|
||||
block_size_ = rtc::nullopt;
|
||||
}
|
||||
|
||||
void RmsLevel::Analyze(rtc::ArrayView<const int16_t> data) {
|
||||
@ -99,9 +99,9 @@ RmsLevel::Levels RmsLevel::AverageAndPeak() {
|
||||
}
|
||||
|
||||
void RmsLevel::CheckBlockSize(size_t block_size) {
|
||||
if (block_size_ != rtc::Optional<size_t>(block_size)) {
|
||||
if (block_size_ != block_size) {
|
||||
Reset();
|
||||
block_size_ = rtc::Optional<size_t>(block_size);
|
||||
block_size_ = block_size;
|
||||
}
|
||||
}
|
||||
} // namespace webrtc
|
||||
|
@ -186,39 +186,39 @@ DEFINE_bool(help, false, "Print this message");
|
||||
void SetSettingIfSpecified(const std::string& value,
|
||||
rtc::Optional<std::string>* parameter) {
|
||||
if (value.compare("") != 0) {
|
||||
*parameter = rtc::Optional<std::string>(value);
|
||||
*parameter = value;
|
||||
}
|
||||
}
|
||||
|
||||
void SetSettingIfSpecified(int value, rtc::Optional<int>* parameter) {
|
||||
if (value != kParameterNotSpecifiedValue) {
|
||||
*parameter = rtc::Optional<int>(value);
|
||||
*parameter = value;
|
||||
}
|
||||
}
|
||||
|
||||
void SetSettingIfFlagSet(int32_t flag, rtc::Optional<bool>* parameter) {
|
||||
if (flag == 0) {
|
||||
*parameter = rtc::Optional<bool>(false);
|
||||
*parameter = false;
|
||||
} else if (flag == 1) {
|
||||
*parameter = rtc::Optional<bool>(true);
|
||||
*parameter = true;
|
||||
}
|
||||
}
|
||||
|
||||
SimulationSettings CreateSettings() {
|
||||
SimulationSettings settings;
|
||||
if (FLAG_all_default) {
|
||||
settings.use_le = rtc::Optional<bool>(true);
|
||||
settings.use_vad = rtc::Optional<bool>(true);
|
||||
settings.use_ie = rtc::Optional<bool>(false);
|
||||
settings.use_bf = rtc::Optional<bool>(false);
|
||||
settings.use_ts = rtc::Optional<bool>(true);
|
||||
settings.use_ns = rtc::Optional<bool>(true);
|
||||
settings.use_hpf = rtc::Optional<bool>(true);
|
||||
settings.use_agc = rtc::Optional<bool>(true);
|
||||
settings.use_agc2 = rtc::Optional<bool>(false);
|
||||
settings.use_aec = rtc::Optional<bool>(true);
|
||||
settings.use_aecm = rtc::Optional<bool>(false);
|
||||
settings.use_ed = rtc::Optional<bool>(false);
|
||||
settings.use_le = true;
|
||||
settings.use_vad = true;
|
||||
settings.use_ie = false;
|
||||
settings.use_bf = false;
|
||||
settings.use_ts = true;
|
||||
settings.use_ns = true;
|
||||
settings.use_hpf = true;
|
||||
settings.use_agc = true;
|
||||
settings.use_agc2 = false;
|
||||
settings.use_aec = true;
|
||||
settings.use_aecm = false;
|
||||
settings.use_ed = false;
|
||||
}
|
||||
SetSettingIfSpecified(FLAG_dump_input, &settings.aec_dump_input_filename);
|
||||
SetSettingIfSpecified(FLAG_dump_output, &settings.aec_dump_output_filename);
|
||||
|
@ -51,9 +51,9 @@ bool DebugDumpReplayer::SetDumpFile(const std::string& filename) {
|
||||
// Get next event that has not run.
|
||||
rtc::Optional<audioproc::Event> DebugDumpReplayer::GetNextEvent() const {
|
||||
if (!has_next_event_)
|
||||
return rtc::Optional<audioproc::Event>();
|
||||
return rtc::nullopt;
|
||||
else
|
||||
return rtc::Optional<audioproc::Event>(next_event_);
|
||||
return next_event_;
|
||||
}
|
||||
|
||||
// Run the next event. Returns the event type.
|
||||
|
@ -34,9 +34,7 @@ class FakeRecordingDeviceWorker {
|
||||
: mic_level_(initial_mic_level) {}
|
||||
int mic_level() const { return mic_level_; }
|
||||
void set_mic_level(const int level) { mic_level_ = level; }
|
||||
void set_undo_mic_level(const int level) {
|
||||
undo_mic_level_ = rtc::Optional<int>(level);
|
||||
}
|
||||
void set_undo_mic_level(const int level) { undo_mic_level_ = level; }
|
||||
virtual ~FakeRecordingDeviceWorker() = default;
|
||||
virtual void ModifyBufferInt16(AudioFrame* buffer) = 0;
|
||||
virtual void ModifyBufferFloat(ChannelBuffer<float>* buffer) = 0;
|
||||
|
@ -27,7 +27,7 @@ PerformanceTimer::PerformanceTimer(int num_frames_to_process)
|
||||
PerformanceTimer::~PerformanceTimer() = default;
|
||||
|
||||
void PerformanceTimer::StartTimer() {
|
||||
start_timestamp_us_ = rtc::Optional<int64_t>(clock_->TimeInMicroseconds());
|
||||
start_timestamp_us_ = clock_->TimeInMicroseconds();
|
||||
}
|
||||
|
||||
void PerformanceTimer::StopTimer() {
|
||||
|
Reference in New Issue
Block a user