Commit: 3d9ecf1cf26e5b55f1d961c9068e20c63d5c03b0
Author: Manuel Castilla
Date:   Mon Jul 5 21:43:44 2021 +0200
Branches: master
https://developer.blender.org/rB3d9ecf1cf26e5b55f1d961c9068e20c63d5c03b0

Compositor: Full frame Color Balance node

Adds full frame implementation to this node operations.
No functional changes.
1.3x faster than tiled fallback.

Reviewed By: jbakker

Differential Revision: https://developer.blender.org/D11764

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

M       source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cc
M       source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h
M       source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cc
M       source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h

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

diff --git 
a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cc 
b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cc
index d1d3752e402..b6f20a740f5 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cc
+++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cc
@@ -76,6 +76,23 @@ void ColorBalanceASCCDLOperation::executePixelSampled(float 
output[4],
   output[3] = inputColor[3];
 }
 
+void ColorBalanceASCCDLOperation::update_memory_buffer_row(PixelCursor &p)
+{
+  for (; p.out < p.row_end; p.next()) {
+    const float *in_factor = p.ins[0];
+    const float *in_color = p.ins[1];
+    const float fac = MIN2(1.0f, in_factor[0]);
+    const float fac_m = 1.0f - fac;
+    p.out[0] = fac_m * in_color[0] +
+               fac * colorbalance_cdl(in_color[0], m_offset[0], m_power[0], 
m_slope[0]);
+    p.out[1] = fac_m * in_color[1] +
+               fac * colorbalance_cdl(in_color[1], m_offset[1], m_power[1], 
m_slope[1]);
+    p.out[2] = fac_m * in_color[2] +
+               fac * colorbalance_cdl(in_color[2], m_offset[2], m_power[2], 
m_slope[2]);
+    p.out[3] = in_color[3];
+  }
+}
+
 void ColorBalanceASCCDLOperation::deinitExecution()
 {
   this->m_inputValueOperation = nullptr;
diff --git 
a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h 
b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h
index 5851600190f..d161ea66af2 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h
+++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h
@@ -18,7 +18,7 @@
 
 #pragma once
 
-#include "COM_NodeOperation.h"
+#include "COM_MultiThreadedRowOperation.h"
 
 namespace blender::compositor {
 
@@ -26,7 +26,7 @@ namespace blender::compositor {
  * this program converts an input color to an output value.
  * it assumes we are in sRGB color space.
  */
-class ColorBalanceASCCDLOperation : public NodeOperation {
+class ColorBalanceASCCDLOperation : public MultiThreadedRowOperation {
  protected:
   /**
    * Prefetched reference to the inputProgram
@@ -71,6 +71,8 @@ class ColorBalanceASCCDLOperation : public NodeOperation {
   {
     copy_v3_v3(this->m_slope, slope);
   }
+
+  void update_memory_buffer_row(PixelCursor &p) override;
 };
 
 }  // namespace blender::compositor
diff --git 
a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cc 
b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cc
index cac16a3f7b0..36307f0b136 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cc
+++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cc
@@ -81,6 +81,23 @@ void ColorBalanceLGGOperation::executePixelSampled(float 
output[4],
   output[3] = inputColor[3];
 }
 
+void ColorBalanceLGGOperation::update_memory_buffer_row(PixelCursor &p)
+{
+  for (; p.out < p.row_end; p.next()) {
+    const float *in_factor = p.ins[0];
+    const float *in_color = p.ins[1];
+    const float fac = MIN2(1.0f, in_factor[0]);
+    const float fac_m = 1.0f - fac;
+    p.out[0] = fac_m * in_color[0] +
+               fac * colorbalance_lgg(in_color[0], m_lift[0], m_gamma_inv[0], 
m_gain[0]);
+    p.out[1] = fac_m * in_color[1] +
+               fac * colorbalance_lgg(in_color[1], m_lift[1], m_gamma_inv[1], 
m_gain[1]);
+    p.out[2] = fac_m * in_color[2] +
+               fac * colorbalance_lgg(in_color[2], m_lift[2], m_gamma_inv[2], 
m_gain[2]);
+    p.out[3] = in_color[3];
+  }
+}
+
 void ColorBalanceLGGOperation::deinitExecution()
 {
   this->m_inputValueOperation = nullptr;
diff --git 
a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h 
b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h
index 23f70247b66..4bc929ed76c 100644
--- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h
+++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h
@@ -18,7 +18,7 @@
 
 #pragma once
 
-#include "COM_NodeOperation.h"
+#include "COM_MultiThreadedRowOperation.h"
 
 namespace blender::compositor {
 
@@ -26,7 +26,7 @@ namespace blender::compositor {
  * this program converts an input color to an output value.
  * it assumes we are in sRGB color space.
  */
-class ColorBalanceLGGOperation : public NodeOperation {
+class ColorBalanceLGGOperation : public MultiThreadedRowOperation {
  protected:
   /**
    * Prefetched reference to the inputProgram
@@ -71,6 +71,8 @@ class ColorBalanceLGGOperation : public NodeOperation {
   {
     copy_v3_v3(this->m_gamma_inv, gamma_inv);
   }
+
+  void update_memory_buffer_row(PixelCursor &p) override;
 };
 
 }  // namespace blender::compositor

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to