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

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

Issue 2750783004: Add mute state field to AudioFrame. (Closed)
Patch Set: Update new usages of AudioFrame::data_ Created 3 years, 6 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
(...skipping 11 matching lines...) Expand all
22 22
23 // Verify output bitexactness for the fixed interface. 23 // Verify output bitexactness for the fixed interface.
24 // TODO(peah): Check whether it would make sense to add a threshold 24 // TODO(peah): Check whether it would make sense to add a threshold
25 // to use for checking the bitexactness in a soft manner. 25 // to use for checking the bitexactness in a soft manner.
26 bool VerifyFixedBitExactness(const webrtc::audioproc::Stream& msg, 26 bool VerifyFixedBitExactness(const webrtc::audioproc::Stream& msg,
27 const AudioFrame& frame) { 27 const AudioFrame& frame) {
28 if ((sizeof(int16_t) * frame.samples_per_channel_ * frame.num_channels_) != 28 if ((sizeof(int16_t) * frame.samples_per_channel_ * frame.num_channels_) !=
29 msg.output_data().size()) { 29 msg.output_data().size()) {
30 return false; 30 return false;
31 } else { 31 } else {
32 const int16_t* frame_data = frame.data();
32 for (size_t k = 0; k < frame.num_channels_ * frame.samples_per_channel_; 33 for (size_t k = 0; k < frame.num_channels_ * frame.samples_per_channel_;
33 ++k) { 34 ++k) {
34 if (msg.output_data().data()[k] != frame.data_[k]) { 35 if (msg.output_data().data()[k] != frame_data[k]) {
35 return false; 36 return false;
36 } 37 }
37 } 38 }
38 } 39 }
39 return true; 40 return true;
40 } 41 }
41 42
42 // Verify output bitexactness for the float interface. 43 // Verify output bitexactness for the float interface.
43 bool VerifyFloatBitExactness(const webrtc::audioproc::Stream& msg, 44 bool VerifyFloatBitExactness(const webrtc::audioproc::Stream& msg,
44 const StreamConfig& out_config, 45 const StreamConfig& out_config,
(...skipping 26 matching lines...) Expand all
71 const webrtc::audioproc::Stream& msg, 72 const webrtc::audioproc::Stream& msg,
72 bool* set_stream_analog_level_called) { 73 bool* set_stream_analog_level_called) {
73 if (msg.has_input_data()) { 74 if (msg.has_input_data()) {
74 // Fixed interface processing. 75 // Fixed interface processing.
75 // Verify interface invariance. 76 // Verify interface invariance.
76 RTC_CHECK(interface_used_ == InterfaceType::kFixedInterface || 77 RTC_CHECK(interface_used_ == InterfaceType::kFixedInterface ||
77 interface_used_ == InterfaceType::kNotSpecified); 78 interface_used_ == InterfaceType::kNotSpecified);
78 interface_used_ = InterfaceType::kFixedInterface; 79 interface_used_ = InterfaceType::kFixedInterface;
79 80
80 // Populate input buffer. 81 // Populate input buffer.
81 RTC_CHECK_EQ(sizeof(fwd_frame_.data_[0]) * fwd_frame_.samples_per_channel_ * 82 RTC_CHECK_EQ(sizeof(*fwd_frame_.data()) * fwd_frame_.samples_per_channel_ *
82 fwd_frame_.num_channels_, 83 fwd_frame_.num_channels_,
83 msg.input_data().size()); 84 msg.input_data().size());
84 memcpy(fwd_frame_.data_, msg.input_data().data(), msg.input_data().size()); 85 memcpy(fwd_frame_.mutable_data(), msg.input_data().data(),
86 msg.input_data().size());
85 } else { 87 } else {
86 // Float interface processing. 88 // Float interface processing.
87 // Verify interface invariance. 89 // Verify interface invariance.
88 RTC_CHECK(interface_used_ == InterfaceType::kFloatInterface || 90 RTC_CHECK(interface_used_ == InterfaceType::kFloatInterface ||
89 interface_used_ == InterfaceType::kNotSpecified); 91 interface_used_ == InterfaceType::kNotSpecified);
90 interface_used_ = InterfaceType::kFloatInterface; 92 interface_used_ = InterfaceType::kFloatInterface;
91 93
92 RTC_CHECK_EQ(in_buf_->num_channels(), 94 RTC_CHECK_EQ(in_buf_->num_channels(),
93 static_cast<size_t>(msg.input_channel_size())); 95 static_cast<size_t>(msg.input_channel_size()));
94 96
95 // Populate input buffer. 97 // Populate input buffer.
96 for (size_t i = 0; i < in_buf_->num_channels(); ++i) { 98 for (size_t i = 0; i < in_buf_->num_channels(); ++i) {
97 RTC_CHECK_EQ(in_buf_->num_frames() * sizeof(*in_buf_->channels()[i]), 99 RTC_CHECK_EQ(in_buf_->num_frames() * sizeof(*in_buf_->channels()[i]),
98 msg.input_channel(i).size()); 100 msg.input_channel(i).size());
99 std::memcpy(in_buf_->channels()[i], msg.input_channel(i).data(), 101 std::memcpy(in_buf_->channels()[i], msg.input_channel(i).data(),
100 msg.input_channel(i).size()); 102 msg.input_channel(i).size());
101 } 103 }
102 } 104 }
103 105
104 if (artificial_nearend_buffer_reader_) { 106 if (artificial_nearend_buffer_reader_) {
105 if (artificial_nearend_buffer_reader_->Read( 107 if (artificial_nearend_buffer_reader_->Read(
106 artificial_nearend_buf_.get())) { 108 artificial_nearend_buf_.get())) {
107 if (msg.has_input_data()) { 109 if (msg.has_input_data()) {
110 int16_t* fwd_frame_data = fwd_frame_.mutable_data();
108 for (size_t k = 0; k < in_buf_->num_frames(); ++k) { 111 for (size_t k = 0; k < in_buf_->num_frames(); ++k) {
109 fwd_frame_.data_[k] = rtc::saturated_cast<int16_t>( 112 fwd_frame_data[k] = rtc::saturated_cast<int16_t>(
110 fwd_frame_.data_[k] + 113 fwd_frame_data[k] +
111 static_cast<int16_t>(32767 * 114 static_cast<int16_t>(32767 *
112 artificial_nearend_buf_->channels()[0][k])); 115 artificial_nearend_buf_->channels()[0][k]));
113 } 116 }
114 } else { 117 } else {
115 for (int i = 0; i < msg.input_channel_size(); ++i) { 118 for (int i = 0; i < msg.input_channel_size(); ++i) {
116 for (size_t k = 0; k < in_buf_->num_frames(); ++k) { 119 for (size_t k = 0; k < in_buf_->num_frames(); ++k) {
117 in_buf_->channels()[i][k] += 120 in_buf_->channels()[i][k] +=
118 artificial_nearend_buf_->channels()[0][k]; 121 artificial_nearend_buf_->channels()[0][k];
119 in_buf_->channels()[i][k] = std::min( 122 in_buf_->channels()[i][k] = std::min(
120 32767.f, std::max(-32768.f, in_buf_->channels()[i][k])); 123 32767.f, std::max(-32768.f, in_buf_->channels()[i][k]));
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 // Fixed interface processing. 187 // Fixed interface processing.
185 // Verify interface invariance. 188 // Verify interface invariance.
186 RTC_CHECK(interface_used_ == InterfaceType::kFixedInterface || 189 RTC_CHECK(interface_used_ == InterfaceType::kFixedInterface ||
187 interface_used_ == InterfaceType::kNotSpecified); 190 interface_used_ == InterfaceType::kNotSpecified);
188 interface_used_ = InterfaceType::kFixedInterface; 191 interface_used_ = InterfaceType::kFixedInterface;
189 192
190 // Populate input buffer. 193 // Populate input buffer.
191 RTC_CHECK_EQ(sizeof(int16_t) * rev_frame_.samples_per_channel_ * 194 RTC_CHECK_EQ(sizeof(int16_t) * rev_frame_.samples_per_channel_ *
192 rev_frame_.num_channels_, 195 rev_frame_.num_channels_,
193 msg.data().size()); 196 msg.data().size());
194 memcpy(rev_frame_.data_, msg.data().data(), msg.data().size()); 197 memcpy(rev_frame_.mutable_data(), msg.data().data(), msg.data().size());
195 } else { 198 } else {
196 // Float interface processing. 199 // Float interface processing.
197 // Verify interface invariance. 200 // Verify interface invariance.
198 RTC_CHECK(interface_used_ == InterfaceType::kFloatInterface || 201 RTC_CHECK(interface_used_ == InterfaceType::kFloatInterface ||
199 interface_used_ == InterfaceType::kNotSpecified); 202 interface_used_ == InterfaceType::kNotSpecified);
200 interface_used_ = InterfaceType::kFloatInterface; 203 interface_used_ = InterfaceType::kFloatInterface;
201 204
202 RTC_CHECK_EQ(reverse_in_buf_->num_channels(), 205 RTC_CHECK_EQ(reverse_in_buf_->num_channels(),
203 static_cast<size_t>(msg.channel_size())); 206 static_cast<size_t>(msg.channel_size()));
204 207
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 } 577 }
575 578
576 void AecDumpBasedSimulator::HandleMessage( 579 void AecDumpBasedSimulator::HandleMessage(
577 const webrtc::audioproc::ReverseStream& msg) { 580 const webrtc::audioproc::ReverseStream& msg) {
578 PrepareReverseProcessStreamCall(msg); 581 PrepareReverseProcessStreamCall(msg);
579 ProcessReverseStream(interface_used_ == InterfaceType::kFixedInterface); 582 ProcessReverseStream(interface_used_ == InterfaceType::kFixedInterface);
580 } 583 }
581 584
582 } // namespace test 585 } // namespace test
583 } // namespace webrtc 586 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698