OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 void VerifyChannelsAreEqual(int16_t* stereo, int samples_per_channel) { | 120 void VerifyChannelsAreEqual(int16_t* stereo, int samples_per_channel) { |
121 for (int i = 0; i < samples_per_channel; i++) { | 121 for (int i = 0; i < samples_per_channel; i++) { |
122 EXPECT_EQ(stereo[i * 2 + 1], stereo[i * 2]); | 122 EXPECT_EQ(stereo[i * 2 + 1], stereo[i * 2]); |
123 } | 123 } |
124 } | 124 } |
125 | 125 |
126 void SetFrameTo(AudioFrame* frame, int16_t value) { | 126 void SetFrameTo(AudioFrame* frame, int16_t value) { |
127 for (int i = 0; i < frame->samples_per_channel_ * frame->num_channels_; ++i) { | 127 for (size_t i = 0; i < frame->samples_per_channel_ * frame->num_channels_; |
| 128 ++i) { |
128 frame->data_[i] = value; | 129 frame->data_[i] = value; |
129 } | 130 } |
130 } | 131 } |
131 | 132 |
132 void SetFrameTo(AudioFrame* frame, int16_t left, int16_t right) { | 133 void SetFrameTo(AudioFrame* frame, int16_t left, int16_t right) { |
133 ASSERT_EQ(2, frame->num_channels_); | 134 ASSERT_EQ(2, frame->num_channels_); |
134 for (int i = 0; i < frame->samples_per_channel_ * 2; i += 2) { | 135 for (size_t i = 0; i < frame->samples_per_channel_ * 2; i += 2) { |
135 frame->data_[i] = left; | 136 frame->data_[i] = left; |
136 frame->data_[i + 1] = right; | 137 frame->data_[i + 1] = right; |
137 } | 138 } |
138 } | 139 } |
139 | 140 |
140 void ScaleFrame(AudioFrame* frame, float scale) { | 141 void ScaleFrame(AudioFrame* frame, float scale) { |
141 for (int i = 0; i < frame->samples_per_channel_ * frame->num_channels_; ++i) { | 142 for (size_t i = 0; i < frame->samples_per_channel_ * frame->num_channels_; |
| 143 ++i) { |
142 frame->data_[i] = FloatS16ToS16(frame->data_[i] * scale); | 144 frame->data_[i] = FloatS16ToS16(frame->data_[i] * scale); |
143 } | 145 } |
144 } | 146 } |
145 | 147 |
146 bool FrameDataAreEqual(const AudioFrame& frame1, const AudioFrame& frame2) { | 148 bool FrameDataAreEqual(const AudioFrame& frame1, const AudioFrame& frame2) { |
147 if (frame1.samples_per_channel_ != frame2.samples_per_channel_) { | 149 if (frame1.samples_per_channel_ != frame2.samples_per_channel_) { |
148 return false; | 150 return false; |
149 } | 151 } |
150 if (frame1.num_channels_ != frame2.num_channels_) { | 152 if (frame1.num_channels_ != frame2.num_channels_) { |
151 return false; | 153 return false; |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 } | 652 } |
651 | 653 |
652 rewind(near_file_); | 654 rewind(near_file_); |
653 while (!frame_queue.empty()) { | 655 while (!frame_queue.empty()) { |
654 AudioFrame* frame = frame_queue.front(); | 656 AudioFrame* frame = frame_queue.front(); |
655 frame_queue.pop(); | 657 frame_queue.pop(); |
656 delete frame; | 658 delete frame; |
657 } | 659 } |
658 // Calculate expected delay estimate and acceptable regions. Further, | 660 // Calculate expected delay estimate and acceptable regions. Further, |
659 // limit them w.r.t. AEC delay estimation support. | 661 // limit them w.r.t. AEC delay estimation support. |
660 const int samples_per_ms = std::min(16, frame_->samples_per_channel_ / 10); | 662 const size_t samples_per_ms = |
| 663 std::min(static_cast<size_t>(16), frame_->samples_per_channel_ / 10); |
661 int expected_median = std::min(std::max(delay_ms - system_delay_ms, | 664 int expected_median = std::min(std::max(delay_ms - system_delay_ms, |
662 delay_min), delay_max); | 665 delay_min), delay_max); |
663 int expected_median_high = std::min(std::max( | 666 int expected_median_high = std::min( |
664 expected_median + 96 / samples_per_ms, delay_min), delay_max); | 667 std::max(expected_median + static_cast<int>(96 / samples_per_ms), |
665 int expected_median_low = std::min(std::max( | 668 delay_min), |
666 expected_median - 96 / samples_per_ms, delay_min), delay_max); | 669 delay_max); |
| 670 int expected_median_low = std::min( |
| 671 std::max(expected_median - static_cast<int>(96 / samples_per_ms), |
| 672 delay_min), |
| 673 delay_max); |
667 // Verify delay metrics. | 674 // Verify delay metrics. |
668 int median; | 675 int median; |
669 int std; | 676 int std; |
670 float poor_fraction; | 677 float poor_fraction; |
671 EXPECT_EQ(apm_->kNoError, | 678 EXPECT_EQ(apm_->kNoError, |
672 apm_->echo_cancellation()->GetDelayMetrics(&median, &std, | 679 apm_->echo_cancellation()->GetDelayMetrics(&median, &std, |
673 &poor_fraction)); | 680 &poor_fraction)); |
674 EXPECT_GE(expected_median_high, median); | 681 EXPECT_GE(expected_median_high, median); |
675 EXPECT_LE(expected_median_low, median); | 682 EXPECT_LE(expected_median_low, median); |
676 } | 683 } |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 // sampling frequency dependent. | 923 // sampling frequency dependent. |
917 for (size_t i = 0; i < kProcessSampleRatesSize; i++) { | 924 for (size_t i = 0; i < kProcessSampleRatesSize; i++) { |
918 Init(kProcessSampleRates[i], | 925 Init(kProcessSampleRates[i], |
919 kProcessSampleRates[i], | 926 kProcessSampleRates[i], |
920 kProcessSampleRates[i], | 927 kProcessSampleRates[i], |
921 2, | 928 2, |
922 2, | 929 2, |
923 2, | 930 2, |
924 false); | 931 false); |
925 // Sampling frequency dependent variables. | 932 // Sampling frequency dependent variables. |
926 const int num_ms_per_block = std::max(4, | 933 const int num_ms_per_block = |
927 640 / frame_->samples_per_channel_); | 934 std::max(4, static_cast<int>(640 / frame_->samples_per_channel_)); |
928 const int delay_min_ms = -kLookaheadBlocks * num_ms_per_block; | 935 const int delay_min_ms = -kLookaheadBlocks * num_ms_per_block; |
929 const int delay_max_ms = (kMaxDelayBlocks - 1) * num_ms_per_block; | 936 const int delay_max_ms = (kMaxDelayBlocks - 1) * num_ms_per_block; |
930 | 937 |
931 // 1) Verify correct delay estimate at lookahead boundary. | 938 // 1) Verify correct delay estimate at lookahead boundary. |
932 int delay_ms = TruncateToMultipleOf10(kSystemDelayMs + delay_min_ms); | 939 int delay_ms = TruncateToMultipleOf10(kSystemDelayMs + delay_min_ms); |
933 ProcessDelayVerificationTest(delay_ms, kSystemDelayMs, delay_min_ms, | 940 ProcessDelayVerificationTest(delay_ms, kSystemDelayMs, delay_min_ms, |
934 delay_max_ms); | 941 delay_max_ms); |
935 // 2) A delay less than maximum lookahead should give an delay estimate at | 942 // 2) A delay less than maximum lookahead should give an delay estimate at |
936 // the boundary (= -kLookaheadBlocks * num_ms_per_block). | 943 // the boundary (= -kLookaheadBlocks * num_ms_per_block). |
937 delay_ms -= 20; | 944 delay_ms -= 20; |
(...skipping 1682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2620 std::tr1::make_tuple(16000, 16000, 32000, 40), | 2627 std::tr1::make_tuple(16000, 16000, 32000, 40), |
2621 std::tr1::make_tuple(16000, 16000, 16000, 0))); | 2628 std::tr1::make_tuple(16000, 16000, 16000, 0))); |
2622 #endif | 2629 #endif |
2623 | 2630 |
2624 // TODO(henrike): re-implement functionality lost when removing the old main | 2631 // TODO(henrike): re-implement functionality lost when removing the old main |
2625 // function. See | 2632 // function. See |
2626 // https://code.google.com/p/webrtc/issues/detail?id=1981 | 2633 // https://code.google.com/p/webrtc/issues/detail?id=1981 |
2627 | 2634 |
2628 } // namespace | 2635 } // namespace |
2629 } // namespace webrtc | 2636 } // namespace webrtc |
OLD | NEW |