1//
2// SPDX-License-Identifier: BSD-3-Clause
3// Copyright (c) Contributors to the OpenEXR Project.
4//
5
6#ifndef INCLUDED_IMF_CONVERT_H
7#define INCLUDED_IMF_CONVERT_H
8
9//-----------------------------------------------------------------------------
10//
11// Routines for converting between pixel data types,
12// with well-defined behavior for exceptional cases,
13// without depending on how hardware and operating
14// system handle integer overflows and floating-point
15// exceptions.
16//
17//-----------------------------------------------------------------------------
18
19#include "ImfExport.h"
20#include "ImfNamespace.h"
21
22#include <half.h>
23
24OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER
25
26
27//---------------------------------------------------------
28// Conversion from half or float to unsigned int:
29//
30// input result
31// ---------------------------------------------------
32//
33// finite, >= 0 input, cast to unsigned int
34// (rounds towards zero)
35//
36// finite, < 0 0
37//
38// NaN 0
39//
40// +infinity UINT_MAX
41//
42// -infinity 0
43//
44//---------------------------------------------------------
45
46IMF_EXPORT unsigned int halfToUint (half h);
47IMF_EXPORT unsigned int floatToUint (float f);
48
49
50//---------------------------------------------------------
51// Conversion from unsigned int or float to half:
52//
53// input result
54// ---------------------------------------------------
55//
56// finite, closest possible half
57// magnitude <= HALF_MAX
58//
59// finite, > HALF_MAX +infinity
60//
61// finite, < -HALF_MAX -infinity
62//
63// NaN NaN
64//
65// +infinity +infinity
66//
67// -infinity -infinity
68//
69//---------------------------------------------------------
70
71IMF_EXPORT half uintToHalf (unsigned int ui);
72IMF_EXPORT half floatToHalf (float f);
73
74
75OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT
76
77
78#endif
79

source code of include/OpenEXR/ImfConvert.h