[Bf-blender-cvs] [dd38dce] master: Part 2 of D1082 by Troy Sobotka, remove our functions that do luma calculations and use the OCIO one instead.

Antony Riakiotakis noreply at git.blender.org
Tue Mar 17 15:20:59 CET 2015


Commit: dd38dce7f0ae604396d1e96bc49500369fdedf29
Author: Antony Riakiotakis
Date:   Tue Mar 17 15:20:33 2015 +0100
Branches: master
https://developer.blender.org/rBdd38dce7f0ae604396d1e96bc49500369fdedf29

Part 2 of D1082 by Troy Sobotka, remove our functions that do luma
calculations and use the OCIO one instead.

===================================================================

M	source/blender/blenkernel/intern/colortools.c
M	source/blender/blenlib/BLI_math_color.h
M	source/blender/blenlib/intern/math_color_inline.c
M	source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
M	source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
M	source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
M	source/blender/compositor/operations/COM_ConvertOperation.cpp
M	source/blender/compositor/operations/COM_GlareThresholdOperation.cpp
M	source/blender/compositor/operations/COM_TonemapOperation.cpp
M	source/blender/editors/interface/interface_draw.c
M	source/blender/editors/interface/interface_regions.c
M	source/blender/editors/interface/interface_widgets.c
M	source/blender/editors/sculpt_paint/paint_image_2d.c
M	source/blender/editors/sculpt_paint/paint_image_proj.c
M	source/blender/editors/sculpt_paint/paint_vertex.c
M	source/blender/editors/space_sequencer/sequencer_scopes.c
M	source/blender/imbuf/IMB_colormanagement.h
M	source/blender/imbuf/intern/colormanagement.c
M	source/blender/imbuf/intern/divers.c
M	source/blender/imbuf/intern/png.c
M	source/blender/nodes/shader/nodes/node_shader_valToRgb.c
M	source/blender/nodes/texture/nodes/node_texture_valToRgb.c
M	source/blender/render/intern/source/render_texture.c
M	source/blender/render/intern/source/shadeoutput.c
M	source/blender/render/intern/source/volumetric.c

===================================================================

diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c
index 89c3e4b..616e8a0 100644
--- a/source/blender/blenkernel/intern/colortools.c
+++ b/source/blender/blenkernel/intern/colortools.c
@@ -994,7 +994,7 @@ void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const ColorM
 				copy_v3_v3(rgb, fp);
 				IMB_colormanagement_processor_apply_v3(cm_processor, rgb);
 
-				hist->data_luma[i]  = rgb_to_luma(rgb);
+				hist->data_luma[i]  = IMB_colormanagement_get_luminance(rgb);
 				hist->data_r[i]     = rgb[0];
 				hist->data_g[i]     = rgb[1];
 				hist->data_b[i]     = rgb[2];
@@ -1002,7 +1002,7 @@ void BKE_histogram_update_sample_line(Histogram *hist, ImBuf *ibuf, const ColorM
 			}
 			else if (ibuf->rect) {
 				cp = (unsigned char *)(ibuf->rect + y * ibuf->x + x);
-				hist->data_luma[i]  = (float)rgb_to_luma_byte(cp) / 255.0f;
+				hist->data_luma[i]  = (float)IMB_colormanagement_get_luminance_byte(cp) / 255.0f;
 				hist->data_r[i]     = (float)cp[0] / 255.0f;
 				hist->data_g[i]     = (float)cp[1] / 255.0f;
 				hist->data_b[i]     = (float)cp[2] / 255.0f;
@@ -1124,7 +1124,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, const ColorManagedViewSettings *
 			}
 
 			/* we still need luma for histogram */
