Remove duplicate CPU detection code; use base::CPU instead.

BUG=none
TEST=media_unittests.


Review URL: https://chromiumcodereview.appspot.com/10537082

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141627 0039d316-1c4b-4281-b951-d872f2087c98
parent 993402c9
// 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 // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -26,13 +26,13 @@ class BASE_EXPORT CPU { ...@@ -26,13 +26,13 @@ class BASE_EXPORT CPU {
int type() const { return type_; } int type() const { return type_; }
int extended_model() const { return ext_model_; } int extended_model() const { return ext_model_; }
int extended_family() const { return ext_family_; } int extended_family() const { return ext_family_; }
int has_mmx() const { return has_mmx_; } bool has_mmx() const { return has_mmx_; }
int has_sse() const { return has_sse_; } bool has_sse() const { return has_sse_; }
int has_sse2() const { return has_sse2_; } bool has_sse2() const { return has_sse2_; }
int has_sse3() const { return has_sse3_; } bool has_sse3() const { return has_sse3_; }
int has_ssse3() const { return has_ssse3_; } bool has_ssse3() const { return has_ssse3_; }
int has_sse41() const { return has_sse41_; } bool has_sse41() const { return has_sse41_; }
int has_sse42() const { return has_sse42_; } bool has_sse42() const { return has_sse42_; }
private: private:
// Query the processor for CPUID information. // Query the processor for CPUID information.
......
// 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_
// 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
// 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
// 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 // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "media/base/simd/convert_rgb_to_yuv.h" #include "media/base/simd/convert_rgb_to_yuv.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "media/base/cpu_features.h"
#include "media/base/simd/convert_rgb_to_yuv_ssse3.h" #include "media/base/simd/convert_rgb_to_yuv_ssse3.h"
namespace media { namespace media {
......
// 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 // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "base/cpu.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "media/base/cpu_features.h"
#include "media/base/simd/convert_rgb_to_yuv.h" #include "media/base/simd/convert_rgb_to_yuv.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -52,7 +52,8 @@ int ConvertRGBToV(const uint8* rgb, int size, bool subsampling) { ...@@ -52,7 +52,8 @@ int ConvertRGBToV(const uint8* rgb, int size, bool subsampling) {
TEST(YUVConvertTest, SideBySideRGB) { TEST(YUVConvertTest, SideBySideRGB) {
// We skip this test on PCs which does not support SSE3 because this test // We skip this test on PCs which does not support SSE3 because this test
// needs it. // needs it.
if (!media::hasSSSE3()) base::CPU cpu;
if (!cpu.has_ssse3())
return; return;
// This test checks a subset of all RGB values so this test does not take so // This test checks a subset of all RGB values so this test does not take so
......
// 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 // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include <mmintrin.h> #include <mmintrin.h>
#endif #endif
#include "media/base/cpu_features.h"
#include "media/base/simd/convert_yuv_to_rgb.h" #include "media/base/simd/convert_yuv_to_rgb.h"
#include "media/base/yuv_convert.h" #include "media/base/yuv_convert.h"
......
...@@ -17,10 +17,10 @@ ...@@ -17,10 +17,10 @@
#include "media/base/yuv_convert.h" #include "media/base/yuv_convert.h"
#include "base/cpu.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "build/build_config.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_rgb_to_yuv.h"
#include "media/base/simd/convert_yuv_to_rgb.h" #include "media/base/simd/convert_yuv_to_rgb.h"
#include "media/base/simd/filter_yuv.h" #include "media/base/simd/filter_yuv.h"
...@@ -37,9 +37,10 @@ namespace media { ...@@ -37,9 +37,10 @@ namespace media {
static FilterYUVRowsProc ChooseFilterYUVRowsProc() { static FilterYUVRowsProc ChooseFilterYUVRowsProc() {
#if defined(ARCH_CPU_X86_FAMILY) #if defined(ARCH_CPU_X86_FAMILY)
if (hasSSE2()) base::CPU cpu;
if (cpu.has_sse2())
return &FilterYUVRows_SSE2; return &FilterYUVRows_SSE2;
if (hasMMX()) if (cpu.has_mmx())
return &FilterYUVRows_MMX; return &FilterYUVRows_MMX;
#endif #endif
return &FilterYUVRows_C; return &FilterYUVRows_C;
...@@ -47,9 +48,10 @@ static FilterYUVRowsProc ChooseFilterYUVRowsProc() { ...@@ -47,9 +48,10 @@ static FilterYUVRowsProc ChooseFilterYUVRowsProc() {
static ConvertYUVToRGB32RowProc ChooseConvertYUVToRGB32RowProc() { static ConvertYUVToRGB32RowProc ChooseConvertYUVToRGB32RowProc() {
#if defined(ARCH_CPU_X86_FAMILY) #if defined(ARCH_CPU_X86_FAMILY)
if (hasSSE()) base::CPU cpu;
if (cpu.has_sse())
return &ConvertYUVToRGB32Row_SSE; return &ConvertYUVToRGB32Row_SSE;
if (hasMMX()) if (cpu.has_mmx())
return &ConvertYUVToRGB32Row_MMX; return &ConvertYUVToRGB32Row_MMX;
#endif #endif
return &ConvertYUVToRGB32Row_C; return &ConvertYUVToRGB32Row_C;
...@@ -60,10 +62,11 @@ static ScaleYUVToRGB32RowProc ChooseScaleYUVToRGB32RowProc() { ...@@ -60,10 +62,11 @@ static ScaleYUVToRGB32RowProc ChooseScaleYUVToRGB32RowProc() {
// Use 64-bits version if possible. // Use 64-bits version if possible.
return &ScaleYUVToRGB32Row_SSE2_X64; return &ScaleYUVToRGB32Row_SSE2_X64;
#elif defined(ARCH_CPU_X86_FAMILY) #elif defined(ARCH_CPU_X86_FAMILY)
base::CPU cpu;
// Choose the best one on 32-bits system. // Choose the best one on 32-bits system.
if (hasSSE()) if (cpu.has_sse())
return &ScaleYUVToRGB32Row_SSE; return &ScaleYUVToRGB32Row_SSE;
if (hasMMX()) if (cpu.has_mmx())
return &ScaleYUVToRGB32Row_MMX; return &ScaleYUVToRGB32Row_MMX;
#endif // defined(ARCH_CPU_X86_64) #endif // defined(ARCH_CPU_X86_64)
return &ScaleYUVToRGB32Row_C; return &ScaleYUVToRGB32Row_C;
...@@ -74,10 +77,11 @@ static ScaleYUVToRGB32RowProc ChooseLinearScaleYUVToRGB32RowProc() { ...@@ -74,10 +77,11 @@ static ScaleYUVToRGB32RowProc ChooseLinearScaleYUVToRGB32RowProc() {
// Use 64-bits version if possible. // Use 64-bits version if possible.
return &LinearScaleYUVToRGB32Row_MMX_X64; return &LinearScaleYUVToRGB32Row_MMX_X64;
#elif defined(ARCH_CPU_X86_FAMILY) #elif defined(ARCH_CPU_X86_FAMILY)
base::CPU cpu;
// 32-bits system. // 32-bits system.
if (hasSSE()) if (cpu.has_sse())
return &LinearScaleYUVToRGB32Row_SSE; return &LinearScaleYUVToRGB32Row_SSE;
if (hasMMX()) if (cpu.has_mmx())
return &LinearScaleYUVToRGB32Row_MMX; return &LinearScaleYUVToRGB32Row_MMX;
#endif // defined(ARCH_CPU_X86_64) #endif // defined(ARCH_CPU_X86_64)
return &LinearScaleYUVToRGB32Row_C; return &LinearScaleYUVToRGB32Row_C;
...@@ -89,7 +93,8 @@ void EmptyRegisterState() { ...@@ -89,7 +93,8 @@ void EmptyRegisterState() {
static bool checked = false; static bool checked = false;
static bool has_mmx = false; static bool has_mmx = false;
if (!checked) { if (!checked) {
has_mmx = hasMMX(); base::CPU cpu;
has_mmx = cpu.has_mmx();
checked = true; checked = true;
} }
if (has_mmx) if (has_mmx)
...@@ -445,7 +450,8 @@ void ConvertRGB32ToYUV(const uint8* rgbframe, ...@@ -445,7 +450,8 @@ void ConvertRGB32ToYUV(const uint8* rgbframe,
#else #else
// TODO(hclam): Switch to SSSE3 version when the cyan problem is solved. // TODO(hclam): Switch to SSSE3 version when the cyan problem is solved.
// See: crbug.com/100462 // See: crbug.com/100462
if (hasSSE2()) base::CPU cpu;
if (cpu.has_sse2())
convert_proc = &ConvertRGB32ToYUV_SSE2; convert_proc = &ConvertRGB32ToYUV_SSE2;
else else
convert_proc = &ConvertRGB32ToYUV_C; convert_proc = &ConvertRGB32ToYUV_C;
...@@ -472,7 +478,8 @@ void ConvertRGB24ToYUV(const uint8* rgbframe, ...@@ -472,7 +478,8 @@ void ConvertRGB24ToYUV(const uint8* rgbframe,
static void (*convert_proc)(const uint8*, uint8*, uint8*, uint8*, static void (*convert_proc)(const uint8*, uint8*, uint8*, uint8*,
int, int, int, int, int) = NULL; int, int, int, int, int) = NULL;
if (!convert_proc) { if (!convert_proc) {
if (hasSSSE3()) base::CPU cpu;
if (cpu.has_ssse3())
convert_proc = &ConvertRGB24ToYUV_SSSE3; convert_proc = &ConvertRGB24ToYUV_SSSE3;
else else
convert_proc = &ConvertRGB24ToYUV_C; convert_proc = &ConvertRGB24ToYUV_C;
...@@ -541,9 +548,10 @@ void ConvertYUVToRGB32(const uint8* yplane, ...@@ -541,9 +548,10 @@ void ConvertYUVToRGB32(const uint8* yplane,
#else #else
static ConvertYUVToRGB32Proc convert_proc = NULL; static ConvertYUVToRGB32Proc convert_proc = NULL;
if (!convert_proc) { if (!convert_proc) {
if (hasSSE()) base::CPU cpu;
if (cpu.has_sse())
convert_proc = &ConvertYUVToRGB32_SSE; convert_proc = &ConvertYUVToRGB32_SSE;
else if (hasMMX()) else if (cpu.has_mmx())
convert_proc = &ConvertYUVToRGB32_MMX; convert_proc = &ConvertYUVToRGB32_MMX;
else else
convert_proc = &ConvertYUVToRGB32_C; convert_proc = &ConvertYUVToRGB32_C;
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
// found in the LICENSE file. // found in the LICENSE file.
#include "base/base_paths.h" #include "base/base_paths.h"
#include "base/cpu.h"
#include "base/file_util.h" #include "base/file_util.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "media/base/cpu_features.h"
#include "media/base/djb2.h" #include "media/base/djb2.h"
#include "media/base/simd/convert_rgb_to_yuv.h" #include "media/base/simd/convert_rgb_to_yuv.h"
#include "media/base/simd/convert_yuv_to_rgb.h" #include "media/base/simd/convert_yuv_to_rgb.h"
...@@ -457,7 +457,8 @@ TEST(YUVConvertTest, DownScaleYUVToRGB32WithRect) { ...@@ -457,7 +457,8 @@ TEST(YUVConvertTest, DownScaleYUVToRGB32WithRect) {
#if !defined(ARCH_CPU_ARM_FAMILY) #if !defined(ARCH_CPU_ARM_FAMILY)
TEST(YUVConvertTest, RGB32ToYUV_SSE2_MatchReference) { 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."; LOG(WARNING) << "System doesn't support SSE2, test not executed.";
return; return;
} }
...@@ -543,7 +544,8 @@ TEST(YUVConvertTest, RGB32ToYUV_SSE2_MatchReference) { ...@@ -543,7 +544,8 @@ TEST(YUVConvertTest, RGB32ToYUV_SSE2_MatchReference) {
} }
TEST(YUVConvertTest, ConvertYUVToRGB32Row_MMX) { TEST(YUVConvertTest, ConvertYUVToRGB32Row_MMX) {
if (!media::hasMMX()) { base::CPU cpu;
if (!cpu.has_mmx()) {
LOG(WARNING) << "System not supported. Test skipped."; LOG(WARNING) << "System not supported. Test skipped.";
return; return;
} }
...@@ -571,7 +573,8 @@ TEST(YUVConvertTest, ConvertYUVToRGB32Row_MMX) { ...@@ -571,7 +573,8 @@ TEST(YUVConvertTest, ConvertYUVToRGB32Row_MMX) {
} }
TEST(YUVConvertTest, ConvertYUVToRGB32Row_SSE) { TEST(YUVConvertTest, ConvertYUVToRGB32Row_SSE) {
if (!media::hasSSE()) { base::CPU cpu;
if (!cpu.has_sse()) {
LOG(WARNING) << "System not supported. Test skipped."; LOG(WARNING) << "System not supported. Test skipped.";
return; return;
} }
...@@ -599,7 +602,8 @@ TEST(YUVConvertTest, ConvertYUVToRGB32Row_SSE) { ...@@ -599,7 +602,8 @@ TEST(YUVConvertTest, ConvertYUVToRGB32Row_SSE) {
} }
TEST(YUVConvertTest, ScaleYUVToRGB32Row_MMX) { TEST(YUVConvertTest, ScaleYUVToRGB32Row_MMX) {
if (!media::hasMMX()) { base::CPU cpu;
if (!cpu.has_mmx()) {
LOG(WARNING) << "System not supported. Test skipped."; LOG(WARNING) << "System not supported. Test skipped.";
return; return;
} }
...@@ -630,7 +634,8 @@ TEST(YUVConvertTest, ScaleYUVToRGB32Row_MMX) { ...@@ -630,7 +634,8 @@ TEST(YUVConvertTest, ScaleYUVToRGB32Row_MMX) {
} }
TEST(YUVConvertTest, ScaleYUVToRGB32Row_SSE) { TEST(YUVConvertTest, ScaleYUVToRGB32Row_SSE) {
if (!media::hasSSE()) { base::CPU cpu;
if (!cpu.has_sse()) {
LOG(WARNING) << "System not supported. Test skipped."; LOG(WARNING) << "System not supported. Test skipped.";
return; return;
} }
...@@ -661,7 +666,8 @@ TEST(YUVConvertTest, ScaleYUVToRGB32Row_SSE) { ...@@ -661,7 +666,8 @@ TEST(YUVConvertTest, ScaleYUVToRGB32Row_SSE) {
} }
TEST(YUVConvertTest, LinearScaleYUVToRGB32Row_MMX) { TEST(YUVConvertTest, LinearScaleYUVToRGB32Row_MMX) {
if (!media::hasMMX()) { base::CPU cpu;
if (!cpu.has_mmx()) {
LOG(WARNING) << "System not supported. Test skipped."; LOG(WARNING) << "System not supported. Test skipped.";
return; return;
} }
...@@ -692,7 +698,8 @@ TEST(YUVConvertTest, LinearScaleYUVToRGB32Row_MMX) { ...@@ -692,7 +698,8 @@ TEST(YUVConvertTest, LinearScaleYUVToRGB32Row_MMX) {
} }
TEST(YUVConvertTest, LinearScaleYUVToRGB32Row_SSE) { TEST(YUVConvertTest, LinearScaleYUVToRGB32Row_SSE) {
if (!media::hasSSE()) { base::CPU cpu;
if (!cpu.has_sse()) {
LOG(WARNING) << "System not supported. Test skipped."; LOG(WARNING) << "System not supported. Test skipped.";
return; return;
} }
...@@ -738,7 +745,8 @@ TEST(YUVConvertTest, FilterYUVRows_C_OutOfBounds) { ...@@ -738,7 +745,8 @@ TEST(YUVConvertTest, FilterYUVRows_C_OutOfBounds) {
} }
TEST(YUVConvertTest, FilterYUVRows_MMX_OutOfBounds) { TEST(YUVConvertTest, FilterYUVRows_MMX_OutOfBounds) {
if (!media::hasMMX()) { base::CPU cpu;
if (!cpu.has_mmx()) {
LOG(WARNING) << "System not supported. Test skipped."; LOG(WARNING) << "System not supported. Test skipped.";
return; return;
} }
...@@ -759,7 +767,8 @@ TEST(YUVConvertTest, FilterYUVRows_MMX_OutOfBounds) { ...@@ -759,7 +767,8 @@ TEST(YUVConvertTest, FilterYUVRows_MMX_OutOfBounds) {
} }
TEST(YUVConvertTest, FilterYUVRows_SSE2_OutOfBounds) { TEST(YUVConvertTest, FilterYUVRows_SSE2_OutOfBounds) {
if (!media::hasSSE2()) { base::CPU cpu;
if (!cpu.has_sse2()) {
LOG(WARNING) << "System not supported. Test skipped."; LOG(WARNING) << "System not supported. Test skipped.";
return; return;
} }
...@@ -779,7 +788,8 @@ TEST(YUVConvertTest, FilterYUVRows_SSE2_OutOfBounds) { ...@@ -779,7 +788,8 @@ TEST(YUVConvertTest, FilterYUVRows_SSE2_OutOfBounds) {
} }
TEST(YUVConvertTest, FilterYUVRows_MMX_UnalignedDestination) { TEST(YUVConvertTest, FilterYUVRows_MMX_UnalignedDestination) {
if (!media::hasMMX()) { base::CPU cpu;
if (!cpu.has_mmx()) {
LOG(WARNING) << "System not supported. Test skipped."; LOG(WARNING) << "System not supported. Test skipped.";
return; return;
} }
...@@ -808,7 +818,8 @@ TEST(YUVConvertTest, FilterYUVRows_MMX_UnalignedDestination) { ...@@ -808,7 +818,8 @@ TEST(YUVConvertTest, FilterYUVRows_MMX_UnalignedDestination) {
} }
TEST(YUVConvertTest, FilterYUVRows_SSE2_UnalignedDestination) { TEST(YUVConvertTest, FilterYUVRows_SSE2_UnalignedDestination) {
if (!media::hasSSE2()) { base::CPU cpu;
if (!cpu.has_sse2()) {
LOG(WARNING) << "System not supported. Test skipped."; LOG(WARNING) << "System not supported. Test skipped.";
return; return;
} }
......
...@@ -444,37 +444,12 @@ ...@@ -444,37 +444,12 @@
}], }],
], ],
}, },
{
'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', 'target_name': 'yuv_convert',
'type': 'static_library', 'type': 'static_library',
'include_dirs': [ 'include_dirs': [
'..', '..',
], ],
'dependencies': [
'cpu_features',
],
'conditions': [ 'conditions': [
['order_profiling != 0', { ['order_profiling != 0', {
'target_conditions' : [ 'target_conditions' : [
......
// 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 // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "remoting/host/differ_block.h" #include "remoting/host/differ_block.h"
#include "base/cpu.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "media/base/cpu_features.h"
#include "remoting/host/differ_block_internal.h" #include "remoting/host/differ_block_internal.h"
namespace remoting { namespace remoting {
...@@ -31,10 +31,11 @@ int BlockDifference(const uint8* image1, const uint8* image2, int stride) { ...@@ -31,10 +31,11 @@ int BlockDifference(const uint8* image1, const uint8* image2, int stride) {
// TODO(hclam): Implement a NEON version. // TODO(hclam): Implement a NEON version.
diff_proc = &BlockDifference_C; diff_proc = &BlockDifference_C;
#else #else
base::CPU cpu;
// For x86 processors, check if SSE2 is supported. // For x86 processors, check if SSE2 is supported.
if (media::hasSSE2() && kBlockSize == 32) if (cpu.has_sse2() && kBlockSize == 32)
diff_proc = &BlockDifference_SSE2_W32; diff_proc = &BlockDifference_SSE2_W32;
else if (media::hasSSE2() && kBlockSize == 16) else if (cpu.has_sse2() && kBlockSize == 16)
diff_proc = &BlockDifference_SSE2_W16; diff_proc = &BlockDifference_SSE2_W16;
else else
diff_proc = &BlockDifference_C; diff_proc = &BlockDifference_C;
......
...@@ -400,7 +400,7 @@ ...@@ -400,7 +400,7 @@
], ],
'sources': [ 'sources': [
# The jsoncpp target is not yet built for Mac OS X 64-bit, so # 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_reader.cpp',
'../third_party/jsoncpp/source/src/lib_json/json_writer.cpp', '../third_party/jsoncpp/source/src/lib_json/json_writer.cpp',
'../third_party/modp_b64/modp_b64.cc', '../third_party/modp_b64/modp_b64.cc',
...@@ -461,7 +461,7 @@ ...@@ -461,7 +461,7 @@
}, # end of target 'remoting_host_prefpane' }, # end of target 'remoting_host_prefpane'
], # end of 'targets' ], # end of 'targets'
}], # 'OS=="mac"' }], # 'OS=="mac"'
['OS=="win"', { ['OS=="win"', {
'targets': [ 'targets': [
{ {
...@@ -1588,9 +1588,6 @@ ...@@ -1588,9 +1588,6 @@
'target_name': 'differ_block', 'target_name': 'differ_block',
'type': 'static_library', 'type': 'static_library',
'variables': { 'enable_wexit_time_destructors': 1, }, 'variables': { 'enable_wexit_time_destructors': 1, },
'dependencies': [
'../media/media.gyp:cpu_features',
],
'conditions': [ 'conditions': [
[ 'target_arch == "ia32" or target_arch == "x64"', { [ 'target_arch == "ia32" or target_arch == "x64"', {
'dependencies': [ 'dependencies': [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment