Compositor cleanup: Merge conversion operations into a single file (see also r59820).

Most convert operations can share a common base class with a single socket reader (except channel separate/combine nodes).
This commit is contained in:
Lukas Toenne 2013-09-05 13:32:14 +00:00
parent bed447b244
commit 028371c174
58 changed files with 657 additions and 1941 deletions

View File

@ -394,37 +394,11 @@ set(SRC
operations/COM_PreviewOperation.cpp
operations/COM_SplitOperation.h
operations/COM_SplitOperation.cpp
operations/COM_ConvertValueToColorProg.h
operations/COM_ConvertValueToColorProg.cpp
operations/COM_ConvertColorToValueProg.h
operations/COM_ConvertColorToValueProg.cpp
operations/COM_ConvertColorToBWOperation.h
operations/COM_ConvertColorToBWOperation.cpp
operations/COM_ConvertColorToVectorOperation.h
operations/COM_ConvertColorToVectorOperation.cpp
operations/COM_ConvertValueToVectorOperation.h
operations/COM_ConvertValueToVectorOperation.cpp
operations/COM_ConvertVectorToColorOperation.h
operations/COM_ConvertVectorToColorOperation.cpp
operations/COM_ConvertVectorToValueOperation.h
operations/COM_ConvertVectorToValueOperation.cpp
operations/COM_ConvertDepthToRadiusOperation.h
operations/COM_ConvertDepthToRadiusOperation.cpp
operations/COM_ZCombineOperation.cpp
operations/COM_ZCombineOperation.h
operations/COM_ConvertRGBToYCCOperation.h
operations/COM_ConvertRGBToYCCOperation.cpp
operations/COM_ConvertYCCToRGBOperation.h
operations/COM_ConvertYCCToRGBOperation.cpp
operations/COM_ConvertRGBToYUVOperation.h
operations/COM_ConvertRGBToYUVOperation.cpp
operations/COM_ConvertYUVToRGBOperation.h
operations/COM_ConvertYUVToRGBOperation.cpp
operations/COM_ConvertRGBToHSVOperation.h
operations/COM_ConvertRGBToHSVOperation.cpp
operations/COM_ConvertHSVToRGBOperation.h
operations/COM_ConvertHSVToRGBOperation.cpp
operations/COM_ChangeHSVOperation.h
operations/COM_ChangeHSVOperation.cpp
operations/COM_ColorCurveOperation.h
@ -451,10 +425,6 @@ set(SRC
operations/COM_ColorMatteOperation.h
operations/COM_ChannelMatteOperation.cpp
operations/COM_ChannelMatteOperation.h
operations/COM_ConvertPremulToStraightOperation.cpp
operations/COM_ConvertPremulToStraightOperation.h
operations/COM_ConvertStraightToPremulOperation.cpp
operations/COM_ConvertStraightToPremulOperation.h
operations/COM_ReadBufferOperation.cpp
operations/COM_ReadBufferOperation.h
@ -556,11 +526,8 @@ set(SRC
#Convert operations
operations/COM_IDMaskOperation.cpp
operations/COM_IDMaskOperation.h
operations/COM_SeparateChannelOperation.cpp
operations/COM_SeparateChannelOperation.h
operations/COM_CombineChannelsOperation.cpp
operations/COM_CombineChannelsOperation.h
operations/COM_ConvertOperation.cpp
operations/COM_ConvertOperation.h
operations/COM_DotproductOperation.cpp
operations/COM_DotproductOperation.h

View File

@ -47,12 +47,7 @@
#include "COM_CombineYUVANode.h"
#include "COM_CompositorNode.h"
#include "COM_ConvertAlphaNode.h"
#include "COM_ConvertColorToVectorOperation.h"
#include "COM_ConvertColorToValueProg.h"
#include "COM_ConvertValueToColorProg.h"
#include "COM_ConvertValueToVectorOperation.h"
#include "COM_ConvertVectorToColorOperation.h"
#include "COM_ConvertVectorToValueOperation.h"
#include "COM_ConvertOperation.h"
#include "COM_Converter.h"
#include "COM_CropNode.h"
#include "COM_DefocusNode.h"
@ -420,13 +415,13 @@ void Converter::convertDataType(SocketConnection *connection, ExecutionSystem *s
DataType toDatatype = inputSocket->getDataType();
NodeOperation *converter = NULL;
if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_COLOR) {
converter = new ConvertValueToColorProg();
converter = new ConvertValueToColorOperation();
}
else if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_VECTOR) {
converter = new ConvertValueToVectorOperation();
}
else if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VALUE) {
converter = new ConvertColorToValueProg();
converter = new ConvertColorToValueOperation();
}
else if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VECTOR) {
converter = new ConvertColorToVectorOperation();

View File

@ -22,9 +22,7 @@
#include "COM_ChannelMatteNode.h"
#include "BKE_node.h"
#include "COM_ChannelMatteOperation.h"
#include "COM_ConvertRGBToHSVOperation.h"
#include "COM_ConvertRGBToYCCOperation.h"
#include "COM_ConvertRGBToYUVOperation.h"
#include "COM_ConvertOperation.h"
#include "COM_SetAlphaOperation.h"
ChannelMatteNode::ChannelMatteNode(bNode *editorNode) : Node(editorNode)

View File

@ -22,7 +22,7 @@
#include "COM_ChromaMatteNode.h"
#include "BKE_node.h"
#include "COM_ChromaMatteOperation.h"
#include "COM_ConvertRGBToYCCOperation.h"
#include "COM_ConvertOperation.h"
#include "COM_SetAlphaOperation.h"
ChromaMatteNode::ChromaMatteNode(bNode *editorNode) : Node(editorNode)

View File

@ -22,7 +22,7 @@
#include "COM_ColorMatteNode.h"
#include "BKE_node.h"
#include "COM_ColorMatteOperation.h"
#include "COM_ConvertRGBToHSVOperation.h"
#include "COM_ConvertOperation.h"
#include "COM_SetAlphaOperation.h"
ColorMatteNode::ColorMatteNode(bNode *editorNode) : Node(editorNode)

View File

@ -24,7 +24,7 @@
#include "COM_ExecutionSystem.h"
#include "BKE_node.h"
#include "COM_ColorRampOperation.h"
#include "COM_SeparateChannelOperation.h"
#include "COM_ConvertOperation.h"
#include "DNA_texture_types.h"
ColorRampNode::ColorRampNode(bNode *editorNode) : Node(editorNode)

View File

@ -22,7 +22,7 @@
#include "COM_ColorToBWNode.h"
#include "COM_ConvertColorToBWOperation.h"
#include "COM_ConvertOperation.h"
#include "COM_ExecutionSystem.h"
ColorToBWNode::ColorToBWNode(bNode *editorNode) : Node(editorNode)

View File

@ -22,11 +22,11 @@
#include "COM_CombineHSVANode.h"
#include "COM_CombineChannelsOperation.h"
#include "COM_ConvertOperation.h"
#include "COM_ExecutionSystem.h"
#include "COM_SetValueOperation.h"
#include "COM_ConvertHSVToRGBOperation.h"
#include "COM_ConvertOperation.h"
CombineHSVANode::CombineHSVANode(bNode *editorNode) : CombineRGBANode(editorNode)
{

View File

@ -22,7 +22,7 @@
#include "COM_CombineRGBANode.h"
#include "COM_CombineChannelsOperation.h"
#include "COM_ConvertOperation.h"
#include "COM_ExecutionSystem.h"
#include "COM_SetValueOperation.h"

View File

@ -20,7 +20,7 @@
*/
#include "COM_CombineYCCANode.h"
#include "COM_ConvertYCCToRGBOperation.h"
#include "COM_ConvertOperation.h"
CombineYCCANode::CombineYCCANode(bNode *editorNode) : CombineRGBANode(editorNode)
{

View File

@ -20,7 +20,7 @@
*/
#include "COM_CombineYUVANode.h"
#include "COM_ConvertYUVToRGBOperation.h"
#include "COM_ConvertOperation.h"
CombineYUVANode::CombineYUVANode(bNode *editorNode) : CombineRGBANode(editorNode)
{

View File

@ -20,8 +20,7 @@
*/
#include "COM_ConvertAlphaNode.h"
#include "COM_ConvertPremulToStraightOperation.h"
#include "COM_ConvertStraightToPremulOperation.h"
#include "COM_ConvertOperation.h"
#include "COM_ExecutionSystem.h"
void ConvertAlphaNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)

View File

@ -24,7 +24,7 @@
#include "COM_DistanceRGBMatteOperation.h"
#include "COM_DistanceYCCMatteOperation.h"
#include "COM_SetAlphaOperation.h"
#include "COM_ConvertRGBToYCCOperation.h"
#include "COM_ConvertOperation.h"
DistanceMatteNode::DistanceMatteNode(bNode *editorNode) : Node(editorNode)
{

View File

@ -22,10 +22,8 @@
#include "COM_HueSaturationValueCorrectNode.h"
#include "COM_ConvertColorToValueProg.h"
#include "COM_ConvertOperation.h"
#include "COM_ExecutionSystem.h"
#include "COM_ConvertRGBToHSVOperation.h"
#include "COM_ConvertHSVToRGBOperation.h"
#include "COM_MixOperation.h"
#include "COM_SetColorOperation.h"
#include "COM_SetValueOperation.h"

View File

@ -22,10 +22,8 @@
#include "COM_HueSaturationValueNode.h"
#include "COM_ConvertColorToValueProg.h"
#include "COM_ConvertOperation.h"
#include "COM_ExecutionSystem.h"
#include "COM_ConvertRGBToHSVOperation.h"
#include "COM_ConvertHSVToRGBOperation.h"
#include "COM_MixOperation.h"
#include "COM_SetColorOperation.h"
#include "COM_SetValueOperation.h"

View File

@ -25,7 +25,7 @@
#include "COM_ExecutionSystem.h"
#include "COM_ImageOperation.h"
#include "COM_MultilayerImageOperation.h"
#include "COM_ConvertPremulToStraightOperation.h"
#include "COM_ConvertOperation.h"
#include "BKE_node.h"
#include "BLI_utildefines.h"

View File

@ -32,10 +32,7 @@
#include "COM_MathBaseOperation.h"
#include "COM_SeparateChannelOperation.h"
#include "COM_CombineChannelsOperation.h"
#include "COM_ConvertRGBToYCCOperation.h"
#include "COM_ConvertYCCToRGBOperation.h"
#include "COM_ConvertOperation.h"
#include "COM_SetValueOperation.h"
#include "COM_DilateErodeOperation.h"

View File

@ -22,7 +22,7 @@
#include "COM_LuminanceMatteNode.h"
#include "BKE_node.h"
#include "COM_LuminanceMatteOperation.h"
#include "COM_ConvertRGBToYUVOperation.h"
#include "COM_ConvertOperation.h"
#include "COM_SetAlphaOperation.h"
LuminanceMatteNode::LuminanceMatteNode(bNode *editorNode) : Node(editorNode)

View File

@ -22,10 +22,9 @@
#include "COM_SeparateHSVANode.h"
#include "COM_SeparateChannelOperation.h"
#include "COM_ExecutionSystem.h"
#include "COM_SetValueOperation.h"
#include "COM_ConvertRGBToHSVOperation.h"
#include "COM_ConvertOperation.h"
SeparateHSVANode::SeparateHSVANode(bNode *editorNode) : SeparateRGBANode(editorNode)
{

View File

@ -22,7 +22,7 @@
#include "COM_SeparateRGBANode.h"
#include "COM_SeparateChannelOperation.h"
#include "COM_ConvertOperation.h"
#include "COM_ExecutionSystem.h"
#include "COM_SetValueOperation.h"
#include "DNA_material_types.h" // the ramp types

View File

@ -20,10 +20,9 @@
*/
#include "COM_SeparateYCCANode.h"
#include "COM_SeparateChannelOperation.h"
#include "COM_ExecutionSystem.h"
#include "COM_SetValueOperation.h"
#include "COM_ConvertRGBToYCCOperation.h"
#include "COM_ConvertOperation.h"
SeparateYCCANode::SeparateYCCANode(bNode *editorNode) : SeparateRGBANode(editorNode)
{

View File

@ -20,10 +20,9 @@
*/
#include "COM_SeparateYUVANode.h"
#include "COM_SeparateChannelOperation.h"
#include "COM_ExecutionSystem.h"
#include "COM_SetValueOperation.h"
#include "COM_ConvertRGBToYUVOperation.h"
#include "COM_ConvertOperation.h"
SeparateYUVANode::SeparateYUVANode(bNode *editorNode) : SeparateRGBANode(editorNode)
{

View File

@ -1,76 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#include "COM_CombineChannelsOperation.h"
#include "BLI_utildefines.h"
CombineChannelsOperation::CombineChannelsOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
this->setResolutionInputSocketIndex(0);
this->m_inputChannel1Operation = NULL;
this->m_inputChannel2Operation = NULL;
this->m_inputChannel3Operation = NULL;
this->m_inputChannel4Operation = NULL;
}
void CombineChannelsOperation::initExecution()
{
this->m_inputChannel1Operation = this->getInputSocketReader(0);
this->m_inputChannel2Operation = this->getInputSocketReader(1);
this->m_inputChannel3Operation = this->getInputSocketReader(2);
this->m_inputChannel4Operation = this->getInputSocketReader(3);
}
void CombineChannelsOperation::deinitExecution()
{
this->m_inputChannel1Operation = NULL;
this->m_inputChannel2Operation = NULL;
this->m_inputChannel3Operation = NULL;
this->m_inputChannel4Operation = NULL;
}
void CombineChannelsOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float input[4];
if (this->m_inputChannel1Operation) {
this->m_inputChannel1Operation->read(input, x, y, sampler);
output[0] = input[0];
}
if (this->m_inputChannel2Operation) {
this->m_inputChannel2Operation->read(input, x, y, sampler);
output[1] = input[0];
}
if (this->m_inputChannel3Operation) {
this->m_inputChannel3Operation->read(input, x, y, sampler);
output[2] = input[0];
}
if (this->m_inputChannel4Operation) {
this->m_inputChannel4Operation->read(input, x, y, sampler);
output[3] = input[0];
}
}

View File

@ -1,42 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#ifndef _COM_CombineChannelsOperation_h_
#define _COM_CombineChannelsOperation_h_
#include "COM_NodeOperation.h"
class CombineChannelsOperation : public NodeOperation {
private:
SocketReader *m_inputChannel1Operation;
SocketReader *m_inputChannel2Operation;
SocketReader *m_inputChannel3Operation;
SocketReader *m_inputChannel4Operation;
public:
CombineChannelsOperation();
void executePixel(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
};
#endif

View File

@ -1,47 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#include "COM_ConvertColorToBWOperation.h"
ConvertColorToBWOperation::ConvertColorToBWOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_VALUE);
this->m_inputOperation = NULL;
}
void ConvertColorToBWOperation::initExecution()
{
this->m_inputOperation = this->getInputSocketReader(0);
}
void ConvertColorToBWOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
this->m_inputOperation->read(inputColor, x, y, sampler);
output[0] = rgb_to_bw(inputColor);
}
void ConvertColorToBWOperation::deinitExecution()
{
this->m_inputOperation = NULL;
}

View File

@ -1,60 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#ifndef _COM_ConvertColorToBWOperation_h
#define _COM_ConvertColorToBWOperation_h
#include "COM_NodeOperation.h"
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class ConvertColorToBWOperation : public NodeOperation {
private:
/**
* Cached reference to the inputProgram
*/
SocketReader *m_inputOperation;
public:
/**
* Default constructor
*/
ConvertColorToBWOperation();
/**
* the inner loop of this program
*/
void executePixel(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
*/
void initExecution();
/**
* Deinitialize the execution
*/
void deinitExecution();
};
#endif

View File

@ -1,47 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#include "COM_ConvertColorToValueProg.h"
ConvertColorToValueProg::ConvertColorToValueProg() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_VALUE);
this->m_inputOperation = NULL;
}
void ConvertColorToValueProg::initExecution()
{
this->m_inputOperation = this->getInputSocketReader(0);
}
void ConvertColorToValueProg::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
this->m_inputOperation->read(inputColor, x, y, sampler);
output[0] = (inputColor[0] + inputColor[1] + inputColor[2]) / 3.0f;
}
void ConvertColorToValueProg::deinitExecution()
{
this->m_inputOperation = NULL;
}

View File

@ -1,59 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#ifndef _COM_ConvertColorToValueProg_h
#define _COM_ConvertColorToValueProg_h
#include "COM_NodeOperation.h"
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class ConvertColorToValueProg : public NodeOperation {
private:
/**
* Cached reference to the inputProgram
*/
SocketReader *m_inputOperation;
public:
/**
* Default constructor
*/
ConvertColorToValueProg();
/**
* the inner loop of this program
*/
void executePixel(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
*/
void initExecution();
/**
* Deinitialize the execution
*/
void deinitExecution();
};
#endif

View File

@ -1,45 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#include "COM_ConvertColorToVectorOperation.h"
ConvertColorToVectorOperation::ConvertColorToVectorOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_VECTOR);
this->m_inputOperation = NULL;
}
void ConvertColorToVectorOperation::initExecution()
{
this->m_inputOperation = this->getInputSocketReader(0);
}
void ConvertColorToVectorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
this->m_inputOperation->read(output, x, y, sampler);
}
void ConvertColorToVectorOperation::deinitExecution()
{
this->m_inputOperation = NULL;
}

