diff options
Diffstat (limited to 'source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp')
-rw-r--r-- | source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp index 2eb51b4577f..09a2a70ead3 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; @@ -93,30 +93,24 @@ void GaussianXBlurOperation::executePixel(float *color, int x, int y, MemoryBuff maxy = min(maxy, inputBuffer->getRect()->ymax); maxx = min(maxx, inputBuffer->getRect()->xmax); - int index = 0; + 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) { - float multiplyer = gausstab[index++]; - tempColor[0] += multiplyer * buffer[bufferindex]; - tempColor[1] += multiplyer * buffer[bufferindex+1]; - tempColor[2] += multiplyer * buffer[bufferindex+2]; - tempColor[3] += multiplyer * buffer[bufferindex+3]; + 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; - bufferindex +=offsetadd; + bufferindex += offsetadd; } - float divider = 1.0f / overallmultiplyer; - color[0] = tempColor[0] * divider; - color[1] = tempColor[1] * divider; - color[2] = tempColor[2] * divider; - color[3] = tempColor[3] * divider; + mul_v4_v4fl(color, tempColor, 1.0f / overallmultiplyer); } void GaussianXBlurOperation::deinitExecution() { BlurBaseOperation::deinitExecution(); - delete this->gausstab; + delete [] this->gausstab; this->gausstab = NULL; } @@ -129,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; } |