| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // MSVC++ requires this to be set before any other includes to get M_PI. | 5 // MSVC++ requires this to be set before any other includes to get M_PI. |
| 6 #define _USE_MATH_DEFINES | 6 #define _USE_MATH_DEFINES |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/bind.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/aligned_memory.h" | 13 #include "base/memory/aligned_memory.h" |
| 13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/stringize_macros.h" | 15 #include "base/strings/stringize_macros.h" |
| 15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 #include "media/base/sinc_resampler.h" |
| 16 #include "media/base/vector_math.h" | 18 #include "media/base/vector_math.h" |
| 17 #include "media/base/vector_math_testing.h" | 19 #include "media/base/vector_math_testing.h" |
| 20 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 22 |
| 20 using std::fill; | 23 using std::fill; |
| 21 | 24 |
| 22 namespace media { | 25 namespace media { |
| 23 | 26 |
| 24 // Default test values. | 27 // Default test values. |
| 25 static const float kScale = 0.5; | 28 static const float kScale = 0.5; |
| 26 static const float kInputFillValue = 1.0; | 29 static const float kInputFillValue = 1.0; |
| 27 static const float kOutputFillValue = 3.0; | 30 static const float kOutputFillValue = 3.0; |
| 28 static const int kVectorSize = 8192; | 31 static const int kVectorSize = 8192; |
| 29 | 32 |
| 33 // Helper class to ensure ChunkedResample() functions properly. |
| 34 class MockSource { |
| 35 public: |
| 36 MOCK_METHOD2(ProvideInput, void(int frames, float* destination)); |
| 37 }; |
| 38 |
| 30 class VectorMathTest : public testing::Test { | 39 class VectorMathTest : public testing::Test { |
| 31 public: | 40 public: |
| 32 | |
| 33 VectorMathTest() { | 41 VectorMathTest() { |
| 34 // Initialize input and output vectors. | 42 // Initialize input and output vectors. |
| 35 input_vector_.reset(static_cast<float*>(base::AlignedAlloc( | 43 input_vector_.reset(static_cast<float*>(base::AlignedAlloc( |
| 36 sizeof(float) * kVectorSize, vector_math::kRequiredAlignment))); | 44 sizeof(float) * kVectorSize, vector_math::kRequiredAlignment))); |
| 37 output_vector_.reset(static_cast<float*>(base::AlignedAlloc( | 45 output_vector_.reset(static_cast<float*>(base::AlignedAlloc( |
| 38 sizeof(float) * kVectorSize, vector_math::kRequiredAlignment))); | 46 sizeof(float) * kVectorSize, vector_math::kRequiredAlignment))); |
| 39 } | 47 } |
| 40 | 48 |
| 41 void FillTestVectors(float input, float output) { | 49 void FillTestVectors(float input, float output) { |
| 42 // Setup input and output vectors. | 50 // Setup input and output vectors. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 56 DISALLOW_COPY_AND_ASSIGN(VectorMathTest); | 64 DISALLOW_COPY_AND_ASSIGN(VectorMathTest); |
| 57 }; | 65 }; |
| 58 | 66 |
| 59 // Ensure each optimized vector_math::FMAC() method returns the same value. | 67 // Ensure each optimized vector_math::FMAC() method returns the same value. |
| 60 TEST_F(VectorMathTest, FMAC) { | 68 TEST_F(VectorMathTest, FMAC) { |
| 61 static const float kResult = kInputFillValue * kScale + kOutputFillValue; | 69 static const float kResult = kInputFillValue * kScale + kOutputFillValue; |
| 62 | 70 |
| 63 { | 71 { |
| 64 SCOPED_TRACE("FMAC"); | 72 SCOPED_TRACE("FMAC"); |
| 65 FillTestVectors(kInputFillValue, kOutputFillValue); | 73 FillTestVectors(kInputFillValue, kOutputFillValue); |
| 66 vector_math::FMAC( | 74 vector_math::FMAC(input_vector_.get(), kScale, kVectorSize, |
| 67 input_vector_.get(), kScale, kVectorSize, output_vector_.get()); | 75 output_vector_.get()); |
| 68 VerifyOutput(kResult); | 76 VerifyOutput(kResult); |
| 69 } | 77 } |
| 70 | 78 |
| 71 { | 79 { |
| 72 SCOPED_TRACE("FMAC_C"); | 80 SCOPED_TRACE("FMAC_C"); |
| 73 FillTestVectors(kInputFillValue, kOutputFillValue); | 81 FillTestVectors(kInputFillValue, kOutputFillValue); |
| 74 vector_math::FMAC_C( | 82 vector_math::FMAC_C(input_vector_.get(), kScale, kVectorSize, |
| 75 input_vector_.get(), kScale, kVectorSize, output_vector_.get()); | 83 output_vector_.get()); |
| 76 VerifyOutput(kResult); | 84 VerifyOutput(kResult); |
| 77 } | 85 } |
| 78 | 86 |
| 79 #if defined(ARCH_CPU_X86_FAMILY) | 87 #if defined(ARCH_CPU_X86_FAMILY) |
| 80 { | 88 { |
| 81 SCOPED_TRACE("FMAC_SSE"); | 89 SCOPED_TRACE("FMAC_SSE"); |
| 82 FillTestVectors(kInputFillValue, kOutputFillValue); | 90 FillTestVectors(kInputFillValue, kOutputFillValue); |
| 83 vector_math::FMAC_SSE( | 91 vector_math::FMAC_SSE(input_vector_.get(), kScale, kVectorSize, |
| 84 input_vector_.get(), kScale, kVectorSize, output_vector_.get()); | 92 output_vector_.get()); |
| 85 VerifyOutput(kResult); | 93 VerifyOutput(kResult); |
| 86 } | 94 } |
| 87 #endif | 95 #endif |
| 88 | 96 |
| 89 #if defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON) | 97 #if defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON) |
| 90 { | 98 { |
| 91 SCOPED_TRACE("FMAC_NEON"); | 99 SCOPED_TRACE("FMAC_NEON"); |
| 92 FillTestVectors(kInputFillValue, kOutputFillValue); | 100 FillTestVectors(kInputFillValue, kOutputFillValue); |
| 93 vector_math::FMAC_NEON( | 101 vector_math::FMAC_NEON(input_vector_.get(), kScale, kVectorSize, |
| 94 input_vector_.get(), kScale, kVectorSize, output_vector_.get()); | 102 output_vector_.get()); |
| 95 VerifyOutput(kResult); | 103 VerifyOutput(kResult); |
| 96 } | 104 } |
| 97 #endif | 105 #endif |
| 98 } | 106 } |
| 99 | 107 |
| 100 // Ensure each optimized vector_math::FMUL() method returns the same value. | 108 // Ensure each optimized vector_math::FMUL() method returns the same value. |
| 101 TEST_F(VectorMathTest, FMUL) { | 109 TEST_F(VectorMathTest, FMUL) { |
| 102 static const float kResult = kInputFillValue * kScale; | 110 static const float kResult = kInputFillValue * kScale; |
| 103 | 111 |
| 104 { | 112 { |
| 105 SCOPED_TRACE("FMUL"); | 113 SCOPED_TRACE("FMUL"); |
| 106 FillTestVectors(kInputFillValue, kOutputFillValue); | 114 FillTestVectors(kInputFillValue, kOutputFillValue); |
| 107 vector_math::FMUL( | 115 vector_math::FMUL(input_vector_.get(), kScale, kVectorSize, |
| 108 input_vector_.get(), kScale, kVectorSize, output_vector_.get()); | 116 output_vector_.get()); |
| 109 VerifyOutput(kResult); | 117 VerifyOutput(kResult); |
| 110 } | 118 } |
| 111 | 119 |
| 112 { | 120 { |
| 113 SCOPED_TRACE("FMUL_C"); | 121 SCOPED_TRACE("FMUL_C"); |
| 114 FillTestVectors(kInputFillValue, kOutputFillValue); | 122 FillTestVectors(kInputFillValue, kOutputFillValue); |
| 115 vector_math::FMUL_C( | 123 vector_math::FMUL_C(input_vector_.get(), kScale, kVectorSize, |
| 116 input_vector_.get(), kScale, kVectorSize, output_vector_.get()); | 124 output_vector_.get()); |
| 117 VerifyOutput(kResult); | 125 VerifyOutput(kResult); |
| 118 } | 126 } |
| 119 | 127 |
| 120 #if defined(ARCH_CPU_X86_FAMILY) | 128 #if defined(ARCH_CPU_X86_FAMILY) |
| 121 { | 129 { |
| 122 SCOPED_TRACE("FMUL_SSE"); | 130 SCOPED_TRACE("FMUL_SSE"); |
| 123 FillTestVectors(kInputFillValue, kOutputFillValue); | 131 FillTestVectors(kInputFillValue, kOutputFillValue); |
| 124 vector_math::FMUL_SSE( | 132 vector_math::FMUL_SSE(input_vector_.get(), kScale, kVectorSize, |
| 125 input_vector_.get(), kScale, kVectorSize, output_vector_.get()); | 133 output_vector_.get()); |
| 126 VerifyOutput(kResult); | 134 VerifyOutput(kResult); |
| 127 } | 135 } |
| 128 #endif | 136 #endif |
| 129 | 137 |
| 130 #if defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON) | 138 #if defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON) |
| 131 { | 139 { |
| 132 SCOPED_TRACE("FMUL_NEON"); | 140 SCOPED_TRACE("FMUL_NEON"); |
| 133 FillTestVectors(kInputFillValue, kOutputFillValue); | 141 FillTestVectors(kInputFillValue, kOutputFillValue); |
| 134 vector_math::FMUL_NEON( | 142 vector_math::FMUL_NEON(input_vector_.get(), kScale, kVectorSize, |
| 135 input_vector_.get(), kScale, kVectorSize, output_vector_.get()); | 143 output_vector_.get()); |
| 136 VerifyOutput(kResult); | 144 VerifyOutput(kResult); |
| 137 } | 145 } |
| 138 #endif | 146 #endif |
| 139 } | 147 } |
| 140 | 148 |
| 141 TEST_F(VectorMathTest, Crossfade) { | 149 // Define platform independent function name for Convolve* tests. |
| 142 FillTestVectors(0, 1); | 150 #if defined(ARCH_CPU_X86_FAMILY) |
| 143 vector_math::Crossfade( | 151 #define CONVOLVE_FUNC Convolve_SSE |
| 144 input_vector_.get(), kVectorSize, output_vector_.get()); | 152 #elif defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON) |
| 145 for (int i = 0; i < kVectorSize; ++i) { | 153 #define CONVOLVE_FUNC Convolve_NEON |
| 146 ASSERT_FLOAT_EQ(i / static_cast<float>(kVectorSize), output_vector_[i]) | 154 #endif |
| 147 << "i=" << i; | 155 |
| 148 } | 156 // Ensure various optimized Convolve() methods return the same value. Only run |
| 157 // this test if other optimized methods exist, otherwise the default Convolve() |
| 158 // will be tested by the parameterized SincResampler tests below. |
| 159 #if defined(CONVOLVE_FUNC) |
| 160 static const double kKernelInterpolationFactor = 0.5; |
| 161 |
| 162 TEST_F(VectorMathTest, Convolve) { |
| 163 // Initialize a dummy resampler. |
| 164 MockSource mock_source; |
| 165 SincResampler resampler( |
| 166 192000.0 / 44100.0, SincResampler::kDefaultRequestSize, |
| 167 base::Bind(&MockSource::ProvideInput, base::Unretained(&mock_source))); |
| 168 |
| 169 // The optimized Convolve methods are slightly more precise than Convolve_C(), |
| 170 // so comparison must be done using an epsilon. |
| 171 static const double kEpsilon = 0.00000005; |
| 172 |
| 173 // Use a kernel from SincResampler as input and kernel data, this has the |
| 174 // benefit of already being properly sized and aligned for Convolve_SSE(). |
| 175 double result = vector_math::Convolve_C( |
| 176 resampler.get_kernel_for_testing(), resampler.get_kernel_for_testing(), |
| 177 resampler.get_kernel_for_testing(), kKernelInterpolationFactor); |
| 178 double result2 = vector_math::CONVOLVE_FUNC( |
| 179 resampler.get_kernel_for_testing(), resampler.get_kernel_for_testing(), |
| 180 resampler.get_kernel_for_testing(), kKernelInterpolationFactor); |
| 181 EXPECT_NEAR(result2, result, kEpsilon); |
| 182 |
| 183 // Test Convolve() w/ unaligned input pointer. |
| 184 result = vector_math::Convolve_C(resampler.get_kernel_for_testing() + 1, |
| 185 resampler.get_kernel_for_testing(), |
| 186 resampler.get_kernel_for_testing(), |
| 187 kKernelInterpolationFactor); |
| 188 result2 = vector_math::CONVOLVE_FUNC(resampler.get_kernel_for_testing() + 1, |
| 189 resampler.get_kernel_for_testing(), |
| 190 resampler.get_kernel_for_testing(), |
| 191 kKernelInterpolationFactor); |
| 192 EXPECT_NEAR(result2, result, kEpsilon); |
| 149 } | 193 } |
| 194 #endif |
| 150 | 195 |
| 151 class EWMATestScenario { | 196 class EWMATestScenario { |
| 152 public: | 197 public: |
| 153 EWMATestScenario(float initial_value, const float src[], int len, | 198 EWMATestScenario(float initial_value, |
| 199 const float src[], |
| 200 int len, |
| 154 float smoothing_factor) | 201 float smoothing_factor) |
| 155 : initial_value_(initial_value), | 202 : initial_value_(initial_value), |
| 156 data_(static_cast<float*>( | 203 data_(static_cast<float*>( |
| 157 len == 0 ? NULL : | 204 len == 0 ? NULL |
| 158 base::AlignedAlloc(len * sizeof(float), | 205 : base::AlignedAlloc(len * sizeof(float), |
| 159 vector_math::kRequiredAlignment))), | 206 vector_math::kRequiredAlignment))), |
| 160 data_len_(len), | 207 data_len_(len), |
| 161 smoothing_factor_(smoothing_factor), | 208 smoothing_factor_(smoothing_factor), |
| 162 expected_final_avg_(initial_value), | 209 expected_final_avg_(initial_value), |
| 163 expected_max_(0.0f) { | 210 expected_max_(0.0f) { |
| 164 if (data_len_ > 0) | 211 if (data_len_ > 0) |
| 165 memcpy(data_.get(), src, len * sizeof(float)); | 212 memcpy(data_.get(), src, len * sizeof(float)); |
| 166 } | 213 } |
| 167 | 214 |
| 168 // Copy constructor and assignment operator for ::testing::Values(...). | 215 // Copy constructor and assignment operator for ::testing::Values(...). |
| 169 EWMATestScenario(const EWMATestScenario& other) { *this = other; } | 216 EWMATestScenario(const EWMATestScenario& other) { *this = other; } |
| 170 EWMATestScenario& operator=(const EWMATestScenario& other) { | 217 EWMATestScenario& operator=(const EWMATestScenario& other) { |
| 171 this->initial_value_ = other.initial_value_; | 218 this->initial_value_ = other.initial_value_; |
| 172 this->smoothing_factor_ = other.smoothing_factor_; | 219 this->smoothing_factor_ = other.smoothing_factor_; |
| 173 if (other.data_len_ == 0) { | 220 if (other.data_len_ == 0) { |
| 174 this->data_.reset(); | 221 this->data_.reset(); |
| 175 } else { | 222 } else { |
| 176 this->data_.reset(static_cast<float*>( | 223 this->data_.reset(static_cast<float*>(base::AlignedAlloc( |
| 177 base::AlignedAlloc(other.data_len_ * sizeof(float), | 224 other.data_len_ * sizeof(float), vector_math::kRequiredAlignment))); |
| 178 vector_math::kRequiredAlignment))); | |
| 179 memcpy(this->data_.get(), other.data_.get(), | 225 memcpy(this->data_.get(), other.data_.get(), |
| 180 other.data_len_ * sizeof(float)); | 226 other.data_len_ * sizeof(float)); |
| 181 } | 227 } |
| 182 this->data_len_ = other.data_len_; | 228 this->data_len_ = other.data_len_; |
| 183 this->expected_final_avg_ = other.expected_final_avg_; | 229 this->expected_final_avg_ = other.expected_final_avg_; |
| 184 this->expected_max_ = other.expected_max_; | 230 this->expected_max_ = other.expected_max_; |
| 185 return *this; | 231 return *this; |
| 186 } | 232 } |
| 187 | 233 |
| 188 EWMATestScenario ScaledBy(float scale) const { | 234 EWMATestScenario ScaledBy(float scale) const { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 float expected_max_; | 301 float expected_max_; |
| 256 }; | 302 }; |
| 257 | 303 |
| 258 typedef testing::TestWithParam<EWMATestScenario> VectorMathEWMAAndMaxPowerTest; | 304 typedef testing::TestWithParam<EWMATestScenario> VectorMathEWMAAndMaxPowerTest; |
| 259 | 305 |
| 260 TEST_P(VectorMathEWMAAndMaxPowerTest, Correctness) { | 306 TEST_P(VectorMathEWMAAndMaxPowerTest, Correctness) { |
| 261 GetParam().RunTest(); | 307 GetParam().RunTest(); |
| 262 } | 308 } |
| 263 | 309 |
| 264 static const float kZeros[] = { // 32 zeros | 310 static const float kZeros[] = { // 32 zeros |
| 265 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 311 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 266 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | 312 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; |
| 267 }; | |
| 268 | 313 |
| 269 static const float kOnes[] = { // 32 ones | 314 static const float kOnes[] = { // 32 ones |
| 270 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 315 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 271 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 | 316 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; |
| 272 }; | |
| 273 | 317 |
| 274 static const float kCheckerboard[] = { // 32 alternating 0, 1 | 318 static const float kCheckerboard[] = { // 32 alternating 0, 1 |
| 275 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, | 319 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, |
| 276 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 | 320 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1}; |
| 277 }; | |
| 278 | 321 |
| 279 static const float kInverseCheckerboard[] = { // 32 alternating 1, 0 | 322 static const float kInverseCheckerboard[] = { // 32 alternating 1, 0 |
| 280 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, | 323 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, |
| 281 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 | 324 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0}; |
| 282 }; | |
| 283 | 325 |
| 284 INSTANTIATE_TEST_CASE_P( | 326 INSTANTIATE_TEST_CASE_P( |
| 285 Scenarios, VectorMathEWMAAndMaxPowerTest, | 327 Scenarios, |
| 328 VectorMathEWMAAndMaxPowerTest, |
| 286 ::testing::Values( | 329 ::testing::Values( |
| 287 // Zero-length input: Result should equal initial value. | 330 // Zero-length input: Result should equal initial value. |
| 288 EWMATestScenario(0.0f, NULL, 0, 0.0f).HasExpectedResult(0.0f, 0.0f), | 331 EWMATestScenario(0.0f, NULL, 0, 0.0f).HasExpectedResult(0.0f, 0.0f), |
| 289 EWMATestScenario(1.0f, NULL, 0, 0.0f).HasExpectedResult(1.0f, 0.0f), | 332 EWMATestScenario(1.0f, NULL, 0, 0.0f).HasExpectedResult(1.0f, 0.0f), |
| 290 | 333 |
| 291 // Smoothing factor of zero: Samples have no effect on result. | 334 // Smoothing factor of zero: Samples have no effect on result. |
| 292 EWMATestScenario(0.0f, kOnes, 32, 0.0f).HasExpectedResult(0.0f, 1.0f), | 335 EWMATestScenario(0.0f, kOnes, 32, 0.0f).HasExpectedResult(0.0f, 1.0f), |
| 293 EWMATestScenario(1.0f, kZeros, 32, 0.0f).HasExpectedResult(1.0f, 0.0f), | 336 EWMATestScenario(1.0f, kZeros, 32, 0.0f).HasExpectedResult(1.0f, 0.0f), |
| 294 | 337 |
| 295 // Smothing factor of one: Result = last sample squared. | 338 // Smothing factor of one: Result = last sample squared. |
| 296 EWMATestScenario(0.0f, kCheckerboard, 32, 1.0f) | 339 EWMATestScenario(0.0f, kCheckerboard, 32, 1.0f) |
| 297 .ScaledBy(2.0f) | 340 .ScaledBy(2.0f) |
| 298 .HasExpectedResult(4.0f, 4.0f), | 341 .HasExpectedResult(4.0f, 4.0f), |
| 299 EWMATestScenario(1.0f, kInverseCheckerboard, 32, 1.0f) | 342 EWMATestScenario(1.0f, kInverseCheckerboard, 32, 1.0f) |
| 300 .ScaledBy(2.0f) | 343 .ScaledBy(2.0f) |
| 301 .HasExpectedResult(0.0f, 4.0f), | 344 .HasExpectedResult(0.0f, 4.0f), |
| 302 | 345 |
| 303 // Smoothing factor of 1/4, muted signal. | 346 // Smoothing factor of 1/4, muted signal. |
| 304 EWMATestScenario(1.0f, kZeros, 1, 0.25f) | 347 EWMATestScenario(1.0f, kZeros, 1, 0.25f) |
| 305 .HasExpectedResult(powf(0.75, 1.0f), 0.0f), | 348 .HasExpectedResult(powf(0.75, 1.0f), 0.0f), |
| 306 EWMATestScenario(1.0f, kZeros, 2, 0.25f) | 349 EWMATestScenario(1.0f, kZeros, 2, 0.25f) |
| 307 .HasExpectedResult(powf(0.75, 2.0f), 0.0f), | 350 .HasExpectedResult(powf(0.75, 2.0f), 0.0f), |
| 308 EWMATestScenario(1.0f, kZeros, 3, 0.25f) | 351 EWMATestScenario(1.0f, kZeros, 3, 0.25f) |
| 309 .HasExpectedResult(powf(0.75, 3.0f), 0.0f), | 352 .HasExpectedResult(powf(0.75, 3.0f), 0.0f), |
| 310 EWMATestScenario(1.0f, kZeros, 12, 0.25f) | 353 EWMATestScenario(1.0f, kZeros, 12, 0.25f) |
| 311 .HasExpectedResult(powf(0.75, 12.0f), 0.0f), | 354 .HasExpectedResult(powf(0.75, 12.0f), 0.0f), |
| 312 EWMATestScenario(1.0f, kZeros, 13, 0.25f) | 355 EWMATestScenario(1.0f, kZeros, 13, 0.25f) |
| 313 .HasExpectedResult(powf(0.75, 13.0f), 0.0f), | 356 .HasExpectedResult(powf(0.75, 13.0f), 0.0f), |
| 314 EWMATestScenario(1.0f, kZeros, 14, 0.25f) | 357 EWMATestScenario(1.0f, kZeros, 14, 0.25f) |
| 315 .HasExpectedResult(powf(0.75, 14.0f), 0.0f), | 358 .HasExpectedResult(powf(0.75, 14.0f), 0.0f), |
| 316 EWMATestScenario(1.0f, kZeros, 15, 0.25f) | 359 EWMATestScenario(1.0f, kZeros, 15, 0.25f) |
| 317 .HasExpectedResult(powf(0.75, 15.0f), 0.0f), | 360 .HasExpectedResult(powf(0.75, 15.0f), 0.0f), |
| 318 | 361 |
| 319 // Smoothing factor of 1/4, constant full-amplitude signal. | 362 // Smoothing factor of 1/4, constant full-amplitude signal. |
| 320 EWMATestScenario(0.0f, kOnes, 1, 0.25f).HasExpectedResult(0.25f, 1.0f), | 363 EWMATestScenario(0.0f, kOnes, 1, 0.25f).HasExpectedResult(0.25f, 1.0f), |
| 321 EWMATestScenario(0.0f, kOnes, 2, 0.25f) | 364 EWMATestScenario(0.0f, kOnes, 2, 0.25f) |
| 322 .HasExpectedResult(0.4375f, 1.0f), | 365 .HasExpectedResult(0.4375f, 1.0f), |
| 323 EWMATestScenario(0.0f, kOnes, 3, 0.25f) | 366 EWMATestScenario(0.0f, kOnes, 3, 0.25f) |
| 324 .HasExpectedResult(0.578125f, 1.0f), | 367 .HasExpectedResult(0.578125f, 1.0f), |
| 325 EWMATestScenario(0.0f, kOnes, 12, 0.25f) | 368 EWMATestScenario(0.0f, kOnes, 12, 0.25f) |
| 326 .HasExpectedResult(0.96832365f, 1.0f), | 369 .HasExpectedResult(0.96832365f, 1.0f), |
| 327 EWMATestScenario(0.0f, kOnes, 13, 0.25f) | 370 EWMATestScenario(0.0f, kOnes, 13, 0.25f) |
| 328 .HasExpectedResult(0.97624274f, 1.0f), | 371 .HasExpectedResult(0.97624274f, 1.0f), |
| 329 EWMATestScenario(0.0f, kOnes, 14, 0.25f) | 372 EWMATestScenario(0.0f, kOnes, 14, 0.25f) |
| 330 .HasExpectedResult(0.98218205f, 1.0f), | 373 .HasExpectedResult(0.98218205f, 1.0f), |
| 331 EWMATestScenario(0.0f, kOnes, 15, 0.25f) | 374 EWMATestScenario(0.0f, kOnes, 15, 0.25f) |
| 332 .HasExpectedResult(0.98663654f, 1.0f), | 375 .HasExpectedResult(0.98663654f, 1.0f), |
| 333 | 376 |
| 334 // Smoothing factor of 1/4, checkerboard signal. | 377 // Smoothing factor of 1/4, checkerboard signal. |
| 335 EWMATestScenario(0.0f, kCheckerboard, 1, 0.25f) | 378 EWMATestScenario(0.0f, kCheckerboard, 1, 0.25f) |
| 336 .HasExpectedResult(0.0f, 0.0f), | 379 .HasExpectedResult(0.0f, 0.0f), |
| 337 EWMATestScenario(0.0f, kCheckerboard, 2, 0.25f) | 380 EWMATestScenario(0.0f, kCheckerboard, 2, 0.25f) |
| 338 .HasExpectedResult(0.25f, 1.0f), | 381 .HasExpectedResult(0.25f, 1.0f), |
| 339 EWMATestScenario(0.0f, kCheckerboard, 3, 0.25f) | 382 EWMATestScenario(0.0f, kCheckerboard, 3, 0.25f) |
| 340 .HasExpectedResult(0.1875f, 1.0f), | 383 .HasExpectedResult(0.1875f, 1.0f), |
| 341 EWMATestScenario(0.0f, kCheckerboard, 12, 0.25f) | 384 EWMATestScenario(0.0f, kCheckerboard, 12, 0.25f) |
| 342 .HasExpectedResult(0.55332780f, 1.0f), | 385 .HasExpectedResult(0.55332780f, 1.0f), |
| 343 EWMATestScenario(0.0f, kCheckerboard, 13, 0.25f) | 386 EWMATestScenario(0.0f, kCheckerboard, 13, 0.25f) |
| 344 .HasExpectedResult(0.41499585f, 1.0f), | 387 .HasExpectedResult(0.41499585f, 1.0f), |
| 345 EWMATestScenario(0.0f, kCheckerboard, 14, 0.25f) | 388 EWMATestScenario(0.0f, kCheckerboard, 14, 0.25f) |
| 346 .HasExpectedResult(0.56124689f, 1.0f), | 389 .HasExpectedResult(0.56124689f, 1.0f), |
| 347 EWMATestScenario(0.0f, kCheckerboard, 15, 0.25f) | 390 EWMATestScenario(0.0f, kCheckerboard, 15, 0.25f) |
| 348 .HasExpectedResult(0.42093517f, 1.0f), | 391 .HasExpectedResult(0.42093517f, 1.0f), |
| 349 | 392 |
| 350 // Smoothing factor of 1/4, inverse checkerboard signal. | 393 // Smoothing factor of 1/4, inverse checkerboard signal. |
| 351 EWMATestScenario(0.0f, kInverseCheckerboard, 1, 0.25f) | 394 EWMATestScenario(0.0f, kInverseCheckerboard, 1, 0.25f) |
| 352 .HasExpectedResult(0.25f, 1.0f), | 395 .HasExpectedResult(0.25f, 1.0f), |
| 353 EWMATestScenario(0.0f, kInverseCheckerboard, 2, 0.25f) | 396 EWMATestScenario(0.0f, kInverseCheckerboard, 2, 0.25f) |
| 354 .HasExpectedResult(0.1875f, 1.0f), | 397 .HasExpectedResult(0.1875f, 1.0f), |
| 355 EWMATestScenario(0.0f, kInverseCheckerboard, 3, 0.25f) | 398 EWMATestScenario(0.0f, kInverseCheckerboard, 3, 0.25f) |
| 356 .HasExpectedResult(0.390625f, 1.0f), | 399 .HasExpectedResult(0.390625f, 1.0f), |
| 357 EWMATestScenario(0.0f, kInverseCheckerboard, 12, 0.25f) | 400 EWMATestScenario(0.0f, kInverseCheckerboard, 12, 0.25f) |
| 358 .HasExpectedResult(0.41499585f, 1.0f), | 401 .HasExpectedResult(0.41499585f, 1.0f), |
| 359 EWMATestScenario(0.0f, kInverseCheckerboard, 13, 0.25f) | 402 EWMATestScenario(0.0f, kInverseCheckerboard, 13, 0.25f) |
| 360 .HasExpectedResult(0.56124689f, 1.0f), | 403 .HasExpectedResult(0.56124689f, 1.0f), |
| 361 EWMATestScenario(0.0f, kInverseCheckerboard, 14, 0.25f) | 404 EWMATestScenario(0.0f, kInverseCheckerboard, 14, 0.25f) |
| 362 .HasExpectedResult(0.42093517f, 1.0f), | 405 .HasExpectedResult(0.42093517f, 1.0f), |
| 363 EWMATestScenario(0.0f, kInverseCheckerboard, 15, 0.25f) | 406 EWMATestScenario(0.0f, kInverseCheckerboard, 15, 0.25f) |
| 364 .HasExpectedResult(0.56570137f, 1.0f), | 407 .HasExpectedResult(0.56570137f, 1.0f), |
| 365 | 408 |
| 366 // Smoothing factor of 1/4, impluse signal. | 409 // Smoothing factor of 1/4, impluse signal. |
| 367 EWMATestScenario(0.0f, kZeros, 3, 0.25f) | 410 EWMATestScenario(0.0f, kZeros, 3, 0.25f) |
| 368 .WithImpulse(2.0f, 0) | 411 .WithImpulse(2.0f, 0) |
| 369 .HasExpectedResult(0.562500f, 4.0f), | 412 .HasExpectedResult(0.562500f, 4.0f), |
| 370 EWMATestScenario(0.0f, kZeros, 3, 0.25f) | 413 EWMATestScenario(0.0f, kZeros, 3, 0.25f) |
| 371 .WithImpulse(2.0f, 1) | 414 .WithImpulse(2.0f, 1) |
| 372 .HasExpectedResult(0.75f, 4.0f), | 415 .HasExpectedResult(0.75f, 4.0f), |
| 373 EWMATestScenario(0.0f, kZeros, 3, 0.25f) | 416 EWMATestScenario(0.0f, kZeros, 3, 0.25f) |
| 374 .WithImpulse(2.0f, 2) | 417 .WithImpulse(2.0f, 2) |
| 375 .HasExpectedResult(1.0f, 4.0f), | 418 .HasExpectedResult(1.0f, 4.0f), |
| 376 EWMATestScenario(0.0f, kZeros, 32, 0.25f) | 419 EWMATestScenario(0.0f, kZeros, 32, 0.25f) |
| 377 .WithImpulse(2.0f, 0) | 420 .WithImpulse(2.0f, 0) |
| 378 .HasExpectedResult(0.00013394f, 4.0f), | 421 .HasExpectedResult(0.00013394f, 4.0f), |
| 379 EWMATestScenario(0.0f, kZeros, 32, 0.25f) | 422 EWMATestScenario(0.0f, kZeros, 32, 0.25f) |
| 380 .WithImpulse(2.0f, 1) | 423 .WithImpulse(2.0f, 1) |
| 381 .HasExpectedResult(0.00017858f, 4.0f), | 424 .HasExpectedResult(0.00017858f, 4.0f), |
| 382 EWMATestScenario(0.0f, kZeros, 32, 0.25f) | 425 EWMATestScenario(0.0f, kZeros, 32, 0.25f) |
| 383 .WithImpulse(2.0f, 2) | 426 .WithImpulse(2.0f, 2) |
| 384 .HasExpectedResult(0.00023811f, 4.0f), | 427 .HasExpectedResult(0.00023811f, 4.0f), |
| 385 EWMATestScenario(0.0f, kZeros, 32, 0.25f) | 428 EWMATestScenario(0.0f, kZeros, 32, 0.25f) |
| 386 .WithImpulse(2.0f, 3) | 429 .WithImpulse(2.0f, 3) |
| 387 .HasExpectedResult(0.00031748f, 4.0f) | 430 .HasExpectedResult(0.00031748f, 4.0f))); |
| 388 )); | |
| 389 | 431 |
| 390 } // namespace media | 432 } // namespace media |
| OLD | NEW |