Skip to content

Commit b5569dc

Browse files
committed
Attemp to reduce dependencies on half.h
Signed-off-by: Kevin Wheatley <kevin.wheatley@framestore.com>
1 parent 47f776c commit b5569dc

File tree

21 files changed

+64
-13
lines changed

21 files changed

+64
-13
lines changed

src/OpenColorIO/AVX.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
#include <immintrin.h>
1212

13+
#if OCIO_USE_F16C
14+
#include <Imath/half.h>
15+
#endif
16+
1317
#include <OpenColorIO/OpenColorIO.h>
1418
#include "BitDepthUtils.h"
1519

src/OpenColorIO/AVX2.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
#include <immintrin.h>
1212

13+
#if OCIO_USE_F16C
14+
#include <Imath/half.h>
15+
#endif
16+
1317
#include <OpenColorIO/OpenColorIO.h>
1418
#include "BitDepthUtils.h"
1519

src/OpenColorIO/AVX512.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
#include <immintrin.h>
1212

13+
#include <Imath/half.h>
14+
1315
#include <OpenColorIO/OpenColorIO.h>
1416
#include "BitDepthUtils.h"
1517

src/OpenColorIO/MathHalfUtils.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// SPDX-License-Identifier: BSD-3-Clause
2+
// Copyright Contributors to the OpenColorIO Project.
3+
4+
#ifndef INCLUDED_OCIO_MATHHALFUTILS_H
5+
#define INCLUDED_OCIO_MATHHALFUTILS_H
6+
7+
#include <OpenColorABI.h>
8+
9+
#include <Imath/half.h>
10+
11+
namespace OCIO_NAMESPACE
12+
{
13+
// Compares half-floats as raw integers with a tolerance (essentially in ULPs).
14+
// Returns true if the integer difference is strictly greater than the tolerance.
15+
// If aimHalf is a NaN, valHalf must also be one of the NaNs.
16+
// Inf is treated like any other value (diff from HALFMAX is 1).
17+
bool HalfsDiffer(const half expected, const half actual, const int tolerance);
18+
19+
} // namespace OCIO_NAMESPACE
20+
21+
#endif

src/OpenColorIO/MathUtils.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
#include <type_traits>
88
#include <limits>
99

10+
#include <Imath/half.h>
11+
1012
#include <OpenColorIO/OpenColorIO.h>
1113

1214
#include "MathUtils.h"
15+
#include "MathHalfUtils.h"
1316

1417
namespace OCIO_NAMESPACE
1518
{

src/OpenColorIO/MathUtils.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
#include <algorithm>
88
#include <cmath>
99

10-
#include <OpenColorIO/OpenColorIO.h>
11-
12-
#include <Imath/half.h>
10+
#include <OpenColorABI.h>
1311

1412
namespace OCIO_NAMESPACE
1513
{
@@ -213,12 +211,6 @@ inline float AddULP(const float f, const int ulp)
213211
bool FloatsDiffer(const float expected, const float actual,
214212
const int tolerance, const bool compressDenorms);
215213

216-
// Compares half-floats as raw integers with a tolerance (essentially in ULPs).
217-
// Returns true if the integer difference is strictly greater than the tolerance.
218-
// If aimHalf is a NaN, valHalf must also be one of the NaNs.
219-
// Inf is treated like any other value (diff from HALFMAX is 1).
220-
bool HalfsDiffer(const half expected, const half actual, const int tolerance);
221-
222214
} // namespace OCIO_NAMESPACE
223215

224216
#endif

src/OpenColorIO/SSE2.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include "CPUInfo.h"
99
#if OCIO_USE_SSE2
1010

11+
#include <Imath/half.h>
12+
1113
// Include the appropriate SIMD intrinsics header based on the architecture (Intel vs. ARM).
1214
#if !defined(__aarch64__) && !defined(_M_ARM64)
1315
#include <emmintrin.h>

src/OpenColorIO/fileformats/FileFormatDiscreet1DL.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
#include <pystring.h>
1313

14+
#include <Imath/half.h>
15+
1416
#include <OpenColorIO/OpenColorIO.h>
1517

1618
#include "BitDepthUtils.h"

src/OpenColorIO/fileformats/ctf/CTFTransform.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <vector>
1111
#include <memory>
1212

13+
#include <Imath/half.h>
14+
1315
#include "BitDepthUtils.h"
1416
#include "fileformats/ctf/CTFReaderUtils.h"
1517
#include "fileformats/ctf/CTFTransform.h"

src/OpenColorIO/ops/lut1d/Lut1DOpCPU.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <memory>
77
#include <cstdint>
88

9+
#include <Imath/half.h>
10+
911
#include <OpenColorIO/OpenColorIO.h>
1012

1113
#include "BitDepthUtils.h"

0 commit comments

Comments
 (0)