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:
authorCampbell Barton <ideasman42@gmail.com>2019-04-17 07:17:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-17 07:21:24 +0300
commite12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch)
tree8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/compositor/operations/COM_DespeckleOperation.cpp
parentb3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff)
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/compositor/operations/COM_DespeckleOperation.cpp')
-rw-r--r--source/blender/compositor/operations/COM_DespeckleOperation.cpp174
1 files changed, 90 insertions, 84 deletions
diff --git a/source/blender/compositor/operations/COM_DespeckleOperation.cpp b/source/blender/compositor/operations/COM_DespeckleOperation.cpp
index 0ac96ac89e9..807450040de 100644
--- a/source/blender/compositor/operations/COM_DespeckleOperation.cpp
+++ b/source/blender/compositor/operations/COM_DespeckleOperation.cpp
@@ -24,114 +24,120 @@
DespeckleOperation::DespeckleOperation() : NodeOperation()
{
- this->addInputSocket(COM_DT_COLOR);
- this->addInputSocket(COM_DT_VALUE);
- this->addOutputSocket(COM_DT_COLOR);
- this->setResolutionInputSocketIndex(0);
- this->m_inputOperation = NULL;
- this->setComplex(true);
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->setResolutionInputSocketIndex(0);
+ this->m_inputOperation = NULL;
+ this->setComplex(true);
}
void DespeckleOperation::initExecution()
{
- this->m_inputOperation = this->getInputSocketReader(0);
- this->m_inputValueOperation = this->getInputSocketReader(1);
+ this->m_inputOperation = this->getInputSocketReader(0);
+ this->m_inputValueOperation = this->getInputSocketReader(1);
}
void DespeckleOperation::deinitExecution()
{
- this->m_inputOperation = NULL;
- this->m_inputValueOperation = NULL;
+ this->m_inputOperation = NULL;
+ this->m_inputValueOperation = NULL;
}
BLI_INLINE int color_diff(const float a[3], const float b[3], const float threshold)
{
- return ((fabsf(a[0] - b[0]) > threshold) ||
- (fabsf(a[1] - b[1]) > threshold) ||
- (fabsf(a[2] - b[2]) > threshold));
+ return ((fabsf(a[0] - b[0]) > threshold) || (fabsf(a[1] - b[1]) > threshold) ||
+ (fabsf(a[2] - b[2]) > threshold));
}
void DespeckleOperation::executePixel(float output[4], int x, int y, void * /*data*/)
{
- float w = 0.0f;
- float color_org[4];
- float color_mid[4];
- float color_mid_ok[4];
- float in1[4];
- int x1 = x - 1;
- int x2 = x;
- int x3 = x + 1;
- int y1 = y - 1;
- int y2 = y;
- int y3 = y + 1;
- CLAMP(x1, 0, getWidth() - 1);
- CLAMP(x2, 0, getWidth() - 1);
- CLAMP(x3, 0, getWidth() - 1);
- CLAMP(y1, 0, getHeight() - 1);
- CLAMP(y2, 0, getHeight() - 1);
- CLAMP(y3, 0, getHeight() - 1);
- float value[4];
- this->m_inputValueOperation->read(value, x2, y2, NULL);
- //const float mval = 1.0f - value[0];
-
-
- this->m_inputOperation->read(color_org, x2, y2, NULL);
+ float w = 0.0f;
+ float color_org[4];
+ float color_mid[4];
+ float color_mid_ok[4];
+ float in1[4];
+ int x1 = x - 1;
+ int x2 = x;
+ int x3 = x + 1;
+ int y1 = y - 1;
+ int y2 = y;
+ int y3 = y + 1;
+ CLAMP(x1, 0, getWidth() - 1);
+ CLAMP(x2, 0, getWidth() - 1);
+ CLAMP(x3, 0, getWidth() - 1);
+ CLAMP(y1, 0, getHeight() - 1);
+ CLAMP(y2, 0, getHeight() - 1);
+ CLAMP(y3, 0, getHeight() - 1);
+ float value[4];
+ this->m_inputValueOperation->read(value, x2, y2, NULL);
+ //const float mval = 1.0f - value[0];
+
+ this->m_inputOperation->read(color_org, x2, y2, NULL);
#define TOT_DIV_ONE 1.0f
#define TOT_DIV_CNR (float)M_SQRT1_2
-#define WTOT (TOT_DIV_ONE * 4 + TOT_DIV_CNR * 4)
-
-#define COLOR_ADD(fac) \
-{ \
- madd_v4_v4fl(color_mid, in1, fac); \
- if (color_diff(in1, color_org, this->m_threshold)) { \
- w += fac; \
- madd_v4_v4fl(color_mid_ok, in1, fac); \
- } \
-}
-
- zero_v4(color_mid);
- zero_v4(color_mid_ok);
-
- this->m_inputOperation->read(in1, x1, y1, NULL); COLOR_ADD(TOT_DIV_CNR)
- this->m_inputOperation->read(in1, x2, y1, NULL); COLOR_ADD(TOT_DIV_ONE)
- this->m_inputOperation->read(in1, x3, y1, NULL); COLOR_ADD(TOT_DIV_CNR)
- this->m_inputOperation->read(in1, x1, y2, NULL); COLOR_ADD(TOT_DIV_ONE)
+#define WTOT (TOT_DIV_ONE * 4 + TOT_DIV_CNR * 4)
+
+#define COLOR_ADD(fac) \
+ { \
+ madd_v4_v4fl(color_mid, in1, fac); \
+ if (color_diff(in1, color_org, this->m_threshold)) { \
+ w += fac; \
+ madd_v4_v4fl(color_mid_ok, in1, fac); \
+ } \
+ }
+
+ zero_v4(color_mid);
+ zero_v4(color_mid_ok);
+
+ this->m_inputOperation->read(in1, x1, y1, NULL);
+ COLOR_ADD(TOT_DIV_CNR)
+ this->m_inputOperation->read(in1, x2, y1, NULL);
+ COLOR_ADD(TOT_DIV_ONE)
+ this->m_inputOperation->read(in1, x3, y1, NULL);
+ COLOR_ADD(TOT_DIV_CNR)
+ this->m_inputOperation->read(in1, x1, y2, NULL);
+ COLOR_ADD(TOT_DIV_ONE)
#if 0
- this->m_inputOperation->read(in2, x2, y2, NULL);
- madd_v4_v4fl(color_mid, in2, this->m_filter[4]);
+ this->m_inputOperation->read(in2, x2, y2, NULL);
+ madd_v4_v4fl(color_mid, in2, this->m_filter[4]);
#endif
- this->m_inputOperation->read(in1, x3, y2, NULL); COLOR_ADD(TOT_DIV_ONE)
- this->m_inputOperation->read(in1, x1, y3, NULL); COLOR_ADD(TOT_DIV_CNR)
- this->m_inputOperation->read(in1, x2, y3, NULL); COLOR_ADD(TOT_DIV_ONE)
- this->m_inputOperation->read(in1, x3, y3, NULL); COLOR_ADD(TOT_DIV_CNR)
-
- mul_v4_fl(color_mid, 1.0f / (4.0f + (4.0f * (float)M_SQRT1_2)));
- //mul_v4_fl(color_mid, 1.0f / w);
-
- if ((w != 0.0f) &&
- ((w / WTOT) > (this->m_threshold_neighbor)) &&
- color_diff(color_mid, color_org, this->m_threshold))
- {
- mul_v4_fl(color_mid_ok, 1.0f / w);
- interp_v4_v4v4(output, color_org, color_mid_ok, value[0]);
- }
- else {
- copy_v4_v4(output, color_org);
- }
+ this->m_inputOperation->read(in1, x3, y2, NULL);
+ COLOR_ADD(TOT_DIV_ONE)
+ this->m_inputOperation->read(in1, x1, y3, NULL);
+ COLOR_ADD(TOT_DIV_CNR)
+ this->m_inputOperation->read(in1, x2, y3, NULL);
+ COLOR_ADD(TOT_DIV_ONE)
+ this->m_inputOperation->read(in1, x3, y3, NULL);
+ COLOR_ADD(TOT_DIV_CNR)
+
+ mul_v4_fl(color_mid, 1.0f / (4.0f + (4.0f * (float)M_SQRT1_2)));
+ //mul_v4_fl(color_mid, 1.0f / w);
+
+ if ((w != 0.0f) && ((w / WTOT) > (this->m_threshold_neighbor)) &&
+ color_diff(color_mid, color_org, this->m_threshold)) {
+ mul_v4_fl(color_mid_ok, 1.0f / w);
+ interp_v4_v4v4(output, color_org, color_mid_ok, value[0]);
+ }
+ else {
+ copy_v4_v4(output, color_org);
+ }
}
-bool DespeckleOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+bool DespeckleOperation::determineDependingAreaOfInterest(rcti *input,
+ ReadBufferOperation *readOperation,
+ rcti *output)
{
- rcti newInput;
- int addx = 2; //(this->m_filterWidth - 1) / 2 + 1;
- int addy = 2; //(this->m_filterHeight - 1) / 2 + 1;
- newInput.xmax = input->xmax + addx;
- newInput.xmin = input->xmin - addx;
- newInput.ymax = input->ymax + addy;
- newInput.ymin = input->ymin - addy;
-
- return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
+ rcti newInput;
+ int addx = 2; //(this->m_filterWidth - 1) / 2 + 1;
+ int addy = 2; //(this->m_filterHeight - 1) / 2 + 1;
+ newInput.xmax = input->xmax + addx;
+ newInput.xmin = input->xmin - addx;
+ newInput.ymax = input->ymax + addy;
+ newInput.ymin = input->ymin - addy;
+
+ return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}