[Bf-blender-cvs] [88289d8f844] master: Tracking: Cleanup, clear variable names and indentation
Sergey Sharybin
noreply at git.blender.org
Mon Nov 30 14:26:53 CET 2020
Commit: 88289d8f844d802c5f06da8b69f42d25e7e33b44
Author: Sergey Sharybin
Date: Mon Nov 30 12:35:51 2020 +0100
Branches: master
https://developer.blender.org/rB88289d8f844d802c5f06da8b69f42d25e7e33b44
Tracking: Cleanup, clear variable names and indentation
Should be no functional changes.
===================================================================
M source/blender/blenkernel/BKE_tracking.h
M source/blender/blenkernel/intern/tracking_auto.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h
index 2dab0a1030e..4dbc22ae18f 100644
--- a/source/blender/blenkernel/BKE_tracking.h
+++ b/source/blender/blenkernel/BKE_tracking.h
@@ -326,7 +326,7 @@ void BKE_tracking_refine_marker(struct MovieClip *clip,
struct AutoTrackContext *BKE_autotrack_context_new(struct MovieClip *clip,
struct MovieClipUser *user,
- const bool backwards);
+ const bool is_backwards);
bool BKE_autotrack_context_step(struct AutoTrackContext *context);
void BKE_autotrack_context_sync(struct AutoTrackContext *context);
void BKE_autotrack_context_sync_user(struct AutoTrackContext *context, struct MovieClipUser *user);
diff --git a/source/blender/blenkernel/intern/tracking_auto.c b/source/blender/blenkernel/intern/tracking_auto.c
index 7222f7346fc..deeaa85fa80 100644
--- a/source/blender/blenkernel/intern/tracking_auto.c
+++ b/source/blender/blenkernel/intern/tracking_auto.c
@@ -58,8 +58,34 @@ typedef struct AutoTrackOptions {
} AutoTrackOptions;
typedef struct AutoTrackContext {
- MovieClip *clips[MAX_ACCESSOR_CLIP];
+ /* Frame at which tracking process started.
+ * TODO(sergey): Disambiguate whether it is a scene or clip frame. */
+ int start_frame;
+
+ /* True when tracking backwards (from higher frame number to lower frame number.) */
+ bool is_backwards;
+
+ /* True when entire sequence is being tracked. */
+ bool is_sequence;
+
+ /* Movie clips used during the trackign process. */
int num_clips;
+ MovieClip *clips[MAX_ACCESSOR_CLIP];
+
+ /* Tracks for which the context has been created for.
+ * Most usually this is all track selected in the interface when tracking in initialized.
+ *
+ * NOTE: Actually being-tracked tracks is a subset of those, as the tracker might loose track of
+ * where markers are. For example, if feature gets occluded, corresponding marker can not be
+ * tracked, and hence track is considered finished.
+ *
+ * The need of knowledge of all tracks which might potentially be modified during tracking comes
+ * form plane tracks: plane tracks needs adjustment if any of their tracks changed during
+ * tracking.
+ *
+ * Indexed by AutoTrackOptions::track_index. */
+ int num_input_tracks;
+ MovieTrackingTrack **input_tracks;
MovieClipUser user;
int frame_width, frame_height;
@@ -67,14 +93,8 @@ typedef struct AutoTrackContext {
struct libmv_AutoTrack *autotrack;
TrackingImageAccessor *image_accessor;
- int num_tracks; /* Number of tracks being tracked. */
- AutoTrackOptions *options; /* Per-tracking track options. */
-
- /* Array of all tracks, indexed by track_index. */
- MovieTrackingTrack **tracks;
+ AutoTrackOptions *track_options; /* Per-tracking track options. */
- bool backwards;
- int first_frame;
int sync_frame;
bool first_sync;
SpinLock spin_lock;
@@ -306,12 +326,12 @@ static void create_per_track_tracking_options(const MovieClip *clip,
/* Count number of trackable tracks. */
LISTBASE_FOREACH (MovieTrackingTrack *, track, tracksbase) {
if (check_track_trackable(clip, track, user)) {
- context->num_tracks++;
+ context->num_input_tracks++;
}
}
/* Allocate required memory. */
- context->options = MEM_callocN(sizeof(AutoTrackOptions) * context->num_tracks,
- "auto track options");
+ context->track_options = MEM_callocN(sizeof(AutoTrackOptions) * context->num_input_tracks,
+ "auto track options");
/* Fill in all the settings. */
int i = 0, track_index = 0;
LISTBASE_FOREACH (MovieTrackingTrack *, track, tracksbase) {
@@ -319,21 +339,25 @@ static void create_per_track_tracking_options(const MovieClip *clip,
track_index++;
continue;
}
- AutoTrackOptions *options = &context->options[i++];
+
+ AutoTrackOptions *track_options = &context->track_options[i++];
+
/* TODO(sergey): Single clip only for now. */
- options->clip_index = 0;
- options->track_index = track_index;
- options->track = track;
- tracking_configure_tracker(track, NULL, &options->track_region_options);
- options->use_keyframe_match = track->pattern_match == TRACK_MATCH_KEYFRAME;
- context->tracks[track_index] = track;
+ track_options->clip_index = 0;
+ track_options->track_index = track_index;
+ track_options->track = track;
+ track_options->use_keyframe_match = (track->pattern_match == TRACK_MATCH_KEYFRAME);
+
+ tracking_configure_tracker(track, NULL, &track_options->track_region_options);
+
+ context->input_tracks[track_index] = track;
track_index++;
}
}
AutoTrackContext *BKE_autotrack_context_new(MovieClip *clip,
MovieClipUser *user,
- const bool backwards)
+ const bool is_backwards)
{
AutoTrackContext *context = MEM_callocN(sizeof(AutoTrackContext), "autotrack context");
MovieTracking *tracking = &clip->tracking;
@@ -349,22 +373,22 @@ AutoTrackContext *BKE_autotrack_context_new(MovieClip *clip,
context->user.render_flag = 0;
context->frame_width = frame_width;
context->frame_height = frame_height;
- context->backwards = backwards;
- context->first_frame = user->framenr;
+ context->is_backwards = is_backwards;
+ context->start_frame = user->framenr;
context->sync_frame = user->framenr;
context->first_sync = true;
BLI_spin_init(&context->spin_lock);
const int num_total_tracks = BLI_listbase_count(tracksbase);
- context->tracks = MEM_callocN(sizeof(MovieTrackingTrack *) * num_total_tracks,
- "auto track pointers");
+ context->input_tracks = MEM_callocN(sizeof(MovieTrackingTrack *) * num_total_tracks,
+ "auto track pointers");
/* Initialize image accessor. */
context->image_accessor = tracking_image_accessor_new(
- context->clips, 1, context->tracks, num_total_tracks, user->framenr);
+ context->clips, 1, context->input_tracks, num_total_tracks, user->framenr);
/* Initialize auto track context and provide all information about currently
* tracked markers.
*/
context->autotrack = libmv_autoTrackNew(context->image_accessor->libmv_accessor);
- fill_autotrack_tracks(frame_width, frame_height, tracksbase, backwards, context->autotrack);
+ fill_autotrack_tracks(frame_width, frame_height, tracksbase, is_backwards, context->autotrack);
/* Create per-track tracking options. */
create_per_track_tracking_options(clip, user, tracksbase, context);
return context;
@@ -375,19 +399,24 @@ static void autotrack_context_step_cb(void *__restrict userdata,
const TaskParallelTLS *__restrict UNUSED(tls))
{
AutoTrackContext *context = userdata;
- const int frame_delta = context->backwards ? -1 : 1;
+ const int frame_delta = context->is_backwards ? -1 : 1;
- AutoTrackOptions *options = &context->options[track];
- if (options->is_failed) {
+ AutoTrackOptions *track_options = &context->track_options[track];
+ if (track_options->is_failed) {
return;
}
+
+ const int track_index = track_options->track_index;
+ const int clip_index = track_options->clip_index;
+
libmv_Marker libmv_current_marker, libmv_reference_marker, libmv_tracked_marker;
libmv_TrackRegionResult libmv_result;
- const int frame = BKE_movieclip_remap_scene_to_clip_frame(context->clips[options->clip_index],
- context->user.framenr);
+
+ MovieClip *clip = context->clips[clip_index];
+ const int frame = BKE_movieclip_remap_scene_to_clip_frame(clip, context->user.framenr);
BLI_spin_lock(&context->spin_lock);
const bool has_marker = libmv_autoTrackGetMarker(
- context->autotrack, options->clip_index, frame, options->track_index, &libmv_current_marker);
+ context->autotrack, clip_index, frame, track_index, &libmv_current_marker);
BLI_spin_unlock(&context->spin_lock);
/* Check whether we've got marker to sync with. */
if (!has_marker) {
@@ -395,7 +424,7 @@ static void autotrack_context_step_cb(void *__restrict userdata,
}
/* Check whether marker is going outside of allowed frame margin. */
if (!tracking_check_marker_margin(&libmv_current_marker,
- options->track->margin,
+ track_options->track->margin,
context->frame_width,
context->frame_height)) {
return;
@@ -403,12 +432,12 @@ static void autotrack_context_step_cb(void *__restrict userdata,
libmv_tracked_marker = libmv_current_marker;
libmv_tracked_marker.frame = frame + frame_delta;
/* Update reference frame. */
- if (options->use_keyframe_match) {
+ if (track_options->use_keyframe_match) {
libmv_tracked_marker.reference_frame = libmv_current_marker.reference_frame;
libmv_autoTrackGetMarker(context->autotrack,
- options->clip_index,
+ track_options->clip_index,
libmv_tracked_marker.reference_frame,
- options->track_index,
+ track_options->track_index,
&libmv_reference_marker);
}
else {
@@ -417,7 +446,7 @@ static void autotrack_context_step_cb(void *__restrict userdata,
}
/* Perform actual tracking. */
if (libmv_autoTrackMarker(context->autotrack,
- &options->track_region_options,
+ &track_options->track_region_options,
&libmv_tracked_marker,
&libmv_result)) {
BLI_spin_lock(&context->spin_lock);
@@ -425,8 +454,8 @@ static void autotrack_context_step_cb(void *__restrict userdata,
BLI_spin_unlock(&context->spin_lock);
}
else {
- options->is_failed = true;
- options->failed_fram
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list