-			luma = rgb_to_luma(rgba);
+			luma = IMB_colormanagement_get_luminance(rgba);
 
 			/* check for min max */
 			if (ycc_mode == -1) {
diff --git a/source/blender/blenlib/BLI_math_color.h b/source/blender/blenlib/BLI_math_color.h
index 55e57b1..5652c80 100644
--- a/source/blender/blenlib/BLI_math_color.h
+++ b/source/blender/blenlib/BLI_math_color.h
@@ -80,13 +80,6 @@ void rgb_to_xyz(float r, float g, float b, float *x, float *y, float *z);
 unsigned int rgb_to_cpack(float r, float g, float b);
 unsigned int hsv_to_cpack(float h, float s, float v);
 
-MINLINE float rgb_to_bw(const float rgb[3]);
-MINLINE float rgb_to_grayscale(const float rgb[3]);
-MINLINE unsigned char rgb_to_grayscale_byte(const unsigned char rgb[3]);
-MINLINE float rgb_to_luma(const float rgb[3]);
-MINLINE unsigned char rgb_to_luma_byte(const unsigned char rgb[3]);
-MINLINE float rgb_to_luma_y(const float rgb[3]);
-
 /**************** Profile Transformations *****************/
 
 float srgb_to_linearrgb(float c);
diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c
index dc62d04..96aa4b5 100644
--- a/source/blender/blenlib/intern/math_color_inline.c
+++ b/source/blender/blenlib/intern/math_color_inline.c
@@ -200,61 +200,6 @@ MINLINE void cpack_cpy_3ub(unsigned char r_col[3], const unsigned int pack)
 	r_col[2] = ((pack) >> 16) & 0xFF;
 }
 
