36 for (
int i = 0;
i < num_pixels;
i++) {
37 const float *pixel = rgba + 4 *
i;
39 gray[
i] = weight_red * pixel[0] + weight_green * pixel[1] + weight_blue * pixel[2];
50 for (
int i = 0;
i < num_pixels;
i++) {
51 const uchar *pixel = rgba +
i * 4;
53 gray[
i] = (weight_red * pixel[0] + weight_green * pixel[1] + weight_blue * pixel[2]) / 255.0f;
76 width = searchibuf->
x;
77 height = searchibuf->
y;
83 searchibuf->
float_buffer.
data, gray_pixels, width * height, 0.2126f, 0.7152f, 0.0722f);
87 searchibuf->
byte_buffer.
data, gray_pixels, width * height, 0.2126f, 0.7152f, 0.0722f);
130 if (marker_keyed ==
nullptr) {
134 keyed_framenr = marker_keyed->
framenr;
136 *r_marker_keyed = marker_keyed;
150 ImBuf *ibuf =
nullptr;
154 clip, user, clip_flag, track, curfra, backwards, reference_marker);
168 const bool is_backwards,
190 options->image1_mask =
nullptr;
204 float *reference_search_area,
205 int reference_search_area_width,
206 int reference_search_area_height,
208 const bool is_backward,
209 double dst_pixel_x[5],
210 double dst_pixel_y[5])
213 double src_pixel_x[5], src_pixel_y[5];
221 int new_search_area_width, new_search_area_height;
222 int frame_width, frame_height;
226 frame_width = destination_ibuf->
x;
227 frame_height = destination_ibuf->
y;
234 destination_ibuf, track, marker, &new_search_area_width, &new_search_area_height);
242 frame_width, frame_height, reference_marker, src_pixel_x, src_pixel_y);
244 frame_width, frame_height, marker, dst_pixel_x, dst_pixel_y);
246 if (patch_new ==
nullptr || reference_search_area ==
nullptr) {
252 reference_search_area,
253 reference_search_area_width,
254 reference_search_area_height,
256 new_search_area_width,
257 new_search_area_height,
272 int *reference_framenr)
278 while (reference >= first_marker && reference <= last_marker &&
289 if (reference < first_marker || reference > last_marker) {
293 *reference_framenr = reference->
framenr;
303 ImBuf *reference_ibuf, *destination_ibuf;
304 float *search_area, *
mask =
nullptr;
305 int frame_width, frame_height;
306 int search_area_height, search_area_width;
308 int reference_framenr;
310 double dst_pixel_x[5], dst_pixel_y[5];
324 clip, &user, clip_flag, track, reference_framenr, backwards, &reference_marker);
325 if (reference_ibuf ==
nullptr) {
330 if (reference_marker == marker) {
336 if (destination_ibuf ==
nullptr) {
343 reference_ibuf, track, reference_marker, &search_area_width, &search_area_height);
366 frame_width, frame_height, marker, dst_pixel_x, dst_pixel_y);
#define MOVIECLIP_CACHE_SKIP
void BKE_movieclip_get_size(struct MovieClip *clip, const struct MovieClipUser *user, int *r_width, int *r_height)
float BKE_movieclip_remap_clip_to_scene_frame(const struct MovieClip *clip, float framenr)
struct ImBuf * BKE_movieclip_get_ibuf_flag(struct MovieClip *clip, const struct MovieClipUser *user, int flag, int cache_flag)
struct MovieTrackingMarker * BKE_tracking_marker_get(struct MovieTrackingTrack *track, int framenr)
struct ImBuf * BKE_tracking_get_search_imbuf(const struct ImBuf *ibuf, const struct MovieTrackingTrack *track, const struct MovieTrackingMarker *marker, bool anchored, bool disable_channels)
float * BKE_tracking_track_get_mask(int frame_width, int frame_height, const struct MovieTrackingTrack *track, const struct MovieTrackingMarker *marker)
#define DNA_struct_default_get(struct_name)
@ TRACK_ALGORITHM_FLAG_USE_NORMALIZATION
@ TRACK_ALGORITHM_FLAG_USE_BRUTE
@ TRACK_ALGORITHM_FLAG_USE_MASK
void IMB_freeImBuf(ImBuf *ibuf)
Read Guarded memory(de)allocation.
CCL_NAMESPACE_BEGIN struct Options options
@ LIBMV_TRACK_REGION_FORWARD
@ LIBMV_TRACK_REGION_BACKWARD
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer
float minimum_correlation
MovieTrackingMarker * markers
int libmv_trackRegion(const libmv_TrackRegionOptions *, const float *, int, int, const float *, int, int, const double *x1, const double *y1, libmv_TrackRegionResult *result, double *x2, double *y2)
void BKE_tracking_refine_marker(MovieClip *clip, MovieTrackingTrack *track, MovieTrackingMarker *marker, bool backwards)
static bool refine_marker_reference_frame_get(MovieTrackingTrack *track, MovieTrackingMarker *marker, bool backwards, int *reference_framenr)
static ImBuf * tracking_context_get_keyframed_ibuf(MovieClip *clip, MovieClipUser *user, int clip_flag, MovieTrackingTrack *track, int curfra, bool backwards, MovieTrackingMarker **r_marker_keyed)
static void float_rgba_to_gray(const float *rgba, float *gray, int num_pixels, float weight_red, float weight_green, float weight_blue)
static void uint8_rgba_to_float_gray(const uchar *rgba, float *gray, int num_pixels, float weight_red, float weight_green, float weight_blue)
static ImBuf * tracking_context_get_reference_ibuf(MovieClip *clip, MovieClipUser *user, int clip_flag, MovieTrackingTrack *track, int curfra, bool backwards, MovieTrackingMarker **reference_marker)
static bool configure_and_run_tracker(ImBuf *destination_ibuf, MovieTrackingTrack *track, MovieTrackingMarker *reference_marker, MovieTrackingMarker *marker, float *reference_search_area, int reference_search_area_width, int reference_search_area_height, float *mask, const bool is_backward, double dst_pixel_x[5], double dst_pixel_y[5])
static float * track_get_search_floatbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTrackingMarker *marker, int *r_width, int *r_height)
void tracking_configure_tracker(const MovieTrackingTrack *track, float *mask, const bool is_backwards, libmv_TrackRegionOptions *options)
static ImBuf * tracking_context_get_frame_ibuf(MovieClip *clip, MovieClipUser *user, int clip_flag, int framenr)
void tracking_get_marker_coords_for_tracking(int frame_width, int frame_height, const MovieTrackingMarker *marker, double search_pixel_x[5], double search_pixel_y[5])
MovieTrackingMarker * tracking_get_keyframed_marker(MovieTrackingTrack *track, int current_frame, bool backwards)
void tracking_set_marker_coords_from_tracking(int frame_width, int frame_height, MovieTrackingMarker *marker, const double search_pixel_x[5], const double search_pixel_y[5])