Johann | cad0eca | 2015-05-07 16:41:33 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Johann | cad0eca | 2015-05-07 16:41:33 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | 9c01aa1 | 2016-09-01 14:32:49 -0700 | [diff] [blame] | 4 | * This source code is subject to the terms of the BSD 2 Clause License and |
| 5 | * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License |
| 6 | * was not distributed with this source code in the LICENSE file, you can |
| 7 | * obtain it at www.aomedia.org/license/software. If the Alliance for Open |
| 8 | * Media Patent License 1.0 was not distributed with this source code in the |
| 9 | * PATENTS file, you can obtain it at www.aomedia.org/license/patent. |
Johann | cad0eca | 2015-05-07 16:41:33 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 12 | #ifndef AOM_PORTS_MSVC_H_ |
| 13 | #define AOM_PORTS_MSVC_H_ |
Johann | cad0eca | 2015-05-07 16:41:33 -0700 | [diff] [blame] | 14 | #ifdef _MSC_VER |
| 15 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 16 | #include "./aom_config.h" |
Johann | cad0eca | 2015-05-07 16:41:33 -0700 | [diff] [blame] | 17 | |
clang-format | 05ce850 | 2016-08-10 18:23:43 -0700 | [diff] [blame] | 18 | #if _MSC_VER < 1900 // VS2015 provides snprintf |
| 19 | #define snprintf _snprintf |
| 20 | #endif // _MSC_VER < 1900 |
Johann | cad0eca | 2015-05-07 16:41:33 -0700 | [diff] [blame] | 21 | |
Alex Converse | f2e44aa | 2015-08-07 18:27:48 -0700 | [diff] [blame] | 22 | #if _MSC_VER < 1800 // VS2013 provides round |
James Zern | d65ea85 | 2015-08-08 11:11:23 -0700 | [diff] [blame] | 23 | #include <math.h> |
Alex Converse | f2e44aa | 2015-08-07 18:27:48 -0700 | [diff] [blame] | 24 | static INLINE double round(double x) { |
| 25 | if (x < 0) |
| 26 | return ceil(x - 0.5); |
| 27 | else |
| 28 | return floor(x + 0.5); |
| 29 | } |
Alex Converse | d1327ae | 2016-04-07 15:16:30 -0700 | [diff] [blame] | 30 | |
| 31 | static INLINE float roundf(float x) { |
| 32 | if (x < 0) |
| 33 | return (float)ceil(x - 0.5f); |
| 34 | else |
| 35 | return (float)floor(x + 0.5f); |
| 36 | } |
| 37 | |
| 38 | static INLINE long lroundf(float x) { |
| 39 | if (x < 0) |
| 40 | return (long)(x - 0.5f); |
| 41 | else |
| 42 | return (long)(x + 0.5f); |
| 43 | } |
Alex Converse | f2e44aa | 2015-08-07 18:27:48 -0700 | [diff] [blame] | 44 | #endif // _MSC_VER < 1800 |
| 45 | |
Johann | cad0eca | 2015-05-07 16:41:33 -0700 | [diff] [blame] | 46 | #endif // _MSC_VER |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 47 | #endif // AOM_PORTS_MSVC_H_ |