View File

@ -1,59 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#ifndef _COM_ConvertColorToVectorOperation_h
#define _COM_ConvertColorToVectorOperation_h
#include "COM_NodeOperation.h"
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class ConvertColorToVectorOperation : public NodeOperation {
private:
/**
* Cached reference to the inputProgram
*/
SocketReader *m_inputOperation;
public:
/**
* Default constructor
*/
ConvertColorToVectorOperation();
/**
* the inner loop of this program
*/
void executePixel(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
*/
void initExecution();
/**
* Deinitialize the execution
*/
void deinitExecution();
};
#endif

View File

@ -1,50 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#include "COM_ConvertHSVToRGBOperation.h"
#include "BLI_math_color.h"
ConvertHSVToRGBOperation::ConvertHSVToRGBOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
this->m_inputOperation = NULL;
}
void ConvertHSVToRGBOperation::initExecution()
{
this->m_inputOperation = this->getInputSocketReader(0);
}
void ConvertHSVToRGBOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
this->m_inputOperation->read(inputColor, x, y, sampler);
hsv_to_rgb_v(inputColor, output);
output[3] = inputColor[3];
}
void ConvertHSVToRGBOperation::deinitExecution()
{
this->m_inputOperation = NULL;
}

View File

@ -1,59 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#ifndef _COM_ConvertHSVToRGBOperation_h
#define _COM_ConvertHSVToRGBOperation_h
#include "COM_NodeOperation.h"
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class ConvertHSVToRGBOperation : public NodeOperation {
private:
/**
* Cached reference to the inputProgram
*/
SocketReader *m_inputOperation;
public:
/**
* Default constructor
*/
ConvertHSVToRGBOperation();
/**
* the inner loop of this program
*/
void executePixel(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
*/
void initExecution();
/**
* Deinitialize the execution
*/
void deinitExecution();
};
#endif

View File

@ -0,0 +1,429 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#include "COM_ConvertOperation.h"
ConvertBaseOperation::ConvertBaseOperation()
{
this->m_inputOperation = NULL;
}
void ConvertBaseOperation::initExecution()
{
this->m_inputOperation = this->getInputSocketReader(0);
}
void ConvertBaseOperation::deinitExecution()
{
this->m_inputOperation = NULL;
}
/* ******** Value to Color ******** */
ConvertValueToColorOperation::ConvertValueToColorOperation() : ConvertBaseOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
}
void ConvertValueToColorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue[4];
this->m_inputOperation->read(inputValue, x, y, sampler);
output[0] = output[1] = output[2] = inputValue[0];
output[3] = 1.0f;
}
/* ******** Color to Value ******** */
ConvertColorToValueOperation::ConvertColorToValueOperation() : ConvertBaseOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_VALUE);
}
void ConvertColorToValueOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
this->m_inputOperation->read(inputColor, x, y, sampler);
output[0] = (inputColor[0] + inputColor[1] + inputColor[2]) / 3.0f;
}
/* ******** Color to BW ******** */
ConvertColorToBWOperation::ConvertColorToBWOperation() : ConvertBaseOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_VALUE);
}
void ConvertColorToBWOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
this->m_inputOperation->read(inputColor, x, y, sampler);
output[0] = rgb_to_bw(inputColor);
}
/* ******** Color to Vector ******** */
ConvertColorToVectorOperation::ConvertColorToVectorOperation() : ConvertBaseOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_VECTOR);
}
void ConvertColorToVectorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
this->m_inputOperation->read(output, x, y, sampler);
}
/* ******** Value to Vector ******** */
ConvertValueToVectorOperation::ConvertValueToVectorOperation() : ConvertBaseOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VECTOR);
}
void ConvertValueToVectorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float input[4];
this->m_inputOperation->read(input, x, y, sampler);
output[0] = input[0];
output[1] = input[0];
output[2] = input[0];
output[3] = 0.0f;
}
/* ******** Vector to Color ******** */
ConvertVectorToColorOperation::ConvertVectorToColorOperation() : ConvertBaseOperation()
{
this->addInputSocket(COM_DT_VECTOR);
this->addOutputSocket(COM_DT_COLOR);
}
void ConvertVectorToColorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
this->m_inputOperation->read(output, x, y, sampler);
output[3] = 1.0f;
}
/* ******** Vector to Value ******** */
ConvertVectorToValueOperation::ConvertVectorToValueOperation() : ConvertBaseOperation()
{
this->addInputSocket(COM_DT_VECTOR);
this->addOutputSocket(COM_DT_VALUE);
}
void ConvertVectorToValueOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float input[4];
this->m_inputOperation->read(input, x, y, sampler);
output[0] = (input[0] + input[1] + input[2]) / 3.0f;
}
/* ******** RGB to YCC ******** */
ConvertRGBToYCCOperation::ConvertRGBToYCCOperation() : ConvertBaseOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
}
void ConvertRGBToYCCOperation::setMode(int mode)
{
switch (mode) {
case 1:
this->m_mode = BLI_YCC_ITU_BT709;
break;
case 2:
this->m_mode = BLI_YCC_JFIF_0_255;
break;
case 0:
default:
this->m_mode = BLI_YCC_ITU_BT601;
break;
}
}
void ConvertRGBToYCCOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
float color[3];
this->m_inputOperation->read(inputColor, x, y, sampler);
rgb_to_ycc(inputColor[0], inputColor[1], inputColor[2], &color[0], &color[1], &color[2], this->m_mode);
/* divided by 255 to normalize for viewing in */
/* R,G,B --> Y,Cb,Cr */
mul_v3_v3fl(output, color, 1.0f / 255.0f);
output[3] = inputColor[3];
}
/* ******** YCC to RGB ******** */
ConvertYCCToRGBOperation::ConvertYCCToRGBOperation() : ConvertBaseOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
}
void ConvertYCCToRGBOperation::setMode(int mode)
{
switch (mode) {
case 1:
this->m_mode = BLI_YCC_ITU_BT709;
break;
case 2:
this->m_mode = BLI_YCC_JFIF_0_255;
break;
case 0:
default:
this->m_mode = BLI_YCC_ITU_BT601;
break;
}
}
void ConvertYCCToRGBOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
this->m_inputOperation->read(inputColor, x, y, sampler);
/* need to un-normalize the data */
/* R,G,B --> Y,Cb,Cr */
mul_v3_fl(inputColor, 255.0f);
ycc_to_rgb(inputColor[0], inputColor[1], inputColor[2], &output[0], &output[1], &output[2], this->m_mode);
output[3] = inputColor[3];
}
/* ******** RGB to YUV ******** */
ConvertRGBToYUVOperation::ConvertRGBToYUVOperation() : ConvertBaseOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
}
void ConvertRGBToYUVOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
this->m_inputOperation->read(inputColor, x, y, sampler);
rgb_to_yuv(inputColor[0], inputColor[1], inputColor[2], &output[0], &output[1], &output[2]);
output[3] = inputColor[3];
}
/* ******** YUV to RGB ******** */
ConvertYUVToRGBOperation::ConvertYUVToRGBOperation() : ConvertBaseOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
}
void ConvertYUVToRGBOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
this->m_inputOperation->read(inputColor, x, y, sampler);
yuv_to_rgb(inputColor[0], inputColor[1], inputColor[2], &output[0], &output[1], &output[2]);
output[3] = inputColor[3];
}
/* ******** RGB to HSV ******** */
ConvertRGBToHSVOperation::ConvertRGBToHSVOperation() : ConvertBaseOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
}
void ConvertRGBToHSVOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
this->m_inputOperation->read(inputColor, x, y, sampler);
rgb_to_hsv_v(inputColor, output);
output[3] = inputColor[3];
}
/* ******** HSV to RGB ******** */
ConvertHSVToRGBOperation::ConvertHSVToRGBOperation() : ConvertBaseOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
}
void ConvertHSVToRGBOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
this->m_inputOperation->read(inputColor, x, y, sampler);
hsv_to_rgb_v(inputColor, output);
output[3] = inputColor[3];
}
/* ******** Premul to Straight ******** */
ConvertPremulToStraightOperation::ConvertPremulToStraightOperation() : ConvertBaseOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
}
void ConvertPremulToStraightOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue[4];
float alpha;
this->m_inputOperation->read(inputValue, x, y, sampler);
alpha = inputValue[3];
if (fabsf(alpha) < 1e-5f) {
zero_v3(output);
}
else {
mul_v3_v3fl(output, inputValue, 1.0f / alpha);
}
/* never touches the alpha */
output[3] = alpha;
}
/* ******** Straight to Premul ******** */
ConvertStraightToPremulOperation::ConvertStraightToPremulOperation() : ConvertBaseOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
}
void ConvertStraightToPremulOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue[4];
float alpha;
this->m_inputOperation->read(inputValue, x, y, sampler);
alpha = inputValue[3];
mul_v3_v3fl(output, inputValue, alpha);
/* never touches the alpha */
output[3] = alpha;
}
/* ******** Separate Channels ******** */
SeparateChannelOperation::SeparateChannelOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_VALUE);
this->m_inputOperation = NULL;
}
void SeparateChannelOperation::initExecution()
{
this->m_inputOperation = this->getInputSocketReader(0);
}
void SeparateChannelOperation::deinitExecution()
{
this->m_inputOperation = NULL;
}
void SeparateChannelOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float input[4];
this->m_inputOperation->read(input, x, y, sampler);
output[0] = input[this->m_channel];
}
/* ******** Combine Channels ******** */
CombineChannelsOperation::CombineChannelsOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
this->setResolutionInputSocketIndex(0);
this->m_inputChannel1Operation = NULL;
this->m_inputChannel2Operation = NULL;
this->m_inputChannel3Operation = NULL;
this->m_inputChannel4Operation = NULL;
}
void CombineChannelsOperation::initExecution()
{
this->m_inputChannel1Operation = this->getInputSocketReader(0);
this->m_inputChannel2Operation = this->getInputSocketReader(1);
this->m_inputChannel3Operation = this->getInputSocketReader(2);
this->m_inputChannel4Operation = this->getInputSocketReader(3);
}
void CombineChannelsOperation::deinitExecution()
{
this->m_inputChannel1Operation = NULL;
this->m_inputChannel2Operation = NULL;
this->m_inputChannel3Operation = NULL;
this->m_inputChannel4Operation = NULL;
}
void CombineChannelsOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float input[4];
if (this->m_inputChannel1Operation) {
this->m_inputChannel1Operation->read(input, x, y, sampler);
output[0] = input[0];
}
if (this->m_inputChannel2Operation) {
this->m_inputChannel2Operation->read(input, x, y, sampler);
output[1] = input[0];
}
if (this->m_inputChannel3Operation) {
this->m_inputChannel3Operation->read(input, x, y, sampler);
output[2] = input[0];
}
if (this->m_inputChannel4Operation) {
this->m_inputChannel4Operation->read(input, x, y, sampler);
output[3] = input[0];
}
}

