summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJorge Zapata <jorgeluis.zapata@gmail.com>2013-09-23 20:48:52 +0200
committerCedric Bail <cedric.bail@samsung.com>2013-09-24 12:20:27 +0900
commit538821f09d4dcd71642eb7f4d782ef350b956ddf (patch)
treef95b2eeac2dbd8ebf2f80edf2f78596cf36d0769
parent4850c4660f226f1d58f3e877d0b8ddbd6a6c77d4 (diff)
eina: add double_from/to and helper defines in f16p16
Diffstat (limited to '')
-rw-r--r--src/lib/eina/eina_fp.h6
-rw-r--r--src/lib/eina/eina_inline_fp.x17
2 files changed, 23 insertions, 0 deletions
diff --git a/src/lib/eina/eina_fp.h b/src/lib/eina/eina_fp.h
index c73dc16fca..bc6c78d196 100644
--- a/src/lib/eina/eina_fp.h
+++ b/src/lib/eina/eina_fp.h
@@ -60,8 +60,14 @@ static inline unsigned int eina_f32p32_fracc_get(Eina_F32p32 v);
60EAPI Eina_F32p32 eina_f32p32_cos(Eina_F32p32 a); 60EAPI Eina_F32p32 eina_f32p32_cos(Eina_F32p32 a);
61EAPI Eina_F32p32 eina_f32p32_sin(Eina_F32p32 a); 61EAPI Eina_F32p32 eina_f32p32_sin(Eina_F32p32 a);
62 62
63
64#define EINA_F16P16_ONE (1 << 16)
65#define EINA_F16P16_HALF (1 << 15)
66
63static inline Eina_F16p16 eina_f16p16_int_from(int32_t v); 67static inline Eina_F16p16 eina_f16p16_int_from(int32_t v);
64static inline int32_t eina_f16p16_int_to(Eina_F16p16 v); 68static inline int32_t eina_f16p16_int_to(Eina_F16p16 v);
69static inline Eina_F16p16 eina_f16p16_double_from(double v);
70static inline double eina_f16p16_double_to(Eina_F16p16 v);
65static inline Eina_F16p16 eina_f16p16_float_from(float v); 71static inline Eina_F16p16 eina_f16p16_float_from(float v);
66static inline float eina_f16p16_float_to(Eina_F16p16 v); 72static inline float eina_f16p16_float_to(Eina_F16p16 v);
67 73
diff --git a/src/lib/eina/eina_inline_fp.x b/src/lib/eina/eina_inline_fp.x
index de44123b28..e459f82f77 100644
--- a/src/lib/eina/eina_inline_fp.x
+++ b/src/lib/eina/eina_inline_fp.x
@@ -80,6 +80,23 @@ eina_f16p16_float_to(Eina_F16p16 v)
80 return r; 80 return r;
81} 81}
82 82
83static inline Eina_F16p16
84eina_f16p16_double_from(double v)
85{
86 Eina_F16p16 r;
87
88 r = (Eina_F16p16)(v * 65536.0 + (v < 0 ? -0.5 : 0.5));
89 return r;
90}
91
92static inline double
93eina_f16p16_double_to(Eina_F16p16 v)
94{
95 double r;
96
97 r = v / 65536.0;
98 return r;
99}
83 100
84 101
85static inline Eina_F8p24 102static inline Eina_F8p24