[Bf-blender-cvs] [d567259] libmv_prediction: Libmv: Fix wrong search area clamping in frame accessor

Sergey Sharybin noreply at git.blender.org
Thu Oct 23 11:40:47 CEST 2014


Commit: d567259d32f17d1d0d0811e3e6489474fd3097db
Author: Sergey Sharybin
Date:   Thu Oct 23 11:39:55 2014 +0200
Branches: libmv_prediction
https://developer.blender.org/rBd567259d32f17d1d0d0811e3e6489474fd3097db

Libmv: Fix wrong search area clamping in frame accessor

Not sure who was that smart to make it wrong :)

Hopefully it'll fix the "magnetic" borders reported by Sebastian,
when the marker gets "attracted" by the frame bounds.

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

M	source/blender/blenkernel/intern/tracking_util.c

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

diff --git a/source/blender/blenkernel/intern/tracking_util.c b/source/blender/blenkernel/intern/tracking_util.c
index 8b2e45f..f64840f 100644
--- a/source/blender/blenkernel/intern/tracking_util.c
+++ b/source/blender/blenkernel/intern/tracking_util.c
@@ -694,16 +694,18 @@ static ImBuf *accessor_get_ibuf(TrackingImageAccessor *accessor,
 		 * the data we can.
 		 */
 		int clamped_origin_x = max_ii((int)region->min[0], 0),
-			clamped_origin_y = max_ii((int)region->min[1], 0);
-		int clamped_width = min_ii(width, orig_ibuf->x - region->min[0] - 1),
-			clamped_height = min_ii(height, orig_ibuf->y - region->min[1] - 1);
+		    clamped_origin_y = max_ii((int)region->min[1], 0);
+		int dst_offset_x = clamped_origin_x - (int)region->min[0],
+		    dst_offset_y = clamped_origin_y - (int)region->min[1];
+		int clamped_width = width - dst_offset_x,
+		    clamped_height = height - dst_offset_y;
 
 		final_ibuf = IMB_allocImBuf(width, height, 32, IB_rectfloat);
 
 		if (orig_ibuf->rect_float != NULL) {
 			IMB_rectcpy(final_ibuf, orig_ibuf,
-			            0, 0,
-			            region->min[0], region->min[1],
+			            dst_offset_x, dst_offset_y,
+			            clamped_origin_x, clamped_origin_y,
 			            clamped_width, clamped_height);
 		}
 		else {
@@ -717,8 +719,10 @@ static ImBuf *accessor_get_ibuf(TrackingImageAccessor *accessor,
 				for (x = 0; x < clamped_width; ++x) {
 					int src_x = x + clamped_origin_x,
 					    src_y = y + clamped_origin_y;
-					int dst_index = (y * width + x) * 4,
-						src_index = (src_y * orig_ibuf->x + src_x) * 4;
+					int dst_x = x + dst_offset_x,
+					    dst_y = y + dst_offset_y;
+					int dst_index = (dst_y * width + dst_x) * 4,
+					    src_index = (src_y * orig_ibuf->x + src_x) * 4;
 					rgba_uchar_to_float(final_ibuf->rect_float + dst_index,
 					                    (unsigned char *)orig_ibuf->rect +
 					                                     src_index);




More information about the Bf-blender-cvs mailing list