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:

committed by
Commit Bot

parent
221ee3c3ca
commit
af6c139eb6
@ -225,24 +225,6 @@ int16_t MaxAudioFrame(const AudioFrame& frame) {
|
||||
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,
|
||||
const MessageLite& msg) {
|
||||
FILE* file = fopen(filename.c_str(), "wb");
|
||||
@ -2047,7 +2029,6 @@ TEST_F(ApmTest, Process) {
|
||||
true);
|
||||
|
||||
int frame_count = 0;
|
||||
int has_echo_count = 0;
|
||||
int has_voice_count = 0;
|
||||
int is_saturated_count = 0;
|
||||
int analog_level = 127;
|
||||
@ -2076,10 +2057,6 @@ TEST_F(ApmTest, Process) {
|
||||
|
||||
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_average += analog_level;
|
||||
if (apm_->gain_control()->stream_is_saturated()) {
|
||||
@ -2108,18 +2085,25 @@ TEST_F(ApmTest, Process) {
|
||||
#if defined(WEBRTC_AUDIOPROC_FLOAT_PROFILE)
|
||||
const int kStatsAggregationFrameNum = 100; // 1 second.
|
||||
if (frame_count % kStatsAggregationFrameNum == 0) {
|
||||
// Get echo metrics.
|
||||
EchoCancellation::Metrics echo_metrics;
|
||||
EXPECT_EQ(apm_->kNoError,
|
||||
apm_->echo_cancellation()->GetMetrics(&echo_metrics));
|
||||
// Get echo and delay metrics.
|
||||
AudioProcessingStats stats =
|
||||
apm_->GetStatistics(true /* has_remote_tracks */);
|
||||
|
||||
// Get delay metrics.
|
||||
int median = 0;
|
||||
int std = 0;
|
||||
float fraction_poor_delays = 0;
|
||||
EXPECT_EQ(apm_->kNoError,
|
||||
apm_->echo_cancellation()->GetDelayMetrics(
|
||||
&median, &std, &fraction_poor_delays));
|
||||
// Echo metrics.
|
||||
const float echo_return_loss = stats.echo_return_loss.value_or(-1.0f);
|
||||
const float echo_return_loss_enhancement =
|
||||
stats.echo_return_loss_enhancement.value_or(-1.0f);
|
||||
const float divergent_filter_fraction =
|
||||
stats.divergent_filter_fraction.value_or(-1.0f);
|
||||
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.
|
||||
int rms_level = apm_->level_estimator()->RMS();
|
||||
@ -2129,46 +2113,40 @@ TEST_F(ApmTest, Process) {
|
||||
if (!write_ref_data) {
|
||||
const audioproc::Test::EchoMetrics& reference =
|
||||
test->echo_metrics(stats_index);
|
||||
TestStats(echo_metrics.residual_echo_return_loss,
|
||||
reference.residual_echo_return_loss());
|
||||
TestStats(echo_metrics.echo_return_loss,
|
||||
reference.echo_return_loss());
|
||||
TestStats(echo_metrics.echo_return_loss_enhancement,
|
||||
reference.echo_return_loss_enhancement());
|
||||
TestStats(echo_metrics.a_nlp,
|
||||
reference.a_nlp());
|
||||
EXPECT_EQ(echo_metrics.divergent_filter_fraction,
|
||||
reference.divergent_filter_fraction());
|
||||
constexpr float kEpsilon = 0.01;
|
||||
EXPECT_NEAR(echo_return_loss, reference.echo_return_loss(), kEpsilon);
|
||||
EXPECT_NEAR(echo_return_loss_enhancement,
|
||||
reference.echo_return_loss_enhancement(), kEpsilon);
|
||||
EXPECT_NEAR(divergent_filter_fraction,
|
||||
reference.divergent_filter_fraction(), kEpsilon);
|
||||
EXPECT_NEAR(residual_echo_likelihood,
|
||||
reference.residual_echo_likelihood(), kEpsilon);
|
||||
EXPECT_NEAR(residual_echo_likelihood_recent_max,
|
||||
reference.residual_echo_likelihood_recent_max(),
|
||||
kEpsilon);
|
||||
|
||||
const audioproc::Test::DelayMetrics& reference_delay =
|
||||
test->delay_metrics(stats_index);
|
||||
EXPECT_EQ(reference_delay.median(), median);
|
||||
EXPECT_EQ(reference_delay.std(), std);
|
||||
EXPECT_EQ(reference_delay.fraction_poor_delays(),
|
||||
fraction_poor_delays);
|
||||
EXPECT_EQ(reference_delay.median(), delay_median_ms);
|
||||
EXPECT_EQ(reference_delay.std(), delay_standard_deviation_ms);
|
||||
|
||||
EXPECT_EQ(test->rms_level(stats_index), rms_level);
|
||||
|
||||
++stats_index;
|
||||
} else {
|
||||
audioproc::Test::EchoMetrics* message =
|
||||
test->add_echo_metrics();
|
||||
WriteStatsMessage(echo_metrics.residual_echo_return_loss,
|
||||
message->mutable_residual_echo_return_loss());
|
||||
WriteStatsMessage(echo_metrics.echo_return_loss,
|
||||
message->mutable_echo_return_loss());
|
||||
WriteStatsMessage(echo_metrics.echo_return_loss_enhancement,
|
||||
message->mutable_echo_return_loss_enhancement());
|
||||
WriteStatsMessage(echo_metrics.a_nlp,
|
||||
message->mutable_a_nlp());
|
||||
message->set_divergent_filter_fraction(
|
||||
echo_metrics.divergent_filter_fraction);
|
||||
|
||||
audioproc::Test::EchoMetrics* message_echo = test->add_echo_metrics();
|
||||
message_echo->set_echo_return_loss(echo_return_loss);
|
||||
message_echo->set_echo_return_loss_enhancement(
|
||||
echo_return_loss_enhancement);
|
||||
message_echo->set_divergent_filter_fraction(
|
||||
divergent_filter_fraction);
|
||||
message_echo->set_residual_echo_likelihood(residual_echo_likelihood);
|
||||
message_echo->set_residual_echo_likelihood_recent_max(
|
||||
residual_echo_likelihood_recent_max);
|
||||
audioproc::Test::DelayMetrics* message_delay =
|
||||
test->add_delay_metrics();
|
||||
message_delay->set_median(median);
|
||||
message_delay->set_std(std);
|
||||
message_delay->set_fraction_poor_delays(fraction_poor_delays);
|
||||
message_delay->set_median(delay_median_ms);
|
||||
message_delay->set_std(delay_standard_deviation_ms);
|
||||
|
||||
test->add_rms_level(rms_level);
|
||||
}
|
||||
@ -2198,7 +2176,6 @@ TEST_F(ApmTest, Process) {
|
||||
const int kMaxOutputAverageOffset = 0;
|
||||
const int kMaxOutputAverageNear = kIntNear;
|
||||
#endif
|
||||
EXPECT_NEAR(test->has_echo_count(), has_echo_count, kIntNear);
|
||||
EXPECT_NEAR(test->has_voice_count(),
|
||||
has_voice_count - kHasVoiceCountOffset,
|
||||
kHasVoiceCountNear);
|
||||
@ -2215,7 +2192,6 @@ TEST_F(ApmTest, Process) {
|
||||
kFloatNear);
|
||||
#endif
|
||||
} else {
|
||||
test->set_has_echo_count(has_echo_count);
|
||||
test->set_has_voice_count(has_voice_count);
|
||||
test->set_is_saturated_count(is_saturated_count);
|
||||
|
||||
|
@ -15,24 +15,15 @@ message Test {
|
||||
|
||||
optional int32 analog_level_average = 6;
|
||||
optional int32 max_output_average = 7;
|
||||
|
||||
optional int32 has_echo_count = 8;
|
||||
optional int32 has_voice_count = 9;
|
||||
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 {
|
||||
optional Statistic residual_echo_return_loss = 1;
|
||||
optional Statistic echo_return_loss = 2;
|
||||
optional Statistic echo_return_loss_enhancement = 3;
|
||||
optional Statistic a_nlp = 4;
|
||||
optional float divergent_filter_fraction = 5;
|
||||
optional float echo_return_loss = 1;
|
||||
optional float echo_return_loss_enhancement = 2;
|
||||
optional float divergent_filter_fraction = 3;
|
||||
optional float residual_echo_likelihood = 4;
|
||||
optional float residual_echo_likelihood_recent_max = 5;
|
||||
}
|
||||
|
||||
repeated EchoMetrics echo_metrics = 11;
|
||||
@ -40,7 +31,6 @@ message Test {
|
||||
message DelayMetrics {
|
||||
optional int32 median = 1;
|
||||
optional int32 std = 2;
|
||||
optional float fraction_poor_delays = 3;
|
||||
}
|
||||
|
||||
repeated DelayMetrics delay_metrics = 12;
|
||||
|
@ -1 +1 @@
|
||||
75a835fd9e641531989b7ee1de20e84b553d3bc9
|
||||
7481cf57b2ade2f600d91e8bc77fd9780a56b62e
|
@ -1 +1 @@
|
||||
64802f0a924f23b86a91d8d9d181bffe3f02c308
|
||||
82e9600c82f03c21e9feb33f82792d8d17908a5f
|
@ -1 +1 @@
|
||||
98249662a7ba79579a199a8b9ef9f6fc26ff33aa
|
||||
3f2550064d3e71c6428c3759dcce18bddec36690
|
Reference in New Issue
Block a user