[Bf-blender-cvs] [63f2f82] master: Fix T46641: Bicubic transform on ID channel is not bicubic

Sergey Sharybin noreply at git.blender.org
Thu Nov 12 16:31:27 CET 2015


Commit: 63f2f82f92936ce642eaa95def1179304ef0b363
Author: Sergey Sharybin
Date:   Sun Nov 8 08:16:04 2015 +0500
Branches: master
https://developer.blender.org/rB63f2f82f92936ce642eaa95def1179304ef0b363

Fix T46641: Bicubic transform on ID channel is not bicubic

Better support of bicubic sampling of ID mask output.

The idea is to generate ID mask into a temporary buffer which is then being
interpolated using current sampling method.

This works fine for upscaling or rotating the ID mask but does not work for
scaling down. This is much-much bigger problem of the compositor design and
can't really be solved currently. Same will happen with other nodes like
blur for example.

Reviewers: campbellbarton

Subscribers: ania

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

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

M	source/blender/compositor/operations/COM_IDMaskOperation.cpp
M	source/blender/compositor/operations/COM_IDMaskOperation.h

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

diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.cpp b/source/blender/compositor/operations/COM_IDMaskOperation.cpp
index 68e681c..05462d3 100644
--- a/source/blender/compositor/operations/COM_IDMaskOperation.cpp
+++ b/source/blender/compositor/operations/COM_IDMaskOperation.cpp
@@ -26,26 +26,23 @@ IDMaskOperation::IDMaskOperation() : NodeOperation()
 {
 	this->addInputSocket(COM_DT_VALUE);
 	this->addOutputSocket(COM_DT_VALUE);
-	this->m_inputProgram = NULL;
-}
-void IDMaskOperation::initExecution()
-{
-	this->m_inputProgram = this->getInputSocketReader(0);
+	this->setComplex(true);
 }
 
-void IDMaskOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void *IDMaskOperation::initializeTileData(rcti *rect)
 {
-	float inputValue[4];
-	
-	this->m_inputProgram->readSampled(inputValue, x, y, sampler);
-	/* 'round' since sampling may adjust value slightly.
-	 * ID-mask input are originally integers too. */
-	const float a = (roundf(inputValue[0]) == this->m_objectIndex) ? 1.0f : 0.0f;
-	output[0] = a;
+	void *buffer = getInputOperation(0)->initializeTileData(rect);
+	return buffer;
 }
 
-void IDMaskOperation::deinitExecution()
+void IDMaskOperation::executePixel(float output[4],
+                                   int x,
+                                   int y,
+                                   void *data)
 {
-	this->m_inputProgram = NULL;
+	MemoryBuffer *input_buffer = (MemoryBuffer *)data;
+	const int buffer_width = input_buffer->getWidth();
+	float *buffer = input_buffer->getBuffer();
+	int buffer_index = (y * buffer_width + x);
+	output[0] = (roundf(buffer[buffer_index]) == this->m_objectIndex) ? 1.0f : 0.0f;
 }
-
diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.h b/source/blender/compositor/operations/COM_IDMaskOperation.h
index dfddc48..841d4a7 100644
--- a/source/blender/compositor/operations/COM_IDMaskOperation.h
+++ b/source/blender/compositor/operations/COM_IDMaskOperation.h
@@ -27,30 +27,13 @@
 
 class IDMaskOperation : public NodeOperation {
 private:
-	/**
-	 * Cached reference to the inputProgram
-	 */
-	SocketReader *m_inputProgram;
-	
 	float m_objectIndex;
 public:
 	IDMaskOperation();
-	
-	/**
-	 * the inner loop of this program
-	 */
-	void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
-	
-	/**
-	 * Initialize the execution
-	 */
-	void initExecution();
-	
-	/**
-	 * Deinitialize the execution
-	 */
-	void deinitExecution();
-	
+
+	void *initializeTileData(rcti *rect);
+	void executePixel(float output[4], int x, int y, void *data);
+
 	void setObjectIndex(float objectIndex) { this->m_objectIndex = objectIndex; }
 
 };




More information about the Bf-blender-cvs mailing list