Page Menu
Home
Search
Configure Global Search
Log In
Files
F22477
fast_gauss_v1.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
David M (erwin94)
Nov 13 2013, 4:45 PM
Size
5 KB
Subscribers
None
fast_gauss_v1.patch
View Options
Index: source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp
===================================================================
--- source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp (revision 54370)
+++ source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp (working copy)
@@ -37,22 +37,58 @@
newData->read(output, x, y);
}
+// Calculate the depending area of interest. This depends on the
+// size of the blur operation; if the blur is large it is faster
+// to just calculate the whole image at once.
+// Returns true if the area is just a tile and false if it is
+// the whole image.
+//
+// Note: The switching point is currently hardcoded at a tilesize
+// of 256x256 and performance tests on a 2-core machine. For
+// other configurations other values might be better. More
+// testing might be useful.
+bool FastGaussianBlurOperation::getDAI(rcti *rect, rcti *output)
+{
+ int sx = this->m_data->sizex * this->m_size * 2;
+ if (sx < 1)
+ sx = 1;
+ int sy = this->m_data->sizey * this->m_size * 2;
+ if (sy < 1)
+ sy = 1;
+ if (sx >= 256 || sy >= 256) {
+ output->xmin = 0;
+ output->xmax = this->getWidth();
+ output->ymin = 0;
+ output->ymax = this->getHeight();
+ return false;
+ }
+ else {
+ output->xmin = rect->xmin - sx - 1;
+ output->xmax = rect->xmax + sx + 1;
+ output->ymin = rect->ymin - sy - 1;
+ output->ymax = rect->ymax + sy + 1;
+ return true;
+ }
+}
+
bool FastGaussianBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
rcti newInput;
- rcti sizeInput;
- sizeInput.xmin = 0;
- sizeInput.ymin = 0;
- sizeInput.xmax = 5;
- sizeInput.ymax = 5;
- NodeOperation *operation = this->getInputOperation(1);
- if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
- return true;
+ if (!this->m_sizeavailable) {
+ rcti sizeInput;
+ sizeInput.xmin = 0;
+ sizeInput.ymin = 0;
+ sizeInput.xmax = 5;
+ sizeInput.ymax = 5;
+ NodeOperation *operation = this->getInputOperation(1);
+ if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) {
+ return true;
+ }
}
- else {
- if (this->m_iirgaus) {
- return false;
+ {
+ if (this->m_sizeavailable) {
+ getDAI(input, &newInput);
}
else {
newInput.xmin = 0;
@@ -82,35 +118,63 @@
void *FastGaussianBlurOperation::initializeTileData(rcti *rect)
{
lockMutex();
- if (!this->m_iirgaus) {
- MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect);
- MemoryBuffer *copy = newBuf->duplicate();
- updateSize();
+ updateSize();
+ rcti dai;
+ bool use_tiles = getDAI(rect, &dai);
+ if (use_tiles) {
+ unlockMutex();
+ }
+ else if (this->m_iirgaus) {
+ unlockMutex();
+ return this->m_iirgaus;
+ }
+ MemoryBuffer *buffer = (MemoryBuffer *)this->m_inputProgram->initializeTileData(NULL);
+
+ rcti *buf_rect = buffer->getRect();
+ dai.xmin = max(dai.xmin, buf_rect->xmin);
+ dai.xmax = min(dai.xmax, buf_rect->xmax);
+ dai.ymin = max(dai.ymin, buf_rect->ymin);
+ dai.ymax = min(dai.ymax, buf_rect->ymax);
+
+ MemoryBuffer *tile = new MemoryBuffer(NULL, &dai);
+ tile->copyContentFrom(buffer);
+
+ {
int c;
- this->m_sx = this->m_data->sizex * this->m_size / 2.0f;
- this->m_sy = this->m_data->sizey * this->m_size / 2.0f;
-
- if ((this->m_sx == this->m_sy) && (this->m_sx > 0.f)) {
+ float sx = this->m_data->sizex * this->m_size / 2.0f;
+ float sy = this->m_data->sizey * this->m_size / 2.0f;
+
+ if ((sx == sy) && (sx > 0.f)) {
for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c)
- IIR_gauss(copy, this->m_sx, c, 3);
+ IIR_gauss(tile, sx, c, 3);
}
else {
- if (this->m_sx > 0.0f) {
+ if (sx > 0.0f) {
for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c)
- IIR_gauss(copy, this->m_sx, c, 1);
+ IIR_gauss(tile, sx, c, 1);
}
- if (this->m_sy > 0.0f) {
+ if (sy > 0.0f) {
for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c)
- IIR_gauss(copy, this->m_sy, c, 2);
+ IIR_gauss(tile, sy, c, 2);
}
}
- this->m_iirgaus = copy;
}
- unlockMutex();
- return this->m_iirgaus;
+ if (!use_tiles) {
+ this->m_iirgaus = tile;
+ unlockMutex();
+ }
+ return tile;
}
+void FastGaussianBlurOperation::deinitializeTileData(rcti *rect, void *data)
+{
+ if (!this->m_iirgaus && data) {
+ MemoryBuffer *tile = (MemoryBuffer *)data;
+ delete tile;
+ }
+}
+
void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, unsigned int chan, unsigned int xy)
{
double q, q2, sc, cf[4], tsM[9], tsu[3], tsv[3];
Index: source/blender/compositor/operations/COM_FastGaussianBlurOperation.h
===================================================================
--- source/blender/compositor/operations/COM_FastGaussianBlurOperation.h (revision 54370)
+++ source/blender/compositor/operations/COM_FastGaussianBlurOperation.h (working copy)
@@ -28,8 +28,6 @@
class FastGaussianBlurOperation : public BlurBaseOperation {
private:
- float m_sx;
- float m_sy;
MemoryBuffer *m_iirgaus;
public:
FastGaussianBlurOperation();
@@ -37,7 +35,9 @@
void executePixel(float output[4], int x, int y, void *data);
static void IIR_gauss(MemoryBuffer *src, float sigma, unsigned int channel, unsigned int xy);
+ bool getDAI(rcti *rect, rcti *output);
void *initializeTileData(rcti *rect);
+ void deinitializeTileData(rcti *rect, void *data);
void deinitExecution();
void initExecution();
};
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
1c/dc/fc6c5478f27b7e29e2ae8fe26741
Event Timeline
Log In to Comment