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_ChromaMatteOperation.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_ChromaMatteOperation.cpp')
-rw-r--r--source/blender/compositor/operations/COM_ChromaMatteOperation.cpp145
1 files changed, 74 insertions, 71 deletions
diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp
index 05a184a4b58..62dc74d2092 100644
--- a/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp
+++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp
@@ -21,87 +21,90 @@
ChromaMatteOperation::ChromaMatteOperation() : NodeOperation()
{
- addInputSocket(COM_DT_COLOR);
- addInputSocket(COM_DT_COLOR);
- addOutputSocket(COM_DT_VALUE);
+ addInputSocket(COM_DT_COLOR);
+ addInputSocket(COM_DT_COLOR);
+ addOutputSocket(COM_DT_VALUE);
- this->m_inputImageProgram = NULL;
- this->m_inputKeyProgram = NULL;
+ this->m_inputImageProgram = NULL;
+ this->m_inputKeyProgram = NULL;
}
void ChromaMatteOperation::initExecution()
{
- this->m_inputImageProgram = this->getInputSocketReader(0);
- this->m_inputKeyProgram = this->getInputSocketReader(1);
+ this->m_inputImageProgram = this->getInputSocketReader(0);
+ this->m_inputKeyProgram = this->getInputSocketReader(1);
}
void ChromaMatteOperation::deinitExecution()
{
- this->m_inputImageProgram = NULL;
- this->m_inputKeyProgram = NULL;
+ this->m_inputImageProgram = NULL;
+ this->m_inputKeyProgram = NULL;
}
-void ChromaMatteOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler)
+void ChromaMatteOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
{
- float inKey[4];
- float inImage[4];
-
- const float acceptance = this->m_settings->t1; /* in radians */
- const float cutoff = this->m_settings->t2; /* in radians */
- const float gain = this->m_settings->fstrength;
-
- float x_angle, z_angle, alpha;
- float theta, beta;
- float kfg;
-
- this->m_inputKeyProgram->readSampled(inKey, x, y, sampler);
- this->m_inputImageProgram->readSampled(inImage, x, y, sampler);
-
- /* store matte(alpha) value in [0] to go with
- * COM_SetAlphaOperation and the Value output
- */
-
- /* Algorithm from book "Video Demistified," does not include the spill reduction part */
- /* find theta, the angle that the color space should be rotated based on key */
-
- /* rescale to -1.0..1.0 */
- // inImage[0] = (inImage[0] * 2.0f) - 1.0f; // UNUSED
- inImage[1] = (inImage[1] * 2.0f) - 1.0f;
- inImage[2] = (inImage[2] * 2.0f) - 1.0f;
-
- // inKey[0] = (inKey[0] * 2.0f) - 1.0f; // UNUSED
- inKey[1] = (inKey[1] * 2.0f) - 1.0f;
- inKey[2] = (inKey[2] * 2.0f) - 1.0f;
-
- theta = atan2(inKey[2], inKey[1]);
-
- /*rotate the cb and cr into x/z space */
- x_angle = inImage[1] * cosf(theta) + inImage[2] * sinf(theta);
- z_angle = inImage[2] * cosf(theta) - inImage[1] * sinf(theta);
-
- /*if within the acceptance angle */
- /* if kfg is <0 then the pixel is outside of the key color */
- kfg = x_angle - (fabsf(z_angle) / tanf(acceptance / 2.0f));
-
- if (kfg > 0.0f) { /* found a pixel that is within key color */
- alpha = 1.0f - (kfg / gain);
-
- beta = atan2(z_angle, x_angle);
-
- /* if beta is within the cutoff angle */
- if (fabsf(beta) < (cutoff / 2.0f)) {
- alpha = 0.0f;
- }
-
- /* don't make something that was more transparent less transparent */
- if (alpha < inImage[3]) {
- output[0] = alpha;
- }
- else {
- output[0] = inImage[3];
- }
- }
- else { /*pixel is outside key color */
- output[0] = inImage[3]; /* make pixel just as transparent as it was before */
- }
+ float inKey[4];
+ float inImage[4];
+
+ const float acceptance = this->m_settings->t1; /* in radians */
+ const float cutoff = this->m_settings->t2; /* in radians */
+ const float gain = this->m_settings->fstrength;
+
+ float x_angle, z_angle, alpha;
+ float theta, beta;
+ float kfg;
+
+ this->m_inputKeyProgram->readSampled(inKey, x, y, sampler);
+ this->m_inputImageProgram->readSampled(inImage, x, y, sampler);
+
+ /* store matte(alpha) value in [0] to go with
+ * COM_SetAlphaOperation and the Value output
+ */
+
+ /* Algorithm from book "Video Demistified," does not include the spill reduction part */
+ /* find theta, the angle that the color space should be rotated based on key */
+
+ /* rescale to -1.0..1.0 */
+ // inImage[0] = (inImage[0] * 2.0f) - 1.0f; // UNUSED
+ inImage[1] = (inImage[1] * 2.0f) - 1.0f;
+ inImage[2] = (inImage[2] * 2.0f) - 1.0f;
+
+ // inKey[0] = (inKey[0] * 2.0f) - 1.0f; // UNUSED
+ inKey[1] = (inKey[1] * 2.0f) - 1.0f;
+ inKey[2] = (inKey[2] * 2.0f) - 1.0f;
+
+ theta = atan2(inKey[2], inKey[1]);
+
+ /*rotate the cb and cr into x/z space */
+ x_angle = inImage[1] * cosf(theta) + inImage[2] * sinf(theta);
+ z_angle = inImage[2] * cosf(theta) - inImage[1] * sinf(theta);
+
+ /*if within the acceptance angle */
+ /* if kfg is <0 then the pixel is outside of the key color */
+ kfg = x_angle - (fabsf(z_angle) / tanf(acceptance / 2.0f));
+
+ if (kfg > 0.0f) { /* found a pixel that is within key color */
+ alpha = 1.0f - (kfg / gain);
+
+ beta = atan2(z_angle, x_angle);
+
+ /* if beta is within the cutoff angle */
+ if (fabsf(beta) < (cutoff / 2.0f)) {
+ alpha = 0.0f;
+ }
+
+ /* don't make something that was more transparent less transparent */
+ if (alpha < inImage[3]) {
+ output[0] = alpha;
+ }
+ else {
+ output[0] = inImage[3];
+ }
+ }
+ else { /*pixel is outside key color */
+ output[0] = inImage[3]; /* make pixel just as transparent as it was before */
+ }
}