2010-05-18 11:58:33 -04:00
|
|
|
/*
|
2010-09-09 08:16:39 -04:00
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 11:58:33 -04:00
|
|
|
*
|
2010-06-18 12:39:21 -04:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-04 16:19:40 -04:00
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
2010-06-18 12:39:21 -04:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-04 16:19:40 -04:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 11:58:33 -04:00
|
|
|
*/
|
2012-12-18 15:31:19 -08:00
|
|
|
|
2012-11-29 16:36:10 -08:00
|
|
|
#ifndef VP9_COMMON_VP9_SYSTEMDEPENDENT_H_
|
|
|
|
#define VP9_COMMON_VP9_SYSTEMDEPENDENT_H_
|
2010-05-18 11:58:33 -04:00
|
|
|
|
2014-02-04 18:28:45 -08:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
# if _MSC_VER > 1310 && (defined(_M_X64) || defined(_M_IX86))
|
|
|
|
# include <intrin.h>
|
|
|
|
# define USE_MSC_INTRIN
|
|
|
|
# endif
|
|
|
|
# include <math.h>
|
|
|
|
# define snprintf _snprintf
|
2014-01-18 12:16:11 -08:00
|
|
|
#endif
|
|
|
|
|
2014-02-04 18:28:45 -08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
2012-12-13 14:51:27 -08:00
|
|
|
#endif
|
|
|
|
|
2012-12-23 07:20:10 -08:00
|
|
|
#include "./vpx_config.h"
|
2010-05-18 11:58:33 -04:00
|
|
|
#if ARCH_X86 || ARCH_X86_64
|
|
|
|
void vpx_reset_mmx_state(void);
|
2012-10-31 14:40:53 -07:00
|
|
|
#define vp9_clear_system_state() vpx_reset_mmx_state()
|
2010-05-18 11:58:33 -04:00
|
|
|
#else
|
2012-10-31 14:40:53 -07:00
|
|
|
#define vp9_clear_system_state()
|
2010-05-18 11:58:33 -04:00
|
|
|
#endif
|
|
|
|
|
2013-10-11 14:27:00 -07:00
|
|
|
#if defined(_MSC_VER) && _MSC_VER < 1800
|
|
|
|
// round is not defined in MSVC before VS2013.
|
2014-02-09 20:19:37 -08:00
|
|
|
static INLINE int round(double x) {
|
2012-12-13 14:51:27 -08:00
|
|
|
if (x < 0)
|
|
|
|
return (int)ceil(x - 0.5);
|
|
|
|
else
|
|
|
|
return (int)floor(x + 0.5);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-01-08 12:25:47 -08:00
|
|
|
// use GNU builtins where available.
|
|
|
|
#if defined(__GNUC__) && \
|
|
|
|
((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || __GNUC__ >= 4)
|
|
|
|
static INLINE int get_msb(unsigned int n) {
|
|
|
|
return 31 ^ __builtin_clz(n);
|
|
|
|
}
|
2014-02-04 18:28:45 -08:00
|
|
|
#elif defined(USE_MSC_INTRIN)
|
2014-01-08 12:25:47 -08:00
|
|
|
#pragma intrinsic(_BitScanReverse)
|
|
|
|
|
|
|
|
static INLINE int get_msb(unsigned int n) {
|
|
|
|
unsigned long first_set_bit;
|
|
|
|
_BitScanReverse(&first_set_bit, n);
|
|
|
|
return first_set_bit;
|
|
|
|
}
|
2014-02-04 18:28:45 -08:00
|
|
|
#undef USE_MSC_INTRIN
|
2014-01-03 13:24:11 -08:00
|
|
|
#else
|
2014-01-08 12:25:47 -08:00
|
|
|
// Returns (int)floor(log2(n)). n must be > 0.
|
|
|
|
static INLINE int get_msb(unsigned int n) {
|
|
|
|
int log = 0;
|
|
|
|
unsigned int value = n;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 4; i >= 0; --i) {
|
|
|
|
const int shift = (1 << i);
|
|
|
|
const unsigned int x = value >> shift;
|
|
|
|
if (x != 0) {
|
|
|
|
value = x;
|
|
|
|
log += shift;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return log;
|
2014-01-03 13:24:11 -08:00
|
|
|
}
|
2014-01-08 12:25:47 -08:00
|
|
|
#endif
|
2014-01-03 13:24:11 -08:00
|
|
|
|
2012-10-30 17:53:32 -07:00
|
|
|
struct VP9Common;
|
2013-08-23 19:30:33 -07:00
|
|
|
void vp9_machine_specific_config(struct VP9Common *cm);
|
2012-12-18 15:31:19 -08:00
|
|
|
|
2014-01-18 12:16:11 -08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
2012-12-18 15:31:19 -08:00
|
|
|
#endif // VP9_COMMON_VP9_SYSTEMDEPENDENT_H_
|