diff options
| author | Mattias Andrée <maandree@kth.se> | 2017-01-08 08:00:53 +0100 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2017-01-08 08:00:53 +0100 |
| commit | 9fa7221a87817fe41a12a9cbdaa4bac6ee67b07d (patch) | |
| tree | fdbc1038680138e03ccc0e9ce753639b19807423 /src/util.h | |
| parent | Add vu-image-to-frame (diff) | |
| download | blind-9fa7221a87817fe41a12a9cbdaa4bac6ee67b07d.tar.gz blind-9fa7221a87817fe41a12a9cbdaa4bac6ee67b07d.tar.bz2 blind-9fa7221a87817fe41a12a9cbdaa4bac6ee67b07d.tar.xz | |
Add vu-stack
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/util.h')
| -rw-r--r-- | src/util.h | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -1,5 +1,6 @@ /* See LICENSE file for copyright and license details. */ +#include <math.h> #include <stdio.h> #define ELEMENTSOF(ARRAY) (sizeof(ARRAY) / sizeof(*(ARRAY))) @@ -33,3 +34,27 @@ DEF_STR_TO_INT(toi, int, tolli, long long int) int fshut(FILE *fp, const char *fname); void enfshut(int status, FILE *fp, const char *fname); void efshut(FILE *fp, const char *fname); + +static inline double +srgb_encode(double t) +{ + double sign = 1; + if (t < 0) { + t = -t; + sign = -1; + } + t = t <= 0.0031306684425217108 ? 12.92 * t : 1.055 * pow(t, 1 / 2.4) - 0.055; + return t * sign; +} + +static inline double +srgb_decode(double t) +{ + double sign = 1; + if (t < 0) { + t = -t; + sign = -1; + } + t = t <= 0.0031306684425217108 * 12.92 ? t / 12.92 : pow((t + 0.055) / 1.055, 2.4); + return t * sign; +} |
