[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48749] trunk/blender/source/blender/ blenkernel/intern/movieclip.c: Fixed issues updating texture buffer used for clip editor frame display

Sergey Sharybin sergey.vfx at gmail.com
Mon Jul 9 12:26:04 CEST 2012


Revision: 48749
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48749
Author:   nazgul
Date:     2012-07-09 10:26:01 +0000 (Mon, 09 Jul 2012)
Log Message:
-----------
Fixed issues updating texture buffer used for clip editor frame display
when specific circumstances are met.

Mainly issue was caused by checking ImBuf pointers, which used to fail
when some post-processing flags are changed. This was caused by the
fact that freeing old ImBuf and allocating new one could lead to new
ImBuf have the same pointer as previous one, which confuses cache.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/movieclip.c

Modified: trunk/blender/source/blender/blenkernel/intern/movieclip.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/movieclip.c	2012-07-09 04:57:21 UTC (rev 48748)
+++ trunk/blender/source/blender/blenkernel/intern/movieclip.c	2012-07-09 10:26:01 UTC (rev 48749)
@@ -322,6 +322,8 @@
 
 	/* cache for stable shot */
 	struct {
+		ImBuf *reference_ibuf;
+
 		ImBuf *ibuf;
 		int framenr;
 		int postprocess_flag;
@@ -655,9 +657,6 @@
 	MovieTrackingCamera *camera = &clip->tracking.camera;
 	ImBuf *postproc_ibuf = NULL;
 
-	if (cache->postprocessed.ibuf)
-		IMB_freeImBuf(cache->postprocessed.ibuf);
-
 	cache->postprocessed.framenr = user->framenr;
 	cache->postprocessed.flag = postprocess_flag;
 
@@ -695,14 +694,11 @@
 
 	IMB_refImBuf(postproc_ibuf);
 
+	if (cache->postprocessed.ibuf)
+		IMB_freeImBuf(cache->postprocessed.ibuf);
+
 	cache->postprocessed.ibuf = postproc_ibuf;
 
-	if (cache->stabilized.ibuf) {
-		/* force stable buffer be re-calculated */
-		IMB_freeImBuf(cache->stabilized.ibuf);
-		cache->stabilized.ibuf = NULL;
-	}
-
 	return postproc_ibuf;
 }
 
@@ -777,7 +773,8 @@
 	return movieclip_get_postprocessed_ibuf(clip, user, clip->flag, postprocess_flag, 0);
 }
 
-static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, int framenr, int postprocess_flag)
+static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, ImBuf *reference_ibuf,
+                                      int framenr, int postprocess_flag)
 {
 	MovieClipCache *cache = clip->cache;
 	MovieTracking *tracking = &clip->tracking;
@@ -796,6 +793,9 @@
 	if (!cache->stabilized.ibuf || cache->stabilized.framenr != framenr)
 		return NULL;
 
+	if (cache->stabilized.reference_ibuf != reference_ibuf)
+		return NULL;
+
 	/* cached ibuf used different proxy settings */
 	if (cache->stabilized.render_flag != render_flag || cache->stabilized.proxy != proxy)
 		return NULL;
@@ -836,13 +836,8 @@
 	float tloc[2], tscale, tangle;
 	int clip_framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, framenr);
 
-	if (cache->stabilized.ibuf)
-		IMB_freeImBuf(cache->stabilized.ibuf);
-
 	stableibuf = BKE_tracking_stabilize_frame(&clip->tracking, clip_framenr, ibuf, tloc, &tscale, &tangle);
 
-	cache->stabilized.ibuf = stableibuf;
-
 	copy_v2_v2(cache->stabilized.loc, tloc);
 
 	cache->stabilized.scale = tscale;
@@ -862,6 +857,11 @@
 
 	cache->stabilized.postprocess_flag = postprocess_flag;
 
+	if (cache->stabilized.ibuf)
+		IMB_freeImBuf(cache->stabilized.ibuf);
+
+	cache->stabilized.ibuf = stableibuf;
+
 	IMB_refImBuf(stableibuf);
 
 	return stableibuf;
@@ -881,7 +881,7 @@
 	if (clip->tracking.stabilization.flag & TRACKING_2D_STABILIZATION) {
 		MovieClipCache *cache = clip->cache;
 
-		stableibuf = get_stable_cached_frame(clip, user, framenr, postprocess_flag);
+		stableibuf = get_stable_cached_frame(clip, user, ibuf, framenr, postprocess_flag);
 
 		if (!stableibuf)
 			stableibuf = put_stabilized_frame_to_cache(clip, user, ibuf, framenr, postprocess_flag);




More information about the Bf-blender-cvs mailing list