View File

@ -0,0 +1,202 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#ifndef _COM_ConvertOperation_h
#define _COM_ConvertOperation_h
#include "COM_NodeOperation.h"
class ConvertBaseOperation : public NodeOperation {
protected:
SocketReader *m_inputOperation;
public:
ConvertBaseOperation();
void initExecution();
void deinitExecution();
};
class ConvertValueToColorOperation : public ConvertBaseOperation {
public:
ConvertValueToColorOperation();
void executePixel(float output[4], float x, float y, PixelSampler sampler);
};
class ConvertColorToValueOperation : public ConvertBaseOperation {
public:
ConvertColorToValueOperation();
void executePixel(float output[4], float x, float y, PixelSampler sampler);
};
class ConvertColorToBWOperation : public ConvertBaseOperation {
public:
ConvertColorToBWOperation();
void executePixel(float output[4], float x, float y, PixelSampler sampler);
};
class ConvertColorToVectorOperation : public ConvertBaseOperation {
public:
ConvertColorToVectorOperation();
void executePixel(float output[4], float x, float y, PixelSampler sampler);
};
class ConvertValueToVectorOperation : public ConvertBaseOperation {
public:
ConvertValueToVectorOperation();
void executePixel(float output[4], float x, float y, PixelSampler sampler);
};
class ConvertVectorToColorOperation : public ConvertBaseOperation {
public:
ConvertVectorToColorOperation();
void executePixel(float output[4], float x, float y, PixelSampler sampler);
};
class ConvertVectorToValueOperation : public ConvertBaseOperation {
public:
ConvertVectorToValueOperation();
void executePixel(float output[4], float x, float y, PixelSampler sampler);
};
class ConvertRGBToYCCOperation : public ConvertBaseOperation {
private:
/** YCbCr mode (Jpeg, ITU601, ITU709) */
int m_mode;
public:
ConvertRGBToYCCOperation();
void executePixel(float output[4], float x, float y, PixelSampler sampler);
/** Set the YCC mode */
void setMode(int mode);
};
class ConvertYCCToRGBOperation : public ConvertBaseOperation {
private:
/** YCbCr mode (Jpeg, ITU601, ITU709) */
int m_mode;
public:
ConvertYCCToRGBOperation();
void executePixel(float output[4], float x, float y, PixelSampler sampler);
/** Set the YCC mode */
void setMode(int mode);
};
class ConvertRGBToYUVOperation : public ConvertBaseOperation {
public:
ConvertRGBToYUVOperation();
void executePixel(float output[4], float x, float y, PixelSampler sampler);
};
class ConvertYUVToRGBOperation : public ConvertBaseOperation {
public:
ConvertYUVToRGBOperation();
void executePixel(float output[4], float x, float y, PixelSampler sampler);
};
class ConvertRGBToHSVOperation : public ConvertBaseOperation {
public:
ConvertRGBToHSVOperation();
void executePixel(float output[4], float x, float y, PixelSampler sampler);
};
class ConvertHSVToRGBOperation : public ConvertBaseOperation {
public:
ConvertHSVToRGBOperation();
void executePixel(float output[4], float x, float y, PixelSampler sampler);
};
class ConvertPremulToStraightOperation : public ConvertBaseOperation {
public:
ConvertPremulToStraightOperation();
void executePixel(float output[4], float x, float y, PixelSampler sampler);
};
class ConvertStraightToPremulOperation : public ConvertBaseOperation {
public:
ConvertStraightToPremulOperation();
void executePixel(float output[4], float x, float y, PixelSampler sampler);
};
class SeparateChannelOperation : public NodeOperation {
private:
SocketReader *m_inputOperation;
int m_channel;
public:
SeparateChannelOperation();
void executePixel(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
void setChannel(int channel) { this->m_channel = channel; }
};
class CombineChannelsOperation : public NodeOperation {
private:
SocketReader *m_inputChannel1Operation;
SocketReader *m_inputChannel2Operation;
SocketReader *m_inputChannel3Operation;
SocketReader *m_inputChannel4Operation;
public:
CombineChannelsOperation();
void executePixel(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
};
#endif

View File

@ -1,60 +0,0 @@
/*
* Copyright 2012, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Dalai Felinto
*/
#include "COM_ConvertPremulToStraightOperation.h"
#include "BLI_math.h"
ConvertPremulToStraightOperation::ConvertPremulToStraightOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
this->m_inputColor = NULL;
}
void ConvertPremulToStraightOperation::initExecution()
{
this->m_inputColor = getInputSocketReader(0);
}
void ConvertPremulToStraightOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue[4];
float alpha;
this->m_inputColor->read(inputValue, x, y, sampler);
alpha = inputValue[3];
if (fabsf(alpha) < 1e-5f) {
zero_v3(output);
}
else {
mul_v3_v3fl(output, inputValue, 1.0f / alpha);
}
/* never touches the alpha */
output[3] = alpha;
}
void ConvertPremulToStraightOperation::deinitExecution()
{
this->m_inputColor = NULL;
}

