| 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 VPX_PORTS_BITOPS_H_ |
| 12 #define VP9_COMMON_VP9_SYSTEMDEPENDENT_H_ | 12 #define VPX_PORTS_BITOPS_H_ |
| 13 | 13 |
| 14 #include "vpx_ports/msvc.h" | 14 #include "vpx_ports/msvc.h" |
| 15 | 15 |
| 16 #ifdef _MSC_VER | 16 #ifdef _MSC_VER |
| 17 # include <math.h> // the ceil() definition must precede intrin.h | 17 # include <math.h> // the ceil() definition must precede intrin.h |
| 18 # if _MSC_VER > 1310 && (defined(_M_X64) || defined(_M_IX86)) | 18 # if _MSC_VER > 1310 && (defined(_M_X64) || defined(_M_IX86)) |
| 19 # include <intrin.h> | 19 # include <intrin.h> |
| 20 # define USE_MSC_INTRINSICS | 20 # define USE_MSC_INTRINSICS |
| 21 # endif | 21 # endif |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 #ifdef __cplusplus | 24 #ifdef __cplusplus |
| 25 extern "C" { | 25 extern "C" { |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 #include "./vpx_config.h" | |
| 29 #if ARCH_X86 || ARCH_X86_64 | |
| 30 void vpx_reset_mmx_state(void); | |
| 31 #define vp9_clear_system_state() vpx_reset_mmx_state() | |
| 32 #else | |
| 33 #define vp9_clear_system_state() | |
| 34 #endif | |
| 35 | |
| 36 #if defined(_MSC_VER) && _MSC_VER < 1800 | |
| 37 // round is not defined in MSVC before VS2013. | |
| 38 static INLINE int round(double x) { | |
| 39 if (x < 0) | |
| 40 return (int)ceil(x - 0.5); | |
| 41 else | |
| 42 return (int)floor(x + 0.5); | |
| 43 } | |
| 44 #endif | |
| 45 | |
| 46 // use GNU builtins where available. | 28 // use GNU builtins where available. |
| 47 #if defined(__GNUC__) && \ | 29 #if defined(__GNUC__) && \ |
| 48 ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) | 30 ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4) |
| 49 static INLINE int get_msb(unsigned int n) { | 31 static INLINE int get_msb(unsigned int n) { |
| 50 return 31 ^ __builtin_clz(n); | 32 return 31 ^ __builtin_clz(n); |
| 51 } | 33 } |
| 52 #elif defined(USE_MSC_INTRINSICS) | 34 #elif defined(USE_MSC_INTRINSICS) |
| 53 #pragma intrinsic(_BitScanReverse) | 35 #pragma intrinsic(_BitScanReverse) |
| 54 | 36 |
| 55 static INLINE int get_msb(unsigned int n) { | 37 static INLINE int get_msb(unsigned int n) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 74 } | 56 } |
| 75 } | 57 } |
| 76 return log; | 58 return log; |
| 77 } | 59 } |
| 78 #endif | 60 #endif |
| 79 | 61 |
| 80 #ifdef __cplusplus | 62 #ifdef __cplusplus |
| 81 } // extern "C" | 63 } // extern "C" |
| 82 #endif | 64 #endif |
| 83 | 65 |
| 84 #endif // VP9_COMMON_VP9_SYSTEMDEPENDENT_H_ | 66 #endif // VPX_PORTS_BITOPS_H_ |
| OLD | NEW |