Allow echo metrics to be enabled in process_test.

Review URL: http://webrtc-codereview.appspot.com/155002

git-svn-id: http://webrtc.googlecode.com/svn/trunk@620 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andrew@webrtc.org 2011-09-19 15:17:57 +00:00
parent 4c36d3b424
commit 94c7413b0d

View File

@ -28,6 +28,7 @@
using webrtc::AudioFrame; using webrtc::AudioFrame;
using webrtc::AudioProcessing; using webrtc::AudioProcessing;
using webrtc::EchoCancellation;
using webrtc::GainControl; using webrtc::GainControl;
using webrtc::NoiseSuppression; using webrtc::NoiseSuppression;
using webrtc::TickInterval; using webrtc::TickInterval;
@ -61,6 +62,12 @@ bool ReadMessageFromFile(FILE* file,
return msg->ParseFromArray(array, usize); return msg->ParseFromArray(array, usize);
} }
void PrintStat(const AudioProcessing::Statistic& stat) {
printf("%d, %d, %d\n", stat.average,
stat.maximum,
stat.minimum);
}
void usage() { void usage() {
printf( printf(
"Usage: process_test [options] [-pb PROTOBUF_FILE]\n" "Usage: process_test [options] [-pb PROTOBUF_FILE]\n"
@ -86,6 +93,8 @@ void usage() {
printf("\n -aec Echo cancellation\n"); printf("\n -aec Echo cancellation\n");
printf(" --drift_compensation\n"); printf(" --drift_compensation\n");
printf(" --no_drift_compensation\n"); printf(" --no_drift_compensation\n");
printf(" --echo_metrics\n");
printf(" --no_echo_metrics\n");
printf("\n -aecm Echo control mobile\n"); printf("\n -aecm Echo control mobile\n");
printf(" --aecm_echo_path_in_file FILE\n"); printf(" --aecm_echo_path_in_file FILE\n");
printf(" --aecm_echo_path_out_file FILE\n"); printf(" --aecm_echo_path_out_file FILE\n");
@ -107,6 +116,7 @@ void usage() {
printf(" --vad_out_file FILE\n"); printf(" --vad_out_file FILE\n");
printf("\n"); printf("\n");
printf("Modifiers:\n"); printf("Modifiers:\n");
printf(" --noasm Disable SSE optimization.\n");
printf(" --perf Measure performance.\n"); printf(" --perf Measure performance.\n");
printf(" --quiet Suppress text output.\n"); printf(" --quiet Suppress text output.\n");
printf(" --no_progress Suppress progress.\n"); printf(" --no_progress Suppress progress.\n");
@ -209,9 +219,6 @@ void void_main(int argc, char* argv[]) {
} else if (strcmp(argv[i], "-aec") == 0) { } else if (strcmp(argv[i], "-aec") == 0) {
ASSERT_EQ(apm->kNoError, apm->echo_cancellation()->Enable(true)); ASSERT_EQ(apm->kNoError, apm->echo_cancellation()->Enable(true));
} else if (strcmp(argv[i], "-noasm") == 0) {
WebRtc_GetCPUInfo = WebRtc_GetCPUInfoNoASM;
} else if (strcmp(argv[i], "--drift_compensation") == 0) { } else if (strcmp(argv[i], "--drift_compensation") == 0) {
ASSERT_EQ(apm->kNoError, apm->echo_cancellation()->Enable(true)); ASSERT_EQ(apm->kNoError, apm->echo_cancellation()->Enable(true));
// TODO(ajm): this is enabled in the VQE test app by default. Investigate // TODO(ajm): this is enabled in the VQE test app by default. Investigate
@ -223,6 +230,16 @@ void void_main(int argc, char* argv[]) {
ASSERT_EQ(apm->kNoError, ASSERT_EQ(apm->kNoError,
apm->echo_cancellation()->enable_drift_compensation(false)); apm->echo_cancellation()->enable_drift_compensation(false));
} else if (strcmp(argv[i], "--echo_metrics") == 0) {
ASSERT_EQ(apm->kNoError, apm->echo_cancellation()->Enable(true));
ASSERT_EQ(apm->kNoError,
apm->echo_cancellation()->enable_metrics(true));
} else if (strcmp(argv[i], "--no_echo_metrics") == 0) {
ASSERT_EQ(apm->kNoError, apm->echo_cancellation()->Enable(true));
ASSERT_EQ(apm->kNoError,
apm->echo_cancellation()->enable_metrics(false));
} else if (strcmp(argv[i], "-aecm") == 0) { } else if (strcmp(argv[i], "-aecm") == 0) {
ASSERT_EQ(apm->kNoError, apm->echo_control_mobile()->Enable(true)); ASSERT_EQ(apm->kNoError, apm->echo_control_mobile()->Enable(true));
@ -316,6 +333,11 @@ void void_main(int argc, char* argv[]) {
ASSERT_LT(i, argc) << "Specify filename after --vad_out_file"; ASSERT_LT(i, argc) << "Specify filename after --vad_out_file";
vad_out_filename = argv[i]; vad_out_filename = argv[i];
} else if (strcmp(argv[i], "--noasm") == 0) {
WebRtc_GetCPUInfo = WebRtc_GetCPUInfoNoASM;
// We need to reinitialize here if components have already been enabled.
ASSERT_EQ(apm->kNoError, apm->Initialize());
} else if (strcmp(argv[i], "--perf") == 0) { } else if (strcmp(argv[i], "--perf") == 0) {
perf_testing = true; perf_testing = true;
@ -642,7 +664,6 @@ void void_main(int argc, char* argv[]) {
} }
ASSERT_TRUE(feof(pb_file)); ASSERT_TRUE(feof(pb_file));
printf("100%% complete\r");
} else { } else {
while (simulating || feof(event_file) == 0) { while (simulating || feof(event_file) == 0) {
@ -708,6 +729,10 @@ void void_main(int argc, char* argv[]) {
if (simulating) { if (simulating) {
if (read_count != far_frame._payloadDataLengthInSamples) { if (read_count != far_frame._payloadDataLengthInSamples) {
// Read an equal amount from the near file to avoid errors due to
// not reaching end-of-file.
EXPECT_EQ(0, fseek(near_file, read_count * sizeof(WebRtc_Word16),
SEEK_CUR));
break; // This is expected. break; // This is expected.
} }
} else { } else {
@ -753,6 +778,10 @@ void void_main(int argc, char* argv[]) {
} }
if (simulating) { if (simulating) {
if (read_count != near_frame._payloadDataLengthInSamples) { if (read_count != near_frame._payloadDataLengthInSamples) {
// Read an equal amount from the far file to avoid errors due to
// not reaching end-of-file.
EXPECT_EQ(0, fseek(far_file, read_count * sizeof(WebRtc_Word16),
SEEK_CUR));
break; // This is expected. break; // This is expected.
} }
@ -828,6 +857,7 @@ void void_main(int argc, char* argv[]) {
} }
} }
} }
printf("100%% complete\r");
if (aecm_echo_path_out_file != NULL) { if (aecm_echo_path_out_file != NULL) {
const size_t path_size = const size_t path_size =
@ -845,6 +875,19 @@ void void_main(int argc, char* argv[]) {
if (verbose) { if (verbose) {
printf("\nProcessed frames: %d (primary), %d (reverse)\n", printf("\nProcessed frames: %d (primary), %d (reverse)\n",
primary_count, reverse_count); primary_count, reverse_count);
if (apm->echo_cancellation()->are_metrics_enabled()) {
EchoCancellation::Metrics metrics;
apm->echo_cancellation()->GetMetrics(&metrics);
printf("\n--Echo metrics--\n");
printf("(avg, max, min)\n");
printf("ERL: ");
PrintStat(metrics.echo_return_loss);
printf("ERLE: ");
PrintStat(metrics.echo_return_loss_enhancement);
printf("ANLP: ");
PrintStat(metrics.a_nlp);
}
} }
if (!pb_file) { if (!pb_file) {