diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-09-11 17:33:01 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-09-11 17:33:01 +0400 |
commit | ed6942f9ad3c9d79a4d3981da3c902ea9d7cacc0 (patch) | |
tree | e5ba8452a75fc0ee67e1d7be7cee1f78a93838d0 | |
parent | 4bbe0c8cded98d4daafe1707766041ca9b86db36 (diff) |
Fix wrong area of interest for movie undistortion
-rw-r--r-- | source/blender/blenkernel/BKE_tracking.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/tracking.c | 20 | ||||
-rw-r--r-- | source/blender/compositor/operations/COM_MovieDistortionOperation.cpp | 34 |
3 files changed, 31 insertions, 26 deletions
diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h index 6d155ba37de..8bc619c1b27 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 22005892535..b77cd744a18 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 eb8e5a8cc50..50fabb09dbb 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, |