diff options
-rw-r--r-- | base/cpu.h | 16 | ||||
-rw-r--r-- | media/base/cpu_features.h | 27 | ||||
-rw-r--r-- | media/base/cpu_features_arm.cc | 17 | ||||
-rw-r--r-- | media/base/cpu_features_x86.cc | 92 | ||||
-rw-r--r-- | media/base/simd/convert_rgb_to_yuv_ssse3.cc | 3 | ||||
-rw-r--r-- | media/base/simd/convert_rgb_to_yuv_unittest.cc | 7 | ||||
-rw-r--r-- | media/base/simd/convert_yuv_to_rgb_x86.cc | 3 | ||||
-rw-r--r-- | media/base/yuv_convert.cc | 36 | ||||
-rw-r--r-- | media/base/yuv_convert_unittest.cc | 35 | ||||
-rw-r--r-- | media/media.gyp | 25 | ||||
-rw-r--r-- | remoting/host/differ_block.cc | 9 | ||||
-rw-r--r-- | remoting/remoting.gyp | 7 |
12 files changed, 66 insertions, 211 deletions
@@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -26,13 +26,13 @@ class BASE_EXPORT CPU { int type() const { return type_; } int extended_model() const { return ext_model_; } int extended_family() const { return ext_family_; } - int has_mmx() const { return has_mmx_; } - int has_sse() const { return has_sse_; } - int has_sse2() const { return has_sse2_; } - int has_sse3() const { return has_sse3_; } - int has_ssse3() const { return has_ssse3_; } - int has_sse41() const { return has_sse41_; } - int has_sse42() const { return has_sse42_; } + bool has_mmx() const { return has_mmx_; } + bool has_sse() const { return has_sse_; } + bool has_sse2() const { return has_sse2_; } + bool has_sse3() const { return has_sse3_; } + bool has_ssse3() const { return has_ssse3_; } + bool has_sse41() const { return has_sse41_; } + bool has_sse42() const { return has_sse42_; } private: // Query the processor for CPUID information. diff --git a/media/base/cpu_features.h b/media/base/cpu_features.h deleted file mode 100644 index 0878385..0000000 --- a/media/base/cpu_features.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This file provide utility functions to check CPU features such as SSE2, -// NEON. - -#ifndef MEDIA_BASE_CPU_FEATURES_H_ -#define MEDIA_BASE_CPU_FEATURES_H_ - -namespace media { - -// Returns true if CPU has MMX support. -bool hasMMX(); - -// Returns true if CPU has SSE support. -bool hasSSE(); - -// Returns true if CPU has SSE2 support. -bool hasSSE2(); - -// Returns true if CPU supports SSE2, SSE3, and SSSE3. -bool hasSSSE3(); - -} // namespace media - -#endif // MEDIA_BASE_CPU_FEATURES_H_ diff --git a/media/base/cpu_features_arm.cc b/media/base/cpu_features_arm.cc deleted file mode 100644 index a0d5c68..0000000 --- a/media/base/cpu_features_arm.cc +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "media/base/cpu_features.h" - -namespace media { - -bool hasSSE2() { - return false; -} - -bool hasSSSE3() { - return false; -} - -} // namespace media diff --git a/media/base/cpu_features_x86.cc b/media/base/cpu_features_x86.cc deleted file mode 100644 index d1c70c5..0000000 --- a/media/base/cpu_features_x86.cc +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Code in this file is taked from -// third_party/skia/src/opts/opts_check_SSE2.cpp. - -// Note that this file cannot be compiled with -msse2 in gcc. - -#include "build/build_config.h" -#include "media/base/cpu_features.h" - -namespace media { - -#ifdef _MSC_VER -static inline void getcpuid(int info_type, int info[4]) { - __asm { - mov eax, [info_type] - cpuid - mov edi, [info] - mov [edi], eax - mov [edi+4], ebx - mov [edi+8], ecx - mov [edi+12], edx - } -} -#else -static inline void getcpuid(int info_type, int info[4]) { - // We save and restore ebx, so this code can be compatible with -fPIC -#if defined(__i386__) - asm volatile ( - "pushl %%ebx \n\t" - "cpuid \n\t" - "movl %%ebx, %1 \n\t" - "popl %%ebx \n\t" - : "=a"(info[0]), "=r"(info[1]), "=c"(info[2]), "=d"(info[3]) - : "a"(info_type) - ); -#else - // We can use cpuid instruction without pushing ebx on gcc x86-64 because it - // does not use ebx (or rbx) as a GOT register. - asm volatile ( - "cpuid \n\t" - : "=a"(info[0]), "=r"(info[1]), "=c"(info[2]), "=d"(info[3]) - : "a"(info_type) - : "%rbx" - ); -#endif -} -#endif - -bool hasMMX() { -#if defined(ARCH_CPU_X86_64) - // Every X86_64 processor has MMX. - return true; -#else - int cpu_info[4] = { 0 }; - getcpuid(1, cpu_info); - return (cpu_info[3] & (1<<23)) != 0; -#endif -} - -bool hasSSE() { -#if defined(ARCH_CPU_X86_64) - // Every X86_64 processor has SSE. - return true; -#else - int cpu_info[4] = { 0 }; - getcpuid(1, cpu_info); - return (cpu_info[3] & (1<<25)) != 0; -#endif -} - -bool hasSSE2() { -#if defined(ARCH_CPU_X86_64) - // All X86_64 machines have SSE2, so don't even bother checking. - return true; -#else - int cpu_info[4] = { 0 }; - getcpuid(1, cpu_info); - return (cpu_info[3] & (1<<26)) != 0; -#endif -} - -bool hasSSSE3() { - int cpu_info[4] = { 0 }; - getcpuid(1, cpu_info); - return (cpu_info[3] & 0x04000000) != 0 && (cpu_info[2] & 0x00000001) != 0 && - (cpu_info[2] & 0x00000200) != 0; -} - -} // namespace media diff --git a/media/base/simd/convert_rgb_to_yuv_ssse3.cc b/media/base/simd/convert_rgb_to_yuv_ssse3.cc index 2bd6930..10eff35 100644 --- a/media/base/simd/convert_rgb_to_yuv_ssse3.cc +++ b/media/base/simd/convert_rgb_to_yuv_ssse3.cc @@ -1,11 +1,10 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "media/base/simd/convert_rgb_to_yuv.h" #include "build/build_config.h" -#include "media/base/cpu_features.h" #include "media/base/simd/convert_rgb_to_yuv_ssse3.h" namespace media { diff --git a/media/base/simd/convert_rgb_to_yuv_unittest.cc b/media/base/simd/convert_rgb_to_yuv_unittest.cc index a1eab03..020fb25 100644 --- a/media/base/simd/convert_rgb_to_yuv_unittest.cc +++ b/media/base/simd/convert_rgb_to_yuv_unittest.cc @@ -1,9 +1,9 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/cpu.h" #include "base/memory/scoped_ptr.h" -#include "media/base/cpu_features.h" #include "media/base/simd/convert_rgb_to_yuv.h" #include "testing/gtest/include/gtest/gtest.h" @@ -52,7 +52,8 @@ int ConvertRGBToV(const uint8* rgb, int size, bool subsampling) { TEST(YUVConvertTest, SideBySideRGB) { // We skip this test on PCs which does not support SSE3 because this test // needs it. - if (!media::hasSSSE3()) + base::CPU cpu; + if (!cpu.has_ssse3()) return; // This test checks a subset of all RGB values so this test does not take so diff --git a/media/base/simd/convert_yuv_to_rgb_x86.cc b/media/base/simd/convert_yuv_to_rgb_x86.cc index 3e03ef9..3825bdb 100644 --- a/media/base/simd/convert_yuv_to_rgb_x86.cc +++ b/media/base/simd/convert_yuv_to_rgb_x86.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,7 +8,6 @@ #include <mmintrin.h> #endif -#include "media/base/cpu_features.h" #include "media/base/simd/convert_yuv_to_rgb.h" #include "media/base/yuv_convert.h" diff --git a/media/base/yuv_convert.cc b/media/base/yuv_convert.cc index f9a6076..094fe794 100644 --- a/media/base/yuv_convert.cc +++ b/media/base/yuv_convert.cc @@ -17,10 +17,10 @@ #include "media/base/yuv_convert.h" +#include "base/cpu.h" #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "build/build_config.h" -#include "media/base/cpu_features.h" #include "media/base/simd/convert_rgb_to_yuv.h" #include "media/base/simd/convert_yuv_to_rgb.h" #include "media/base/simd/filter_yuv.h" @@ -37,9 +37,10 @@ namespace media { static FilterYUVRowsProc ChooseFilterYUVRowsProc() { #if defined(ARCH_CPU_X86_FAMILY) - if (hasSSE2()) + base::CPU cpu; + if (cpu.has_sse2()) return &FilterYUVRows_SSE2; - if (hasMMX()) + if (cpu.has_mmx()) return &FilterYUVRows_MMX; #endif return &FilterYUVRows_C; @@ -47,9 +48,10 @@ static FilterYUVRowsProc ChooseFilterYUVRowsProc() { static ConvertYUVToRGB32RowProc ChooseConvertYUVToRGB32RowProc() { #if defined(ARCH_CPU_X86_FAMILY) - if (hasSSE()) + base::CPU cpu; + if (cpu.has_sse()) return &ConvertYUVToRGB32Row_SSE; - if (hasMMX()) + if (cpu.has_mmx()) return &ConvertYUVToRGB32Row_MMX; #endif return &ConvertYUVToRGB32Row_C; @@ -60,10 +62,11 @@ static ScaleYUVToRGB32RowProc ChooseScaleYUVToRGB32RowProc() { // Use 64-bits version if possible. return &ScaleYUVToRGB32Row_SSE2_X64; #elif defined(ARCH_CPU_X86_FAMILY) + base::CPU cpu; // Choose the best one on 32-bits system. - if (hasSSE()) + if (cpu.has_sse()) return &ScaleYUVToRGB32Row_SSE; - if (hasMMX()) + if (cpu.has_mmx()) return &ScaleYUVToRGB32Row_MMX; #endif // defined(ARCH_CPU_X86_64) return &ScaleYUVToRGB32Row_C; @@ -74,10 +77,11 @@ static ScaleYUVToRGB32RowProc ChooseLinearScaleYUVToRGB32RowProc() { // Use 64-bits version if possible. return &LinearScaleYUVToRGB32Row_MMX_X64; #elif defined(ARCH_CPU_X86_FAMILY) + base::CPU cpu; // 32-bits system. - if (hasSSE()) + if (cpu.has_sse()) return &LinearScaleYUVToRGB32Row_SSE; - if (hasMMX()) + if (cpu.has_mmx()) return &LinearScaleYUVToRGB32Row_MMX; #endif // defined(ARCH_CPU_X86_64) return &LinearScaleYUVToRGB32Row_C; @@ -89,7 +93,8 @@ void EmptyRegisterState() { static bool checked = false; static bool has_mmx = false; if (!checked) { - has_mmx = hasMMX(); + base::CPU cpu; + has_mmx = cpu.has_mmx(); checked = true; } if (has_mmx) @@ -445,7 +450,8 @@ void ConvertRGB32ToYUV(const uint8* rgbframe, #else // TODO(hclam): Switch to SSSE3 version when the cyan problem is solved. // See: crbug.com/100462 - if (hasSSE2()) + base::CPU cpu; + if (cpu.has_sse2()) convert_proc = &ConvertRGB32ToYUV_SSE2; else convert_proc = &ConvertRGB32ToYUV_C; @@ -472,7 +478,8 @@ void ConvertRGB24ToYUV(const uint8* rgbframe, static void (*convert_proc)(const uint8*, uint8*, uint8*, uint8*, int, int, int, int, int) = NULL; if (!convert_proc) { - if (hasSSSE3()) + base::CPU cpu; + if (cpu.has_ssse3()) convert_proc = &ConvertRGB24ToYUV_SSSE3; else convert_proc = &ConvertRGB24ToYUV_C; @@ -541,9 +548,10 @@ void ConvertYUVToRGB32(const uint8* yplane, #else static ConvertYUVToRGB32Proc convert_proc = NULL; if (!convert_proc) { - if (hasSSE()) + base::CPU cpu; + if (cpu.has_sse()) convert_proc = &ConvertYUVToRGB32_SSE; - else if (hasMMX()) + else if (cpu.has_mmx()) convert_proc = &ConvertYUVToRGB32_MMX; else convert_proc = &ConvertYUVToRGB32_C; diff --git a/media/base/yuv_convert_unittest.cc b/media/base/yuv_convert_unittest.cc index 7d059c7..153cad8 100644 --- a/media/base/yuv_convert_unittest.cc +++ b/media/base/yuv_convert_unittest.cc @@ -3,10 +3,10 @@ // found in the LICENSE file. #include "base/base_paths.h" +#include "base/cpu.h" #include "base/file_util.h" #include "base/logging.h" #include "base/path_service.h" -#include "media/base/cpu_features.h" #include "media/base/djb2.h" #include "media/base/simd/convert_rgb_to_yuv.h" #include "media/base/simd/convert_yuv_to_rgb.h" @@ -457,7 +457,8 @@ TEST(YUVConvertTest, DownScaleYUVToRGB32WithRect) { #if !defined(ARCH_CPU_ARM_FAMILY) TEST(YUVConvertTest, RGB32ToYUV_SSE2_MatchReference) { - if (!media::hasSSE2()) { + base::CPU cpu; + if (!cpu.has_sse2()) { LOG(WARNING) << "System doesn't support SSE2, test not executed."; return; } @@ -543,7 +544,8 @@ TEST(YUVConvertTest, RGB32ToYUV_SSE2_MatchReference) { } TEST(YUVConvertTest, ConvertYUVToRGB32Row_MMX) { - if (!media::hasMMX()) { + base::CPU cpu; + if (!cpu.has_mmx()) { LOG(WARNING) << "System not supported. Test skipped."; return; } @@ -571,7 +573,8 @@ TEST(YUVConvertTest, ConvertYUVToRGB32Row_MMX) { } TEST(YUVConvertTest, ConvertYUVToRGB32Row_SSE) { - if (!media::hasSSE()) { + base::CPU cpu; + if (!cpu.has_sse()) { LOG(WARNING) << "System not supported. Test skipped."; return; } @@ -599,7 +602,8 @@ TEST(YUVConvertTest, ConvertYUVToRGB32Row_SSE) { } TEST(YUVConvertTest, ScaleYUVToRGB32Row_MMX) { - if (!media::hasMMX()) { + base::CPU cpu; + if (!cpu.has_mmx()) { LOG(WARNING) << "System not supported. Test skipped."; return; } @@ -630,7 +634,8 @@ TEST(YUVConvertTest, ScaleYUVToRGB32Row_MMX) { } TEST(YUVConvertTest, ScaleYUVToRGB32Row_SSE) { - if (!media::hasSSE()) { + base::CPU cpu; + if (!cpu.has_sse()) { LOG(WARNING) << "System not supported. Test skipped."; return; } @@ -661,7 +666,8 @@ TEST(YUVConvertTest, ScaleYUVToRGB32Row_SSE) { } TEST(YUVConvertTest, LinearScaleYUVToRGB32Row_MMX) { - if (!media::hasMMX()) { + base::CPU cpu; + if (!cpu.has_mmx()) { LOG(WARNING) << "System not supported. Test skipped."; return; } @@ -692,7 +698,8 @@ TEST(YUVConvertTest, LinearScaleYUVToRGB32Row_MMX) { } TEST(YUVConvertTest, LinearScaleYUVToRGB32Row_SSE) { - if (!media::hasSSE()) { + base::CPU cpu; + if (!cpu.has_sse()) { LOG(WARNING) << "System not supported. Test skipped."; return; } @@ -738,7 +745,8 @@ TEST(YUVConvertTest, FilterYUVRows_C_OutOfBounds) { } TEST(YUVConvertTest, FilterYUVRows_MMX_OutOfBounds) { - if (!media::hasMMX()) { + base::CPU cpu; + if (!cpu.has_mmx()) { LOG(WARNING) << "System not supported. Test skipped."; return; } @@ -759,7 +767,8 @@ TEST(YUVConvertTest, FilterYUVRows_MMX_OutOfBounds) { } TEST(YUVConvertTest, FilterYUVRows_SSE2_OutOfBounds) { - if (!media::hasSSE2()) { + base::CPU cpu; + if (!cpu.has_sse2()) { LOG(WARNING) << "System not supported. Test skipped."; return; } @@ -779,7 +788,8 @@ TEST(YUVConvertTest, FilterYUVRows_SSE2_OutOfBounds) { } TEST(YUVConvertTest, FilterYUVRows_MMX_UnalignedDestination) { - if (!media::hasMMX()) { + base::CPU cpu; + if (!cpu.has_mmx()) { LOG(WARNING) << "System not supported. Test skipped."; return; } @@ -808,7 +818,8 @@ TEST(YUVConvertTest, FilterYUVRows_MMX_UnalignedDestination) { } TEST(YUVConvertTest, FilterYUVRows_SSE2_UnalignedDestination) { - if (!media::hasSSE2()) { + base::CPU cpu; + if (!cpu.has_sse2()) { LOG(WARNING) << "System not supported. Test skipped."; return; } diff --git a/media/media.gyp b/media/media.gyp index 2a8c6c6..056407f 100644 --- a/media/media.gyp +++ b/media/media.gyp @@ -445,36 +445,11 @@ ], }, { - 'target_name': 'cpu_features', - 'type': 'static_library', - 'include_dirs': [ - '..', - ], - 'conditions': [ - [ 'target_arch == "ia32" or target_arch == "x64"', { - 'sources': [ - 'base/cpu_features_x86.cc', - ], - }], - [ 'target_arch == "arm"', { - 'sources': [ - 'base/cpu_features_arm.cc', - ], - }], - ], - 'sources': [ - 'base/cpu_features.h', - ], - }, - { 'target_name': 'yuv_convert', 'type': 'static_library', 'include_dirs': [ '..', ], - 'dependencies': [ - 'cpu_features', - ], 'conditions': [ ['order_profiling != 0', { 'target_conditions' : [ diff --git a/remoting/host/differ_block.cc b/remoting/host/differ_block.cc index a8da5b9..3e0b12c 100644 --- a/remoting/host/differ_block.cc +++ b/remoting/host/differ_block.cc @@ -1,11 +1,11 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "remoting/host/differ_block.h" +#include "base/cpu.h" #include "build/build_config.h" -#include "media/base/cpu_features.h" #include "remoting/host/differ_block_internal.h" namespace remoting { @@ -31,10 +31,11 @@ int BlockDifference(const uint8* image1, const uint8* image2, int stride) { // TODO(hclam): Implement a NEON version. diff_proc = &BlockDifference_C; #else + base::CPU cpu; // For x86 processors, check if SSE2 is supported. - if (media::hasSSE2() && kBlockSize == 32) + if (cpu.has_sse2() && kBlockSize == 32) diff_proc = &BlockDifference_SSE2_W32; - else if (media::hasSSE2() && kBlockSize == 16) + else if (cpu.has_sse2() && kBlockSize == 16) diff_proc = &BlockDifference_SSE2_W16; else diff_proc = &BlockDifference_C; diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index dce6863..dc72521 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -400,7 +400,7 @@ ], 'sources': [ # The jsoncpp target is not yet built for Mac OS X 64-bit, so - # include the files directly, instead of depending on the target. + # include the files directly, instead of depending on the target. '../third_party/jsoncpp/source/src/lib_json/json_reader.cpp', '../third_party/jsoncpp/source/src/lib_json/json_writer.cpp', '../third_party/modp_b64/modp_b64.cc', @@ -461,7 +461,7 @@ }, # end of target 'remoting_host_prefpane' ], # end of 'targets' }], # 'OS=="mac"' - + ['OS=="win"', { 'targets': [ { @@ -1588,9 +1588,6 @@ 'target_name': 'differ_block', 'type': 'static_library', 'variables': { 'enable_wexit_time_destructors': 1, }, - 'dependencies': [ - '../media/media.gyp:cpu_features', - ], 'conditions': [ [ 'target_arch == "ia32" or target_arch == "x64"', { 'dependencies': [ |