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.vfx@gmail.com>2017-08-14 12:41:12 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-08-14 12:43:19 +0300
commita850235a44207d856644cab38a1155a85d90337a (patch)
tree4b086840edcfdd461bb72a5b4bc316b195b98908
parentba84eb0f19224987a3158ea333cac76554f2a904 (diff)
Fix T51850: Motion tracking - poor performance with keyframe matching on large video
Enabled cache for frame accessor and tweaked policy so we guarantee keyframed images to be always in the cache. The logic might fail in some real corner case (for example, when doing multiple tracks at once on a system where we can not fit 2 clip frames in cache) but things are much better now for regular use.
-rw-r--r--source/blender/blenkernel/intern/tracking_util.c46
1 files changed, 18 insertions, 28 deletions
diff --git a/source/blender/blenkernel/intern/tracking_util.c b/source/blender/blenkernel/intern/tracking_util.c
index bf2dabfab8b..b1a092517de 100644
--- a/source/blender/blenkernel/intern/tracking_util.c
+++ b/source/blender/blenkernel/intern/tracking_util.c
@@ -597,11 +597,6 @@ static void accesscache_put(TrackingImageAccessor *accessor,
int64_t transform_key,
ImBuf *ibuf)
{
- /* Currently we don't want global memory limiter to be tossing our cached
- * frames from tracking context. We are controlling what we want to be cached
- * from our side.
- */
- ibuf->userflags |= IB_PERSISTENT;
AccessCacheKey key;
accesscache_construct_key(&key, clip_index, frame, input_mode, downscale,
region, transform_key);
@@ -721,7 +716,14 @@ static ImBuf *accessor_get_ibuf(TrackingImageAccessor *accessor,
transform_key);
BLI_spin_unlock(&accessor->cache_lock);
if (ibuf != NULL) {
- CACHE_PRINTF("Used buffer from cache for frame %d\n", frame);
+ CACHE_PRINTF("Used cached buffer for frame %d\n", frame);
+ /* This is a little heuristic here: if we re-used image once, this is
+ * a high probability of the image to be related to a keyframe matched
+ * reference image. Those images we don't want to be thrown away because
+ * if we toss them out we'll be re-calculating them at the next
+ * iteration.
+ */
+ ibuf->userflags |= IB_PERSISTENT;
return ibuf;
}
CACHE_PRINTF("Calculate new buffer for frame %d\n", frame);
@@ -835,29 +837,17 @@ static ImBuf *accessor_get_ibuf(TrackingImageAccessor *accessor,
if (final_ibuf == orig_ibuf) {
final_ibuf = IMB_dupImBuf(orig_ibuf);
}
-
IMB_freeImBuf(orig_ibuf);
-
- /* We put postprocessed frame to the cache always for now,
- * not the smartest thing in the world, but who cares at this point.
- */
-
- /* TODO(sergey): Disable cache for now, need some good policy on what to
- * cache and for how long.
- */
- if (false) {
- BLI_spin_lock(&accessor->cache_lock);
- accesscache_put(accessor,
- clip_index,
- frame,
- input_mode,
- downscale,
- region,
- transform_key,
- final_ibuf);
- BLI_spin_unlock(&accessor->cache_lock);
- }
-
+ BLI_spin_lock(&accessor->cache_lock);
+ /* Put final buffer to cache. */
+ accesscache_put(accessor,
+ clip_index,
+ frame,
+ input_mode,
+ downscale,
+ region,
+ transform_key,
+ final_ibuf);
return final_ibuf;
}