View File

@ -1,48 +0,0 @@
/*
* Copyright 2012, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Dalai Felinto
*/
#ifndef _COM_ConvertPremulToStraightOperation_h
#define _COM_ConvertPremulToStraightOperation_h
#include "COM_NodeOperation.h"
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class ConvertPremulToStraightOperation : public NodeOperation {
private:
SocketReader *m_inputColor;
public:
/**
* Default constructor
*/
ConvertPremulToStraightOperation();
/**
* the inner loop of this program
*/
void executePixel(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
};
#endif

View File

@ -1,49 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#include "COM_ConvertRGBToHSVOperation.h"
#include "BLI_math_color.h"
ConvertRGBToHSVOperation::ConvertRGBToHSVOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
this->m_inputOperation = NULL;
}
void ConvertRGBToHSVOperation::initExecution()
{
this->m_inputOperation = this->getInputSocketReader(0);
}
void ConvertRGBToHSVOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
this->m_inputOperation->read(inputColor, x, y, sampler);
rgb_to_hsv_v(inputColor, output);
output[3] = inputColor[3];
}
void ConvertRGBToHSVOperation::deinitExecution()
{
this->m_inputOperation = NULL;
}

View File

@ -1,60 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#ifndef _COM_ConvertRGBToHSVOperation_h
#define _COM_ConvertRGBToHSVOperation_h
#include "COM_NodeOperation.h"
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class ConvertRGBToHSVOperation : public NodeOperation {
private:
/**
* Cached reference to the inputProgram
*/
SocketReader *m_inputOperation;
public:
/**
* Default constructor
*/
ConvertRGBToHSVOperation();
/**
* the inner loop of this program
*/
void executePixel(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
*/
void initExecution();
/**
* Deinitialize the execution
*/
void deinitExecution();
};
#endif

View File

@ -1,70 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Dalai Felinto
*/
#include "COM_ConvertRGBToYCCOperation.h"
#include "BLI_math_color.h"
ConvertRGBToYCCOperation::ConvertRGBToYCCOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
this->m_inputOperation = NULL;
}
void ConvertRGBToYCCOperation::initExecution()
{
this->m_inputOperation = this->getInputSocketReader(0);
}
void ConvertRGBToYCCOperation::setMode(int mode)
{
switch (mode) {
case 1:
this->m_mode = BLI_YCC_ITU_BT709;
break;
case 2:
this->m_mode = BLI_YCC_JFIF_0_255;
break;
case 0:
default:
this->m_mode = BLI_YCC_ITU_BT601;
break;
}
}
void ConvertRGBToYCCOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
float color[3];
this->m_inputOperation->read(inputColor, x, y, sampler);
rgb_to_ycc(inputColor[0], inputColor[1], inputColor[2], &color[0], &color[1], &color[2], this->m_mode);
/* divided by 255 to normalize for viewing in */
/* R,G,B --> Y,Cb,Cr */
mul_v3_v3fl(output, color, 1.0f / 255.0f);
output[3] = inputColor[3];
}
void ConvertRGBToYCCOperation::deinitExecution()
{
this->m_inputOperation = NULL;
}

