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

Side by Side Diff: media/base/vector_math_unittest.cc

Issue 308003004: Remove runtime CPU detection for SSE optimized media/ methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: One more salty fix. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « media/base/vector_math_testing.h ('k') | media/media.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/cpu.h"
10 #include "base/memory/aligned_memory.h" 9 #include "base/memory/aligned_memory.h"
11 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/stringize_macros.h" 12 #include "base/strings/stringize_macros.h"
14 #include "media/base/vector_math.h" 13 #include "media/base/vector_math.h"
15 #include "media/base/vector_math_testing.h" 14 #include "media/base/vector_math_testing.h"
16 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
17 16
18 using std::fill; 17 using std::fill;
19 18
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 { 68 {
70 SCOPED_TRACE("FMAC_C"); 69 SCOPED_TRACE("FMAC_C");
71 FillTestVectors(kInputFillValue, kOutputFillValue); 70 FillTestVectors(kInputFillValue, kOutputFillValue);
72 vector_math::FMAC_C( 71 vector_math::FMAC_C(
73 input_vector_.get(), kScale, kVectorSize, output_vector_.get()); 72 input_vector_.get(), kScale, kVectorSize, output_vector_.get());
74 VerifyOutput(kResult); 73 VerifyOutput(kResult);
75 } 74 }
76 75
77 #if defined(ARCH_CPU_X86_FAMILY) 76 #if defined(ARCH_CPU_X86_FAMILY)
78 { 77 {
79 ASSERT_TRUE(base::CPU().has_sse());
80 SCOPED_TRACE("FMAC_SSE"); 78 SCOPED_TRACE("FMAC_SSE");
81 FillTestVectors(kInputFillValue, kOutputFillValue); 79 FillTestVectors(kInputFillValue, kOutputFillValue);
82 vector_math::FMAC_SSE( 80 vector_math::FMAC_SSE(
83 input_vector_.get(), kScale, kVectorSize, output_vector_.get()); 81 input_vector_.get(), kScale, kVectorSize, output_vector_.get());
84 VerifyOutput(kResult); 82 VerifyOutput(kResult);
85 } 83 }
86 #endif 84 #endif
87 85
88 #if defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON) 86 #if defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON)
89 { 87 {
(...skipping 21 matching lines...) Expand all
111 { 109 {
112 SCOPED_TRACE("FMUL_C"); 110 SCOPED_TRACE("FMUL_C");
113 FillTestVectors(kInputFillValue, kOutputFillValue); 111 FillTestVectors(kInputFillValue, kOutputFillValue);
114 vector_math::FMUL_C( 112 vector_math::FMUL_C(
115 input_vector_.get(), kScale, kVectorSize, output_vector_.get()); 113 input_vector_.get(), kScale, kVectorSize, output_vector_.get());
116 VerifyOutput(kResult); 114 VerifyOutput(kResult);
117 } 115 }
118 116
119 #if defined(ARCH_CPU_X86_FAMILY) 117 #if defined(ARCH_CPU_X86_FAMILY)
120 { 118 {
121 ASSERT_TRUE(base::CPU().has_sse());
122 SCOPED_TRACE("FMUL_SSE"); 119 SCOPED_TRACE("FMUL_SSE");
123 FillTestVectors(kInputFillValue, kOutputFillValue); 120 FillTestVectors(kInputFillValue, kOutputFillValue);
124 vector_math::FMUL_SSE( 121 vector_math::FMUL_SSE(
125 input_vector_.get(), kScale, kVectorSize, output_vector_.get()); 122 input_vector_.get(), kScale, kVectorSize, output_vector_.get());
126 VerifyOutput(kResult); 123 VerifyOutput(kResult);
127 } 124 }
128 #endif 125 #endif
129 126
130 #if defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON) 127 #if defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON)
131 { 128 {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 { 217 {
221 SCOPED_TRACE("EWMAAndMaxPower_C"); 218 SCOPED_TRACE("EWMAAndMaxPower_C");
222 const std::pair<float, float>& result = vector_math::EWMAAndMaxPower_C( 219 const std::pair<float, float>& result = vector_math::EWMAAndMaxPower_C(
223 initial_value_, data_.get(), data_len_, smoothing_factor_); 220 initial_value_, data_.get(), data_len_, smoothing_factor_);
224 EXPECT_NEAR(expected_final_avg_, result.first, 0.0000001f); 221 EXPECT_NEAR(expected_final_avg_, result.first, 0.0000001f);
225 EXPECT_NEAR(expected_max_, result.second, 0.0000001f); 222 EXPECT_NEAR(expected_max_, result.second, 0.0000001f);
226 } 223 }
227 224
228 #if defined(ARCH_CPU_X86_FAMILY) 225 #if defined(ARCH_CPU_X86_FAMILY)
229 { 226 {
230 ASSERT_TRUE(base::CPU().has_sse());
231 SCOPED_TRACE("EWMAAndMaxPower_SSE"); 227 SCOPED_TRACE("EWMAAndMaxPower_SSE");
232 const std::pair<float, float>& result = vector_math::EWMAAndMaxPower_SSE( 228 const std::pair<float, float>& result = vector_math::EWMAAndMaxPower_SSE(
233 initial_value_, data_.get(), data_len_, smoothing_factor_); 229 initial_value_, data_.get(), data_len_, smoothing_factor_);
234 EXPECT_NEAR(expected_final_avg_, result.first, 0.0000001f); 230 EXPECT_NEAR(expected_final_avg_, result.first, 0.0000001f);
235 EXPECT_NEAR(expected_max_, result.second, 0.0000001f); 231 EXPECT_NEAR(expected_max_, result.second, 0.0000001f);
236 } 232 }
237 #endif 233 #endif
238 234
239 #if defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON) 235 #if defined(ARCH_CPU_ARM_FAMILY) && defined(USE_NEON)
240 { 236 {
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 .HasExpectedResult(0.00017858f, 4.0f), 378 .HasExpectedResult(0.00017858f, 4.0f),
383 EWMATestScenario(0.0f, kZeros, 32, 0.25f) 379 EWMATestScenario(0.0f, kZeros, 32, 0.25f)
384 .WithImpulse(2.0f, 2) 380 .WithImpulse(2.0f, 2)
385 .HasExpectedResult(0.00023811f, 4.0f), 381 .HasExpectedResult(0.00023811f, 4.0f),
386 EWMATestScenario(0.0f, kZeros, 32, 0.25f) 382 EWMATestScenario(0.0f, kZeros, 32, 0.25f)
387 .WithImpulse(2.0f, 3) 383 .WithImpulse(2.0f, 3)
388 .HasExpectedResult(0.00031748f, 4.0f) 384 .HasExpectedResult(0.00031748f, 4.0f)
389 )); 385 ));
390 386
391 } // namespace media 387 } // namespace media
OLDNEW
« no previous file with comments | « media/base/vector_math_testing.h ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698