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
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-06-25 12:21:55 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-06-25 12:21:55 +0400
commit44c82198d4852484493c2e33b3ca4ad67fd76fd8 (patch)
tree4bf2bc23d6034647e0006dfb0c0d2f25f0eb951c /source/blender/compositor/operations
parent15cb064e1b853a56fc676db1c2869db47657d91a (diff)
Optimization of Keying Blur operation
Separate X and Y passes of blurring like it's done for flat gaussian blur. This reduces computing difficulty from size^2 to 2*size without any visual changes in matte.
Diffstat (limited to 'source/blender/compositor/operations')
-rw-r--r--source/blender/compositor/operations/COM_KeyingBlurOperation.cpp43
-rw-r--r--source/blender/compositor/operations/COM_KeyingBlurOperation.h9
2 files changed, 40 insertions, 12 deletions
diff --git a/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp b/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp
index fd80b6b5ccf..eb956403e1f 100644
--- a/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingBlurOperation.cpp
@@ -33,7 +33,8 @@ KeyingBlurOperation::KeyingBlurOperation() : NodeOperation()
this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_VALUE);
- this->size = 0.0f;
+ this->size = 0;
+ this->axis = 0;
this->setComplex(true);
}
@@ -53,16 +54,28 @@ void KeyingBlurOperation::executePixel(float *color, int x, int y, MemoryBuffer
int bufferWidth = inputBuffer->getWidth();
int bufferHeight = inputBuffer->getHeight();
- int i, j, count = 0;
+ int i, count = 0;
float average = 0.0f;
- for (i = -this->size + 1; i < this->size; i++) {
- for (j = -this->size + 1; j < this->size; j++) {
- int cx = x + j, cy = y + i;
+ if (this->axis == 0) {
+ for (i = -this->size + 1; i < this->size; i++) {
+ int cx = x + i;
- if (cx >= 0 && cx < bufferWidth && cy >= 0 && cy < bufferHeight) {
- int bufferIndex = (cy * bufferWidth + cx) * 4;
+ if (cx >= 0 && cx < bufferWidth) {
+ int bufferIndex = (y * bufferWidth + cx) * 4;
+
+ average += buffer[bufferIndex];
+ count++;
+ }
+ }
+ }
+ else {
+ for (i = -this->size + 1; i < this->size; i++) {
+ int cy = y + i;
+
+ if (cy >= 0 && cy < bufferHeight) {
+ int bufferIndex = (cy * bufferWidth + x) * 4;
average += buffer[bufferIndex];
count++;
@@ -79,10 +92,18 @@ bool KeyingBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBuff
{
rcti newInput;
- newInput.xmin = input->xmin - this->size;
- newInput.ymin = input->ymin - this->size;
- newInput.xmax = input->xmax + this->size;
- newInput.ymax = input->ymax + this->size;
+ if (this->axis == 0) {
+ newInput.xmin = input->xmin - this->size;
+ newInput.ymin = input->ymin;
+ newInput.xmax = input->xmax + this->size;
+ newInput.ymax = input->ymax;
+ }
+ else {
+ newInput.xmin = input->xmin;
+ newInput.ymin = input->ymin - this->size;
+ newInput.xmax = input->xmax;
+ newInput.ymax = input->ymax + this->size;
+ }
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
diff --git a/source/blender/compositor/operations/COM_KeyingBlurOperation.h b/source/blender/compositor/operations/COM_KeyingBlurOperation.h
index 2848f260cbd..41ccb465eab 100644
--- a/source/blender/compositor/operations/COM_KeyingBlurOperation.h
+++ b/source/blender/compositor/operations/COM_KeyingBlurOperation.h
@@ -32,11 +32,18 @@
class KeyingBlurOperation : public NodeOperation {
protected:
int size;
+ int axis;
public:
+ enum BlurAxis {
+ BLUR_AXIS_X = 0,
+ BLUR_AXIS_Y = 1
+ };
+
KeyingBlurOperation();
- void setSize(float value) {this->size = value;}
+ void setSize(int value) {this->size = value;}
+ void setAxis(int value) {this->axis = value;}
void *initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers);