aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcolour.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2016-12-17 14:37:48 +0100
committerMattias Andrée <maandree@kth.se>2016-12-17 14:37:48 +0100
commitc72ccb7d2cec01c8a614ef6746733dc8f66bb468 (patch)
tree2dbd7cdd43fb42ba6d65e4bba88fb2f00f9f4135 /src/libcolour.c
parentmore direction conversions (diff)
downloadlibcolour-c72ccb7d2cec01c8a614ef6746733dc8f66bb468.tar.gz
libcolour-c72ccb7d2cec01c8a614ef6746733dc8f66bb468.tar.bz2
libcolour-c72ccb7d2cec01c8a614ef6746733dc8f66bb468.tar.xz
Implement OEFT HLG
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--src/libcolour.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/libcolour.c b/src/libcolour.c
index 60dab61..57f1e80 100644
--- a/src/libcolour.c
+++ b/src/libcolour.c
@@ -296,6 +296,28 @@ static double invtransfer_function_l_star(double t)
return t * sign;
}
+static double transfer_function_oetf_hlg(double t)
+{
+ double sign = 1;
+ if (t < 0) {
+ t = -t;
+ sign = -1;
+ }
+ t = 12 * t <= 1 ? sqrt(3 * t) : 0.17883277 * log(t - 0.02372241) + 1.004293468902569985701234145381;
+ return t * sign;
+}
+
+static double invtransfer_function_oetf_hlg(double t)
+{
+ double sign = 1;
+ if (t < 0) {
+ t = -t;
+ sign = -1;
+ }
+ t = t <= 0.5 ? t * t / 3 : exp(t - 1.004293468902569985701234145381) / 0.17883277 + 0.02372241;
+ return t * sign;
+}
+
static void get_transfer_function(libcolour_colour_t* cs)
{
@@ -310,9 +332,12 @@ static void get_transfer_function(libcolour_colour_t* cs)
case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_PQ:
case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_HLG:
case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_HLG:
- case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_HLG:
/* TODO http://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.2100-0-201607-I!!PDF-E.pdf */
break;
+ case LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_HLG:
+ cs->rgb.to_encoded_red = cs->rgb.to_encoded_green = cs->rgb.to_encoded_blue = transfer_function_oetf_hlg;
+ cs->rgb.to_decoded_red = cs->rgb.to_decoded_green = cs->rgb.to_decoded_blue = invtransfer_function_oetf_hlg;
+ break;
default:
break;
}