diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2015-01-19 20:13:26 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2015-01-19 20:17:50 +0300 |
commit | 35d3b6316b21ad9ae7eb96a7a541c4051eae3441 (patch) | |
tree | dd4eea63f9229d87041e2f5a5679d05f1360afea /source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp | |
parent | a8fa291b8c539da7669463ef622d5c61ee9c90e7 (diff) |
D627: Memory usage optimization for the compositor.
The compostor used a fixed size of 4 floats to hold pixel data. this
patch will select size of a pixel based on its type.
It uses 1 float for Value, 3 float for vector and 4 floats for color
data types.
When benchmarking on shots (opening shot of caminandes) we get a
reduction of memory of 30% and a tiny speedup as less data
transformations needs to take place (but these are negligable.
More information of the patch can be found on
https://developer.blender.org/D627 and
http://wiki.blender.org/index.php/Dev:Ref/Proposals/Compositor2014_p1.1_TD
Developers: jbakker & mdewanchand
Thanks for Sergey for his indept review.
Diffstat (limited to 'source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp')
-rw-r--r-- | source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp index 705a8c07381..08f520e4271 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp @@ -92,16 +92,16 @@ void *FastGaussianBlurOperation::initializeTileData(rcti *rect) this->m_sy = this->m_data.sizey * this->m_size / 2.0f; if ((this->m_sx == this->m_sy) && (this->m_sx > 0.f)) { - for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c) + for (c = 0; c < COM_NUM_CHANNELS_COLOR; ++c) IIR_gauss(copy, this->m_sx, c, 3); } else { if (this->m_sx > 0.0f) { - for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c) + for (c = 0; c < COM_NUM_CHANNELS_COLOR; ++c) IIR_gauss(copy, this->m_sx, c, 1); } if (this->m_sy > 0.0f) { - for (c = 0; c < COM_NUMBER_OF_CHANNELS; ++c) + for (c = 0; c < COM_NUM_CHANNELS_COLOR; ++c) IIR_gauss(copy, this->m_sy, c, 2); } } @@ -120,6 +120,7 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, unsign unsigned int x, y, sz; unsigned int i; float *buffer = src->getBuffer(); + const unsigned int num_channels = src->get_num_channels(); // <0.5 not valid, though can have a possibly useful sort of sharpening effect if (sigma < 0.5f) return; @@ -198,31 +199,31 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, unsign int offset; for (y = 0; y < src_height; ++y) { const int yx = y * src_width; - offset = yx * COM_NUMBER_OF_CHANNELS + chan; + offset = yx * num_channels + chan; for (x = 0; x < src_width; ++x) { X[x] = buffer[offset]; - offset += COM_NUMBER_OF_CHANNELS; + offset += num_channels; } YVV(src_width); - offset = yx * COM_NUMBER_OF_CHANNELS + chan; + offset = yx * num_channels + chan; for (x = 0; x < src_width; ++x) { buffer[offset] = Y[x]; - offset += COM_NUMBER_OF_CHANNELS; + offset += num_channels; } } } if (xy & 2) { // V int offset; - const int add = src_width * COM_NUMBER_OF_CHANNELS; + const int add = src_width * num_channels; for (x = 0; x < src_width; ++x) { - offset = x * COM_NUMBER_OF_CHANNELS + chan; + offset = x * num_channels + chan; for (y = 0; y < src_height; ++y) { X[y] = buffer[offset]; offset += add; } YVV(src_height); - offset = x * COM_NUMBER_OF_CHANNELS + chan; + offset = x * num_channels + chan; for (y = 0; y < src_height; ++y) { buffer[offset] = Y[y]; offset += add; @@ -298,7 +299,7 @@ void *FastGaussianBlurValueOperation::initializeTileData(rcti *rect) if (this->m_overlay == FAST_GAUSS_OVERLAY_MIN) { float *src = newBuf->getBuffer(); float *dst = copy->getBuffer(); - for (int i = copy->getWidth() * copy->getHeight(); i != 0; i--, src += COM_NUMBER_OF_CHANNELS, dst += COM_NUMBER_OF_CHANNELS) { + for (int i = copy->getWidth() * copy->getHeight(); i != 0; i--, src += COM_NUM_CHANNELS_VALUE, dst += COM_NUM_CHANNELS_VALUE) { if (*src < *dst) { *dst = *src; } @@ -307,7 +308,7 @@ void *FastGaussianBlurValueOperation::initializeTileData(rcti *rect) else if (this->m_overlay == FAST_GAUSS_OVERLAY_MAX) { float *src = newBuf->getBuffer(); float *dst = copy->getBuffer(); - for (int i = copy->getWidth() * copy->getHeight(); i != 0; i--, src += COM_NUMBER_OF_CHANNELS, dst += COM_NUMBER_OF_CHANNELS) { + for (int i = copy->getWidth() * copy->getHeight(); i != 0; i--, src += COM_NUM_CHANNELS_VALUE, dst += COM_NUM_CHANNELS_VALUE) { if (*src > *dst) { *dst = *src; } |