[Bf-blender-cvs] [ed6942f] master: Fix wrong area of interest for movie undistortion

Sergey Sharybin noreply at git.blender.org
Thu Sep 11 15:33:18 CEST 2014


Commit: ed6942f9ad3c9d79a4d3981da3c902ea9d7cacc0
Author: Sergey Sharybin
Date:   Thu Sep 11 19:33:01 2014 +0600
Branches: master
https://developer.blender.org/rBed6942f9ad3c9d79a4d3981da3c902ea9d7cacc0

Fix wrong area of interest for movie undistortion

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

M	source/blender/blenkernel/BKE_tracking.h
M	source/blender/blenkernel/intern/tracking.c
M	source/blender/compositor/operations/COM_MovieDistortionOperation.cpp

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

diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h
index 6d155ba..8bc619c 100644
--- a/source/blender/blenkernel/BKE_tracking.h
+++ b/source/blender/blenkernel/BKE_tracking.h
@@ -193,7 +193,8 @@ struct ImBuf *BKE_tracking_undistort_frame(struct MovieTracking *tracking, struc
 struct ImBuf *BKE_tracking_distort_frame(struct MovieTracking *tracking, struct ImBuf *ibuf,
                                          int calibration_width, int calibration_height, float overscan);
 
-void BKE_tracking_max_undistortion_delta_across_bound(struct MovieTracking *tracking, struct rcti *rect, float delta[2]);
+void BKE_tracking_max_distortion_delta_across_bound(struct MovieTracking *tracking, struct rcti *rect,
+                                                    bool undistort, float delta[2]);
 
 /* **** Image sampling **** */
 struct ImBuf *BKE_tracking_sample_pattern(int frame_width, int frame_height,
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index 2200589..b77cd74 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -1891,11 +1891,21 @@ ImBuf *BKE_tracking_distort_frame(MovieTracking *tracking, ImBuf *ibuf, int cali
 	                                    calibration_height, overscan, false);
 }
 
-void BKE_tracking_max_undistortion_delta_across_bound(MovieTracking *tracking, rcti *rect, float delta[2])
+void BKE_tracking_max_distortion_delta_across_bound(MovieTracking *tracking, rcti *rect,
+                                                    bool undistort, float delta[2])
 {
 	int a;
 	float pos[2], warped_pos[2];
 	const int coord_delta = 5;
+	void (*apply_distortion) (MovieTracking *tracking,
+	                         const float pos[2], float out[2]);
+
+	if (undistort) {
+		apply_distortion = BKE_tracking_undistort_v2;
+	}
+	else {
+		apply_distortion = BKE_tracking_distort_v2;
+	}
 
 	delta[0] = delta[1] = -FLT_MAX;
 
@@ -1907,7 +1917,7 @@ void BKE_tracking_max_undistortion_delta_across_bound(MovieTracking *tracking, r
 		pos[0] = a;
 		pos[1] = rect->ymin;
 
-		BKE_tracking_undistort_v2(tracking, pos, warped_pos);
+		apply_distortion(tracking, pos, warped_pos);
 
 		delta[0] = max_ff(delta[0], fabsf(pos[0] - warped_pos[0]));
 		delta[1] = max_ff(delta[1], fabsf(pos[1] - warped_pos[1]));
@@ -1916,7 +1926,7 @@ void BKE_tracking_max_undistortion_delta_across_bound(MovieTracking *tracking, r
 		pos[0] = a;
 		pos[1] = rect->ymax;
 
-		BKE_tracking_undistort_v2(tracking, pos, warped_pos);
+		apply_distortion(tracking, pos, warped_pos);
 
 		delta[0] = max_ff(delta[0], fabsf(pos[0] - warped_pos[0]));
 		delta[1] = max_ff(delta[1], fabsf(pos[1] - warped_pos[1]));
@@ -1933,7 +1943,7 @@ void BKE_tracking_max_undistortion_delta_across_bound(MovieTracking *tracking, r
 		pos[0] = rect->xmin;
 		pos[1] = a;
 
-		BKE_tracking_undistort_v2(tracking, pos, warped_pos);
+		apply_distortion(tracking, pos, warped_pos);
 
 		delta[0] = max_ff(delta[0], fabsf(pos[0] - warped_pos[0]));
 		delta[1] = max_ff(delta[1], fabsf(pos[1] - warped_pos[1]));
@@ -1942,7 +1952,7 @@ void BKE_tracking_max_undistortion_delta_across_bound(MovieTracking *tracking, r
 		pos[0] = rect->xmax;
 		pos[1] = a;
 
-		BKE_tracking_undistort_v2(tracking, pos, warped_pos);
+		apply_distortion(tracking, pos, warped_pos);
 
 		delta[0] = max_ff(delta[0], fabsf(pos[0] - warped_pos[0]));
 		delta[1] = max_ff(delta[1], fabsf(pos[1] - warped_pos[1]));
diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp
index eb8e5a8..50fabb0 100644
--- a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp
@@ -73,26 +73,20 @@ void MovieDistortionOperation::initExecution()
 			}
 		}
 
-		if (this->m_distortion) {
-			float delta[2];
-			rcti full_frame;
-			full_frame.xmin = full_frame.ymin = 0;
-			full_frame.xmax = this->m_width;
-			full_frame.ymax = this->m_height;
-			BKE_tracking_max_undistortion_delta_across_bound(&this->m_movieClip->tracking, &full_frame, delta);
-
-			/* 5 is just in case we didn't hit real max of distortion in
-			 * BKE_tracking_max_undistortion_delta_across_bound
-			 */
-			m_margin[0] = delta[0] + 5;
-			m_margin[1] = delta[1] + 5;
-		}
-		else {
-			/* undistortion with sane distortion coefficients would be mapped inside
-			 * of each tile, should be no need in margin in this case
-			 */
-			m_margin[0] = m_margin[1] = 0;
-		}
+		float delta[2];
+		rcti full_frame;
+		full_frame.xmin = full_frame.ymin = 0;
+		full_frame.xmax = this->m_width;
+		full_frame.ymax = this->m_height;
+		BKE_tracking_max_distortion_delta_across_bound(
+			&this->m_movieClip->tracking, &full_frame,
+			!this->m_distortion, delta);
+
+		/* 5 is just in case we didn't hit real max of distortion in
+		 * BKE_tracking_max_undistortion_delta_across_bound
+		 */
+		m_margin[0] = delta[0] + 5;
+		m_margin[1] = delta[1] + 5;
 
 		DistortionCache *newC = new DistortionCache(this->m_movieClip,
 		                                            this->m_width, this->m_height,




More information about the Bf-blender-cvs mailing list