View File

@ -1,68 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Dalai Felinto
*/
#ifndef _COM_ConvertRGBToYCCOperation_h
#define _COM_ConvertRGBToYCCOperation_h
#include "COM_NodeOperation.h"
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class ConvertRGBToYCCOperation : public NodeOperation {
private:
/**
* Cached reference to the inputProgram
*/
SocketReader *m_inputOperation;
/**
* YCbCr mode (Jpeg, ITU601, ITU709)
*/
int m_mode;
public:
/**
* Default constructor
*/
ConvertRGBToYCCOperation();
/**
* the inner loop of this program
*/
void executePixel(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
*/
void initExecution();
/**
* Deinitialize the execution
*/
void deinitExecution();
/**
* Set the YCC mode
*/
void setMode(int mode);
};
#endif

View File

@ -1,48 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Dalai Felinto
*/
#include "COM_ConvertRGBToYUVOperation.h"
#include "BLI_math_color.h"
ConvertRGBToYUVOperation::ConvertRGBToYUVOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
this->m_inputOperation = NULL;
}
void ConvertRGBToYUVOperation::initExecution()
{
this->m_inputOperation = this->getInputSocketReader(0);
}
void ConvertRGBToYUVOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
this->m_inputOperation->read(inputColor, x, y, sampler);
rgb_to_yuv(inputColor[0], inputColor[1], inputColor[2], &output[0], &output[1], &output[2]);
output[3] = inputColor[3];
}
void ConvertRGBToYUVOperation::deinitExecution()
{
this->m_inputOperation = NULL;
}

