diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-11-07 15:18:42 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-11-07 15:18:42 +0400 |
commit | 1c450d71efc1f86419ff74041efc0630d4f1ce09 (patch) | |
tree | 079e00aed6c82d9a423a4c094a3903c4abd23b73 /source/blender/blenkernel/intern/tracking.c | |
parent | 552c0e74f4027e0d11475ff395b5b2ce2dd0c9c0 (diff) |
Fixed crashes when motion tracks are zero-sized
This is probably versioning issue happened when both trunk and tomato
were mixed to work on the same file.
Anyway, there're few files here locally and it's probably other users
do have the same files, so lets keep things safe here :)
Diffstat (limited to 'source/blender/blenkernel/intern/tracking.c')
-rw-r--r-- | source/blender/blenkernel/intern/tracking.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 89446a1856f..b174f27b7e1 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -1624,6 +1624,9 @@ ImBuf *BKE_tracking_sample_pattern(int frame_width, int frame_height, ImBuf *sea double warped_position_x, warped_position_y; float *mask = NULL; + if (num_samples_x <= 0 || num_samples_y <= 0) + return NULL; + pattern_ibuf = IMB_allocImBuf(num_samples_x, num_samples_y, 32, IB_rectfloat); if (!search_ibuf->rect_float) { @@ -1690,10 +1693,15 @@ ImBuf *BKE_tracking_get_pattern_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, Mo search_ibuf = BKE_tracking_get_search_imbuf(ibuf, track, marker, anchored, disable_channels); - pattern_ibuf = BKE_tracking_sample_pattern(ibuf->x, ibuf->y, search_ibuf, track, marker, - FALSE, num_samples_x, num_samples_y, NULL); + if (search_ibuf) { + pattern_ibuf = BKE_tracking_sample_pattern(ibuf->x, ibuf->y, search_ibuf, track, marker, + FALSE, num_samples_x, num_samples_y, NULL); - IMB_freeImBuf(search_ibuf); + IMB_freeImBuf(search_ibuf); + } + else { + pattern_ibuf = NULL; + } return pattern_ibuf; } @@ -1718,6 +1726,9 @@ ImBuf *BKE_tracking_get_search_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, Mov w = (marker->search_max[0] - marker->search_min[0]) * ibuf->x; h = (marker->search_max[1] - marker->search_min[1]) * ibuf->y; + if (w <= 0 || h <= 0) + return NULL; + searchibuf = IMB_allocImBuf(w, h, 32, ibuf->rect_float ? IB_rectfloat : IB_rect); IMB_rectcpy(searchibuf, ibuf, 0, 0, x, y, w, h); @@ -2187,6 +2198,12 @@ static float *track_get_search_floatbuf(ImBuf *ibuf, MovieTrackingTrack *track, searchibuf = BKE_tracking_get_search_imbuf(ibuf, track, marker, FALSE, TRUE); + if (!searchibuf) { + *width_r = 0; + *height_r = 0; + return NULL; + } + width = searchibuf->x; height = searchibuf->y; @@ -2506,6 +2523,9 @@ int BKE_tracking_context_step(MovieTrackingContext *context) get_marker_coords_for_tracking(frame_width, frame_height, &track_context->marker, src_pixel_x, src_pixel_y); get_marker_coords_for_tracking(frame_width, frame_height, marker, dst_pixel_x, dst_pixel_y); + if (!patch_new || !track_context->search_area) + continue; + /* run the tracker! */ tracked = libmv_trackRegion(&options, track_context->search_area, |