-/* TODO:
- *
- * regarding #rgb_to_bw vs #rgb_to_grayscale,
- * it seems nobody knows why we have both functions which convert color to grays
- * but with different influences, this is quite stupid, and should be resolved
- * by someone who knows this stuff: see this thread
- * http://lists.blender.org/pipermail/bf-committers/2012-June/037180.html
- *
- * Only conclusion is that rgb_to_grayscale is used more for compositing.
- */
-MINLINE float rgb_to_bw(const float rgb[3])
-{
-	return 0.35f * rgb[0] + 0.45f * rgb[1] + 0.2f * rgb[2];
-}
-
-/* non-linear luma from ITU-R BT.601-2
- * see: http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html#RTFToC11
- * note: the values used for are not exact matches to those documented above,
- * but they are from the same */
-MINLINE float rgb_to_grayscale(const float rgb[3])
-{
-	return 0.3f * rgb[0] + 0.58f * rgb[1] + 0.12f * rgb[2];
-}
-
-MINLINE unsigned char rgb_to_grayscale_byte(const unsigned char rgb[3])
-{
-	return (unsigned char)(((76  * (unsigned short)rgb[0]) +
-	                        (148 * (unsigned short)rgb[1]) +
-	                        (31  * (unsigned short)rgb[2])) / 255);
-}
-
-/* luma from defined by 'YCC_JFIF', see #rgb_to_ycc */
-MINLINE float rgb_to_luma(const float rgb[3])
-{
-	return 0.299f * rgb[0] + 0.587f * rgb[1] + 0.114f * rgb[2];
-}
-
-MINLINE unsigned char rgb_to_luma_byte(const unsigned char rgb[3])
-{
-	return (unsigned char)(((76  * (unsigned short)rgb[0]) +
-	                        (150 * (unsigned short)rgb[1]) +
-	                        (29  * (unsigned short)rgb[2])) / 255);
-}
-
-/* gamma-corrected RGB --> CIE XYZ
- * for this function we only get the Y component
- * see: http://software.intel.com/sites/products/documentation/hpc/ipp/ippi/ippi_ch6/ch6_color_models.html
- *
- * also known as:
- * luminance rec. 709 */
-MINLINE float rgb_to_luma_y(const float rgb[3])
-{
-	return 0.212671f * rgb[0] + 0.71516f * rgb[1] + 0.072169f * rgb[2];
-}
-
 MINLINE int compare_rgb_uchar(const unsigned char col_a[3], const unsigned char col_b[3], const int limit)
 {
 	const int r = (int)col_a[0] - (int)col_b[0];
diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
index a2954a2..54b0e37 100644
--- a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
+++ b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp
@@ -24,7 +24,9 @@
 #include "BLI_math.h"
 #include "BLI_utildefines.h"
 
-
+extern "C" {
+#include "IMB_colormanagement.h"
+}
 
 CalculateMeanOperation::CalculateMeanOperation() : NodeOperation()
 {
@@ -96,7 +98,7 @@ void CalculateMeanOperation::calculateMean(MemoryBuffer *tile)
 			switch (this->m_setting) {
 				case 1:
 				{
-					sum += rgb_to_bw(&buffer[offset]);
+					sum += IMB_colormanagement_get_luminance(&buffer[offset]);
 					break;
 				}
 				case 2:
diff --git a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
index 0c67da2..32c5fc1 100644
--- a/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
+++ b/source/blender/compositor/operations/COM_CalculateStandardDeviationOperation.cpp
@@ -24,7 +24,9 @@
 #include "BLI_math.h"
 #include "BLI_utildefines.h"
 
-
+extern "C" {
+#include "IMB_colormanagement.h"
+}
 
 CalculateStandardDeviationOperation::CalculateStandardDeviationOperation() : CalculateMeanOperation()
 {
@@ -55,7 +57,7 @@ void *CalculateStandardDeviationOperation::initializeTileData(rcti *rect)
 				switch (this->m_setting) {
 					case 1:  /* rgb combined */
 					{
-						float value = rgb_to_bw(&buffer[offset]);
+						float value = IMB_colormanagement_get_luminance(&buffer[offset]);
 						sum += (value - mean) * (value - mean);
 						break;
 					}
diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
index 1920995..54e0fb4 100644
--- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cpp
@@ -23,6 +23,10 @@
 #include "COM_ColorCorrectionOperation.h"
 #include "BLI_math.h"
 
+extern "C" {
+#include "IMB_colormanagement.h"
+}
+
 ColorCorrectionOperation::ColorCorrectionOperation() : NodeOperation()
 {
 	this->addInputSocket(COM_DT_COLOR);
@@ -90,7 +94,7 @@ void ColorCorrectionOperation::executePixelSampled(float output[4], float x, flo
 	lift += (levelShadows * this->m_data->shadows.lift) + (levelMidtones * this->m_data->midtones.lift) + (levelHighlights * this->m_data->highlights.lift);
 	
 	float invgamma = 1.0f / gamma;
-	float luma = rgb_to_luma_y(inputImageColor);
+	float luma = IMB_colormanagement_get_luminance(inputImageColor);
 
 	r = inputImageColor[0];
 	g = inputImageColor[1];
diff --git a/source/blender/compositor/operations/COM_ConvertOperation.cpp b/source/blender/compositor/operations/COM_ConvertOperation.cpp
index 977586a..8b8e840 100644
--- a/source/blender/compositor/operations/COM_ConvertOperation.cpp
+++ b/source/blender/compositor/operations/COM_ConvertOperation.cpp
@@ -22,6 +22,9 @@
 
 #include "COM_ConvertOperation.h"
 
+extern "C" {
+#include "IMB_colormanagement.h"
+}
 
 ConvertBaseOperation::ConvertBaseOperation()
 {
@@ -84,7 +87,7 @@ void ConvertColorToBWOperation::executePixelSampled(float output[4], float x, fl
 {
 	float inputColor[4];
 	this->m_inputOperation->readSampled(inputColor, x, y, sampler);
-	output[0] = rgb_to_bw(inputColor);
+	output[0] = IMB_colormanagement_get_luminance(inputColor);
 }
 
 
diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp
index 78e1e80..d2bd7cb 100644
--- a/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp
+++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.cpp
@@ -23,6 +23,10 @@
 #include "COM_GlareThresholdOperation.h"
 #include "BLI_math.h"
 
+extern "C" {
+#include "IMB_colormanagement.h"
+}
+
 GlareThresholdOperation::GlareThresholdOperation() : NodeOperation()
 {
 	this->addInputSocket(COM_DT_COLOR, COM_SC_FIT);
@@ -47,7 +51,7 @@ void GlareThresholdOperation::executePixelSampled(float output[4], float x, floa
 	const float threshold = this->m_settings->threshold;
 	
 	this->m_inputProgram->readSampled(output, x, y, sampler);
-	if (rgb_to_luma_y(output) >= threshold) {
+	if (IMB_colormanagement_get_luminance(output) >= threshold) {
 		output[0] -= threshold, output[1] -= threshold, output[2] -= threshold;
 		output[0] = max(output[0], 0.0f);
 		output[1] = max(output[1], 0.0f);
diff --git a/source/blender/compositor/operations/COM_TonemapOperation.cpp b/source/blender/compositor/operations/COM_TonemapOperation.cpp
index e8a578f..54ba218 100644
--- a/source/blender/compositor/operations/COM_TonemapOperation.cpp
+++ b/source/blender/compositor/operations/COM_TonemapOperation.cpp
@@ -24,6 +24,10 @@
 #include "BLI_math.h"
 #include "BLI_utildefines.h"
 
+extern "C" {
+#include "IMB_colormanagement.h"
+}
+
 TonemapOperation::TonemapOperation() : NodeOperation()
 {
 	this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
@@ -69,7 +73,7 @@ void PhotoreceptorTonemapOperation::executePixel(float output[4], int x, int y,
 
 	this->m_imageReader->read(output, x, y, NULL);
 
-	const float L = rgb_to_luma_y(output);
+	const float L = IMB_colormanagem

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list