Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntony Riakiotakis <kalast@gmail.com>2015-03-17 17:20:33 +0300
committerAntony Riakiotakis <kalast@gmail.com>2015-03-17 17:20:33 +0300
commitdd38dce7f0ae604396d1e96bc49500369fdedf29 (patch)
tree2b32e776f0bb972705d2c884cb6d5ec77deaf714 /source/blender/imbuf/intern/colormanagement.c
parent42aac45d7f0e0f43725093e97ebb8175a95aa247 (diff)
Part 2 of D1082 by Troy Sobotka, remove our functions that do luma
calculations and use the OCIO one instead.
Diffstat (limited to 'source/blender/imbuf/intern/colormanagement.c')
-rw-r--r--source/blender/imbuf/intern/colormanagement.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index 95e166b2f8b..588d81f9a75 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -90,6 +90,11 @@ static int global_tot_display = 0;
static int global_tot_view = 0;
static int global_tot_looks = 0;
+/* Set to ITU-BT.709 / sRGB primaries weight. Brute force stupid, but only
+ * option with no colormanagement in place.
+ */
+static float luma_coefficients[3] = { 0.2126729f, 0.7151522f, 0.0721750f };
+
/* lock used by pre-cached processors getters, so processor wouldn't
* be created several times
* LOCK_COLORMANAGE can not be used since this mutex could be needed to
@@ -545,6 +550,9 @@ static void colormanage_load_config(OCIO_ConstConfigRcPtr *config)
colormanage_look_add(name, process_space, false);
}
+
+ /* Load luminance coefficients. */
+ OCIO_configGetDefaultLumaCoefs(config, luma_coefficients);
}
static void colormanage_free_config(void)
@@ -1222,6 +1230,34 @@ const char *IMB_colormanagement_get_rect_colorspace(ImBuf *ibuf)
return ibuf->rect_colorspace->name;
}
+/* Convert a float RGB triplet to the correct luminance weighted average.
+ *
+ * Grayscale, or Luma is a distillation of RGB data values down to a weighted average
+ * based on the luminance positions of the red, green, and blue primaries.
+ * Given that the internal reference space may be arbitrarily set, any
+ * effort to glean the luminance coefficients must be aware of the reference
+ * space primaries.
+ *
+ * See http://wiki.blender.org/index.php/User:Nazg-gul/ColorManagement#Luminance
+ */
+
+float IMB_colormanagement_get_luminance(const float rgb[3])
+{
+ return dot_v3v3(luma_coefficients, rgb);
+}
+
+/* Byte equivalent of IMB_colormanagement_get_luminance(). */
+unsigned char IMB_colormanagement_get_luminance_byte(const unsigned char rgb[3])
+{
+ float rgbf[3];
+
+ rgbf[0] = (float) rgb[0] / 255.0f;
+ rgbf[1] = (float) rgb[1] / 255.0f;
+ rgbf[2] = (float) rgb[2] / 255.0f;
+
+ return FTOCHAR(dot_v3v3(luma_coefficients, rgbf));
+}
+
/*********************** Threaded display buffer transform routines *************************/
typedef struct DisplayBufferThread {