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 :)
This commit is contained in:
@@ -1176,13 +1176,16 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip
|
||||
|
||||
search_ibuf = BKE_tracking_get_search_imbuf(ibuf, track, &undist_marker, TRUE, TRUE);
|
||||
|
||||
if (!search_ibuf->rect_float) {
|
||||
/* sampling happens in float buffer */
|
||||
IMB_float_from_rect(search_ibuf);
|
||||
if (search_ibuf) {
|
||||
if (!search_ibuf->rect_float) {
|
||||
/* sampling happens in float buffer */
|
||||
IMB_float_from_rect(search_ibuf);
|
||||
}
|
||||
|
||||
scopes->track_search = search_ibuf;
|
||||
}
|
||||
|
||||
scopes->undist_marker = undist_marker;
|
||||
scopes->track_search = search_ibuf;
|
||||
|
||||
scopes->frame_width = ibuf->x;
|
||||
scopes->frame_height = ibuf->y;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -151,22 +151,25 @@ KeyingScreenOperation::TriangulationData *KeyingScreenOperation::buildVoronoiTri
|
||||
pattern_ibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, marker, TRUE, FALSE);
|
||||
|
||||
zero_v3(site->color);
|
||||
for (j = 0; j < pattern_ibuf->x * pattern_ibuf->y; j++) {
|
||||
if (pattern_ibuf->rect_float) {
|
||||
add_v3_v3(site->color, &pattern_ibuf->rect_float[4 * j]);
|
||||
}
|
||||
else {
|
||||
unsigned char *rrgb = (unsigned char *)pattern_ibuf->rect;
|
||||
|
||||
site->color[0] += srgb_to_linearrgb((float)rrgb[4 * j + 0] / 255.0f);
|
||||
site->color[1] += srgb_to_linearrgb((float)rrgb[4 * j + 1] / 255.0f);
|
||||
site->color[2] += srgb_to_linearrgb((float)rrgb[4 * j + 2] / 255.0f);
|
||||
if (pattern_ibuf) {
|
||||
for (j = 0; j < pattern_ibuf->x * pattern_ibuf->y; j++) {
|
||||
if (pattern_ibuf->rect_float) {
|
||||
add_v3_v3(site->color, &pattern_ibuf->rect_float[4 * j]);
|
||||
}
|
||||
else {
|
||||
unsigned char *rrgb = (unsigned char *)pattern_ibuf->rect;
|
||||
|
||||
site->color[0] += srgb_to_linearrgb((float)rrgb[4 * j + 0] / 255.0f);
|
||||
site->color[1] += srgb_to_linearrgb((float)rrgb[4 * j + 1] / 255.0f);
|
||||
site->color[2] += srgb_to_linearrgb((float)rrgb[4 * j + 2] / 255.0f);
|
||||
}
|
||||
}
|
||||
|
||||
mul_v3_fl(site->color, 1.0f / (pattern_ibuf->x * pattern_ibuf->y));
|
||||
IMB_freeImBuf(pattern_ibuf);
|
||||
}
|
||||
|
||||
mul_v3_fl(site->color, 1.0f / (pattern_ibuf->x * pattern_ibuf->y));
|
||||
IMB_freeImBuf(pattern_ibuf);
|
||||
|
||||
site->co[0] = pos[0] * width;
|
||||
site->co[1] = pos[1] * height;
|
||||
|
||||
|
||||
@@ -1597,17 +1597,15 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
|
||||
&scopes->undist_marker, scopes->use_track_mask,
|
||||
width, height, scopes->track_pos);
|
||||
|
||||
if (tmpibuf->rect_float)
|
||||
IMB_rect_from_float(tmpibuf);
|
||||
if (tmpibuf) {
|
||||
if (tmpibuf->rect_float)
|
||||
IMB_rect_from_float(tmpibuf);
|
||||
|
||||
/* XXX: for debug only
|
||||
* tmpibuf->ftype = PNG;
|
||||
* IMB_saveiff(tmpibuf, "sample.png", IB_rect); */
|
||||
|
||||
if (tmpibuf->rect)
|
||||
scopes->track_preview = tmpibuf;
|
||||
else
|
||||
IMB_freeImBuf(tmpibuf);
|
||||
if (tmpibuf->rect)
|
||||
scopes->track_preview = tmpibuf;
|
||||
else
|
||||
IMB_freeImBuf(tmpibuf);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ok && scopes->track_preview) {
|
||||
|
||||
@@ -96,22 +96,25 @@ static void compute_gradient_screen(RenderData *rd, NodeKeyingScreenData *keying
|
||||
int j;
|
||||
|
||||
zero_v3(site->color);
|
||||
for (j = 0; j < pattern_ibuf->x * pattern_ibuf->y; j++) {
|
||||
if (pattern_ibuf->rect_float) {
|
||||
add_v3_v3(site->color, &pattern_ibuf->rect_float[4 * j]);
|
||||
}
|
||||
else {
|
||||
unsigned char *rrgb = (unsigned char *)pattern_ibuf->rect;
|
||||
|
||||
site->color[0] += srgb_to_linearrgb((float)rrgb[4 * j + 0] / 255.0f);
|
||||
site->color[1] += srgb_to_linearrgb((float)rrgb[4 * j + 1] / 255.0f);
|
||||
site->color[2] += srgb_to_linearrgb((float)rrgb[4 * j + 2] / 255.0f);
|
||||
if (pattern_ibuf) {
|
||||
for (j = 0; j < pattern_ibuf->x * pattern_ibuf->y; j++) {
|
||||
if (pattern_ibuf->rect_float) {
|
||||
add_v3_v3(site->color, &pattern_ibuf->rect_float[4 * j]);
|
||||
}
|
||||
else {
|
||||
unsigned char *rrgb = (unsigned char *)pattern_ibuf->rect;
|
||||
|
||||
site->color[0] += srgb_to_linearrgb((float)rrgb[4 * j + 0] / 255.0f);
|
||||
site->color[1] += srgb_to_linearrgb((float)rrgb[4 * j + 1] / 255.0f);
|
||||
site->color[2] += srgb_to_linearrgb((float)rrgb[4 * j + 2] / 255.0f);
|
||||
}
|
||||
}
|
||||
|
||||
mul_v3_fl(site->color, 1.0f / (pattern_ibuf->x * pattern_ibuf->y));
|
||||
IMB_freeImBuf(pattern_ibuf);
|
||||
}
|
||||
|
||||
mul_v3_fl(site->color, 1.0f / (pattern_ibuf->x * pattern_ibuf->y));
|
||||
IMB_freeImBuf(pattern_ibuf);
|
||||
|
||||
site->co[0] = marker->pos[0] * screenbuf->x;
|
||||
site->co[1] = marker->pos[1] * screenbuf->y;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user