Drop legacy AEC metrics interface from ApmTest.Process

The test is refitted to use the AudioProcessingStats struct to get
reference data.

The old metrics do not map entirely injectively to the new ones, so the
reference protobuf and files are updated as well.

Bug: webrtc:9535
Change-Id: I546dca2979380e03895af0077bfc77ffd24abe36
Reviewed-on: https://webrtc-review.googlesource.com/100100
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24740}
This commit is contained in:
Sam Zackrisson
2018-09-13 12:59:09 +02:00
committed by Commit Bot
parent 221ee3c3ca
commit af6c139eb6
5 changed files with 50 additions and 84 deletions

View File

@ -225,24 +225,6 @@ int16_t MaxAudioFrame(const AudioFrame& frame) {
return max_data; return max_data;
} }
#if defined(WEBRTC_AUDIOPROC_FLOAT_PROFILE)
void TestStats(const AudioProcessing::Statistic& test,
const audioproc::Test::Statistic& reference) {
EXPECT_EQ(reference.instant(), test.instant);
EXPECT_EQ(reference.average(), test.average);
EXPECT_EQ(reference.maximum(), test.maximum);
EXPECT_EQ(reference.minimum(), test.minimum);
}
void WriteStatsMessage(const AudioProcessing::Statistic& output,
audioproc::Test::Statistic* msg) {
msg->set_instant(output.instant);
msg->set_average(output.average);
msg->set_maximum(output.maximum);
msg->set_minimum(output.minimum);
}
#endif
void OpenFileAndWriteMessage(const std::string& filename, void OpenFileAndWriteMessage(const std::string& filename,
const MessageLite& msg) { const MessageLite& msg) {
FILE* file = fopen(filename.c_str(), "wb"); FILE* file = fopen(filename.c_str(), "wb");
@ -2047,7 +2029,6 @@ TEST_F(ApmTest, Process) {
true); true);
int frame_count = 0; int frame_count = 0;
int has_echo_count = 0;
int has_voice_count = 0; int has_voice_count = 0;
int is_saturated_count = 0; int is_saturated_count = 0;
int analog_level = 127; int analog_level = 127;
@ -2076,10 +2057,6 @@ TEST_F(ApmTest, Process) {
max_output_average += MaxAudioFrame(*frame_); max_output_average += MaxAudioFrame(*frame_);
if (apm_->echo_cancellation()->stream_has_echo()) {
has_echo_count++;
}
analog_level = apm_->gain_control()->stream_analog_level(); analog_level = apm_->gain_control()->stream_analog_level();
analog_level_average += analog_level; analog_level_average += analog_level;
if (apm_->gain_control()->stream_is_saturated()) { if (apm_->gain_control()->stream_is_saturated()) {
@ -2108,18 +2085,25 @@ TEST_F(ApmTest, Process) {
#if defined(WEBRTC_AUDIOPROC_FLOAT_PROFILE) #if defined(WEBRTC_AUDIOPROC_FLOAT_PROFILE)
const int kStatsAggregationFrameNum = 100; // 1 second. const int kStatsAggregationFrameNum = 100; // 1 second.
if (frame_count % kStatsAggregationFrameNum == 0) { if (frame_count % kStatsAggregationFrameNum == 0) {
// Get echo metrics. // Get echo and delay metrics.
EchoCancellation::Metrics echo_metrics; AudioProcessingStats stats =
EXPECT_EQ(apm_->kNoError, apm_->GetStatistics(true /* has_remote_tracks */);
apm_->echo_cancellation()->GetMetrics(&echo_metrics));
// Get delay metrics. // Echo metrics.
int median = 0; const float echo_return_loss = stats.echo_return_loss.value_or(-1.0f);
int std = 0; const float echo_return_loss_enhancement =
float fraction_poor_delays = 0; stats.echo_return_loss_enhancement.value_or(-1.0f);
EXPECT_EQ(apm_->kNoError, const float divergent_filter_fraction =
apm_->echo_cancellation()->GetDelayMetrics( stats.divergent_filter_fraction.value_or(-1.0f);
&median, &std, &fraction_poor_delays)); const float residual_echo_likelihood =
stats.residual_echo_likelihood.value_or(-1.0f);
const float residual_echo_likelihood_recent_max =
stats.residual_echo_likelihood_recent_max.value_or(-1.0f);
// Delay metrics.
const int32_t delay_median_ms = stats.delay_median_ms.value_or(-1.0);
const int32_t delay_standard_deviation_ms =
stats.delay_standard_deviation_ms.value_or(-1.0);
// Get RMS. // Get RMS.
int rms_level = apm_->level_estimator()->RMS(); int rms_level = apm_->level_estimator()->RMS();
@ -2129,46 +2113,40 @@ TEST_F(ApmTest, Process) {
if (!write_ref_data) { if (!write_ref_data) {
const audioproc::Test::EchoMetrics& reference = const audioproc::Test::EchoMetrics& reference =
test->echo_metrics(stats_index); test->echo_metrics(stats_index);
TestStats(echo_metrics.residual_echo_return_loss, constexpr float kEpsilon = 0.01;
reference.residual_echo_return_loss()); EXPECT_NEAR(echo_return_loss, reference.echo_return_loss(), kEpsilon);
TestStats(echo_metrics.echo_return_loss, EXPECT_NEAR(echo_return_loss_enhancement,
reference.echo_return_loss()); reference.echo_return_loss_enhancement(), kEpsilon);
TestStats(echo_metrics.echo_return_loss_enhancement, EXPECT_NEAR(divergent_filter_fraction,
reference.echo_return_loss_enhancement()); reference.divergent_filter_fraction(), kEpsilon);
TestStats(echo_metrics.a_nlp, EXPECT_NEAR(residual_echo_likelihood,
reference.a_nlp()); reference.residual_echo_likelihood(), kEpsilon);
EXPECT_EQ(echo_metrics.divergent_filter_fraction, EXPECT_NEAR(residual_echo_likelihood_recent_max,
reference.divergent_filter_fraction()); reference.residual_echo_likelihood_recent_max(),
kEpsilon);
const audioproc::Test::DelayMetrics& reference_delay = const audioproc::Test::DelayMetrics& reference_delay =
test->delay_metrics(stats_index); test->delay_metrics(stats_index);
EXPECT_EQ(reference_delay.median(), median); EXPECT_EQ(reference_delay.median(), delay_median_ms);
EXPECT_EQ(reference_delay.std(), std); EXPECT_EQ(reference_delay.std(), delay_standard_deviation_ms);
EXPECT_EQ(reference_delay.fraction_poor_delays(),
fraction_poor_delays);
EXPECT_EQ(test->rms_level(stats_index), rms_level); EXPECT_EQ(test->rms_level(stats_index), rms_level);
++stats_index; ++stats_index;
} else { } else {
audioproc::Test::EchoMetrics* message = audioproc::Test::EchoMetrics* message_echo = test->add_echo_metrics();
test->add_echo_metrics(); message_echo->set_echo_return_loss(echo_return_loss);
WriteStatsMessage(echo_metrics.residual_echo_return_loss, message_echo->set_echo_return_loss_enhancement(
message->mutable_residual_echo_return_loss()); echo_return_loss_enhancement);
WriteStatsMessage(echo_metrics.echo_return_loss, message_echo->set_divergent_filter_fraction(
message->mutable_echo_return_loss()); divergent_filter_fraction);
WriteStatsMessage(echo_metrics.echo_return_loss_enhancement, message_echo->set_residual_echo_likelihood(residual_echo_likelihood);
message->mutable_echo_return_loss_enhancement()); message_echo->set_residual_echo_likelihood_recent_max(
WriteStatsMessage(echo_metrics.a_nlp, residual_echo_likelihood_recent_max);
message->mutable_a_nlp());
message->set_divergent_filter_fraction(
echo_metrics.divergent_filter_fraction);
audioproc::Test::DelayMetrics* message_delay = audioproc::Test::DelayMetrics* message_delay =
test->add_delay_metrics(); test->add_delay_metrics();
message_delay->set_median(median); message_delay->set_median(delay_median_ms);
message_delay->set_std(std); message_delay->set_std(delay_standard_deviation_ms);
message_delay->set_fraction_poor_delays(fraction_poor_delays);
test->add_rms_level(rms_level); test->add_rms_level(rms_level);
} }
@ -2198,7 +2176,6 @@ TEST_F(ApmTest, Process) {
const int kMaxOutputAverageOffset = 0; const int kMaxOutputAverageOffset = 0;
const int kMaxOutputAverageNear = kIntNear; const int kMaxOutputAverageNear = kIntNear;
#endif #endif
EXPECT_NEAR(test->has_echo_count(), has_echo_count, kIntNear);
EXPECT_NEAR(test->has_voice_count(), EXPECT_NEAR(test->has_voice_count(),
has_voice_count - kHasVoiceCountOffset, has_voice_count - kHasVoiceCountOffset,
kHasVoiceCountNear); kHasVoiceCountNear);
@ -2215,7 +2192,6 @@ TEST_F(ApmTest, Process) {
kFloatNear); kFloatNear);
#endif #endif
} else { } else {
test->set_has_echo_count(has_echo_count);
test->set_has_voice_count(has_voice_count); test->set_has_voice_count(has_voice_count);
test->set_is_saturated_count(is_saturated_count); test->set_is_saturated_count(is_saturated_count);

View File

@ -15,24 +15,15 @@ message Test {
optional int32 analog_level_average = 6; optional int32 analog_level_average = 6;
optional int32 max_output_average = 7; optional int32 max_output_average = 7;
optional int32 has_echo_count = 8;
optional int32 has_voice_count = 9; optional int32 has_voice_count = 9;
optional int32 is_saturated_count = 10; optional int32 is_saturated_count = 10;
message Statistic {
optional int32 instant = 1;
optional int32 average = 2;
optional int32 maximum = 3;
optional int32 minimum = 4;
}
message EchoMetrics { message EchoMetrics {
optional Statistic residual_echo_return_loss = 1; optional float echo_return_loss = 1;
optional Statistic echo_return_loss = 2; optional float echo_return_loss_enhancement = 2;
optional Statistic echo_return_loss_enhancement = 3; optional float divergent_filter_fraction = 3;
optional Statistic a_nlp = 4; optional float residual_echo_likelihood = 4;
optional float divergent_filter_fraction = 5; optional float residual_echo_likelihood_recent_max = 5;
} }
repeated EchoMetrics echo_metrics = 11; repeated EchoMetrics echo_metrics = 11;
@ -40,7 +31,6 @@ message Test {
message DelayMetrics { message DelayMetrics {
optional int32 median = 1; optional int32 median = 1;
optional int32 std = 2; optional int32 std = 2;
optional float fraction_poor_delays = 3;
} }
repeated DelayMetrics delay_metrics = 12; repeated DelayMetrics delay_metrics = 12;

View File

@ -1 +1 @@
75a835fd9e641531989b7ee1de20e84b553d3bc9 7481cf57b2ade2f600d91e8bc77fd9780a56b62e

View File

@ -1 +1 @@
64802f0a924f23b86a91d8d9d181bffe3f02c308 82e9600c82f03c21e9feb33f82792d8d17908a5f

View File

@ -1 +1 @@
98249662a7ba79579a199a8b9ef9f6fc26ff33aa 3f2550064d3e71c6428c3759dcce18bddec36690