Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-06-15 13:58:52 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-06-15 13:58:52 +0400
commitec755bdfa7920c9db4dd771c065e85539b00d140 (patch)
treefc05b551bd397aae04c478a5fcb6ea7c0be05b2e /source
parent3264db37972877184ead9785181722e5cf65f164 (diff)
style cleanup: composite/blur
Diffstat (limited to 'source')
-rw-r--r--source/blender/compositor/nodes/COM_BilateralBlurNode.cpp6
-rw-r--r--source/blender/compositor/nodes/COM_BlurNode.cpp10
-rw-r--r--source/blender/compositor/nodes/COM_BokehBlurNode.cpp6
-rw-r--r--source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp6
-rw-r--r--source/blender/compositor/nodes/COM_VectorBlurNode.cpp6
-rw-r--r--source/blender/compositor/operations/COM_BilateralBlurOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.cpp38
-rw-r--r--source/blender/compositor/operations/COM_BokehBlurOperation.cpp38
-rw-r--r--source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp8
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp126
-rw-r--r--source/blender/compositor/operations/COM_FastGaussianBlurOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp48
-rw-r--r--source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp20
-rw-r--r--source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp20
-rw-r--r--source/blender/compositor/operations/COM_KeyingBlurOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_KeyingBlurOperation.h4
-rw-r--r--source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp18
-rw-r--r--source/blender/compositor/operations/COM_VectorBlurOperation.cpp24
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_bilateralblur.c146
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_blur.c622
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_bokehblur.c20
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_directionalblur.c74
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_vecBlur.c48
23 files changed, 652 insertions, 650 deletions
diff --git a/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp b/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp
index fa654d35785..6baa04ff7c2 100644
--- a/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_BilateralBlurNode.cpp
@@ -26,13 +26,13 @@
#include "COM_ExecutionSystem.h"
#include "COM_BilateralBlurOperation.h"
-BilateralBlurNode::BilateralBlurNode(bNode *editorNode): Node(editorNode)
+BilateralBlurNode::BilateralBlurNode(bNode *editorNode) : Node(editorNode)
{
}
-void BilateralBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void BilateralBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
- NodeBilateralBlurData *data = (NodeBilateralBlurData*)this->getbNode()->storage;
+ NodeBilateralBlurData *data = (NodeBilateralBlurData *)this->getbNode()->storage;
BilateralBlurOperation *operation = new BilateralBlurOperation();
operation->setQuality(context->getQuality());
operation->setData(data);
diff --git a/source/blender/compositor/nodes/COM_BlurNode.cpp b/source/blender/compositor/nodes/COM_BlurNode.cpp
index b27b6323f49..fe93768161c 100644
--- a/source/blender/compositor/nodes/COM_BlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_BlurNode.cpp
@@ -29,19 +29,19 @@
#include "COM_GaussianBokehBlurOperation.h"
#include "COM_FastGaussianBlurOperation.h"
-BlurNode::BlurNode(bNode *editorNode): Node(editorNode)
+BlurNode::BlurNode(bNode *editorNode) : Node(editorNode)
{
}
-void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
bNode *editorNode = this->getbNode();
- NodeBlurData * data = (NodeBlurData*)editorNode->storage;
- InputSocket * inputSizeSocket = this->getInputSocket(1);
+ NodeBlurData *data = (NodeBlurData *)editorNode->storage;
+ InputSocket *inputSizeSocket = this->getInputSocket(1);
bool connectedSizeSocket = inputSizeSocket->isConnected();
const bNodeSocket *sock = this->getInputSocket(1)->getbNodeSocket();
- const float size = ((const bNodeSocketValueFloat*)sock->default_value)->value;
+ const float size = ((const bNodeSocketValueFloat *)sock->default_value)->value;
CompositorQuality quality = context->getQuality();
diff --git a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp
index abae1b88890..ee0119230f4 100644
--- a/source/blender/compositor/nodes/COM_BokehBlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_BokehBlurNode.cpp
@@ -30,11 +30,11 @@
#include "COM_VariableSizeBokehBlurOperation.h"
#include "COM_ConvertDepthToRadiusOperation.h"
-BokehBlurNode::BokehBlurNode(bNode *editorNode): Node(editorNode)
+BokehBlurNode::BokehBlurNode(bNode *editorNode) : Node(editorNode)
{
}
-void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
Object *camob = context->getScene()->camera;
@@ -58,7 +58,7 @@ void BokehBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContex
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
this->getInputSocket(3)->relinkConnections(operation->getInputSocket(2), 3, graph);
- operation->setSize(((bNodeSocketValueFloat*)this->getInputSocket(2)->getbNodeSocket()->default_value)->value);
+ operation->setSize(((bNodeSocketValueFloat *)this->getInputSocket(2)->getbNodeSocket()->default_value)->value);
operation->setQuality(context->getQuality());
graph->addOperation(operation);
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
diff --git a/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp b/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp
index d63fbbdb092..d096ef977f8 100644
--- a/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_DirectionalBlurNode.cpp
@@ -26,13 +26,13 @@
#include "COM_ExecutionSystem.h"
#include "COM_DirectionalBlurOperation.h"
-DirectionalBlurNode::DirectionalBlurNode(bNode *editorNode): Node(editorNode)
+DirectionalBlurNode::DirectionalBlurNode(bNode *editorNode) : Node(editorNode)
{
}
-void DirectionalBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext * context)
+void DirectionalBlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
- NodeDBlurData *data = (NodeDBlurData*)this->getbNode()->storage;
+ NodeDBlurData *data = (NodeDBlurData *)this->getbNode()->storage;
DirectionalBlurOperation *operation = new DirectionalBlurOperation();
operation->setQuality(context->getQuality());
operation->setData(data);
diff --git a/source/blender/compositor/nodes/COM_VectorBlurNode.cpp b/source/blender/compositor/nodes/COM_VectorBlurNode.cpp
index 98096c3de7b..78b9065b4da 100644
--- a/source/blender/compositor/nodes/COM_VectorBlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_VectorBlurNode.cpp
@@ -24,14 +24,14 @@
#include "DNA_node_types.h"
#include "COM_VectorBlurOperation.h"
-VectorBlurNode::VectorBlurNode(bNode *editorNode): Node(editorNode)
+VectorBlurNode::VectorBlurNode(bNode *editorNode) : Node(editorNode)
{
}
-void VectorBlurNode::convertToOperations(ExecutionSystem *system, CompositorContext * context)
+void VectorBlurNode::convertToOperations(ExecutionSystem *system, CompositorContext *context)
{
bNode *node = this->getbNode();
- NodeBlurData *vectorBlurSettings = (NodeBlurData*)node->storage;
+ NodeBlurData *vectorBlurSettings = (NodeBlurData *)node->storage;
VectorBlurOperation *operation = new VectorBlurOperation();
operation->setVectorBlurSettings(vectorBlurSettings);
operation->setQuality(context->getQuality());
diff --git a/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
index 7129e7c140a..3628c399581 100644
--- a/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_BilateralBlurOperation.cpp
@@ -65,14 +65,14 @@ void BilateralBlurOperation::executePixel(float *color, int x, int y, MemoryBuff
zero_v4(blurColor);
blurDivider = 0.0f;
- for (int yi = miny ; yi < maxy ; yi+=QualityStepHelper::getStep()) {
- for (int xi = minx ; xi < maxx ; xi+=QualityStepHelper::getStep()) {
+ for (int yi = miny; yi < maxy; yi += QualityStepHelper::getStep()) {
+ for (int xi = minx; xi < maxx; xi += QualityStepHelper::getStep()) {
// read determinator
this->inputDeterminatorProgram->read(determinator, xi, yi, inputBuffers, data);
deltaColor = (fabsf(determinatorReferenceColor[0] - determinator[0]) +
fabsf(determinatorReferenceColor[1] - determinator[1]) +
fabsf(determinatorReferenceColor[2] - determinator[2])); // do not take the alpha channel into account
- if (deltaColor< sigmacolor) {
+ if (deltaColor < sigmacolor) {
// add this to the blur
this->inputColorProgram->read(tempColor, xi, yi, inputBuffers, data);
add_v4_v4(blurColor, tempColor);
@@ -101,7 +101,7 @@ void BilateralBlurOperation::deinitExecution()
bool BilateralBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
rcti newInput;
- int add = ceil(this->space)+1;
+ int add = ceil(this->space) + 1;
newInput.xmax = input->xmax + (add);
newInput.xmin = input->xmin - (add);
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
index 2280ee3a435..bb915fec590 100644
--- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
@@ -27,7 +27,7 @@ extern "C" {
#include "RE_pipeline.h"
}
-BlurBaseOperation::BlurBaseOperation(): NodeOperation()
+BlurBaseOperation::BlurBaseOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE);
@@ -37,7 +37,7 @@ BlurBaseOperation::BlurBaseOperation(): NodeOperation()
this->data = NULL;
this->size = 1.0f;
this->deleteData = false;
- this->sizeavailable=false;
+ this->sizeavailable = false;
}
void BlurBaseOperation::initExecution()
{
@@ -47,18 +47,18 @@ void BlurBaseOperation::initExecution()
this->data->image_in_height = this->getHeight();
if (this->data->relative) {
switch (this->data->aspect) {
- case CMP_NODE_BLUR_ASPECT_NONE:
- this->data->sizex = (int)(this->data->percentx*0.01f*this->data->image_in_width);
- this->data->sizey = (int)(this->data->percenty*0.01f*this->data->image_in_height);
- break;
- case CMP_NODE_BLUR_ASPECT_Y:
- this->data->sizex = (int)(this->data->percentx*0.01f*this->data->image_in_width);
- this->data->sizey = (int)(this->data->percenty*0.01f*this->data->image_in_width);
- break;
- case CMP_NODE_BLUR_ASPECT_X:
- this->data->sizex = (int)(this->data->percentx*0.01f*this->data->image_in_height);
- this->data->sizey = (int)(this->data->percenty*0.01f*this->data->image_in_height);
- break;
+ case CMP_NODE_BLUR_ASPECT_NONE:
+ this->data->sizex = (int)(this->data->percentx * 0.01f * this->data->image_in_width);
+ this->data->sizey = (int)(this->data->percenty * 0.01f * this->data->image_in_height);
+ break;
+ case CMP_NODE_BLUR_ASPECT_Y:
+ this->data->sizex = (int)(this->data->percentx * 0.01f * this->data->image_in_width);
+ this->data->sizey = (int)(this->data->percenty * 0.01f * this->data->image_in_width);
+ break;
+ case CMP_NODE_BLUR_ASPECT_X:
+ this->data->sizex = (int)(this->data->percentx * 0.01f * this->data->image_in_height);
+ this->data->sizey = (int)(this->data->percenty * 0.01f * this->data->image_in_height);
+ break;
}
}
@@ -77,14 +77,14 @@ float *BlurBaseOperation::make_gausstab(int rad)
sum = 0.0f;
for (i = -rad; i <= rad; i++) {
- val = RE_filter_value(this->data->filtertype, (float)i/(float)rad);
+ val = RE_filter_value(this->data->filtertype, (float)i / (float)rad);
sum += val;
- gausstab[i+rad] = val;
+ gausstab[i + rad] = val;
}
- sum = 1.0f/sum;
- for (i=0; i<n; i++)
- gausstab[i]*= sum;
+ sum = 1.0f / sum;
+ for (i = 0; i < n; i++)
+ gausstab[i] *= sum;
return gausstab;
}
diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
index 67e24496cbe..dca087bb587 100644
--- a/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_BokehBlurOperation.cpp
@@ -59,15 +59,15 @@ void BokehBlurOperation::initExecution()
int height = inputBokehProgram->getHeight();
float dimension;
- if (width<height) {
+ if (width < height) {
dimension = width;
}
else {
dimension = height;
}
- this->bokehMidX = width/2.0f;
- this->bokehMidY = height/2.0f;
- this->bokehDimension = dimension/2.0f;
+ this->bokehMidX = width / 2.0f;
+ this->bokehMidY = height / 2.0f;
+ this->bokehDimension = dimension / 2.0f;
QualityStepHelper::initExecution(COM_QH_INCREASE);
}
@@ -78,14 +78,14 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *
float bokeh[4];
inputBoundingBoxReader->read(tempBoundingBox, x, y, COM_PS_NEAREST, inputBuffers);
- if (tempBoundingBox[0] >0.0f) {
+ if (tempBoundingBox[0] > 0.0f) {
float overallmultiplyer[4] = {0.0f, 0.0f, 0.0f, 0.0f};
- MemoryBuffer *inputBuffer = (MemoryBuffer*)data;
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
int bufferwidth = inputBuffer->getWidth();
int bufferstartx = inputBuffer->getRect()->xmin;
int bufferstarty = inputBuffer->getRect()->ymin;
- int pixelSize = this->size*this->getWidth()/100.0f;
+ int pixelSize = this->size * this->getWidth() / 100.0f;
int miny = y - pixelSize;
int maxy = y + pixelSize;
@@ -101,16 +101,16 @@ void BokehBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *
int step = getStep();
int offsetadd = getOffsetAdd();
- float m = this->bokehDimension/pixelSize;
- for (int ny = miny ; ny < maxy ; ny +=step) {
- int bufferindex = ((minx - bufferstartx)*4)+((ny-bufferstarty)*4*bufferwidth);
- for (int nx = minx ; nx < maxx ; nx +=step) {
- float u = this->bokehMidX - (nx-x) *m;
- float v = this->bokehMidY - (ny-y) *m;
+ float m = this->bokehDimension / pixelSize;
+ for (int ny = miny; ny < maxy; ny += step) {
+ int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth);
+ for (int nx = minx; nx < maxx; nx += step) {
+ float u = this->bokehMidX - (nx - x) * m;
+ float v = this->bokehMidY - (ny - y) * m;
inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers);
madd_v4_v4v4(tempColor, bokeh, &buffer[bufferindex]);
add_v4_v4(overallmultiplyer, bokeh);
- bufferindex +=offsetadd;
+ bufferindex += offsetadd;
}
}
color[0] = tempColor[0] * (1.0f / overallmultiplyer[0]);
@@ -135,10 +135,10 @@ bool BokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBuffe
rcti newInput;
rcti bokehInput;
- newInput.xmax = input->xmax + (size*this->getWidth()/100.0f);
- newInput.xmin = input->xmin - (size*this->getWidth()/100.0f);
- newInput.ymax = input->ymax + (size*this->getWidth()/100.0f);
- newInput.ymin = input->ymin - (size*this->getWidth()/100.0f);
+ newInput.xmax = input->xmax + (size * this->getWidth() / 100.0f);
+ newInput.xmin = input->xmin - (size * this->getWidth() / 100.0f);
+ newInput.ymax = input->ymax + (size * this->getWidth() / 100.0f);
+ newInput.ymin = input->ymin - (size * this->getWidth() / 100.0f);
NodeOperation *operation = getInputOperation(1);
bokehInput.xmax = operation->getWidth();
@@ -168,7 +168,7 @@ void BokehBlurOperation::executeOpenCL(cl_context context, cl_program program, c
if (!kernel) {
kernel = COM_clCreateKernel(program, "bokehBlurKernel", NULL);
}
- cl_int radius = this->getWidth()*this->size/100.0f;
+ cl_int radius = this->getWidth() * this->size / 100.0f;
cl_int step = this->getStep();
COM_clAttachMemoryBufferToKernelParameter(context, kernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->inputBoundingBoxReader);
diff --git a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
index 60c31400eca..271a165f0ff 100644
--- a/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_DirectionalBlurOperation.cpp
@@ -54,12 +54,12 @@ void DirectionalBlurOperation::initExecution()
const float itsc = 1.0f / powf(2.0f, (float)iterations);
float D;
- D = distance * sqrtf(width*width + height*height);
+ D = distance * sqrtf(width * width + height * height);
center_x_pix = center_x * width;
center_y_pix = center_y * height;
tx = itsc * D * cosf(a);
- ty = -itsc * D * sinf(a);
+ ty = -itsc *D *sinf(a);
sc = itsc * zoom;
rot = itsc * spin;
@@ -68,8 +68,8 @@ void DirectionalBlurOperation::initExecution()
void DirectionalBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
const int iterations = pow(2.f, this->data->iter);
- float col[4] = {0,0,0,0};
- float col2[4] = {0,0,0,0};
+ float col[4] = {0, 0, 0, 0};
+ float col2[4] = {0, 0, 0, 0};
this->inputProgram->read(col2, x, y, COM_PS_NEAREST, inputBuffers);
float ltx = tx;
float lty = ty;
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
index 92e1aace9e2..7830eef829c 100644
--- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
@@ -24,14 +24,14 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
-FastGaussianBlurOperation::FastGaussianBlurOperation(): BlurBaseOperation()
+FastGaussianBlurOperation::FastGaussianBlurOperation() : BlurBaseOperation()
{
this->iirgaus = NULL;
}
-void FastGaussianBlurOperation::executePixel(float *color,int x, int y, MemoryBuffer *inputBuffers[], void *data)
+void FastGaussianBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
- MemoryBuffer *newData = (MemoryBuffer*)data;
+ MemoryBuffer *newData = (MemoryBuffer *)data;
newData->read(color, x, y);
}
@@ -44,7 +44,7 @@ bool FastGaussianBlurOperation::determineDependingAreaOfInterest(rcti *input, Re
sizeInput.xmax = 5;
sizeInput.ymax = 5;
- NodeOperation * operation = this->getInputOperation(1);
+ NodeOperation *operation = this->getInputOperation(1);
if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
return true;
}
@@ -81,25 +81,25 @@ void *FastGaussianBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **m
{
lockMutex();
if (!iirgaus) {
- MemoryBuffer *newBuf = (MemoryBuffer*)this->inputProgram->initializeTileData(rect, memoryBuffers);
+ MemoryBuffer *newBuf = (MemoryBuffer *)this->inputProgram->initializeTileData(rect, memoryBuffers);
MemoryBuffer *copy = newBuf->duplicate();
updateSize(memoryBuffers);
int c;
- sx = data->sizex * this->size/2.0f;
- sy = data->sizey * this->size/2.0f;
+ sx = data->sizex * this->size / 2.0f;
+ sy = data->sizey * this->size / 2.0f;
if ((sx == sy) && (sx > 0.f)) {
- for (c=0; c<COM_NUMBER_OF_CHANNELS; ++c)
+ for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c)
IIR_gauss(copy, sx, c, 3);
}
else {
if (sx > 0.f) {
- for (c=0; c<COM_NUMBER_OF_CHANNELS; ++c)
+ for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c)
IIR_gauss(copy, sx, c, 1);
}
if (sy > 0.f) {
- for (c=0; c<COM_NUMBER_OF_CHANNELS; ++c)
+ for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c)
IIR_gauss(copy, sy, c, 2);
}
}
@@ -130,17 +130,17 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, int ch
// see "Recursive Gabor Filtering" by Young/VanVliet
// all factors here in double.prec. Required, because for single.prec it seems to blow up if sigma > ~200
if (sigma >= 3.556f)
- q = 0.9804f*(sigma - 3.556f) + 2.5091f;
+ q = 0.9804f * (sigma - 3.556f) + 2.5091f;
else // sigma >= 0.5
- q = (0.0561f*sigma + 0.5784f)*sigma - 0.2568f;
- q2 = q*q;
- sc = (1.1668 + q)*(3.203729649 + (2.21566 + q)*q);
+ q = (0.0561f * sigma + 0.5784f) * sigma - 0.2568f;
+ q2 = q * q;
+ sc = (1.1668 + q) * (3.203729649 + (2.21566 + q) * q);
// no gabor filtering here, so no complex multiplies, just the regular coefs.
// all negated here, so as not to have to recalc Triggs/Sdika matrix
- cf[1] = q*(5.788961737 + (6.76492 + 3.0*q)*q)/ sc;
- cf[2] = -q2*(3.38246 + 3.0*q)/sc;
+ cf[1] = q * (5.788961737 + (6.76492 + 3.0 * q) * q) / sc;
+ cf[2] = -q2 * (3.38246 + 3.0 * q) / sc;
// 0 & 3 unchanged
- cf[3] = q2*q/sc;
+ cf[3] = q2 * q / sc;
cf[0] = 1.0 - cf[1] - cf[2] - cf[3];
// Triggs/Sdika border corrections,
@@ -150,59 +150,61 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, int ch
// but neither seem to be quite the same, result seems to be ok so far anyway.
// Extra scale factor here to not have to do it in filter,
// though maybe this had something to with the precision errors
- sc = cf[0]/((1.0 + cf[1] - cf[2] + cf[3])*(1.0 - cf[1] - cf[2] - cf[3])*(1.0 + cf[2] + (cf[1] - cf[3])*cf[3]));
- tsM[0] = sc*(-cf[3]*cf[1] + 1.0 - cf[3]*cf[3] - cf[2]);
- tsM[1] = sc*((cf[3] + cf[1])*(cf[2] + cf[3]*cf[1]));
- tsM[2] = sc*(cf[3]*(cf[1] + cf[3]*cf[2]));
- tsM[3] = sc*(cf[1] + cf[3]*cf[2]);
- tsM[4] = sc*(-(cf[2] - 1.0)*(cf[2] + cf[3]*cf[1]));
- tsM[5] = sc*(-(cf[3]*cf[1] + cf[3]*cf[3] + cf[2] - 1.0)*cf[3]);
- tsM[6] = sc*(cf[3]*cf[1] + cf[2] + cf[1]*cf[1] - cf[2]*cf[2]);
- tsM[7] = sc*(cf[1]*cf[2] + cf[3]*cf[2]*cf[2] - cf[1]*cf[3]*cf[3] - cf[3]*cf[3]*cf[3] - cf[3]*cf[2] + cf[3]);
- tsM[8] = sc*(cf[3]*(cf[1] + cf[3]*cf[2]));
+ sc = cf[0] / ((1.0 + cf[1] - cf[2] + cf[3]) * (1.0 - cf[1] - cf[2] - cf[3]) * (1.0 + cf[2] + (cf[1] - cf[3]) * cf[3]));
+ tsM[0] = sc * (-cf[3] * cf[1] + 1.0 - cf[3] * cf[3] - cf[2]);
+ tsM[1] = sc * ((cf[3] + cf[1]) * (cf[2] + cf[3] * cf[1]));
+ tsM[2] = sc * (cf[3] * (cf[1] + cf[3] * cf[2]));
+ tsM[3] = sc * (cf[1] + cf[3] * cf[2]);
+ tsM[4] = sc * (-(cf[2] - 1.0) * (cf[2] + cf[3] * cf[1]));
+ tsM[5] = sc * (-(cf[3] * cf[1] + cf[3] * cf[3] + cf[2] - 1.0) * cf[3]);
+ tsM[6] = sc * (cf[3] * cf[1] + cf[2] + cf[1] * cf[1] - cf[2] * cf[2]);
+ tsM[7] = sc * (cf[1] * cf[2] + cf[3] * cf[2] * cf[2] - cf[1] * cf[3] * cf[3] - cf[3] * cf[3] * cf[3] - cf[3] * cf[2] + cf[3]);
+ tsM[8] = sc * (cf[3] * (cf[1] + cf[3] * cf[2]));
-#define YVV(L) \
-{ \
-W[0] = cf[0]*X[0] + cf[1]*X[0] + cf[2]*X[0] + cf[3]*X[0]; \
-W[1] = cf[0]*X[1] + cf[1]*W[0] + cf[2]*X[0] + cf[3]*X[0]; \
-W[2] = cf[0]*X[2] + cf[1]*W[1] + cf[2]*W[0] + cf[3]*X[0]; \
-for (i=3; i<L; i++) \
-W[i] = cf[0]*X[i] + cf[1]*W[i-1] + cf[2]*W[i-2] + cf[3]*W[i-3]; \
-tsu[0] = W[L-1] - X[L-1]; \
-tsu[1] = W[L-2] - X[L-1]; \
-tsu[2] = W[L-3] - X[L-1]; \
-tsv[0] = tsM[0]*tsu[0] + tsM[1]*tsu[1] + tsM[2]*tsu[2] + X[L-1]; \
-tsv[1] = tsM[3]*tsu[0] + tsM[4]*tsu[1] + tsM[5]*tsu[2] + X[L-1]; \
-tsv[2] = tsM[6]*tsu[0] + tsM[7]*tsu[1] + tsM[8]*tsu[2] + X[L-1]; \
-Y[L-1] = cf[0]*W[L-1] + cf[1]*tsv[0] + cf[2]*tsv[1] + cf[3]*tsv[2]; \
-Y[L-2] = cf[0]*W[L-2] + cf[1]*Y[L-1] + cf[2]*tsv[0] + cf[3]*tsv[1]; \
-Y[L-3] = cf[0]*W[L-3] + cf[1]*Y[L-2] + cf[2]*Y[L-1] + cf[3]*tsv[0]; \
-for (i=L-4; i>=0; i--) \
-Y[i] = cf[0]*W[i] + cf[1]*Y[i+1] + cf[2]*Y[i+2] + cf[3]*Y[i+3]; \
-}
+#define YVV(L) \
+{ \
+ W[0] = cf[0] * X[0] + cf[1] * X[0] + cf[2] * X[0] + cf[3] * X[0]; \
+ W[1] = cf[0] * X[1] + cf[1] * W[0] + cf[2] * X[0] + cf[3] * X[0]; \
+ W[2] = cf[0] * X[2] + cf[1] * W[1] + cf[2] * W[0] + cf[3] * X[0]; \
+ for (i = 3; i < L; i++) { \
+ W[i] = cf[0] * X[i] + cf[1] * W[i - 1] + cf[2] * W[i - 2] + cf[3] * W[i - 3]; \
+ } \
+ tsu[0] = W[L - 1] - X[L - 1]; \
+ tsu[1] = W[L - 2] - X[L - 1]; \
+ tsu[2] = W[L - 3] - X[L - 1]; \
+ tsv[0] = tsM[0] * tsu[0] + tsM[1] * tsu[1] + tsM[2] * tsu[2] + X[L - 1]; \
+ tsv[1] = tsM[3] * tsu[0] + tsM[4] * tsu[1] + tsM[5] * tsu[2] + X[L - 1]; \
+ tsv[2] = tsM[6] * tsu[0] + tsM[7] * tsu[1] + tsM[8] * tsu[2] + X[L - 1]; \
+ Y[L - 1] = cf[0] * W[L - 1] + cf[1] * tsv[0] + cf[2] * tsv[1] + cf[3] * tsv[2]; \
+ Y[L - 2] = cf[0] * W[L - 2] + cf[1] * Y[L - 1] + cf[2] * tsv[0] + cf[3] * tsv[1]; \
+ Y[L - 3] = cf[0] * W[L - 3] + cf[1] * Y[L - 2] + cf[2] * Y[L - 1] + cf[3] * tsv[0]; \
+ for (i = L - 4; i >= 0; i--) { \
+ Y[i] = cf[0] * W[i] + cf[1] * Y[i + 1] + cf[2] * Y[i + 2] + cf[3] * Y[i + 3]; \
+ } \
+} (void)0
// intermediate buffers
sz = MAX2(src->getWidth(), src->getHeight());
- X = (double*)MEM_callocN(sz*sizeof(double), "IIR_gauss X buf");
- Y = (double*)MEM_callocN(sz*sizeof(double), "IIR_gauss Y buf");
- W = (double*)MEM_callocN(sz*sizeof(double), "IIR_gauss W buf");
- if (xy & 1) { // H
- for (y=0; y<src->getHeight(); ++y) {
- const int yx = y*src->getWidth();
- for (x=0; x<src->getWidth(); ++x)
- X[x] = buffer[(x + yx)*COM_NUMBER_OF_CHANNELS + chan];
+ X = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss X buf");
+ Y = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss Y buf");
+ W = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss W buf");
+ if (xy & 1) { // H
+ for (y = 0; y < src->getHeight(); ++y) {
+ const int yx = y * src->getWidth();
+ for (x = 0; x < src->getWidth(); ++x)
+ X[x] = buffer[(x + yx) * COM_NUMBER_OF_CHANNELS + chan];
YVV(src->getWidth());
- for (x=0; x<src->getWidth(); ++x)
- buffer[(x + yx)*COM_NUMBER_OF_CHANNELS + chan] = Y[x];
+ for (x = 0; x < src->getWidth(); ++x)
+ buffer[(x + yx) * COM_NUMBER_OF_CHANNELS + chan] = Y[x];
}
}
- if (xy & 2) { // V
- for (x=0; x<src->getWidth(); ++x) {
- for (y=0; y<src->getHeight(); ++y)
- X[y] = buffer[(x + y*src->getWidth())*COM_NUMBER_OF_CHANNELS + chan];
+ if (xy & 2) { // V
+ for (x = 0; x < src->getWidth(); ++x) {
+ for (y = 0; y < src->getHeight(); ++y)
+ X[y] = buffer[(x + y * src->getWidth()) * COM_NUMBER_OF_CHANNELS + chan];
YVV(src->getHeight());
- for (y=0; y<src->getHeight(); ++y)
- buffer[(x + y*src->getWidth())*COM_NUMBER_OF_CHANNELS + chan] = Y[y];
+ for (y = 0; y < src->getHeight(); ++y)
+ buffer[(x + y * src->getWidth()) * COM_NUMBER_OF_CHANNELS + chan] = Y[y];
}
}
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
index 9c8973f6a3a..f92e3dc68a5 100644
--- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
+++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
@@ -34,7 +34,7 @@ private:
public:
FastGaussianBlurOperation();
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
- void executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data);
+ void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data);
static void IIR_gauss(MemoryBuffer *src, float sigma, int channel, int xy);
void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);
diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
index 80e35f63ac5..b5ae54299eb 100644
--- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp
@@ -27,7 +27,7 @@ extern "C" {
#include "RE_pipeline.h"
}
-GaussianBokehBlurOperation::GaussianBokehBlurOperation(): BlurBaseOperation()
+GaussianBokehBlurOperation::GaussianBokehBlurOperation() : BlurBaseOperation()
{
this->gausstab = NULL;
}
@@ -65,42 +65,42 @@ void GaussianBokehBlurOperation::updateGauss(MemoryBuffer **memoryBuffers)
if (!sizeavailable) {
updateSize(memoryBuffers);
}
- radxf = size*(float)this->data->sizex;
- if (radxf>width/2.0f)
- radxf = width/2.0f;
- else if (radxf<1.0f)
+ radxf = size * (float)this->data->sizex;
+ if (radxf > width / 2.0f)
+ radxf = width / 2.0f;
+ else if (radxf < 1.0f)
radxf = 1.0f;
/* vertical */
- radyf = size*(float)this->data->sizey;
- if (radyf>height/2.0f)
- radyf = height/2.0f;
- else if (radyf<1.0f)
+ radyf = size * (float)this->data->sizey;
+ if (radyf > height / 2.0f)
+ radyf = height / 2.0f;
+ else if (radyf < 1.0f)
radyf = 1.0f;
radx = ceil(radxf);
rady = ceil(radyf);
- n = (2*radx+1)*(2*rady+1);
+ n = (2 * radx + 1) * (2 * rady + 1);
/* create a full filter image */
ddgauss = new float[n];
dgauss = ddgauss;
val = 0.0f;
- for (j=-rady; j<=rady; j++) {
- for (i=-radx; i<=radx; i++, dgauss++) {
+ for (j = -rady; j <= rady; j++) {
+ for (i = -radx; i <= radx; i++, dgauss++) {
float fj = (float)j / radyf;
float fi = (float)i / radxf;
float dist = sqrt(fj * fj + fi * fi);
*dgauss = RE_filter_value(this->data->filtertype, dist);
- val+= *dgauss;
+ val += *dgauss;
}
}
- if (val!=0.0f) {
- val = 1.0f/val;
- for (j = n - 1; j>=0; j--)
- ddgauss[j]*= val;
+ if (val != 0.0f) {
+ val = 1.0f / val;
+ for (j = n - 1; j >= 0; j--)
+ ddgauss[j] *= val;
}
else ddgauss[4] = 1.0f;
@@ -116,7 +116,7 @@ void GaussianBokehBlurOperation::executePixel(float *color, int x, int y, Memory
tempColor[2] = 0;
tempColor[3] = 0;
float overallmultiplyer = 0;
- MemoryBuffer *inputBuffer = (MemoryBuffer*)data;
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
int bufferwidth = inputBuffer->getWidth();
int bufferstartx = inputBuffer->getRect()->xmin;
@@ -134,15 +134,15 @@ void GaussianBokehBlurOperation::executePixel(float *color, int x, int y, Memory
int index;
int step = QualityStepHelper::getStep();
int offsetadd = QualityStepHelper::getOffsetAdd();
- for (int ny = miny ; ny < maxy ; ny +=step) {
- index = ((ny-y)+this->rady) * (this->radx*2+1) + (minx-x+this->radx);
- int bufferindex = ((minx - bufferstartx)*4)+((ny-bufferstarty)*4*bufferwidth);
- for (int nx = minx ; nx < maxx ; nx +=step) {
+ for (int ny = miny; ny < maxy; ny += step) {
+ index = ((ny - y) + this->rady) * (this->radx * 2 + 1) + (minx - x + this->radx);
+ int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth);
+ for (int nx = minx; nx < maxx; nx += step) {
const float multiplyer = gausstab[index];
madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplyer);
overallmultiplyer += multiplyer;
index += step;
- bufferindex +=offsetadd;
+ bufferindex += offsetadd;
}
}
@@ -164,7 +164,7 @@ bool GaussianBokehBlurOperation::determineDependingAreaOfInterest(rcti *input, R
sizeInput.ymin = 0;
sizeInput.xmax = 5;
sizeInput.ymax = 5;
- NodeOperation * operation = this->getInputOperation(1);
+ NodeOperation *operation = this->getInputOperation(1);
if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
return true;
diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
index e30cbfeff7e..8edbf8f0617 100644
--- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
@@ -27,7 +27,7 @@ extern "C" {
#include "RE_pipeline.h"
}
-GaussianXBlurOperation::GaussianXBlurOperation(): BlurBaseOperation()
+GaussianXBlurOperation::GaussianXBlurOperation() : BlurBaseOperation()
{
this->gausstab = NULL;
this->rad = 0;
@@ -48,8 +48,8 @@ void GaussianXBlurOperation::initExecution()
BlurBaseOperation::initExecution();
if (this->sizeavailable) {
- float rad = size*this->data->sizex;
- if (rad<1)
+ float rad = size * this->data->sizex;
+ if (rad < 1)
rad = 1;
this->rad = rad;
@@ -61,8 +61,8 @@ void GaussianXBlurOperation::updateGauss(MemoryBuffer **memoryBuffers)
{
if (this->gausstab == NULL) {
updateSize(memoryBuffers);
- float rad = size*this->data->sizex;
- if (rad<1)
+ float rad = size * this->data->sizex;
+ if (rad < 1)
rad = 1;
this->rad = rad;
@@ -78,7 +78,7 @@ void GaussianXBlurOperation::executePixel(float *color, int x, int y, MemoryBuff
tempColor[2] = 0;
tempColor[3] = 0;
float overallmultiplyer = 0.0f;
- MemoryBuffer *inputBuffer = (MemoryBuffer*)data;
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
int bufferwidth = inputBuffer->getWidth();
int bufferstartx = inputBuffer->getRect()->xmin;
@@ -96,9 +96,9 @@ void GaussianXBlurOperation::executePixel(float *color, int x, int y, MemoryBuff
int index;
int step = getStep();
int offsetadd = getOffsetAdd();
- int bufferindex = ((minx - bufferstartx)*4)+((miny-bufferstarty)*4*bufferwidth);
- for (int nx = minx ; nx < maxx ; nx +=step) {
- index = (nx-x)+this->rad;
+ int bufferindex = ((minx - bufferstartx) * 4) + ((miny - bufferstarty) * 4 * bufferwidth);
+ for (int nx = minx; nx < maxx; nx += step) {
+ index = (nx - x) + this->rad;
const float multiplyer = gausstab[index];
madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplyer);
overallmultiplyer += multiplyer;
@@ -123,7 +123,7 @@ bool GaussianXBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadB
sizeInput.xmax = 5;
sizeInput.ymax = 5;
- NodeOperation * operation = this->getInputOperation(1);
+ NodeOperation *operation = this->getInputOperation(1);
if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
return true;
}
diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
index c0561704596..7143cc02615 100644
--- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp
@@ -27,7 +27,7 @@ extern "C" {
#include "RE_pipeline.h"
}
-GaussianYBlurOperation::GaussianYBlurOperation(): BlurBaseOperation()
+GaussianYBlurOperation::GaussianYBlurOperation() : BlurBaseOperation()
{
this->gausstab = NULL;
this->rad = 0;
@@ -45,8 +45,8 @@ void *GaussianYBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memo
void GaussianYBlurOperation::initExecution()
{
if (this->sizeavailable) {
- float rad = size*this->data->sizey;
- if (rad<1)
+ float rad = size * this->data->sizey;
+ if (rad < 1)
rad = 1;
this->rad = rad;
@@ -58,8 +58,8 @@ void GaussianYBlurOperation::updateGauss(MemoryBuffer **memoryBuffers)
{
if (this->gausstab == NULL) {
updateSize(memoryBuffers);
- float rad = size*this->data->sizey;
- if (rad<1)
+ float rad = size * this->data->sizey;
+ if (rad < 1)
rad = 1;
this->rad = rad;
@@ -75,7 +75,7 @@ void GaussianYBlurOperation::executePixel(float *color, int x, int y, MemoryBuff
tempColor[2] = 0;
tempColor[3] = 0;
float overallmultiplyer = 0;
- MemoryBuffer *inputBuffer = (MemoryBuffer*)data;
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
int bufferwidth = inputBuffer->getWidth();
int bufferstartx = inputBuffer->getRect()->xmin;
@@ -92,9 +92,9 @@ void GaussianYBlurOperation::executePixel(float *color, int x, int y, MemoryBuff
int step = getStep();
int index;
- for (int ny = miny ; ny < maxy ; ny +=step) {
- index = (ny-y)+this->rad;
- int bufferindex = ((minx - bufferstartx)*4)+((ny-bufferstarty)*4*bufferwidth);
+ for (int ny = miny; ny < maxy; ny += step) {
+ index = (ny - y) + this->rad;
+ int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth);
const float multiplyer = gausstab[index];
madd_v4_v4fl(tempColor, &buffer[bufferindex], multiplyer);
overallmultiplyer += multiplyer;
@@ -118,7 +118,7 @@ bool GaussianYBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadB
sizeInput.xmax = 5;
sizeInput.ymax = 5;
- NodeOperation * operation = this->getInputOperation(1);
+ NodeOperation *operation = this->getInputOperation(1);
if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
return true;
}
diff --git a/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp b/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp
index 3ed3921e0c1..9c7a33c1327 100644
--- a/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp
@@ -28,7 +28,7 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
-KeyingBlurOperation::KeyingBlurOperation(): NodeOperation()
+KeyingBlurOperation::KeyingBlurOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
@@ -47,7 +47,7 @@ void *KeyingBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryB
void KeyingBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
- MemoryBuffer *inputBuffer = (MemoryBuffer*)data;
+ MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer();
int bufferWidth = inputBuffer->getWidth();
diff --git a/source/blender/compositor/operations/COM_KeyingBlurOperation.h b/source/blender/compositor/operations/COM_KeyingBlurOperation.h
index 8d7834c7265..2848f260cbd 100644
--- a/source/blender/compositor/operations/COM_KeyingBlurOperation.h
+++ b/source/blender/compositor/operations/COM_KeyingBlurOperation.h
@@ -27,8 +27,8 @@
#include "COM_NodeOperation.h"
/**
- * Class with implementation of bluring for keying node
- */
+ * Class with implementation of bluring for keying node
+ */
class KeyingBlurOperation : public NodeOperation {
protected:
int size;
diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
index 1544b1c8d06..7c9b0c75518 100644
--- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp
@@ -76,9 +76,9 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me
add_v4_v4(tempColor, readColor);
add_v3_fl(overallmultiplyer, 1.0f);
- for (int ny = miny ; ny < maxy ; ny += QualityStepHelper::getStep()) {
- for (int nx = minx ; nx < maxx ; nx += QualityStepHelper::getStep()) {
- if (nx >=0 && nx < this->getWidth() && ny >= 0 && ny < getHeight()) {
+ for (int ny = miny; ny < maxy; ny += QualityStepHelper::getStep()) {
+ for (int nx = minx; nx < maxx; nx += QualityStepHelper::getStep()) {
+ if (nx >= 0 && nx < this->getWidth() && ny >= 0 && ny < getHeight()) {
inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers);
float size = tempSize[0];
// size += this->threshold;
@@ -88,8 +88,8 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me
/* pass */
}
else if (size >= fabsf(dx) && size >= fabsf(dy)) {
- float u = 256 + dx*256/size;
- float v = 256 + dy*256/size;
+ float u = 256 + dx * 256 / size;
+ float v = 256 + dy * 256 / size;
inputBokehProgram->read(bokeh, u, v, COM_PS_NEAREST, inputBuffers);
inputProgram->read(readColor, nx, ny, COM_PS_NEAREST, inputBuffers);
madd_v4_v4v4(tempColor, bokeh, readColor);
@@ -119,10 +119,10 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *inpu
rcti newInput;
rcti bokehInput;
- newInput.xmax = input->xmax + maxBlur+2;
- newInput.xmin = input->xmin - maxBlur+2;
- newInput.ymax = input->ymax + maxBlur-2;
- newInput.ymin = input->ymin - maxBlur-2;
+ newInput.xmax = input->xmax + maxBlur + 2;
+ newInput.xmin = input->xmin - maxBlur + 2;
+ newInput.ymax = input->ymax + maxBlur - 2;
+ newInput.ymin = input->ymin - maxBlur - 2;
bokehInput.xmax = 512;
bokehInput.xmin = 0;
bokehInput.ymax = 512;
diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
index 3dac3547b8a..3efae2c4e3d 100644
--- a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp
@@ -28,7 +28,7 @@ extern "C" {
#include "RE_pipeline.h"
}
-VectorBlurOperation::VectorBlurOperation(): NodeOperation()
+VectorBlurOperation::VectorBlurOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VALUE); // ZBUF
@@ -54,12 +54,12 @@ void VectorBlurOperation::initExecution()
void VectorBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data)
{
- float *buffer = (float*) data;
- int index = (y*this->getWidth() + x) * COM_NUMBER_OF_CHANNELS;
+ float *buffer = (float *) data;
+ int index = (y * this->getWidth() + x) * COM_NUMBER_OF_CHANNELS;
color[0] = buffer[index];
- color[1] = buffer[index+1];
- color[2] = buffer[index+2];
- color[3] = buffer[index+3];
+ color[1] = buffer[index + 1];
+ color[2] = buffer[index + 2];
+ color[3] = buffer[index + 3];
}
void VectorBlurOperation::deinitExecution()
@@ -79,11 +79,11 @@ void *VectorBlurOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryB
lockMutex();
if (this->cachedInstance == NULL) {
- MemoryBuffer *tile = (MemoryBuffer*)inputImageProgram->initializeTileData(rect, memoryBuffers);
- MemoryBuffer *speed = (MemoryBuffer*)inputSpeedProgram->initializeTileData(rect, memoryBuffers);
- MemoryBuffer *z = (MemoryBuffer*)inputZProgram->initializeTileData(rect, memoryBuffers);
- float *data = new float[this->getWidth()*this->getHeight()*COM_NUMBER_OF_CHANNELS];
- memcpy(data, tile->getBuffer(),this->getWidth()*this->getHeight()*COM_NUMBER_OF_CHANNELS*sizeof(float));
+ MemoryBuffer *tile = (MemoryBuffer *)inputImageProgram->initializeTileData(rect, memoryBuffers);
+ MemoryBuffer *speed = (MemoryBuffer *)inputSpeedProgram->initializeTileData(rect, memoryBuffers);
+ MemoryBuffer *z = (MemoryBuffer *)inputZProgram->initializeTileData(rect, memoryBuffers);
+ float *data = new float[this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS];
+ memcpy(data, tile->getBuffer(), this->getWidth() * this->getHeight() * COM_NUMBER_OF_CHANNELS * sizeof(float));
this->generateVectorBlur(data, tile, speed, z);
this->cachedInstance = data;
}
@@ -110,7 +110,7 @@ void VectorBlurOperation::generateVectorBlur(float *data, MemoryBuffer *inputIma
{
float *zbuf = inputZ->convertToValueBuffer();
NodeBlurData blurdata;
- blurdata.samples = this->settings->samples/QualityStepHelper::getStep();
+ blurdata.samples = this->settings->samples / QualityStepHelper::getStep();
blurdata.maxspeed = this->settings->maxspeed;
blurdata.minspeed = this->settings->minspeed;
blurdata.curved = this->settings->curved;
diff --git a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c
index 196234d658f..62e8138f5e1 100644
--- a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c
+++ b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c
@@ -32,71 +32,71 @@
#include "node_composite_util.h"
/* **************** BILATERALBLUR ******************** */
-static bNodeSocketTemplate cmp_node_bilateralblur_in[]= {
+static bNodeSocketTemplate cmp_node_bilateralblur_in[] = {
{ SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{ SOCK_RGBA, 1, N_("Determinator"), 1.0f, 1.0f, 1.0f, 1.0f},
{ -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_bilateralblur_out[]= {
+static bNodeSocketTemplate cmp_node_bilateralblur_out[] = {
{ SOCK_RGBA, 0, N_("Image")},
{ -1, 0, "" }
};
#define INIT_C3 \
- mean0 = 1; \
- mean1[0] = src[0]; \
- mean1[1] = src[1]; \
- mean1[2] = src[2]; \
- mean1[3] = src[3]; \
- (void)0
+ mean0 = 1; \
+ mean1[0] = src[0]; \
+ mean1[1] = src[1]; \
+ mean1[2] = src[2]; \
+ mean1[3] = src[3]; \
+ (void)0
/* finds color distances */
#define COLOR_DISTANCE_C3(c1, c2) \
- ((c1[0] - c2[0])*(c1[0] - c2[0]) + \
- (c1[1] - c2[1])*(c1[1] - c2[1]) + \
- (c1[2] - c2[2])*(c1[2] - c2[2]) + \
- (c1[3] - c2[3])*(c1[3] - c2[3]))
+ ((c1[0] - c2[0]) * (c1[0] - c2[0]) + \
+ (c1[1] - c2[1]) * (c1[1] - c2[1]) + \
+ (c1[2] - c2[2]) * (c1[2] - c2[2]) + \
+ (c1[3] - c2[3]) * (c1[3] - c2[3]))
/* this is the main kernel function for comparing color distances
- and adding them weighted to the final color */
+ and adding them weighted to the final color */
#define KERNEL_ELEMENT_C3(k) \
- temp_color = src + deltas[k]; \
- ref_color = ref + deltas[k]; \
- w = weight_tab[k] + \
- (double)COLOR_DISTANCE_C3(ref, ref_color ) * i2sigma_color; \
- w = 1.0/(w*w + 1); \
- mean0 += w; \
- mean1[0] += (double)temp_color[0] * w; \
- mean1[1] += (double)temp_color[1] * w; \
- mean1[2] += (double)temp_color[2] * w; \
- mean1[3] += (double)temp_color[3] * w; \
- (void)0
+ temp_color = src + deltas[k]; \
+ ref_color = ref + deltas[k]; \
+ w = weight_tab[k] + \
+ (double)COLOR_DISTANCE_C3(ref, ref_color) * i2sigma_color; \
+ w = 1.0 / (w * w + 1); \
+ mean0 += w; \
+ mean1[0] += (double)temp_color[0] * w; \
+ mean1[1] += (double)temp_color[1] * w; \
+ mean1[2] += (double)temp_color[2] * w; \
+ mean1[3] += (double)temp_color[3] * w; \
+ (void)0
/* write blurred values to image */
#define UPDATE_OUTPUT_C3 \
- mean0 = 1.0/mean0; \
- dest[x * pix + 0] = mean1[0] * mean0; \
- dest[x * pix + 1] = mean1[1] * mean0; \
- dest[x * pix + 2] = mean1[2] * mean0; \
- dest[x * pix + 3] = mean1[3] * mean0; \
- (void)0
+ mean0 = 1.0 / mean0; \
+ dest[x * pix + 0] = mean1[0] * mean0; \
+ dest[x * pix + 1] = mean1[1] * mean0; \
+ dest[x * pix + 2] = mean1[2] * mean0; \
+ dest[x * pix + 3] = mean1[3] * mean0; \
+ (void)0
/* initializes deltas for fast access to neighbor pixels */
-#define INIT_3X3_DELTAS( deltas, step, nch ) \
- ((deltas)[0] = (nch), (deltas)[1] = -(step) + (nch), \
- (deltas)[2] = -(step), (deltas)[3] = -(step) - (nch), \
- (deltas)[4] = -(nch), (deltas)[5] = (step) - (nch), \
- (deltas)[6] = (step), (deltas)[7] = (step) + (nch)); \
- (void)0
+#define INIT_3X3_DELTAS(deltas, step, nch) \
+ ((deltas)[0] = (nch), (deltas)[1] = -(step) + (nch), \
+ (deltas)[2] = -(step), (deltas)[3] = -(step) - (nch), \
+ (deltas)[4] = -(nch), (deltas)[5] = (step) - (nch), \
+ (deltas)[6] = (step), (deltas)[7] = (step) + (nch)); \
+ (void)0
/* code of this node was heavily inspired by the smooth function of opencv library.
* The main change is an optional image input */
static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
{
- NodeBilateralBlurData *nbbd= node->storage;
- CompBuf *new, *source, *img= in[0]->data, *refimg= in[1]->data;
+ NodeBilateralBlurData *nbbd = node->storage;
+ CompBuf *new, *source, *img = in[0]->data, *refimg = in[1]->data;
double mean0, w, i2sigma_color, i2sigma_space;
double mean1[4];
double weight_tab[8];
@@ -104,46 +104,46 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN
float sigma_color, sigma_space;
int imgx, imgy, x, y, pix, i, step;
int deltas[8];
- short found_determinator= 0;
+ short found_determinator = 0;
if (img == NULL || out[0]->hasoutput == 0)
return;
if (img->type != CB_RGBA) {
- img= typecheck_compbuf(in[0]->data, CB_RGBA);
+ img = typecheck_compbuf(in[0]->data, CB_RGBA);
}
- imgx= img->x;
- imgy= img->y;
- pix= img->type;
- step= pix * imgx;
+ imgx = img->x;
+ imgy = img->y;
+ pix = img->type;
+ step = pix * imgx;
if (refimg) {
if (refimg->x == imgx && refimg->y == imgy) {
if (ELEM3(refimg->type, CB_VAL, CB_VEC2, CB_VEC3)) {
- refimg= typecheck_compbuf(in[1]->data, CB_RGBA);
- found_determinator= 1;
+ refimg = typecheck_compbuf(in[1]->data, CB_RGBA);
+ found_determinator = 1;
}
}
}
else {
- refimg= img;
+ refimg = img;
}
/* allocs */
- source= dupalloc_compbuf(img);
- new= alloc_compbuf(imgx, imgy, pix, 1);
+ source = dupalloc_compbuf(img);
+ new = alloc_compbuf(imgx, imgy, pix, 1);
/* accept image offsets from other nodes */
- new->xof= img->xof;
- new->yof= img->yof;
+ new->xof = img->xof;
+ new->yof = img->yof;
/* bilateral code properties */
- sigma_color= nbbd->sigma_color;
- sigma_space= nbbd->sigma_space;
+ sigma_color = nbbd->sigma_color;
+ sigma_space = nbbd->sigma_space;
- i2sigma_color= 1.0f / (sigma_color * sigma_color);
- i2sigma_space= 1.0f / (sigma_space * sigma_space);
+ i2sigma_color = 1.0f / (sigma_color * sigma_color);
+ i2sigma_space = 1.0f / (sigma_space * sigma_space);
INIT_3X3_DELTAS(deltas, step, pix);
@@ -151,13 +151,13 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN
weight_tab[1] = weight_tab[3] = weight_tab[5] = weight_tab[7] = i2sigma_space * 2;
/* iterations */
- for (i= 0; i < nbbd->iter; i++) {
- src= source->rect;
- ref= refimg->rect;
- dest= new->rect;
+ for (i = 0; i < nbbd->iter; i++) {
+ src = source->rect;
+ ref = refimg->rect;
+ dest = new->rect;
/*goes through image, there are more loops for 1st/last line and all other lines*/
/*kernel element accumulates surrounding colors, which are then written with the update_output function*/
- for (x= 0; x < imgx; x++, src+= pix, ref+= pix) {
+ for (x = 0; x < imgx; x++, src += pix, ref += pix) {
INIT_C3;
KERNEL_ELEMENT_C3(6);
@@ -175,10 +175,10 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN
UPDATE_OUTPUT_C3;
}
- dest+= step;
+ dest += step;
- for (y= 1; y < imgy - 1; y++, dest+= step, src+= pix, ref+= pix) {
- x= 0;
+ for (y = 1; y < imgy - 1; y++, dest += step, src += pix, ref += pix) {
+ x = 0;
INIT_C3;
@@ -190,10 +190,10 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN
UPDATE_OUTPUT_C3;
- src+= pix;
- ref+= pix;
+ src += pix;
+ ref += pix;
- for (x= 1; x < imgx - 1; x++, src+= pix, ref+= pix) {
+ for (x = 1; x < imgx - 1; x++, src += pix, ref += pix) {
INIT_C3;
KERNEL_ELEMENT_C3(0);
@@ -219,7 +219,7 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN
UPDATE_OUTPUT_C3;
}
- for (x= 0; x < imgx; x++, src+= pix, ref+= pix) {
+ for (x = 0; x < imgx; x++, src += pix, ref += pix) {
INIT_C3;
KERNEL_ELEMENT_C3(2);
@@ -249,17 +249,17 @@ static void node_composit_exec_bilateralblur(void *UNUSED(data), bNode *node, bN
free_compbuf(refimg);
}
- out[0]->data= source;
+ out[0]->data = source;
free_compbuf(new);
}
-static void node_composit_init_bilateralblur(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+static void node_composit_init_bilateralblur(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
{
- NodeBilateralBlurData *nbbd= MEM_callocN(sizeof(NodeBilateralBlurData), "node bilateral blur data");
- node->storage= nbbd;
- nbbd->sigma_color= 0.3;
- nbbd->sigma_space= 5.0;
+ NodeBilateralBlurData *nbbd = MEM_callocN(sizeof(NodeBilateralBlurData), "node bilateral blur data");
+ node->storage = nbbd;
+ nbbd->sigma_color = 0.3;
+ nbbd->sigma_space = 5.0;
}
void register_node_type_cmp_bilateralblur(bNodeTreeType *ttype)
diff --git a/source/blender/nodes/composite/nodes/node_composite_blur.c b/source/blender/nodes/composite/nodes/node_composite_blur.c
index f10e6bfe939..046623f5b26 100644
--- a/source/blender/nodes/composite/nodes/node_composite_blur.c
+++ b/source/blender/nodes/composite/nodes/node_composite_blur.c
@@ -34,14 +34,14 @@
#include "node_composite_util.h"
/* **************** BLUR ******************** */
-static bNodeSocketTemplate cmp_node_blur_in[]= {
- { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("Size"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_blur_in[] = {
+ { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
+ { SOCK_FLOAT, 1, N_("Size"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
+ { -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_blur_out[]= {
- { SOCK_RGBA, 0, N_("Image")},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_blur_out[] = {
+ { SOCK_RGBA, 0, N_("Image")},
+ { -1, 0, "" }
};
static float *make_gausstab(int filtertype, int rad)
@@ -55,14 +55,14 @@ static float *make_gausstab(int filtertype, int rad)
sum = 0.0f;
for (i = -rad; i <= rad; i++) {
- val= RE_filter_value(filtertype, (float)i/(float)rad);
+ val = RE_filter_value(filtertype, (float)i / (float)rad);
sum += val;
- gausstab[i+rad] = val;
+ gausstab[i + rad] = val;
}
- sum= 1.0f/sum;
- for (i=0; i<n; i++)
- gausstab[i]*= sum;
+ sum = 1.0f / sum;
+ for (i = 0; i < n; i++)
+ gausstab[i] *= sum;
return gausstab;
}
@@ -77,8 +77,8 @@ static float *make_bloomtab(int rad)
bloomtab = (float *) MEM_mallocN(n * sizeof(float), "bloom");
for (i = -rad; i <= rad; i++) {
- val = powf(1.0f - fabsf((float)i)/((float)rad), 4.0f);
- bloomtab[i+rad] = val;
+ val = powf(1.0f - fabsf((float)i) / ((float)rad), 4.0f);
+ bloomtab[i + rad] = val;
}
return bloomtab;
@@ -87,61 +87,61 @@ static float *make_bloomtab(int rad)
/* both input images of same type, either 4 or 1 channel */
static void blur_single_image(bNode *node, CompBuf *new, CompBuf *img, float scale)
{
- NodeBlurData *nbd= node->storage;
+ NodeBlurData *nbd = node->storage;
CompBuf *work;
register float sum, val;
float rval, gval, bval, aval;
float *gausstab, *gausstabcent;
- int rad, imgx= img->x, imgy= img->y;
- int x, y, pix= img->type;
+ int rad, imgx = img->x, imgy = img->y;
+ int x, y, pix = img->type;
int i, bigstep;
float *src, *dest;
/* helper image */
- work= alloc_compbuf(imgx, imgy, img->type, 1); /* allocs */
+ work = alloc_compbuf(imgx, imgy, img->type, 1); /* allocs */
/* horizontal */
if (nbd->sizex == 0) {
memcpy(work->rect, img->rect, sizeof(float) * img->type * imgx * imgy);
}
else {
- rad = scale*(float)nbd->sizex;
- if (rad>imgx/2)
- rad= imgx/2;
- else if (rad<1)
- rad= 1;
+ rad = scale * (float)nbd->sizex;
+ if (rad > imgx / 2)
+ rad = imgx / 2;
+ else if (rad < 1)
+ rad = 1;
- gausstab= make_gausstab(nbd->filtertype, rad);
- gausstabcent= gausstab+rad;
+ gausstab = make_gausstab(nbd->filtertype, rad);
+ gausstabcent = gausstab + rad;
for (y = 0; y < imgy; y++) {
- float *srcd= img->rect + pix*(y*img->x);
+ float *srcd = img->rect + pix * (y * img->x);
- dest = work->rect + pix*(y * img->x);
+ dest = work->rect + pix * (y * img->x);
- for (x = 0; x < imgx ; x++) {
- int minr= x-rad<0?-x:-rad;
- int maxr= x+rad>imgx?imgx-x:rad;
+ for (x = 0; x < imgx; x++) {
+ int minr = x - rad < 0 ? -x : -rad;
+ int maxr = x + rad > imgx ? imgx - x : rad;
- src= srcd + pix*(x+minr);
+ src = srcd + pix * (x + minr);
- sum= gval = rval= bval= aval= 0.0f;
- for (i= minr; i < maxr; i++) {
- val= gausstabcent[i];
- sum+= val;
+ sum = gval = rval = bval = aval = 0.0f;
+ for (i = minr; i < maxr; i++) {
+ val = gausstabcent[i];
+ sum += val;
rval += val * (*src++);
- if (pix==4) {
+ if (pix == 4) {
gval += val * (*src++);
bval += val * (*src++);
aval += val * (*src++);
}
}
- sum= 1.0f/sum;
- *dest++ = rval*sum;
- if (pix==4) {
- *dest++ = gval*sum;
- *dest++ = bval*sum;
- *dest++ = aval*sum;
+ sum = 1.0f / sum;
+ *dest++ = rval * sum;
+ if (pix == 4) {
+ *dest++ = gval * sum;
+ *dest++ = bval * sum;
+ *dest++ = aval * sum;
}
}
if (node->exec & NODE_BREAK)
@@ -156,47 +156,47 @@ static void blur_single_image(bNode *node, CompBuf *new, CompBuf *img, float sca
memcpy(new->rect, work->rect, sizeof(float) * img->type * imgx * imgy);
}
else {
- rad = scale*(float)nbd->sizey;
- if (rad>imgy/2)
- rad= imgy/2;
- else if (rad<1)
- rad= 1;
-
- gausstab= make_gausstab(nbd->filtertype, rad);
- gausstabcent= gausstab+rad;
+ rad = scale * (float)nbd->sizey;
+ if (rad > imgy / 2)
+ rad = imgy / 2;
+ else if (rad < 1)
+ rad = 1;
+
+ gausstab = make_gausstab(nbd->filtertype, rad);
+ gausstabcent = gausstab + rad;
- bigstep = pix*imgx;
+ bigstep = pix * imgx;
for (x = 0; x < imgx; x++) {
- float *srcd= work->rect + pix*x;
+ float *srcd = work->rect + pix * x;
- dest = new->rect + pix*x;
+ dest = new->rect + pix * x;
- for (y = 0; y < imgy ; y++) {
- int minr= y-rad<0?-y:-rad;
- int maxr= y+rad>imgy?imgy-y:rad;
+ for (y = 0; y < imgy; y++) {
+ int minr = y - rad < 0 ? -y : -rad;
+ int maxr = y + rad > imgy ? imgy - y : rad;
- src= srcd + bigstep*(y+minr);
+ src = srcd + bigstep * (y + minr);
- sum= gval = rval= bval= aval= 0.0f;
- for (i= minr; i < maxr; i++) {
- val= gausstabcent[i];
- sum+= val;
+ sum = gval = rval = bval = aval = 0.0f;
+ for (i = minr; i < maxr; i++) {
+ val = gausstabcent[i];
+ sum += val;
rval += val * src[0];
- if (pix==4) {
+ if (pix == 4) {
gval += val * src[1];
bval += val * src[2];
aval += val * src[3];
}
src += bigstep;
}
- sum= 1.0f/sum;
- dest[0] = rval*sum;
- if (pix==4) {
- dest[1] = gval*sum;
- dest[2] = bval*sum;
- dest[3] = aval*sum;
+ sum = 1.0f / sum;
+ dest[0] = rval * sum;
+ if (pix == 4) {
+ dest[1] = gval * sum;
+ dest[2] = bval * sum;
+ dest[3] = aval * sum;
}
- dest+= bigstep;
+ dest += bigstep;
}
if (node->exec & NODE_BREAK)
break;
@@ -216,83 +216,83 @@ static void bloom_with_reference(CompBuf *new, CompBuf *img, CompBuf *UNUSED(ref
float **maintabs;
float *gausstabx, *gausstabcenty;
float *gausstaby, *gausstabcentx;
- int radx, rady, imgx= img->x, imgy= img->y;
+ int radx, rady, imgx = img->x, imgy = img->y;
int x, y;
int i, j;
float *src, *dest, *wb;
- wbuf= alloc_compbuf(imgx, imgy, CB_VAL, 1);
+ wbuf = alloc_compbuf(imgx, imgy, CB_VAL, 1);
/* horizontal */
radx = (float)nbd->sizex;
- if (radx>imgx/2)
- radx= imgx/2;
- else if (radx<1)
- radx= 1;
+ if (radx > imgx / 2)
+ radx = imgx / 2;
+ else if (radx < 1)
+ radx = 1;
/* vertical */
rady = (float)nbd->sizey;
- if (rady>imgy/2)
- rady= imgy/2;
- else if (rady<1)
- rady= 1;
-
- x= MAX2(radx, rady);
- maintabs= MEM_mallocN(x*sizeof(void *), "gauss array");
- for (i= 0; i<x; i++)
- maintabs[i]= make_bloomtab(i+1);
+ if (rady > imgy / 2)
+ rady = imgy / 2;
+ else if (rady < 1)
+ rady = 1;
+
+ x = MAX2(radx, rady);
+ maintabs = MEM_mallocN(x * sizeof(void *), "gauss array");
+ for (i = 0; i < x; i++)
+ maintabs[i] = make_bloomtab(i + 1);
/* vars to store before we go */
// refd= ref->rect;
- src= img->rect;
+ src = img->rect;
- radxf= (float)radx;
- radyf= (float)rady;
+ radxf = (float)radx;
+ radyf = (float)rady;
for (y = 0; y < imgy; y++) {
- for (x = 0; x < imgx ; x++, src+=4) {//, refd++) {
+ for (x = 0; x < imgx; x++, src += 4) { //, refd++) {
// int refradx= (int)(refd[0]*radxf);
// int refrady= (int)(refd[0]*radyf);
- int refradx= (int)(radxf*0.3f*src[3]*(src[0]+src[1]+src[2]));
- int refrady= (int)(radyf*0.3f*src[3]*(src[0]+src[1]+src[2]));
-
- if (refradx>radx) refradx= radx;
- else if (refradx<1) refradx= 1;
- if (refrady>rady) refrady= rady;
- else if (refrady<1) refrady= 1;
+ int refradx = (int)(radxf * 0.3f * src[3] * (src[0] + src[1] + src[2]));
+ int refrady = (int)(radyf * 0.3f * src[3] * (src[0] + src[1] + src[2]));
- if (refradx==1 && refrady==1) {
- wb= wbuf->rect + ( y*imgx + x);
- dest= new->rect + 4*( y*imgx + x);
- wb[0]+= 1.0f;
+ if (refradx > radx) refradx = radx;
+ else if (refradx < 1) refradx = 1;
+ if (refrady > rady) refrady = rady;
+ else if (refrady < 1) refrady = 1;
+
+ if (refradx == 1 && refrady == 1) {
+ wb = wbuf->rect + (y * imgx + x);
+ dest = new->rect + 4 * (y * imgx + x);
+ wb[0] += 1.0f;
dest[0] += src[0];
dest[1] += src[1];
dest[2] += src[2];
dest[3] += src[3];
}
else {
- int minxr= x-refradx<0?-x:-refradx;
- int maxxr= x+refradx>imgx?imgx-x:refradx;
- int minyr= y-refrady<0?-y:-refrady;
- int maxyr= y+refrady>imgy?imgy-y:refrady;
-
- float *destd= new->rect + 4*( (y + minyr)*imgx + x + minxr);
- float *wbufd= wbuf->rect + ( (y + minyr)*imgx + x + minxr);
-
- gausstabx= maintabs[refradx-1];
- gausstabcentx= gausstabx+refradx;
- gausstaby= maintabs[refrady-1];
- gausstabcenty= gausstaby+refrady;
-
- for (i= minyr; i < maxyr; i++, destd+= 4*imgx, wbufd+= imgx) {
- dest= destd;
- wb= wbufd;
- for (j= minxr; j < maxxr; j++, dest+=4, wb++) {
+ int minxr = x - refradx < 0 ? -x : -refradx;
+ int maxxr = x + refradx > imgx ? imgx - x : refradx;
+ int minyr = y - refrady < 0 ? -y : -refrady;
+ int maxyr = y + refrady > imgy ? imgy - y : refrady;
+
+ float *destd = new->rect + 4 * ( (y + minyr) * imgx + x + minxr);
+ float *wbufd = wbuf->rect + ( (y + minyr) * imgx + x + minxr);
+
+ gausstabx = maintabs[refradx - 1];
+ gausstabcentx = gausstabx + refradx;
+ gausstaby = maintabs[refrady - 1];
+ gausstabcenty = gausstaby + refrady;
+
+ for (i = minyr; i < maxyr; i++, destd += 4 * imgx, wbufd += imgx) {
+ dest = destd;
+ wb = wbufd;
+ for (j = minxr; j < maxxr; j++, dest += 4, wb++) {
- val= gausstabcenty[i]*gausstabcentx[j];
- wb[0]+= val;
+ val = gausstabcenty[i] * gausstabcentx[j];
+ wb[0] += val;
dest[0] += val * src[0];
dest[1] += val * src[1];
dest[2] += val * src[2];
@@ -303,23 +303,23 @@ static void bloom_with_reference(CompBuf *new, CompBuf *img, CompBuf *UNUSED(ref
}
}
- x= imgx*imgy;
- dest= new->rect;
- wb= wbuf->rect;
+ x = imgx * imgy;
+ dest = new->rect;
+ wb = wbuf->rect;
while (x--) {
- val= 1.0f/wb[0];
- dest[0]*= val;
- dest[1]*= val;
- dest[2]*= val;
- dest[3]*= val;
+ val = 1.0f / wb[0];
+ dest[0] *= val;
+ dest[1] *= val;
+ dest[2] *= val;
+ dest[3] *= val;
wb++;
- dest+= 4;
+ dest += 4;
}
free_compbuf(wbuf);
- x= MAX2(radx, rady);
- for (i= 0; i<x; i++)
+ x = MAX2(radx, rady);
+ for (i = 0; i < x; i++)
MEM_freeN(maintabs[i]);
MEM_freeN(maintabs);
@@ -328,12 +328,12 @@ static void bloom_with_reference(CompBuf *new, CompBuf *img, CompBuf *UNUSED(ref
#if 0
static float hexagon_filter(float fi, float fj)
{
- fi= fabs(fi);
- fj= fabs(fj);
+ fi = fabs(fi);
+ fj = fabs(fj);
- if (fj>0.33f) {
- fj= (fj-0.33f)/0.66f;
- if (fi+fj>1.0f)
+ if (fj > 0.33f) {
+ fj = (fj - 0.33f) / 0.66f;
+ if (fi + fj > 1.0f)
return 0.0f;
else
return 1.0f;
@@ -346,85 +346,85 @@ static float hexagon_filter(float fi, float fj)
/* both images same type, either 1 or 4 channels */
static void bokeh_single_image(bNode *node, CompBuf *new, CompBuf *img, float fac)
{
- NodeBlurData *nbd= node->storage;
+ NodeBlurData *nbd = node->storage;
register float val;
float radxf, radyf;
float *gausstab, *dgauss;
- int radx, rady, imgx= img->x, imgy= img->y;
- int x, y, pix= img->type;
+ int radx, rady, imgx = img->x, imgy = img->y;
+ int x, y, pix = img->type;
int i, j, n;
- float *src= NULL, *dest, *srcd= NULL;
+ float *src = NULL, *dest, *srcd = NULL;
/* horizontal */
- radxf = fac*(float)nbd->sizex;
- if (radxf>imgx/2.0f)
- radxf= imgx/2.0f;
- else if (radxf<1.0f)
- radxf= 1.0f;
+ radxf = fac * (float)nbd->sizex;
+ if (radxf > imgx / 2.0f)
+ radxf = imgx / 2.0f;
+ else if (radxf < 1.0f)
+ radxf = 1.0f;
/* vertical */
- radyf = fac*(float)nbd->sizey;
- if (radyf>imgy/2.0f)
- radyf= imgy/2.0f;
- else if (radyf<1.0f)
- radyf= 1.0f;
+ radyf = fac * (float)nbd->sizey;
+ if (radyf > imgy / 2.0f)
+ radyf = imgy / 2.0f;
+ else if (radyf < 1.0f)
+ radyf = 1.0f;
- radx= ceil(radxf);
- rady= ceil(radyf);
+ radx = ceil(radxf);
+ rady = ceil(radyf);
- n = (2*radx+1)*(2*rady+1);
+ n = (2 * radx + 1) * (2 * rady + 1);
/* create a full filter image */
- gausstab= MEM_mallocN(sizeof(float)*n, "filter tab");
- dgauss= gausstab;
- val= 0.0f;
- for (j=-rady; j<=rady; j++) {
- for (i=-radx; i<=radx; i++, dgauss++) {
- float fj= (float)j/radyf;
- float fi= (float)i/radxf;
- float dist= sqrt(fj*fj + fi*fi);
-
- //*dgauss= hexagon_filter(fi, fj);
- *dgauss= RE_filter_value(nbd->filtertype, dist);
+ gausstab = MEM_mallocN(sizeof(float) * n, "filter tab");
+ dgauss = gausstab;
+ val = 0.0f;
+ for (j = -rady; j <= rady; j++) {
+ for (i = -radx; i <= radx; i++, dgauss++) {
+ float fj = (float)j / radyf;
+ float fi = (float)i / radxf;
+ float dist = sqrt(fj * fj + fi * fi);
- val+= *dgauss;
+ //*dgauss= hexagon_filter(fi, fj);
+ *dgauss = RE_filter_value(nbd->filtertype, dist);
+
+ val += *dgauss;
}
}
- if (val!=0.0f) {
- val= 1.0f/val;
- for (j= n -1; j>=0; j--)
- gausstab[j]*= val;
+ if (val != 0.0f) {
+ val = 1.0f / val;
+ for (j = n - 1; j >= 0; j--)
+ gausstab[j] *= val;
}
- else gausstab[4]= 1.0f;
-
- for (y = -rady+1; y < imgy+rady-1; y++) {
-
- if (y<=0) srcd= img->rect;
- else if (y<imgy) srcd+= pix*imgx;
- else srcd= img->rect + pix*(imgy-1)*imgx;
-
- for (x = -radx+1; x < imgx+radx-1 ; x++) {
- int minxr= x-radx<0?-x:-radx;
- int maxxr= x+radx>=imgx?imgx-x-1:radx;
- int minyr= y-rady<0?-y:-rady;
- int maxyr= y+rady>imgy-1?imgy-y-1:rady;
-
- float *destd= new->rect + pix*( (y + minyr)*imgx + x + minxr);
- float *dgausd= gausstab + (minyr+rady)*(2*radx+1) + minxr+radx;
-
- if (x<=0) src= srcd;
- else if (x<imgx) src+= pix;
- else src= srcd + pix*(imgx-1);
-
- for (i= minyr; i <=maxyr; i++, destd+= pix*imgx, dgausd+= 2*radx + 1) {
- dest= destd;
- dgauss= dgausd;
- for (j= minxr; j <=maxxr; j++, dest+=pix, dgauss++) {
- val= *dgauss;
- if (val!=0.0f) {
+ else gausstab[4] = 1.0f;
+
+ for (y = -rady + 1; y < imgy + rady - 1; y++) {
+
+ if (y <= 0) srcd = img->rect;
+ else if (y < imgy) srcd += pix * imgx;
+ else srcd = img->rect + pix * (imgy - 1) * imgx;
+
+ for (x = -radx + 1; x < imgx + radx - 1; x++) {
+ int minxr = x - radx < 0 ? -x : -radx;
+ int maxxr = x + radx >= imgx ? imgx - x - 1 : radx;
+ int minyr = y - rady < 0 ? -y : -rady;
+ int maxyr = y + rady > imgy - 1 ? imgy - y - 1 : rady;
+
+ float *destd = new->rect + pix * ( (y + minyr) * imgx + x + minxr);
+ float *dgausd = gausstab + (minyr + rady) * (2 * radx + 1) + minxr + radx;
+
+ if (x <= 0) src = srcd;
+ else if (x < imgx) src += pix;
+ else src = srcd + pix * (imgx - 1);
+
+ for (i = minyr; i <= maxyr; i++, destd += pix * imgx, dgausd += 2 * radx + 1) {
+ dest = destd;
+ dgauss = dgausd;
+ for (j = minxr; j <= maxxr; j++, dest += pix, dgauss++) {
+ val = *dgauss;
+ if (val != 0.0f) {
dest[0] += val * src[0];
- if (pix>1) {
+ if (pix > 1) {
dest[1] += val * src[1];
dest[2] += val * src[2];
dest[3] += val * src[3];
@@ -444,116 +444,116 @@ static void bokeh_single_image(bNode *node, CompBuf *new, CompBuf *img, float fa
/* reference has to be mapped 0-1, and equal in size */
static void blur_with_reference(bNode *node, CompBuf *new, CompBuf *img, CompBuf *ref)
{
- NodeBlurData *nbd= node->storage;
+ NodeBlurData *nbd = node->storage;
CompBuf *blurbuf, *ref_use;
register float sum, val;
float rval, gval, bval, aval, radxf, radyf;
float **maintabs;
float *gausstabx, *gausstabcenty;
float *gausstaby, *gausstabcentx;
- int radx, rady, imgx= img->x, imgy= img->y;
- int x, y, pix= img->type;
+ int radx, rady, imgx = img->x, imgy = img->y;
+ int x, y, pix = img->type;
int i, j;
float *src, *dest, *refd, *blurd;
- float defcol[4] = {1.0f, 1.0f, 1.0f, 1.0f}; /* default color for compbuf_get_pixel */
- float proccol[4]; /* local color if compbuf is procedural */
+ float defcol[4] = {1.0f, 1.0f, 1.0f, 1.0f}; /* default color for compbuf_get_pixel */
+ float proccol[4]; /* local color if compbuf is procedural */
int refradx, refrady;
- if (ref->x!=img->x || ref->y!=img->y)
+ if (ref->x != img->x || ref->y != img->y)
return;
- ref_use= typecheck_compbuf(ref, CB_VAL);
+ ref_use = typecheck_compbuf(ref, CB_VAL);
/* trick is; we blur the reference image... but only works with clipped values*/
- blurbuf= alloc_compbuf(imgx, imgy, CB_VAL, 1);
- blurbuf->xof= ref_use->xof;
- blurbuf->yof= ref_use->yof;
- blurd= blurbuf->rect;
- refd= ref_use->rect;
- for (x= imgx*imgy; x>0; x--, refd++, blurd++) {
- if (refd[0]<0.0f) blurd[0]= 0.0f;
- else if (refd[0]>1.0f) blurd[0]= 1.0f;
- else blurd[0]= refd[0];
+ blurbuf = alloc_compbuf(imgx, imgy, CB_VAL, 1);
+ blurbuf->xof = ref_use->xof;
+ blurbuf->yof = ref_use->yof;
+ blurd = blurbuf->rect;
+ refd = ref_use->rect;
+ for (x = imgx * imgy; x > 0; x--, refd++, blurd++) {
+ if (refd[0] < 0.0f) blurd[0] = 0.0f;
+ else if (refd[0] > 1.0f) blurd[0] = 1.0f;
+ else blurd[0] = refd[0];
}
blur_single_image(node, blurbuf, blurbuf, 1.0f);
/* horizontal */
radx = (float)nbd->sizex;
- if (radx>imgx/2)
- radx= imgx/2;
- else if (radx<1)
- radx= 1;
+ if (radx > imgx / 2)
+ radx = imgx / 2;
+ else if (radx < 1)
+ radx = 1;
/* vertical */
rady = (float)nbd->sizey;
- if (rady>imgy/2)
- rady= imgy/2;
- else if (rady<1)
- rady= 1;
-
- x= MAX2(radx, rady);
- maintabs= MEM_mallocN(x*sizeof(void *), "gauss array");
- for (i= 0; i<x; i++)
- maintabs[i]= make_gausstab(nbd->filtertype, i+1);
-
- dest= new->rect;
- radxf= (float)radx;
- radyf= (float)rady;
+ if (rady > imgy / 2)
+ rady = imgy / 2;
+ else if (rady < 1)
+ rady = 1;
+
+ x = MAX2(radx, rady);
+ maintabs = MEM_mallocN(x * sizeof(void *), "gauss array");
+ for (i = 0; i < x; i++)
+ maintabs[i] = make_gausstab(nbd->filtertype, i + 1);
+
+ dest = new->rect;
+ radxf = (float)radx;
+ radyf = (float)rady;
for (y = 0; y < imgy; y++) {
- for (x = 0; x < imgx ; x++, dest+=pix) {
- refd= compbuf_get_pixel(blurbuf, defcol, proccol, x-blurbuf->xrad, y-blurbuf->yrad, blurbuf->xrad, blurbuf->yrad);
- refradx= (int)(refd[0]*radxf);
- refrady= (int)(refd[0]*radyf);
-
- if (refradx>radx) refradx= radx;
- else if (refradx<1) refradx= 1;
- if (refrady>rady) refrady= rady;
- else if (refrady<1) refrady= 1;
-
- if (refradx==1 && refrady==1) {
- src= img->rect + pix*( y*imgx + x);
- if (pix==1)
- dest[0]= src[0];
+ for (x = 0; x < imgx; x++, dest += pix) {
+ refd = compbuf_get_pixel(blurbuf, defcol, proccol, x - blurbuf->xrad, y - blurbuf->yrad, blurbuf->xrad, blurbuf->yrad);
+ refradx = (int)(refd[0] * radxf);
+ refrady = (int)(refd[0] * radyf);
+
+ if (refradx > radx) refradx = radx;
+ else if (refradx < 1) refradx = 1;
+ if (refrady > rady) refrady = rady;
+ else if (refrady < 1) refrady = 1;
+
+ if (refradx == 1 && refrady == 1) {
+ src = img->rect + pix * (y * imgx + x);
+ if (pix == 1)
+ dest[0] = src[0];
else
copy_v4_v4(dest, src);
}
else {
- int minxr= x-refradx<0?-x:-refradx;
- int maxxr= x+refradx>imgx?imgx-x:refradx;
- int minyr= y-refrady<0?-y:-refrady;
- int maxyr= y+refrady>imgy?imgy-y:refrady;
-
- float *srcd= img->rect + pix*( (y + minyr)*imgx + x + minxr);
-
- gausstabx= maintabs[refradx-1];
- gausstabcentx= gausstabx+refradx;
- gausstaby= maintabs[refrady-1];
- gausstabcenty= gausstaby+refrady;
+ int minxr = x - refradx < 0 ? -x : -refradx;
+ int maxxr = x + refradx > imgx ? imgx - x : refradx;
+ int minyr = y - refrady < 0 ? -y : -refrady;
+ int maxyr = y + refrady > imgy ? imgy - y : refrady;
- sum= gval = rval= bval= aval= 0.0f;
-
- for (i= minyr; i < maxyr; i++, srcd+= pix*imgx) {
- src= srcd;
- for (j= minxr; j < maxxr; j++, src+=pix) {
+ float *srcd = img->rect + pix * ( (y + minyr) * imgx + x + minxr);
+
+ gausstabx = maintabs[refradx - 1];
+ gausstabcentx = gausstabx + refradx;
+ gausstaby = maintabs[refrady - 1];
+ gausstabcenty = gausstaby + refrady;
+
+ sum = gval = rval = bval = aval = 0.0f;
+
+ for (i = minyr; i < maxyr; i++, srcd += pix * imgx) {
+ src = srcd;
+ for (j = minxr; j < maxxr; j++, src += pix) {
- val= gausstabcenty[i]*gausstabcentx[j];
- sum+= val;
+ val = gausstabcenty[i] * gausstabcentx[j];
+ sum += val;
rval += val * src[0];
- if (pix>1) {
+ if (pix > 1) {
gval += val * src[1];
bval += val * src[2];
aval += val * src[3];
}
}
}
- sum= 1.0f/sum;
- dest[0] = rval*sum;
- if (pix>1) {
- dest[1] = gval*sum;
- dest[2] = bval*sum;
- dest[3] = aval*sum;
+ sum = 1.0f / sum;
+ dest[0] = rval * sum;
+ if (pix > 1) {
+ dest[1] = gval * sum;
+ dest[2] = bval * sum;
+ dest[3] = aval * sum;
}
}
}
@@ -563,46 +563,46 @@ static void blur_with_reference(bNode *node, CompBuf *new, CompBuf *img, CompBuf
free_compbuf(blurbuf);
- x= MAX2(radx, rady);
- for (i= 0; i<x; i++)
+ x = MAX2(radx, rady);
+ for (i = 0; i < x; i++)
MEM_freeN(maintabs[i]);
MEM_freeN(maintabs);
- if (ref_use!=ref)
+ if (ref_use != ref)
free_compbuf(ref_use);
}
static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
- CompBuf *new, *img= in[0]->data;
- NodeBlurData *nbd= node->storage;
+ CompBuf *new, *img = in[0]->data;
+ NodeBlurData *nbd = node->storage;
- if (img==NULL) return;
+ if (img == NULL) return;
/* store image in size that is needed for absolute/relative conversions on ui level */
- nbd->image_in_width= img->x;
- nbd->image_in_height= img->y;
+ nbd->image_in_width = img->x;
+ nbd->image_in_height = img->y;
- if (out[0]->hasoutput==0) return;
+ if (out[0]->hasoutput == 0) return;
if (nbd->relative) {
- if (nbd->aspect==CMP_NODE_BLUR_ASPECT_NONE) {
- nbd->sizex= (int)(nbd->percentx*0.01f*nbd->image_in_width);
- nbd->sizey= (int)(nbd->percenty*0.01f*nbd->image_in_height);
+ if (nbd->aspect == CMP_NODE_BLUR_ASPECT_NONE) {
+ nbd->sizex = (int)(nbd->percentx * 0.01f * nbd->image_in_width);
+ nbd->sizey = (int)(nbd->percenty * 0.01f * nbd->image_in_height);
}
- else if (nbd->aspect==CMP_NODE_BLUR_ASPECT_Y) {
- nbd->sizex= (int)(nbd->percentx*0.01f*nbd->image_in_width);
- nbd->sizey= (int)(nbd->percenty*0.01f*nbd->image_in_width);
+ else if (nbd->aspect == CMP_NODE_BLUR_ASPECT_Y) {
+ nbd->sizex = (int)(nbd->percentx * 0.01f * nbd->image_in_width);
+ nbd->sizey = (int)(nbd->percenty * 0.01f * nbd->image_in_width);
}
- else if (nbd->aspect==CMP_NODE_BLUR_ASPECT_X) {
- nbd->sizex= (int)(nbd->percentx*0.01f*nbd->image_in_height);
- nbd->sizey= (int)(nbd->percenty*0.01f*nbd->image_in_height);
+ else if (nbd->aspect == CMP_NODE_BLUR_ASPECT_X) {
+ nbd->sizex = (int)(nbd->percentx * 0.01f * nbd->image_in_height);
+ nbd->sizey = (int)(nbd->percenty * 0.01f * nbd->image_in_height);
}
}
- if (nbd->sizex==0 && nbd->sizey==0) {
- new= pass_on_compbuf(img);
- out[0]->data= new;
+ if (nbd->sizex == 0 && nbd->sizey == 0) {
+ new = pass_on_compbuf(img);
+ out[0]->data = new;
}
else if (nbd->filtertype == R_FILTER_FAST_GAUSS) {
if (in[1]->vec[0] < 0.001f) { /* time node inputs can be a tiny value */
@@ -610,10 +610,10 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN
}
else {
// TODO: can this be mapped with reference, too?
- const float sx = ((float)nbd->sizex*in[1]->vec[0])/2.0f, sy = ((float)nbd->sizey*in[1]->vec[0])/2.0f;
+ const float sx = ((float)nbd->sizex * in[1]->vec[0]) / 2.0f, sy = ((float)nbd->sizey * in[1]->vec[0]) / 2.0f;
int c;
- if ((img==NULL) || (out[0]->hasoutput==0)) return;
+ if ((img == NULL) || (out[0]->hasoutput == 0)) return;
if (img->type == CB_VEC2)
new = typecheck_compbuf(img, CB_VAL);
@@ -623,16 +623,16 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN
new = dupalloc_compbuf(img);
if ((sx == sy) && (sx > 0.f)) {
- for (c=0; c<new->type; ++c)
+ for (c = 0; c < new->type; ++c)
IIR_gauss(new, sx, c, 3);
}
else {
if (sx > 0.f) {
- for (c=0; c<new->type; ++c)
+ for (c = 0; c < new->type; ++c)
IIR_gauss(new, sx, c, 1);
}
if (sy > 0.f) {
- for (c=0; c<new->type; ++c)
+ for (c = 0; c < new->type; ++c)
IIR_gauss(new, sy, c, 2);
}
}
@@ -641,8 +641,8 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN
}
else {
/* All non fast gauss blur methods */
- if (img->type==CB_VEC2 || img->type==CB_VEC3) {
- img= typecheck_compbuf(in[0]->data, CB_RGBA);
+ if (img->type == CB_VEC2 || img->type == CB_VEC3) {
+ img = typecheck_compbuf(in[0]->data, CB_RGBA);
}
/* if fac input, we do it different */
@@ -650,17 +650,17 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN
CompBuf *gammabuf;
/* make output size of input image */
- new= alloc_compbuf(img->x, img->y, img->type, 1); /* allocs */
+ new = alloc_compbuf(img->x, img->y, img->type, 1); /* allocs */
/* accept image offsets from other nodes */
new->xof = img->xof;
new->yof = img->yof;
if (nbd->gamma) {
- gammabuf= dupalloc_compbuf(img);
+ gammabuf = dupalloc_compbuf(img);
gamma_correct_compbuf(gammabuf, 0);
}
- else gammabuf= img;
+ else gammabuf = img;
blur_with_reference(node, new, gammabuf, in[1]->data);
@@ -670,30 +670,30 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN
}
if (node->exec & NODE_BREAK) {
free_compbuf(new);
- new= NULL;
+ new = NULL;
}
- out[0]->data= new;
+ out[0]->data = new;
}
else {
- if (in[1]->vec[0]<=0.001f) { /* time node inputs can be a tiny value */
- new= pass_on_compbuf(img);
+ if (in[1]->vec[0] <= 0.001f) { /* time node inputs can be a tiny value */
+ new = pass_on_compbuf(img);
}
else {
CompBuf *gammabuf;
/* make output size of input image */
- new= alloc_compbuf(img->x, img->y, img->type, 1); /* allocs */
+ new = alloc_compbuf(img->x, img->y, img->type, 1); /* allocs */
/* accept image offsets from other nodes */
new->xof = img->xof;
new->yof = img->yof;
if (nbd->gamma) {
- gammabuf= dupalloc_compbuf(img);
+ gammabuf = dupalloc_compbuf(img);
gamma_correct_compbuf(gammabuf, 0);
}
- else gammabuf= img;
+ else gammabuf = img;
if (nbd->bokeh)
bokeh_single_image(node, new, gammabuf, in[1]->vec[0]);
@@ -708,28 +708,28 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN
}
if (node->exec & NODE_BREAK) {
free_compbuf(new);
- new= NULL;
+ new = NULL;
}
}
- out[0]->data= new;
+ out[0]->data = new;
}
- if (img!=in[0]->data)
+ if (img != in[0]->data)
free_compbuf(img);
}
generate_preview(data, node, out[0]->data);
}
-static void node_composit_init_blur(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+static void node_composit_init_blur(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
{
- node->storage= MEM_callocN(sizeof(NodeBlurData), "node blur data");
+ node->storage = MEM_callocN(sizeof(NodeBlurData), "node blur data");
}
void register_node_type_cmp_blur(bNodeTreeType *ttype)
{
static bNodeType ntype;
- node_type_base(ttype, &ntype, CMP_NODE_BLUR, "Blur", NODE_CLASS_OP_FILTER, NODE_PREVIEW|NODE_OPTIONS);
+ node_type_base(ttype, &ntype, CMP_NODE_BLUR, "Blur", NODE_CLASS_OP_FILTER, NODE_PREVIEW | NODE_OPTIONS);
node_type_socket_templates(&ntype, cmp_node_blur_in, cmp_node_blur_out);
node_type_size(&ntype, 120, 80, 200);
node_type_init(&ntype, node_composit_init_blur);
diff --git a/source/blender/nodes/composite/nodes/node_composite_bokehblur.c b/source/blender/nodes/composite/nodes/node_composite_bokehblur.c
index 6b24bdb5c52..222ac7a5cdf 100644
--- a/source/blender/nodes/composite/nodes/node_composite_bokehblur.c
+++ b/source/blender/nodes/composite/nodes/node_composite_bokehblur.c
@@ -36,20 +36,20 @@
#include "../node_composite_util.h"
/* **************** BLUR ******************** */
-static bNodeSocketTemplate cmp_node_bokehblur_in[]= {
- { SOCK_RGBA, 1, N_("Image"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
- { SOCK_RGBA, 1, N_("Bokeh"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("Size"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f},
- { SOCK_FLOAT, 1, N_("Bounding box"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_bokehblur_in[] = {
+ { SOCK_RGBA, 1, N_("Image"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f},
+ { SOCK_RGBA, 1, N_("Bokeh"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f},
+ { SOCK_FLOAT, 1, N_("Size"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 10.0f},
+ { SOCK_FLOAT, 1, N_("Bounding box"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_bokehblur_out[]= {
- { SOCK_RGBA, 0, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_bokehblur_out[] = {
+ { SOCK_RGBA, 0, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+ { -1, 0, "" }
};
-static void node_composit_init_bokehblur(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+static void node_composit_init_bokehblur(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
{
node->custom3 = 4.0f;
node->custom4 = 16.0f;
diff --git a/source/blender/nodes/composite/nodes/node_composite_directionalblur.c b/source/blender/nodes/composite/nodes/node_composite_directionalblur.c
index 395fa154a89..73e28658309 100644
--- a/source/blender/nodes/composite/nodes/node_composite_directionalblur.c
+++ b/source/blender/nodes/composite/nodes/node_composite_directionalblur.c
@@ -32,23 +32,23 @@
#include "node_composite_util.h"
-static bNodeSocketTemplate cmp_node_dblur_in[]= {
- { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.f},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_dblur_in[] = {
+ { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.f},
+ { -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_dblur_out[]= {
- { SOCK_RGBA, 0, N_("Image")},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_dblur_out[] = {
+ { SOCK_RGBA, 0, N_("Image")},
+ { -1, 0, "" }
};
static CompBuf *dblur(bNode *node, CompBuf *img, int iterations, int wrap,
- float center_x, float center_y, float dist, float angle, float spin, float zoom)
+ float center_x, float center_y, float dist, float angle, float spin, float zoom)
{
if ((dist != 0.f) || (spin != 0.f) || (zoom != 0.f)) {
- void (*getpix)(CompBuf*, float, float, float*) = wrap ? qd_getPixelLerpWrap : qd_getPixelLerp;
- const float a= angle;
- const float itsc= 1.f / powf(2.f, (float)iterations);
+ void (*getpix)(CompBuf *, float, float, float *) = wrap ? qd_getPixelLerpWrap : qd_getPixelLerp;
+ const float a = angle;
+ const float itsc = 1.f / powf(2.f, (float)iterations);
float D;
float center_x_pix, center_y_pix;
float tx, ty;
@@ -56,36 +56,36 @@ static CompBuf *dblur(bNode *node, CompBuf *img, int iterations, int wrap,
CompBuf *tmp;
int i, j;
- tmp= dupalloc_compbuf(img);
+ tmp = dupalloc_compbuf(img);
- D= dist * sqrtf(img->x * img->x + img->y * img->y);
- center_x_pix= center_x * img->x;
- center_y_pix= center_y * img->y;
+ D = dist * sqrtf(img->x * img->x + img->y * img->y);
+ center_x_pix = center_x * img->x;
+ center_y_pix = center_y * img->y;
- tx= itsc * D * cosf(a);
- ty= -itsc * D * sinf(a);
- sc= itsc * zoom;
- rot= itsc * spin;
+ tx = itsc * D * cosf(a);
+ ty = -itsc *D *sinf(a);
+ sc = itsc * zoom;
+ rot = itsc * spin;
/* blur the image */
- for (i= 0; i < iterations; ++i) {
- const float cs= cosf(rot), ss= sinf(rot);
- const float isc= 1.f / (1.f + sc);
+ for (i = 0; i < iterations; ++i) {
+ const float cs = cosf(rot), ss = sinf(rot);
+ const float isc = 1.f / (1.f + sc);
unsigned int x, y;
- float col[4]= {0, 0, 0, 0};
+ float col[4] = {0, 0, 0, 0};
- for (y= 0; y < img->y; ++y) {
- const float v= isc * (y - center_y_pix) + ty;
+ for (y = 0; y < img->y; ++y) {
+ const float v = isc * (y - center_y_pix) + ty;
- for (x= 0; x < img->x; ++x) {
- const float u= isc * (x - center_x_pix) + tx;
- unsigned int p= (x + y * img->x) * img->type;
+ for (x = 0; x < img->x; ++x) {
+ const float u = isc * (x - center_x_pix) + tx;
+ unsigned int p = (x + y * img->x) * img->type;
getpix(tmp, cs * u + ss * v + center_x_pix, cs * v - ss * u + center_y_pix, col);
/* mix img and transformed tmp */
- for (j= 0; j < 4; ++j) {
- img->rect[p + j]= 0.5f * (img->rect[p + j] + col[j]);
+ for (j = 0; j < 4; ++j) {
+ img->rect[p + j] = 0.5f * (img->rect[p + j] + col[j]);
}
}
}
@@ -109,8 +109,8 @@ static CompBuf *dblur(bNode *node, CompBuf *img, int iterations, int wrap,
static void node_composit_exec_dblur(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
{
- NodeDBlurData *ndbd= node->storage;
- CompBuf *new, *img= in[0]->data;
+ NodeDBlurData *ndbd = node->storage;
+ CompBuf *new, *img = in[0]->data;
if ((img == NULL) || (out[0]->hasoutput == 0)) return;
@@ -119,15 +119,15 @@ static void node_composit_exec_dblur(void *UNUSED(data), bNode *node, bNodeStack
else
new = dupalloc_compbuf(img);
- out[0]->data= dblur(node, new, ndbd->iter, ndbd->wrap, ndbd->center_x, ndbd->center_y, ndbd->distance, ndbd->angle, ndbd->spin, ndbd->zoom);
+ out[0]->data = dblur(node, new, ndbd->iter, ndbd->wrap, ndbd->center_x, ndbd->center_y, ndbd->distance, ndbd->angle, ndbd->spin, ndbd->zoom);
}
-static void node_composit_init_dblur(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+static void node_composit_init_dblur(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
{
- NodeDBlurData *ndbd= MEM_callocN(sizeof(NodeDBlurData), "node dblur data");
- node->storage= ndbd;
- ndbd->center_x= 0.5;
- ndbd->center_y= 0.5;
+ NodeDBlurData *ndbd = MEM_callocN(sizeof(NodeDBlurData), "node dblur data");
+ node->storage = ndbd;
+ ndbd->center_x = 0.5;
+ ndbd->center_y = 0.5;
}
void register_node_type_cmp_dblur(bNodeTreeType *ttype)
diff --git a/source/blender/nodes/composite/nodes/node_composite_vecBlur.c b/source/blender/nodes/composite/nodes/node_composite_vecBlur.c
index fd2cc724b82..e1a20a65227 100644
--- a/source/blender/nodes/composite/nodes/node_composite_vecBlur.c
+++ b/source/blender/nodes/composite/nodes/node_composite_vecBlur.c
@@ -34,63 +34,63 @@
/* **************** VECTOR BLUR ******************** */
-static bNodeSocketTemplate cmp_node_vecblur_in[]= {
- { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
- { SOCK_FLOAT, 1, N_("Z"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
- { SOCK_VECTOR, 1, N_("Speed"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_VELOCITY},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_vecblur_in[] = {
+ { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
+ { SOCK_FLOAT, 1, N_("Z"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE},
+ { SOCK_VECTOR, 1, N_("Speed"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_VELOCITY},
+ { -1, 0, "" }
};
-static bNodeSocketTemplate cmp_node_vecblur_out[]= {
- { SOCK_RGBA, 0, N_("Image")},
- { -1, 0, "" }
+static bNodeSocketTemplate cmp_node_vecblur_out[] = {
+ { SOCK_RGBA, 0, N_("Image")},
+ { -1, 0, "" }
};
static void node_composit_exec_vecblur(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out)
{
- NodeBlurData *nbd= node->storage;
- CompBuf *new, *img= in[0]->data, *vecbuf= in[2]->data, *zbuf= in[1]->data;
+ NodeBlurData *nbd = node->storage;
+ CompBuf *new, *img = in[0]->data, *vecbuf = in[2]->data, *zbuf = in[1]->data;
- if (img==NULL || vecbuf==NULL || zbuf==NULL || out[0]->hasoutput==0)
+ if (img == NULL || vecbuf == NULL || zbuf == NULL || out[0]->hasoutput == 0)
return;
- if (vecbuf->x!=img->x || vecbuf->y!=img->y) {
+ if (vecbuf->x != img->x || vecbuf->y != img->y) {
printf("ERROR: cannot do different sized vecbuf yet\n");
return;
}
- if (vecbuf->type!=CB_VEC4) {
+ if (vecbuf->type != CB_VEC4) {
printf("ERROR: input should be vecbuf\n");
return;
}
- if (zbuf->type!=CB_VAL) {
+ if (zbuf->type != CB_VAL) {
printf("ERROR: input should be zbuf\n");
return;
}
- if (zbuf->x!=img->x || zbuf->y!=img->y) {
+ if (zbuf->x != img->x || zbuf->y != img->y) {
printf("ERROR: cannot do different sized zbuf yet\n");
return;
}
/* allow the input image to be of another type */
- img= typecheck_compbuf(in[0]->data, CB_RGBA);
+ img = typecheck_compbuf(in[0]->data, CB_RGBA);
- new= dupalloc_compbuf(img);
+ new = dupalloc_compbuf(img);
/* call special zbuffer version */
RE_zbuf_accumulate_vecblur(nbd, img->x, img->y, new->rect, img->rect, vecbuf->rect, zbuf->rect);
- out[0]->data= new;
+ out[0]->data = new;
- if (img!=in[0]->data)
+ if (img != in[0]->data)
free_compbuf(img);
}
-static void node_composit_init_vecblur(bNodeTree *UNUSED(ntree), bNode* node, bNodeTemplate *UNUSED(ntemp))
+static void node_composit_init_vecblur(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp))
{
- NodeBlurData *nbd= MEM_callocN(sizeof(NodeBlurData), "node blur data");
- node->storage= nbd;
- nbd->samples= 32;
- nbd->fac= 1.0f;
+ NodeBlurData *nbd = MEM_callocN(sizeof(NodeBlurData), "node blur data");
+ node->storage = nbd;
+ nbd->samples = 32;
+ nbd->fac = 1.0f;
}
/* custom1: itterations, custom2: maxspeed (0 = nolimit) */