blob: 2d3ab9b6537dc8c0c3c79af96e0b59b7d769c0ab [file] [log] [blame]
Johanncad0eca2015-05-07 16:41:33 -07001/*
Yaowu Xu9c01aa12016-09-01 14:32:49 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Johanncad0eca2015-05-07 16:41:33 -07003 *
Yaowu Xu9c01aa12016-09-01 14:32:49 -07004 * 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.
Johanncad0eca2015-05-07 16:41:33 -070010 */
11
Yaowu Xuf883b422016-08-30 14:01:10 -070012#ifndef AOM_PORTS_MSVC_H_
13#define AOM_PORTS_MSVC_H_
Johanncad0eca2015-05-07 16:41:33 -070014#ifdef _MSC_VER
15
Yaowu Xuf883b422016-08-30 14:01:10 -070016#include "./aom_config.h"
Johanncad0eca2015-05-07 16:41:33 -070017
clang-format05ce8502016-08-10 18:23:43 -070018#if _MSC_VER < 1900 // VS2015 provides snprintf
19#define snprintf _snprintf
20#endif // _MSC_VER < 1900
Johanncad0eca2015-05-07 16:41:33 -070021
Alex Conversef2e44aa2015-08-07 18:27:48 -070022#if _MSC_VER < 1800 // VS2013 provides round
James Zernd65ea852015-08-08 11:11:23 -070023#include <math.h>
Alex Conversef2e44aa2015-08-07 18:27:48 -070024static 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 Conversed1327ae2016-04-07 15:16:30 -070030
31static 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
38static 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 Conversef2e44aa2015-08-07 18:27:48 -070044#endif // _MSC_VER < 1800
45
Johanncad0eca2015-05-07 16:41:33 -070046#endif // _MSC_VER
Yaowu Xuf883b422016-08-30 14:01:10 -070047#endif // AOM_PORTS_MSVC_H_