View File

@ -1,59 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Dalai Felinto
*/
#ifndef _COM_ConvertRGBToYUVOperation_h
#define _COM_ConvertRGBToYUVOperation_h
#include "COM_NodeOperation.h"
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class ConvertRGBToYUVOperation : public NodeOperation {
private:
/**
* Cached reference to the inputProgram
*/
SocketReader *m_inputOperation;
public:
/**
* Default constructor
*/
ConvertRGBToYUVOperation();
/**
* the inner loop of this program
*/
void executePixel(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
*/
void initExecution();
/**
* Deinitialize the execution
*/
void deinitExecution();
};
#endif

View File

@ -1,55 +0,0 @@
/*
* Copyright 2012, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Dalai Felinto
*/
#include "COM_ConvertStraightToPremulOperation.h"
#include "BLI_math.h"
ConvertStraightToPremulOperation::ConvertStraightToPremulOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
this->m_inputColor = NULL;
}
void ConvertStraightToPremulOperation::initExecution()
{
this->m_inputColor = getInputSocketReader(0);
}
void ConvertStraightToPremulOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue[4];
float alpha;
this->m_inputColor->read(inputValue, x, y, sampler);
alpha = inputValue[3];
mul_v3_v3fl(output, inputValue, alpha);
/* never touches the alpha */
output[3] = alpha;
}
void ConvertStraightToPremulOperation::deinitExecution()
{
this->m_inputColor = NULL;
}

