| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 } | 48 } |
| 49 | 49 |
| 50 DecimatorBy4 decimator; | 50 DecimatorBy4 decimator; |
| 51 std::array<float, kSubBlockSize * kNumBlocks> output; | 51 std::array<float, kSubBlockSize * kNumBlocks> output; |
| 52 | 52 |
| 53 for (size_t k = 0; k < kNumBlocks; ++k) { | 53 for (size_t k = 0; k < kNumBlocks; ++k) { |
| 54 std::array<float, kSubBlockSize> sub_block; | 54 std::array<float, kSubBlockSize> sub_block; |
| 55 | 55 |
| 56 decimator.Decimate( | 56 decimator.Decimate( |
| 57 rtc::ArrayView<const float>(&input[k * kBlockSize], kBlockSize), | 57 rtc::ArrayView<const float>(&input[k * kBlockSize], kBlockSize), |
| 58 &sub_block); | 58 sub_block); |
| 59 | 59 |
| 60 std::copy(sub_block.begin(), sub_block.end(), | 60 std::copy(sub_block.begin(), sub_block.end(), |
| 61 output.begin() + k * kSubBlockSize); | 61 output.begin() + k * kSubBlockSize); |
| 62 } | 62 } |
| 63 | 63 |
| 64 ASSERT_GT(kNumBlocks, kNumStartupBlocks); | 64 ASSERT_GT(kNumBlocks, kNumStartupBlocks); |
| 65 rtc::ArrayView<const float> input_to_evaluate( | 65 rtc::ArrayView<const float> input_to_evaluate( |
| 66 &input[kNumStartupBlocks * kBlockSize], | 66 &input[kNumStartupBlocks * kBlockSize], |
| 67 (kNumBlocks - kNumStartupBlocks) * kBlockSize); | 67 (kNumBlocks - kNumStartupBlocks) * kBlockSize); |
| 68 rtc::ArrayView<const float> output_to_evaluate( | 68 rtc::ArrayView<const float> output_to_evaluate( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 EXPECT_LT(0.7f * input_power, output_power); | 105 EXPECT_LT(0.7f * input_power, output_power); |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) | 109 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
| 110 // Verifies the check for the input size. | 110 // Verifies the check for the input size. |
| 111 TEST(DecimatorBy4, WrongInputSize) { | 111 TEST(DecimatorBy4, WrongInputSize) { |
| 112 DecimatorBy4 decimator; | 112 DecimatorBy4 decimator; |
| 113 std::vector<float> x(std::vector<float>(kBlockSize - 1, 0.f)); | 113 std::vector<float> x(std::vector<float>(kBlockSize - 1, 0.f)); |
| 114 std::array<float, kSubBlockSize> x_downsampled; | 114 std::array<float, kSubBlockSize> x_downsampled; |
| 115 EXPECT_DEATH(decimator.Decimate(x, &x_downsampled), ""); | 115 EXPECT_DEATH(decimator.Decimate(x, x_downsampled), ""); |
| 116 } | 116 } |
| 117 | 117 |
| 118 // Verifies the check for non-null output parameter. | 118 // Verifies the check for non-null output parameter. |
| 119 TEST(DecimatorBy4, NullOutput) { | 119 TEST(DecimatorBy4, NullOutput) { |
| 120 DecimatorBy4 decimator; | 120 DecimatorBy4 decimator; |
| 121 std::vector<float> x(std::vector<float>(kBlockSize, 0.f)); | 121 std::vector<float> x(std::vector<float>(kBlockSize, 0.f)); |
| 122 EXPECT_DEATH(decimator.Decimate(x, nullptr), ""); | 122 EXPECT_DEATH(decimator.Decimate(x, nullptr), ""); |
| 123 } | 123 } |
| 124 | 124 |
| 125 #endif | 125 #endif |
| 126 | 126 |
| 127 } // namespace webrtc | 127 } // namespace webrtc |
| OLD | NEW |