Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey@blender.org>2020-11-30 17:55:52 +0300
committerSergey Sharybin <sergey@blender.org>2020-11-30 18:24:11 +0300
commit0f30edc20c6206b40216b162fa435d23562127f8 (patch)
treeec5e4345fd0d8a818ecfa44f37300435c877410a /source/blender
parent13ce25d24c9d667282784f34fd5e5e875b350c91 (diff)
Tracking: Make image accessor own what it needs
Previously image accessor was sharing array pointer for tracks access. Now it is possible to pass a temporary array valid only during the initialization process. Should be no functional changes.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/tracking_util.c6
-rw-r--r--source/blender/blenkernel/tracking_private.h11
2 files changed, 16 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/tracking_util.c b/source/blender/blenkernel/intern/tracking_util.c
index 7146be1d521..eb57c28de09 100644
--- a/source/blender/blenkernel/intern/tracking_util.c
+++ b/source/blender/blenkernel/intern/tracking_util.c
@@ -1021,7 +1021,10 @@ TrackingImageAccessor *tracking_image_accessor_new(MovieClip *clips[MAX_ACCESSOR
memcpy(accessor->clips, clips, num_clips * sizeof(MovieClip *));
accessor->num_clips = num_clips;
- accessor->tracks = tracks;
+
+ accessor->tracks = MEM_malloc_arrayN(
+ num_tracks, sizeof(MovieTrackingTrack *), "image accessor tracks");
+ memcpy(accessor->tracks, tracks, num_tracks * sizeof(MovieTrackingTrack *));
accessor->num_tracks = num_tracks;
accessor->libmv_accessor = libmv_FrameAccessorNew((libmv_FrameAccessorUserData *)accessor,
@@ -1040,5 +1043,6 @@ void tracking_image_accessor_destroy(TrackingImageAccessor *accessor)
IMB_moviecache_free(accessor->cache);
libmv_FrameAccessorDestroy(accessor->libmv_accessor);
BLI_spin_end(&accessor->cache_lock);
+ MEM_freeN(accessor->tracks);
MEM_freeN(accessor);
}
diff --git a/source/blender/blenkernel/tracking_private.h b/source/blender/blenkernel/tracking_private.h
index 5bd4baa536d..64db84d5ac3 100644
--- a/source/blender/blenkernel/tracking_private.h
+++ b/source/blender/blenkernel/tracking_private.h
@@ -132,14 +132,25 @@ struct libmv_FrameAccessor;
#define MAX_ACCESSOR_CLIP 64
typedef struct TrackingImageAccessor {
struct MovieCache *cache;
+
struct MovieClip *clips[MAX_ACCESSOR_CLIP];
int num_clips;
+
+ /* Array of tracks which are being tracked.
+ * Points to actual track from the `MovieClip` (or multiple of them).
+ * This accessor owns the array, but not the tracks themselves. */
struct MovieTrackingTrack **tracks;
int num_tracks;
+
struct libmv_FrameAccessor *libmv_accessor;
SpinLock cache_lock;
} TrackingImageAccessor;
+/* Clips are used to access images of an actual footage.
+ * Tracks are used to access masks associated with the tracks.
+ *
+ * NOTE: Both clips and tracks arrays are copied into the image accessor. It means that the caller
+ * is allowed to pass temporary arrays which are only valid during initialization. */
TrackingImageAccessor *tracking_image_accessor_new(MovieClip *clips[MAX_ACCESSOR_CLIP],
int num_clips,
MovieTrackingTrack **tracks,