View File

@ -1,49 +0,0 @@
/*
* Copyright 2012, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Dalai Felinto
*/
#ifndef _COM_ConvertStraightToPremulOperation_h
#define _COM_ConvertStraightToPremulOperation_h
#include "COM_NodeOperation.h"
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class ConvertStraightToPremulOperation : public NodeOperation {
private:
SocketReader *m_inputColor;
public:
/**
* Default constructor
*/
ConvertStraightToPremulOperation();
/**
* the inner loop of this program
*/
void executePixel(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
};
#endif

View File

@ -1,47 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#include "COM_ConvertValueToColorProg.h"
ConvertValueToColorProg::ConvertValueToColorProg() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
this->m_inputProgram = NULL;
}
void ConvertValueToColorProg::initExecution()
{
this->m_inputProgram = this->getInputSocketReader(0);
}
void ConvertValueToColorProg::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputValue[4];
this->m_inputProgram->read(inputValue, x, y, sampler);
output[0] = output[1] = output[2] = inputValue[0];
output[3] = 1.0f;
}
void ConvertValueToColorProg::deinitExecution()
{
this->m_inputProgram = NULL;
}

View File

@ -1,53 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#ifndef _COM_ConvertValueToColorProg_h
#define _COM_ConvertValueToColorProg_h
#include "COM_NodeOperation.h"
class ConvertValueToColorProg : public NodeOperation {
private:
/**
* Cached reference to the inputProgram
*/
SocketReader *m_inputProgram;
public:
ConvertValueToColorProg();
/**
* the inner loop of this program
*/
void executePixel(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
*/
void initExecution();
/**
* Deinitialize the execution
*/
void deinitExecution();
};
#endif

View File

@ -1,50 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#include "COM_ConvertValueToVectorOperation.h"
ConvertValueToVectorOperation::ConvertValueToVectorOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VECTOR);
this->m_inputOperation = NULL;
}
void ConvertValueToVectorOperation::initExecution()
{
this->m_inputOperation = this->getInputSocketReader(0);
}
void ConvertValueToVectorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float input[4];
this->m_inputOperation->read(input, x, y, sampler);
output[0] = input[0];
output[1] = input[0];
output[2] = input[0];
output[3] = 0.0f;
}
void ConvertValueToVectorOperation::deinitExecution()
{
this->m_inputOperation = NULL;
}

View File

@ -1,59 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#ifndef _COM_ConvertValueToVectorOperation_h
#define _COM_ConvertValueToVectorOperation_h
#include "COM_NodeOperation.h"
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class ConvertValueToVectorOperation : public NodeOperation {
private:
/**
* Cached reference to the inputProgram
*/
SocketReader *m_inputOperation;
public:
/**
* Default constructor
*/
ConvertValueToVectorOperation();
/**
* the inner loop of this program
*/
void executePixel(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
*/
void initExecution();
/**
* Deinitialize the execution
*/
void deinitExecution();
};
#endif

View File

@ -1,46 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#include "COM_ConvertVectorToColorOperation.h"
ConvertVectorToColorOperation::ConvertVectorToColorOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VECTOR);
this->addOutputSocket(COM_DT_COLOR);
this->m_inputOperation = NULL;
}
void ConvertVectorToColorOperation::initExecution()
{
this->m_inputOperation = this->getInputSocketReader(0);
}
void ConvertVectorToColorOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
this->m_inputOperation->read(output, x, y, sampler);
output[3] = 1.0f;
}
void ConvertVectorToColorOperation::deinitExecution()
{
this->m_inputOperation = NULL;
}

View File

