blob: de44123b289f2d6cd4ceac0c8a802503e06f744e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
/* EINA - EFL data type library
* Copyright (C) 2007-2008 Jorge Luis Zapata Muga
* Copyright (C) 2009 Cedric BAIL
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library;
* if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef EINA_INLINE_FP_X_
# define EINA_INLINE_FP_X_
static inline Eina_F32p32
eina_f32p32_int_from(int32_t v)
{
return (Eina_F32p32)(v) << 32;
}
static inline int32_t
eina_f32p32_int_to(Eina_F32p32 v)
{
return (int32_t)(v >> 32);
}
static inline Eina_F32p32
eina_f32p32_double_from(double v)
{
Eina_F32p32 r;
r = (Eina_F32p32)(v * 4294967296.0 + (v < 0 ? -0.5 : 0.5));
return r;
}
static inline double
eina_f32p32_double_to(Eina_F32p32 v)
{
double r;
r = v / 4294967296.0;
return r;
}
static inline Eina_F16p16
eina_f16p16_int_from(int32_t v)
{
return v << 16;
}
static inline int32_t
eina_f16p16_int_to(Eina_F16p16 v)
{
return v >> 16;
}
static inline Eina_F16p16
eina_f16p16_float_from(float v)
{
Eina_F16p16 r;
r = (Eina_F16p16)(v * 65536.0f + (v < 0 ? -0.5f : 0.5f));
return r;
}
static inline float
eina_f16p16_float_to(Eina_F16p16 v)
{
float r;
r = v / 65536.0f;
return r;
}
static inline Eina_F8p24
eina_f8p24_int_from(int32_t v)
{
return v << 24;
}
static inline int32_t
eina_f8p24_int_to(Eina_F8p24 v)
{
return v >> 24;
}
static inline Eina_F8p24
eina_f8p24_float_from(float v)
{
Eina_F8p24 r;
r = (Eina_F8p24)(v * 16777216.0f + (v < 0 ? -0.5f : 0.5f));
return r;
}
static inline float
eina_f8p24_float_to(Eina_F8p24 v)
{
float r;
r = v / 16777216.0f;
return r;
}
static inline Eina_F32p32
eina_f16p16_to_f32p32(Eina_F16p16 a)
{
return ((Eina_F32p32) a) << 16;
}
static inline Eina_F32p32
eina_f8p24_to_f32p32(Eina_F8p24 a)
{
return ((Eina_F32p32) a) << 8;
}
static inline Eina_F16p16
eina_f32p32_to_f16p16(Eina_F32p32 a)
{
return (Eina_F16p16) (a >> 16);
}
static inline Eina_F16p16
eina_f8p24_to_f16p16(Eina_F8p24 a)
{
return (Eina_F16p16) (a >> 8);
}
static inline Eina_F8p24
eina_f32p32_to_f8p24(Eina_F32p32 a)
{
return (Eina_F8p24) (a >> 8);
}
static inline Eina_F8p24
eina_f16p16_to_f8p24(Eina_F16p16 a)
{
return (Eina_F8p24) (a << 8);
}
#endif
|