[Bf-blender-cvs] [efafe7474dd] compositor-full-frame: Compositor: Fix dilare erode reading input out of bounds

Manuel Castilla noreply at git.blender.org
Fri Aug 20 17:34:37 CEST 2021


Commit: efafe7474ddfc993b63524983e6d8de7f86feae5
Author: Manuel Castilla
Date:   Fri Aug 20 17:12:48 2021 +0200
Branches: compositor-full-frame
https://developer.blender.org/rBefafe7474ddfc993b63524983e6d8de7f86feae5

Compositor: Fix dilare erode reading input out of bounds

Happened when output area was partial horizontally, for example
when using a viewer border.

===================================================================

M	source/blender/compositor/operations/COM_DilateErodeOperation.cc

===================================================================

diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cc b/source/blender/compositor/operations/COM_DilateErodeOperation.cc
index 1a413257f00..cf59872165d 100644
--- a/source/blender/compositor/operations/COM_DilateErodeOperation.cc
+++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cc
@@ -723,11 +723,9 @@ static void step_update_memory_buffer(MemoryBuffer *output,
   const int bwidth = area.xmax - area.xmin;
   const int bheight = area.ymax - area.ymin;
 
-  /* NOTE: #result has area width, but new height.
-   * We have to calculate the additional rows in the first pass,
-   * to have valid data available for the second pass. */
+  /* Create a buffer with the area needed for horizontal and vertical passes. */
   rcti result_area;
-  BLI_rcti_init(&result_area, area.xmin, area.xmax, ymin, ymax);
+  BLI_rcti_init(&result_area, xmin, xmax, ymin, ymax);
   MemoryBuffer result(DataType::Value, result_area);
 
   /* #temp holds maxima for every step in the algorithm, #buf holds a
@@ -764,12 +762,12 @@ static void step_update_memory_buffer(MemoryBuffer *output,
   }
 
   /* Second pass, vertical dilate/erode. */
-  for (int x = 0; x < bwidth; x++) {
+  for (int x = xmin; x < xmax; x++) {
     for (int y = 0; y < bheight + 5 * half_window; y++) {
       buf[y] = compare_min_value;
     }
     for (int y = ymin; y < ymax; y++) {
-      buf[y - area.ymin + window - 1] = result.get_value(x + area.xmin, y, 0);
+      buf[y - area.ymin + window - 1] = result.get_value(x, y, 0);
     }
 
     for (int i = 0; i < (bheight + 3 * half_window) / window; i++) {



More information about the Bf-blender-cvs mailing list