From dd38dce7f0ae604396d1e96bc49500369fdedf29 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Tue, 17 Mar 2015 15:20:33 +0100 Subject: Part 2 of D1082 by Troy Sobotka, remove our functions that do luma calculations and use the OCIO one instead. --- .../blender/compositor/operations/COM_CalculateMeanOperation.cpp | 6 ++++-- .../operations/COM_CalculateStandardDeviationOperation.cpp | 6 ++++-- .../compositor/operations/COM_ColorCorrectionOperation.cpp | 6 +++++- source/blender/compositor/operations/COM_ConvertOperation.cpp | 5 ++++- .../blender/compositor/operations/COM_GlareThresholdOperation.cpp | 6 +++++- source/blender/compositor/operations/COM_TonemapOperation.cpp | 8 ++++++-- 6 files changed, 28 insertions(+), 9 deletions(-) (limited to 'source/blender/compositor') diff --git a/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp b/source/blender/compositor/operations/COM_CalculateMeanOperation.cpp index a2954a20e90..54b0e37c791 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 0c67da2d552..32c5fc1adc7 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 19209951005..54e0fb41abf 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 977586acb60..8b8e8408208 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 78e1e80cafc..d2bd7cbeeab 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 e8a578fa131..54ba218b802 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_colormanagement_get_luminance(output); float I_l = output[0] + ic * (L - output[0]); float I_g = avg->cav[0] + ic * (avg->lav - avg->cav[0]); float I_a = I_l + ia * (I_g - I_l); @@ -125,7 +129,7 @@ void *TonemapOperation::initializeTileData(rcti *rect) float Lav = 0.f; float cav[4] = {0.0f, 0.0f, 0.0f, 0.0f}; while (p--) { - float L = rgb_to_luma_y(bc); + float L = IMB_colormanagement_get_luminance(bc); Lav += L; add_v3_v3(cav, bc); lsum += logf(MAX2(L, 0.0f) + 1e-5f); -- cgit v1.2.3