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