@ -1,59 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#ifndef _COM_ConvertVectorToColorOperation_h
#define _COM_ConvertVectorToColorOperation_h
#include "COM_NodeOperation.h"
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class ConvertVectorToColorOperation : public NodeOperation {
private:
/**
* Cached reference to the inputProgram
*/
SocketReader *m_inputOperation;
public:
/**
* Default constructor
*/
ConvertVectorToColorOperation();
/**
* the inner loop of this program
*/
void executePixel(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
*/
void initExecution();
/**
* Deinitialize the execution
*/
void deinitExecution();
};
#endif

View File

@ -1,47 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#include "COM_ConvertVectorToValueOperation.h"
ConvertVectorToValueOperation::ConvertVectorToValueOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VECTOR);
this->addOutputSocket(COM_DT_VALUE);
this->m_inputOperation = NULL;
}
void ConvertVectorToValueOperation::initExecution()
{
this->m_inputOperation = this->getInputSocketReader(0);
}
void ConvertVectorToValueOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float input[4];
this->m_inputOperation->read(input, x, y, sampler);
output[0] = (input[0] + input[1] + input[2]) / 3.0f;
}
void ConvertVectorToValueOperation::deinitExecution()
{
this->m_inputOperation = NULL;
}

View File

@ -1,59 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#ifndef _COM_ConvertVectorToValueOperation_h
#define _COM_ConvertVectorToValueOperation_h
#include "COM_NodeOperation.h"
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class ConvertVectorToValueOperation : public NodeOperation {
private:
/**
* Cached reference to the inputProgram
*/
SocketReader *m_inputOperation;
public:
/**
* Default constructor
*/
ConvertVectorToValueOperation();
/**
* the inner loop of this program
*/
void executePixel(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
*/
void initExecution();
/**
* Deinitialize the execution
*/
void deinitExecution();
};
#endif

View File

@ -1,70 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Dalai Felinto
*/
#include "COM_ConvertYCCToRGBOperation.h"
#include "BLI_math_color.h"
ConvertYCCToRGBOperation::ConvertYCCToRGBOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
this->m_inputOperation = NULL;
}
void ConvertYCCToRGBOperation::initExecution()
{
this->m_inputOperation = this->getInputSocketReader(0);
}
void ConvertYCCToRGBOperation::setMode(int mode)
{
switch (mode) {
case 1:
this->m_mode = BLI_YCC_ITU_BT709;
break;
case 2:
this->m_mode = BLI_YCC_JFIF_0_255;
break;
case 0:
default:
this->m_mode = BLI_YCC_ITU_BT601;
break;
}
}
void ConvertYCCToRGBOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
this->m_inputOperation->read(inputColor, x, y, sampler);
/* need to un-normalize the data */
/* R,G,B --> Y,Cb,Cr */
mul_v3_fl(inputColor, 255.0f);
ycc_to_rgb(inputColor[0], inputColor[1], inputColor[2], &output[0], &output[1], &output[2], this->m_mode);
output[3] = inputColor[3];
}
void ConvertYCCToRGBOperation::deinitExecution()
{
this->m_inputOperation = NULL;
}

View File

@ -1,68 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Dalai Felinto
*/
#ifndef _COM_ConvertYCCToRGBOperation_h
#define _COM_ConvertYCCToRGBOperation_h
#include "COM_NodeOperation.h"
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class ConvertYCCToRGBOperation : public NodeOperation {
private:
/**
* Cached reference to the inputProgram
*/
SocketReader *m_inputOperation;
/**
* YCbCr mode (Jpeg, ITU601, ITU709)
*/
int m_mode;
public:
/**
* Default constructor
*/
ConvertYCCToRGBOperation();
/**
* the inner loop of this program
*/
void executePixel(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
*/
void initExecution();
/**
* Deinitialize the execution
*/
void deinitExecution();
/**
* Set the YCC mode
*/
void setMode(int mode);
};
#endif

View File

@ -1,49 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Dalai Felinto
*/
#include "COM_ConvertYUVToRGBOperation.h"
#include "BLI_math_color.h"
ConvertYUVToRGBOperation::ConvertYUVToRGBOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
this->m_inputOperation = NULL;
}
void ConvertYUVToRGBOperation::initExecution()
{
this->m_inputOperation = this->getInputSocketReader(0);
}
void ConvertYUVToRGBOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float inputColor[4];
this->m_inputOperation->read(inputColor, x, y, sampler);
yuv_to_rgb(inputColor[0], inputColor[1], inputColor[2], &output[0], &output[1], &output[2]);
output[3] = inputColor[3];
}
void ConvertYUVToRGBOperation::deinitExecution()
{
this->m_inputOperation = NULL;
}

View File

@ -1,58 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Dalai Felinto
*/
#ifndef _COM_ConvertYUVToRGBOperation_h
#define _COM_ConvertYUVToRGBOperation_h
#include "COM_NodeOperation.h"
/**
* this program converts an input color to an output value.
* it assumes we are in sRGB color space.
*/
class ConvertYUVToRGBOperation : public NodeOperation {
private:
/**
* Cached reference to the inputProgram
*/
SocketReader *m_inputOperation;
public:
/**
* Default constructor
*/
ConvertYUVToRGBOperation();
/**
* the inner loop of this program
*/
void executePixel(float output[4], float x, float y, PixelSampler sampler);
/**
* Initialize the execution
*/
void initExecution();
/**
* Deinitialize the execution
*/
void deinitExecution();
};
#endif

View File

@ -1,47 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#include "COM_SeparateChannelOperation.h"
SeparateChannelOperation::SeparateChannelOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_VALUE);
this->m_inputOperation = NULL;
}
void SeparateChannelOperation::initExecution()
{
this->m_inputOperation = this->getInputSocketReader(0);
}
void SeparateChannelOperation::deinitExecution()
{
this->m_inputOperation = NULL;
}
void SeparateChannelOperation::executePixel(float output[4], float x, float y, PixelSampler sampler)
{
float input[4];
this->m_inputOperation->read(input, x, y, sampler);
output[0] = input[this->m_channel];
}

View File

@ -1,42 +0,0 @@
/*
* Copyright 2011, Blender Foundation.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Contributor:
* Jeroen Bakker
* Monique Dewanchand
*/
#ifndef _COM_SeparateChannelOperation_h_
#define _COM_SeparateChannelOperation_h_
#include "COM_NodeOperation.h"
class SeparateChannelOperation : public NodeOperation {
private:
SocketReader *m_inputOperation;
int m_channel;
public:
SeparateChannelOperation();
void executePixel(float output[4], float x, float y, PixelSampler sampler);
void initExecution();
void deinitExecution();
void setChannel(int channel) { this->m_channel = channel; }
};
#endif