Speedup track preview widget for byte images
This gives a huge speedup gain for cases when you've got rather huge markers on a byte images. Done by skipping IMB_float_from_rect()/IMB_rect_from_float() for such cases. We can sample the buffers without color space conversion.
This commit is contained in:
@@ -1243,7 +1243,6 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip
|
||||
scopes->track_disabled = false;
|
||||
|
||||
if (ibuf && (ibuf->rect || ibuf->rect_float)) {
|
||||
ImBuf *search_ibuf;
|
||||
MovieTrackingMarker undist_marker = *marker;
|
||||
|
||||
if (user->render_flag & MCLIP_PROXY_RENDER_UNDISTORT) {
|
||||
@@ -1261,16 +1260,7 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip
|
||||
undist_marker.pos[1] /= height * aspy;
|
||||
}
|
||||
|
||||
search_ibuf = BKE_tracking_get_search_imbuf(ibuf, track, &undist_marker, true, true);
|
||||
|
||||
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->track_search = BKE_tracking_get_search_imbuf(ibuf, track, &undist_marker, true, true);
|
||||
|
||||
scopes->undist_marker = undist_marker;
|
||||
|
||||
|
||||
@@ -1981,11 +1981,9 @@ ImBuf *BKE_tracking_sample_pattern(int frame_width, int frame_height, ImBuf *sea
|
||||
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) {
|
||||
IMB_float_from_rect(search_ibuf);
|
||||
}
|
||||
pattern_ibuf = IMB_allocImBuf(num_samples_x, num_samples_y,
|
||||
32,
|
||||
search_ibuf->rect_float ? IB_rectfloat : IB_rect);
|
||||
|
||||
tracking_get_marker_coords_for_tracking(frame_width, frame_height, marker, src_pixel_x, src_pixel_y);
|
||||
|
||||
@@ -2015,10 +2013,26 @@ ImBuf *BKE_tracking_sample_pattern(int frame_width, int frame_height, ImBuf *sea
|
||||
mask = BKE_tracking_track_get_mask(frame_width, frame_height, track, marker);
|
||||
}
|
||||
|
||||
libmv_samplePlanarPatch(search_ibuf->rect_float, search_ibuf->x, search_ibuf->y, 4,
|
||||
src_pixel_x, src_pixel_y, num_samples_x,
|
||||
num_samples_y, mask, pattern_ibuf->rect_float,
|
||||
&warped_position_x, &warped_position_y);
|
||||
if (search_ibuf->rect_float) {
|
||||
libmv_samplePlanarPatch(search_ibuf->rect_float,
|
||||
search_ibuf->x, search_ibuf->y, 4,
|
||||
src_pixel_x, src_pixel_y,
|
||||
num_samples_x, num_samples_y,
|
||||
mask,
|
||||
pattern_ibuf->rect_float,
|
||||
&warped_position_x,
|
||||
&warped_position_y);
|
||||
}
|
||||
else {
|
||||
libmv_samplePlanarPatchByte((unsigned char *) search_ibuf->rect,
|
||||
search_ibuf->x, search_ibuf->y, 4,
|
||||
src_pixel_x, src_pixel_y,
|
||||
num_samples_x, num_samples_y,
|
||||
mask,
|
||||
(unsigned char *) pattern_ibuf->rect,
|
||||
&warped_position_x,
|
||||
&warped_position_y);
|
||||
}
|
||||
|
||||
if (pos) {
|
||||
pos[0] = warped_position_x;
|
||||
|
||||
@@ -1522,9 +1522,9 @@ void ui_draw_but_TRACKPREVIEW(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wc
|
||||
IMB_freeImBuf(scopes->track_preview);
|
||||
|
||||
tmpibuf = BKE_tracking_sample_pattern(scopes->frame_width, scopes->frame_height,
|
||||
scopes->track_search, scopes->track,
|
||||
&scopes->undist_marker, true, scopes->use_track_mask,
|
||||
width, height, scopes->track_pos);
|
||||
scopes->track_search, scopes->track,
|
||||
&scopes->undist_marker, true, scopes->use_track_mask,
|
||||
width, height, scopes->track_pos);
|
||||
|
||||
if (tmpibuf) {
|
||||
if (tmpibuf->rect_float)
|
||||
|
||||
Reference in New Issue
Block a user