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:
authorManuel Castilla <manzanillawork@gmail.com>2021-08-23 16:30:46 +0300
committerManuel Castilla <manzanillawork@gmail.com>2021-08-23 18:09:59 +0300
commit153b45037f5d27cf125d56ebb9aa77aca53d0981 (patch)
treebcf590fc895b03efbfb090acd1fecfb1fa4f04a0 /source/blender/compositor/operations/COM_KeyingBlurOperation.cc
parentdaa7c59e38c8fe464004b3becd6956b880c38c92 (diff)
Compositor: Full frame matte nodes
Adds full frame implementation to Channel Key, Chroma Key, Color Key, Color Spill, Cryptomatte, Difference Key, Distance Key, Keying, Keying Screen and Luminance Key nodes. The other nodes in "Matte" sub-menu are submitted separately. No functional changes. Part of T88150. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D12220
Diffstat (limited to 'source/blender/compositor/operations/COM_KeyingBlurOperation.cc')
-rw-r--r--source/blender/compositor/operations/COM_KeyingBlurOperation.cc63
1 files changed, 63 insertions, 0 deletions
diff --git a/source/blender/compositor/operations/COM_KeyingBlurOperation.cc b/source/blender/compositor/operations/COM_KeyingBlurOperation.cc
index 994b00cd3f4..d5ebd5e9df7 100644
--- a/source/blender/compositor/operations/COM_KeyingBlurOperation.cc
+++ b/source/blender/compositor/operations/COM_KeyingBlurOperation.cc
@@ -96,4 +96,67 @@ bool KeyingBlurOperation::determineDependingAreaOfInterest(rcti *input,
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
+void KeyingBlurOperation::get_area_of_interest(const int UNUSED(input_idx),
+ const rcti &output_area,
+ rcti &r_input_area)
+{
+ switch (m_axis) {
+ case BLUR_AXIS_X:
+ r_input_area.xmin = output_area.xmin - m_size;
+ r_input_area.ymin = output_area.ymin;
+ r_input_area.xmax = output_area.xmax + m_size;
+ r_input_area.ymax = output_area.ymax;
+ break;
+ case BLUR_AXIS_Y:
+ r_input_area.xmin = output_area.xmin;
+ r_input_area.ymin = output_area.ymin - m_size;
+ r_input_area.xmax = output_area.xmax;
+ r_input_area.ymax = output_area.ymax + m_size;
+ break;
+ default:
+ BLI_assert_msg(0, "Unknown axis");
+ break;
+ }
+}
+
+void KeyingBlurOperation::update_memory_buffer_partial(MemoryBuffer *output,
+ const rcti &area,
+ Span<MemoryBuffer *> inputs)
+{
+ const MemoryBuffer *input = inputs[0];
+ BuffersIterator<float> it = output->iterate_with(inputs, area);
+
+ int coord_max;
+ int elem_stride;
+ std::function<int()> get_current_coord;
+ switch (m_axis) {
+ case BLUR_AXIS_X:
+ get_current_coord = [&] { return it.x; };
+ coord_max = this->getWidth();
+ elem_stride = input->elem_stride;
+ break;
+ case BLUR_AXIS_Y:
+ get_current_coord = [&] { return it.y; };
+ coord_max = this->getHeight();
+ elem_stride = input->row_stride;
+ break;
+ }
+
+ for (; !it.is_end(); ++it) {
+ const int coord = get_current_coord();
+ const int start_coord = MAX2(0, coord - m_size + 1);
+ const int end_coord = MIN2(coord_max, coord + m_size);
+ const int count = end_coord - start_coord;
+
+ float sum = 0.0f;
+ const float *start = it.in(0) + (start_coord - coord) * elem_stride;
+ const float *end = start + count * elem_stride;
+ for (const float *elem = start; elem < end; elem += elem_stride) {
+ sum += *elem;
+ }
+
+ *it.out = sum / count;
+ }
+}
+
} // namespace blender::compositor