| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 void VerifyChannelsAreEqual(int16_t* stereo, int samples_per_channel) { | 125 void VerifyChannelsAreEqual(int16_t* stereo, int samples_per_channel) { |
| 126 for (int i = 0; i < samples_per_channel; i++) { | 126 for (int i = 0; i < samples_per_channel; i++) { |
| 127 EXPECT_EQ(stereo[i * 2 + 1], stereo[i * 2]); | 127 EXPECT_EQ(stereo[i * 2 + 1], stereo[i * 2]); |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 | 130 |
| 131 void SetFrameTo(AudioFrame* frame, int16_t value) { | 131 void SetFrameTo(AudioFrame* frame, int16_t value) { |
| 132 for (int i = 0; i < frame->samples_per_channel_ * frame->num_channels_; ++i) { | 132 for (size_t i = 0; i < frame->samples_per_channel_ * frame->num_channels_; |
| 133 ++i) { |
| 133 frame->data_[i] = value; | 134 frame->data_[i] = value; |
| 134 } | 135 } |
| 135 } | 136 } |
| 136 | 137 |
| 137 void SetFrameTo(AudioFrame* frame, int16_t left, int16_t right) { | 138 void SetFrameTo(AudioFrame* frame, int16_t left, int16_t right) { |
| 138 ASSERT_EQ(2, frame->num_channels_); | 139 ASSERT_EQ(2, frame->num_channels_); |
| 139 for (int i = 0; i < frame->samples_per_channel_ * 2; i += 2) { | 140 for (size_t i = 0; i < frame->samples_per_channel_ * 2; i += 2) { |
| 140 frame->data_[i] = left; | 141 frame->data_[i] = left; |
| 141 frame->data_[i + 1] = right; | 142 frame->data_[i + 1] = right; |
| 142 } | 143 } |
| 143 } | 144 } |
| 144 | 145 |
| 145 void ScaleFrame(AudioFrame* frame, float scale) { | 146 void ScaleFrame(AudioFrame* frame, float scale) { |
| 146 for (int i = 0; i < frame->samples_per_channel_ * frame->num_channels_; ++i) { | 147 for (size_t i = 0; i < frame->samples_per_channel_ * frame->num_channels_; |
| 148 ++i) { |
| 147 frame->data_[i] = FloatS16ToS16(frame->data_[i] * scale); | 149 frame->data_[i] = FloatS16ToS16(frame->data_[i] * scale); |
| 148 } | 150 } |
| 149 } | 151 } |
| 150 | 152 |
| 151 bool FrameDataAreEqual(const AudioFrame& frame1, const AudioFrame& frame2) { | 153 bool FrameDataAreEqual(const AudioFrame& frame1, const AudioFrame& frame2) { |
| 152 if (frame1.samples_per_channel_ != frame2.samples_per_channel_) { | 154 if (frame1.samples_per_channel_ != frame2.samples_per_channel_) { |
| 153 return false; | 155 return false; |
| 154 } | 156 } |
| 155 if (frame1.num_channels_ != frame2.num_channels_) { | 157 if (frame1.num_channels_ != frame2.num_channels_) { |
| 156 return false; | 158 return false; |
| (...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 } | 671 } |
| 670 | 672 |
| 671 rewind(near_file_); | 673 rewind(near_file_); |
| 672 while (!frame_queue.empty()) { | 674 while (!frame_queue.empty()) { |
| 673 AudioFrame* frame = frame_queue.front(); | 675 AudioFrame* frame = frame_queue.front(); |
| 674 frame_queue.pop(); | 676 frame_queue.pop(); |
| 675 delete frame; | 677 delete frame; |
| 676 } | 678 } |
| 677 // Calculate expected delay estimate and acceptable regions. Further, | 679 // Calculate expected delay estimate and acceptable regions. Further, |
| 678 // limit them w.r.t. AEC delay estimation support. | 680 // limit them w.r.t. AEC delay estimation support. |
| 679 const int samples_per_ms = std::min(16, frame_->samples_per_channel_ / 10); | 681 const size_t samples_per_ms = |
| 682 std::min(static_cast<size_t>(16), frame_->samples_per_channel_ / 10); |
| 680 int expected_median = std::min(std::max(delay_ms - system_delay_ms, | 683 int expected_median = std::min(std::max(delay_ms - system_delay_ms, |
| 681 delay_min), delay_max); | 684 delay_min), delay_max); |
| 682 int expected_median_high = std::min(std::max( | 685 int expected_median_high = std::min( |
| 683 expected_median + 96 / samples_per_ms, delay_min), delay_max); | 686 std::max(expected_median + static_cast<int>(96 / samples_per_ms), |
| 684 int expected_median_low = std::min(std::max( | 687 delay_min), |
| 685 expected_median - 96 / samples_per_ms, delay_min), delay_max); | 688 delay_max); |
| 689 int expected_median_low = std::min( |
| 690 std::max(expected_median - static_cast<int>(96 / samples_per_ms), |
| 691 delay_min), |
| 692 delay_max); |
| 686 // Verify delay metrics. | 693 // Verify delay metrics. |
| 687 int median; | 694 int median; |
| 688 int std; | 695 int std; |
| 689 float poor_fraction; | 696 float poor_fraction; |
| 690 EXPECT_EQ(apm_->kNoError, | 697 EXPECT_EQ(apm_->kNoError, |
| 691 apm_->echo_cancellation()->GetDelayMetrics(&median, &std, | 698 apm_->echo_cancellation()->GetDelayMetrics(&median, &std, |
| 692 &poor_fraction)); | 699 &poor_fraction)); |
| 693 EXPECT_GE(expected_median_high, median); | 700 EXPECT_GE(expected_median_high, median); |
| 694 EXPECT_LE(expected_median_low, median); | 701 EXPECT_LE(expected_median_low, median); |
| 695 } | 702 } |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 // sampling frequency dependent. | 998 // sampling frequency dependent. |
| 992 for (size_t i = 0; i < kProcessSampleRatesSize; i++) { | 999 for (size_t i = 0; i < kProcessSampleRatesSize; i++) { |
| 993 Init(kProcessSampleRates[i], | 1000 Init(kProcessSampleRates[i], |
| 994 kProcessSampleRates[i], | 1001 kProcessSampleRates[i], |
| 995 kProcessSampleRates[i], | 1002 kProcessSampleRates[i], |
| 996 2, | 1003 2, |
| 997 2, | 1004 2, |
| 998 2, | 1005 2, |
| 999 false); | 1006 false); |
| 1000 // Sampling frequency dependent variables. | 1007 // Sampling frequency dependent variables. |
| 1001 const int num_ms_per_block = std::max(4, | 1008 const int num_ms_per_block = |
| 1002 640 / frame_->samples_per_channel_); | 1009 std::max(4, static_cast<int>(640 / frame_->samples_per_channel_)); |
| 1003 const int delay_min_ms = -kLookaheadBlocks * num_ms_per_block; | 1010 const int delay_min_ms = -kLookaheadBlocks * num_ms_per_block; |
| 1004 const int delay_max_ms = (kMaxDelayBlocks - 1) * num_ms_per_block; | 1011 const int delay_max_ms = (kMaxDelayBlocks - 1) * num_ms_per_block; |
| 1005 | 1012 |
| 1006 // 1) Verify correct delay estimate at lookahead boundary. | 1013 // 1) Verify correct delay estimate at lookahead boundary. |
| 1007 int delay_ms = TruncateToMultipleOf10(kSystemDelayMs + delay_min_ms); | 1014 int delay_ms = TruncateToMultipleOf10(kSystemDelayMs + delay_min_ms); |
| 1008 ProcessDelayVerificationTest(delay_ms, kSystemDelayMs, delay_min_ms, | 1015 ProcessDelayVerificationTest(delay_ms, kSystemDelayMs, delay_min_ms, |
| 1009 delay_max_ms); | 1016 delay_max_ms); |
| 1010 // 2) A delay less than maximum lookahead should give an delay estimate at | 1017 // 2) A delay less than maximum lookahead should give an delay estimate at |
| 1011 // the boundary (= -kLookaheadBlocks * num_ms_per_block). | 1018 // the boundary (= -kLookaheadBlocks * num_ms_per_block). |
| 1012 delay_ms -= 20; | 1019 delay_ms -= 20; |
| (...skipping 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2741 std::tr1::make_tuple(16000, 16000, 32000, 16000, 40, 20), | 2748 std::tr1::make_tuple(16000, 16000, 32000, 16000, 40, 20), |
| 2742 std::tr1::make_tuple(16000, 16000, 16000, 16000, 0, 0))); | 2749 std::tr1::make_tuple(16000, 16000, 16000, 16000, 0, 0))); |
| 2743 #endif | 2750 #endif |
| 2744 | 2751 |
| 2745 // TODO(henrike): re-implement functionality lost when removing the old main | 2752 // TODO(henrike): re-implement functionality lost when removing the old main |
| 2746 // function. See | 2753 // function. See |
| 2747 // https://code.google.com/p/webrtc/issues/detail?id=1981 | 2754 // https://code.google.com/p/webrtc/issues/detail?id=1981 |
| 2748 | 2755 |
| 2749 } // namespace | 2756 } // namespace |
| 2750 } // namespace webrtc | 2757 } // namespace webrtc |
| OLD | NEW |