Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: webrtc/modules/audio_processing/test/aec_dump_based_simulator.cc

Issue 2834643002: audioproc_f with simulated mic analog gain (Closed)
Patch Set: Merge + comments addressed Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <iostream> 11 #include <iostream>
12 12
13 #include "webrtc/modules/audio_processing/test/aec_dump_based_simulator.h" 13 #include "webrtc/modules/audio_processing/test/aec_dump_based_simulator.h"
14 14
15 #include "webrtc/base/checks.h" 15 #include "webrtc/base/checks.h"
16 #include "webrtc/base/logging.h"
16 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" 17 #include "webrtc/modules/audio_processing/test/protobuf_utils.h"
17 #include "webrtc/test/testsupport/trace_to_stderr.h" 18 #include "webrtc/test/testsupport/trace_to_stderr.h"
18 19
19 namespace webrtc { 20 namespace webrtc {
20 namespace test { 21 namespace test {
21 namespace { 22 namespace {
22 23
23 // Verify output bitexactness for the fixed interface. 24 // Verify output bitexactness for the fixed interface.
24 // TODO(peah): Check whether it would make sense to add a threshold 25 // TODO(peah): Check whether it would make sense to add a threshold
25 // to use for checking the bitexactness in a soft manner. 26 // to use for checking the bitexactness in a soft manner.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 58 }
58 } 59 }
59 } 60 }
60 } 61 }
61 return true; 62 return true;
62 } 63 }
63 64
64 } // namespace 65 } // namespace
65 66
66 AecDumpBasedSimulator::AecDumpBasedSimulator(const SimulationSettings& settings) 67 AecDumpBasedSimulator::AecDumpBasedSimulator(const SimulationSettings& settings)
67 : AudioProcessingSimulator(settings) {} 68 : AudioProcessingSimulator(settings) {
69 if (settings_.simulate_mic_gain) {
70 LOG(LS_VERBOSE)
71 << "Simulating analog mic gain using AEC dump as input "
AleBzk 2017/06/29 11:43:36 Just git cl format
72 << "(the unmodified mic gain level will be virtually restored)";
peah-webrtc 2017/06/29 22:03:59 This comment is not really fully correct, right?
AleBzk 2017/07/26 13:42:30 Done.
73 }
74 }
68 75
69 AecDumpBasedSimulator::~AecDumpBasedSimulator() = default; 76 AecDumpBasedSimulator::~AecDumpBasedSimulator() = default;
70 77
71 void AecDumpBasedSimulator::PrepareProcessStreamCall( 78 void AecDumpBasedSimulator::PrepareProcessStreamCall(
72 const webrtc::audioproc::Stream& msg, 79 const webrtc::audioproc::Stream& msg) {
73 bool* set_stream_analog_level_called) {
74 if (msg.has_input_data()) { 80 if (msg.has_input_data()) {
75 // Fixed interface processing. 81 // Fixed interface processing.
76 // Verify interface invariance. 82 // Verify interface invariance.
77 RTC_CHECK(interface_used_ == InterfaceType::kFixedInterface || 83 RTC_CHECK(interface_used_ == InterfaceType::kFixedInterface ||
78 interface_used_ == InterfaceType::kNotSpecified); 84 interface_used_ == InterfaceType::kNotSpecified);
79 interface_used_ = InterfaceType::kFixedInterface; 85 interface_used_ = InterfaceType::kFixedInterface;
80 86
81 // Populate input buffer. 87 // Populate input buffer.
82 RTC_CHECK_EQ(sizeof(*fwd_frame_.data()) * fwd_frame_.samples_per_channel_ * 88 RTC_CHECK_EQ(sizeof(*fwd_frame_.data()) * fwd_frame_.samples_per_channel_ *
83 fwd_frame_.num_channels_, 89 fwd_frame_.num_channels_,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } 158 }
153 159
154 if (!settings_.use_ts) { 160 if (!settings_.use_ts) {
155 if (msg.has_keypress()) { 161 if (msg.has_keypress()) {
156 ap_->set_stream_key_pressed(msg.keypress()); 162 ap_->set_stream_key_pressed(msg.keypress());
157 } 163 }
158 } else { 164 } else {
159 ap_->set_stream_key_pressed(*settings_.use_ts); 165 ap_->set_stream_key_pressed(*settings_.use_ts);
160 } 166 }
161 167
162 // TODO(peah): Add support for controlling the analog level via the 168 // Level is always logged in AEC dumps.
163 // command-line. 169 RTC_CHECK(msg.has_level());
164 if (msg.has_level()) { 170 aec_dump_mic_level_ = rtc::Optional<int>(msg.level());
165 RTC_CHECK_EQ(AudioProcessing::kNoError,
166 ap_->gain_control()->set_stream_analog_level(msg.level()));
167 *set_stream_analog_level_called = true;
168 } else {
169 *set_stream_analog_level_called = false;
170 }
171 } 171 }
172 172
173 void AecDumpBasedSimulator::VerifyProcessStreamBitExactness( 173 void AecDumpBasedSimulator::VerifyProcessStreamBitExactness(
174 const webrtc::audioproc::Stream& msg) { 174 const webrtc::audioproc::Stream& msg) {
175 if (bitexact_output_) { 175 if (bitexact_output_) {
176 if (interface_used_ == InterfaceType::kFixedInterface) { 176 if (interface_used_ == InterfaceType::kFixedInterface) {
177 bitexact_output_ = VerifyFixedBitExactness(msg, fwd_frame_); 177 bitexact_output_ = VerifyFixedBitExactness(msg, fwd_frame_);
178 } else { 178 } else {
179 bitexact_output_ = VerifyFloatBitExactness(msg, out_config_, *out_buf_); 179 bitexact_output_ = VerifyFloatBitExactness(msg, out_config_, *out_buf_);
180 } 180 }
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 } 558 }
559 559
560 SetupBuffersConfigsOutputs( 560 SetupBuffersConfigsOutputs(
561 msg.sample_rate(), output_sample_rate, msg.reverse_sample_rate(), 561 msg.sample_rate(), output_sample_rate, msg.reverse_sample_rate(),
562 reverse_output_sample_rate, msg.num_input_channels(), num_output_channels, 562 reverse_output_sample_rate, msg.num_input_channels(), num_output_channels,
563 msg.num_reverse_channels(), num_reverse_output_channels); 563 msg.num_reverse_channels(), num_reverse_output_channels);
564 } 564 }
565 565
566 void AecDumpBasedSimulator::HandleMessage( 566 void AecDumpBasedSimulator::HandleMessage(
567 const webrtc::audioproc::Stream& msg) { 567 const webrtc::audioproc::Stream& msg) {
568 bool set_stream_analog_level_called = false; 568 PrepareProcessStreamCall(msg);
569 PrepareProcessStreamCall(msg, &set_stream_analog_level_called);
570 ProcessStream(interface_used_ == InterfaceType::kFixedInterface); 569 ProcessStream(interface_used_ == InterfaceType::kFixedInterface);
571 if (set_stream_analog_level_called) {
572 // Call stream analog level to ensure that any side-effects are triggered.
573 (void)ap_->gain_control()->stream_analog_level();
574 }
575
576 VerifyProcessStreamBitExactness(msg); 570 VerifyProcessStreamBitExactness(msg);
577 } 571 }
578 572
579 void AecDumpBasedSimulator::HandleMessage( 573 void AecDumpBasedSimulator::HandleMessage(
580 const webrtc::audioproc::ReverseStream& msg) { 574 const webrtc::audioproc::ReverseStream& msg) {
581 PrepareReverseProcessStreamCall(msg); 575 PrepareReverseProcessStreamCall(msg);
582 ProcessReverseStream(interface_used_ == InterfaceType::kFixedInterface); 576 ProcessReverseStream(interface_used_ == InterfaceType::kFixedInterface);
583 } 577 }
584 578
585 } // namespace test 579 } // namespace test
586 } // namespace webrtc 580 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698