| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM 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 |
| 11 #ifndef VP9_COMMON_VP9_SYSTEMDEPENDENT_H_ | 11 #ifndef VP9_COMMON_VP9_SYSTEMDEPENDENT_H_ |
| 12 #define VP9_COMMON_VP9_SYSTEMDEPENDENT_H_ | 12 #define VP9_COMMON_VP9_SYSTEMDEPENDENT_H_ |
| 13 | 13 |
| 14 #include "vpx_ports/msvc.h" |
| 15 |
| 14 #ifdef _MSC_VER | 16 #ifdef _MSC_VER |
| 15 # include <math.h> // the ceil() definition must precede intrin.h | 17 # include <math.h> // the ceil() definition must precede intrin.h |
| 16 # if _MSC_VER > 1310 && (defined(_M_X64) || defined(_M_IX86)) | 18 # if _MSC_VER > 1310 && (defined(_M_X64) || defined(_M_IX86)) |
| 17 # include <intrin.h> | 19 # include <intrin.h> |
| 18 # define USE_MSC_INTRIN | 20 # define USE_MSC_INTRINSICS |
| 19 # endif | 21 # endif |
| 20 #if _MSC_VER < 1900 | |
| 21 # define snprintf _snprintf | |
| 22 #endif | |
| 23 #endif | 22 #endif |
| 24 | 23 |
| 25 #ifdef __cplusplus | 24 #ifdef __cplusplus |
| 26 extern "C" { | 25 extern "C" { |
| 27 #endif | 26 #endif |
| 28 | 27 |
| 29 #include "./vpx_config.h" | 28 #include "./vpx_config.h" |
| 30 #if ARCH_X86 || ARCH_X86_64 | 29 #if ARCH_X86 || ARCH_X86_64 |
| 31 void vpx_reset_mmx_state(void); | 30 void vpx_reset_mmx_state(void); |
| 32 #define vp9_clear_system_state() vpx_reset_mmx_state() | 31 #define vp9_clear_system_state() vpx_reset_mmx_state() |
| (...skipping 10 matching lines...) Expand all Loading... |
| 43 return (int)floor(x + 0.5); | 42 return (int)floor(x + 0.5); |
| 44 } | 43 } |
| 45 #endif | 44 #endif |
| 46 | 45 |
| 47 // use GNU builtins where available. | 46 // use GNU builtins where available. |
| 48 #if defined(__GNUC__) && \ | 47 #if defined(__GNUC__) && \ |
| 49 ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) | 48 ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) |
| 50 static INLINE int get_msb(unsigned int n) { | 49 static INLINE int get_msb(unsigned int n) { |
| 51 return 31 ^ __builtin_clz(n); | 50 return 31 ^ __builtin_clz(n); |
| 52 } | 51 } |
| 53 #elif defined(USE_MSC_INTRIN) | 52 #elif defined(USE_MSC_INTRINSICS) |
| 54 #pragma intrinsic(_BitScanReverse) | 53 #pragma intrinsic(_BitScanReverse) |
| 55 | 54 |
| 56 static INLINE int get_msb(unsigned int n) { | 55 static INLINE int get_msb(unsigned int n) { |
| 57 unsigned long first_set_bit; | 56 unsigned long first_set_bit; |
| 58 _BitScanReverse(&first_set_bit, n); | 57 _BitScanReverse(&first_set_bit, n); |
| 59 return first_set_bit; | 58 return first_set_bit; |
| 60 } | 59 } |
| 61 #undef USE_MSC_INTRIN | 60 #undef USE_MSC_INTRINSICS |
| 62 #else | 61 #else |
| 63 // Returns (int)floor(log2(n)). n must be > 0. | 62 // Returns (int)floor(log2(n)). n must be > 0. |
| 64 static INLINE int get_msb(unsigned int n) { | 63 static INLINE int get_msb(unsigned int n) { |
| 65 int log = 0; | 64 int log = 0; |
| 66 unsigned int value = n; | 65 unsigned int value = n; |
| 67 int i; | 66 int i; |
| 68 | 67 |
| 69 for (i = 4; i >= 0; --i) { | 68 for (i = 4; i >= 0; --i) { |
| 70 const int shift = (1 << i); | 69 const int shift = (1 << i); |
| 71 const unsigned int x = value >> shift; | 70 const unsigned int x = value >> shift; |
| 72 if (x != 0) { | 71 if (x != 0) { |
| 73 value = x; | 72 value = x; |
| 74 log += shift; | 73 log += shift; |
| 75 } | 74 } |
| 76 } | 75 } |
| 77 return log; | 76 return log; |
| 78 } | 77 } |
| 79 #endif | 78 #endif |
| 80 | 79 |
| 81 #ifdef __cplusplus | 80 #ifdef __cplusplus |
| 82 } // extern "C" | 81 } // extern "C" |
| 83 #endif | 82 #endif |
| 84 | 83 |
| 85 #endif // VP9_COMMON_VP9_SYSTEMDEPENDENT_H_ | 84 #endif // VP9_COMMON_VP9_SYSTEMDEPENDENT_H_ |
| OLD | NEW |