[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43400] trunk/blender: Color channels now can be disabled for the whole frame in clip editor

Sergey Sharybin sergey.vfx at gmail.com
Sun Jan 15 14:31:59 CET 2012


Revision: 43400
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43400
Author:   nazgul
Date:     2012-01-15 13:31:58 +0000 (Sun, 15 Jan 2012)
Log Message:
-----------
Color channels now can be disabled for the whole frame in clip editor

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/space_clip.py
    trunk/blender/source/blender/blenkernel/BKE_movieclip.h
    trunk/blender/source/blender/blenkernel/BKE_tracking.h
    trunk/blender/source/blender/blenkernel/intern/movieclip.c
    trunk/blender/source/blender/blenkernel/intern/tracking.c
    trunk/blender/source/blender/editors/space_clip/clip_editor.c
    trunk/blender/source/blender/makesdna/DNA_space_types.h
    trunk/blender/source/blender/makesrna/intern/rna_space.c

Modified: trunk/blender/release/scripts/startup/bl_ui/space_clip.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_clip.py	2012-01-15 13:31:40 UTC (rev 43399)
+++ trunk/blender/release/scripts/startup/bl_ui/space_clip.py	2012-01-15 13:31:58 UTC (rev 43400)
@@ -515,6 +515,17 @@
         layout = self.layout
         sc = context.space_data
 
+        row = layout.row(align=True)
+        sub = row.row()
+        sub.prop(sc, "show_red_channel", text="R", toggle=True)
+        sub.prop(sc, "show_green_channel", text="G", toggle=True)
+        sub.prop(sc, "show_blue_channel", text="B", toggle=True)
+
+        row.separator()
+
+        sub = row.row()
+        sub.prop(sc, "use_grayscale_preview", text="B/W", toggle=True)
+
         col = layout.column(align=True)
 
         col.prop(sc, "show_marker_pattern", text="Pattern")

Modified: trunk/blender/source/blender/blenkernel/BKE_movieclip.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_movieclip.h	2012-01-15 13:31:40 UTC (rev 43399)
+++ trunk/blender/source/blender/blenkernel/BKE_movieclip.h	2012-01-15 13:31:58 UTC (rev 43400)
@@ -47,7 +47,8 @@
 void BKE_movieclip_reload(struct MovieClip *clip);
 
 struct ImBuf *BKE_movieclip_get_ibuf(struct MovieClip *clip, struct MovieClipUser *user);
-struct ImBuf *BKE_movieclip_get_stable_ibuf(struct MovieClip *clip, struct MovieClipUser *user, float loc[2], float *scale, float *angle);
+struct ImBuf *BKE_movieclip_get_postprocessed_ibuf(struct MovieClip *clip, struct MovieClipUser *user, int postprocess_flag);
+struct ImBuf *BKE_movieclip_get_stable_ibuf(struct MovieClip *clip, struct MovieClipUser *user, float loc[2], float *scale, float *angle, int postprocess_flag);
 struct ImBuf *BKE_movieclip_get_ibuf_flag(struct MovieClip *clip, struct MovieClipUser *user, int flag);
 void BKE_movieclip_get_size(struct MovieClip *clip, struct MovieClipUser *user, int *width, int *height);
 void BKE_movieclip_aspect(struct MovieClip *clip, float *aspx, float *aspy);
@@ -63,8 +64,10 @@
 void BKE_movieclip_build_proxy_frame(struct MovieClip *clip, int clip_flag, struct MovieDistortion *distortion,
 			int cfra, int *build_sizes, int build_count, int undistorted);
 
-#define TRACK_CLEAR_UPTO		0
-#define TRACK_CLEAR_REMAINED	1
-#define TRACK_CLEAR_ALL			2
+/* postprocessing flags */
+#define MOVIECLIP_DISABLE_RED       (1<<0)
+#define MOVIECLIP_DISABLE_GREEN     (1<<1)
+#define MOVIECLIP_DISABLE_BLUE      (1<<2)
+#define MOVIECLIP_PREVIEW_GRAYSCALE (1<<3)
 
 #endif

Modified: trunk/blender/source/blender/blenkernel/BKE_tracking.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_tracking.h	2012-01-15 13:31:40 UTC (rev 43399)
+++ trunk/blender/source/blender/blenkernel/BKE_tracking.h	2012-01-15 13:31:58 UTC (rev 43400)
@@ -97,6 +97,8 @@
 struct MovieTrackingReconstruction *BKE_tracking_object_reconstruction(struct MovieTracking *tracking,
 			struct MovieTrackingObject *object);
 
+void BKE_tracking_disable_imbuf_channels(struct ImBuf *ibuf, int disable_red, int disable_green, int disable_blue, int grayscale);
+
 /* clipboard */
 void BKE_tracking_free_clipboard(void);
 void BKE_tracking_clipboard_copy_tracks(struct MovieTracking *tracking, struct MovieTrackingObject *object);
@@ -166,6 +168,10 @@
 
 #define MARKER_VISIBLE(sc, marker)			(((marker)->flag&MARKER_DISABLED)==0 || ((sc)->flag&SC_HIDE_DISABLED)==0)
 
+#define TRACK_CLEAR_UPTO		0
+#define TRACK_CLEAR_REMAINED	1
+#define TRACK_CLEAR_ALL			2
+
 #define CLAMP_PAT_DIM		1
 #define CLAMP_PAT_POS		2
 #define CLAMP_SEARCH_DIM	3

Modified: trunk/blender/source/blender/blenkernel/intern/movieclip.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/movieclip.c	2012-01-15 13:31:40 UTC (rev 43399)
+++ trunk/blender/source/blender/blenkernel/intern/movieclip.c	2012-01-15 13:31:58 UTC (rev 43400)
@@ -261,10 +261,12 @@
 	struct {
 		ImBuf *ibuf;
 		int framenr;
+		int flag;
 
 		/* cache for undistorted shot */
 		float principal[2];
 		float k1, k2, k3;
+		short undistoriton_used;
 
 		int proxy;
 		short render_flag;
@@ -511,9 +513,9 @@
 	return result;
 }
 
-static int need_postprocessed_frame(MovieClipUser *user, int flag)
+static int need_postprocessed_frame(MovieClipUser *user, int flag, int postprocess_flag)
 {
-	int result = 0;
+	int result = postprocess_flag;
 
 	result |= need_undistortion_postprocess(user, flag);
 
@@ -535,7 +537,7 @@
 	return 1;
 }
 
-static ImBuf *get_postprocessed_cached_frame(MovieClip *clip, MovieClipUser *user, int flag)
+static ImBuf *get_postprocessed_cached_frame(MovieClip *clip, MovieClipUser *user, int flag, int postprocess_flag)
 {
 	MovieClipCache *cache= clip->cache;
 	int framenr= user->framenr;
@@ -556,29 +558,35 @@
 		return NULL;
 
 	/* cached ibuf used different proxy settings */
-	if(cache->postprocessed.render_flag!=render_flag || cache->postprocessed.proxy!=proxy)
+	if(cache->postprocessed.render_flag != render_flag || cache->postprocessed.proxy != proxy)
 		return NULL;
 
+	if(cache->postprocessed.flag != postprocess_flag)
+		return NULL;
+
 	if(need_undistortion_postprocess(user, flag)) {
 		if(!check_undistortion_cache_flags(clip))
 			return NULL;
 	}
+	else if(cache->postprocessed.undistoriton_used)
+		return NULL;
 
 	IMB_refImBuf(cache->postprocessed.ibuf);
 
 	return cache->postprocessed.ibuf;
 }
 
-static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, int flag)
+static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, int flag, int postprocess_flag)
 {
 	MovieClipCache *cache= clip->cache;
 	MovieTrackingCamera *camera= &clip->tracking.camera;
-	ImBuf *postproc_ibuf;
+	ImBuf *postproc_ibuf = NULL;
 
 	if(cache->postprocessed.ibuf)
 		IMB_freeImBuf(cache->postprocessed.ibuf);
 
 	cache->postprocessed.framenr= user->framenr;
+	cache->postprocessed.flag = postprocess_flag;
 
 	if(flag&MCLIP_USE_PROXY) {
 		cache->postprocessed.proxy= rendersize_to_proxy(user, flag);
@@ -592,18 +600,38 @@
 	if(need_undistortion_postprocess(user, flag)) {
 		copy_v2_v2(cache->postprocessed.principal, camera->principal);
 		copy_v3_v3(&cache->postprocessed.k1, &camera->k1);
+		cache->postprocessed.undistoriton_used = 1;
+		postproc_ibuf= get_undistorted_ibuf(clip, NULL, ibuf);
 	}
+	else cache->postprocessed.undistoriton_used = 0;
 
-	postproc_ibuf= get_undistorted_ibuf(clip, NULL, ibuf);
+	if(postprocess_flag) {
+		int disable_red   = postprocess_flag & MOVIECLIP_DISABLE_RED,
+		    disable_green = postprocess_flag & MOVIECLIP_DISABLE_GREEN,
+			disable_blue  = postprocess_flag & MOVIECLIP_DISABLE_BLUE,
+			grayscale     = postprocess_flag & MOVIECLIP_PREVIEW_GRAYSCALE;
 
+		if(!postproc_ibuf)
+			postproc_ibuf = IMB_dupImBuf(ibuf);
+
+		if(disable_red || disable_green || disable_blue || grayscale)
+			BKE_tracking_disable_imbuf_channels(postproc_ibuf, disable_red, disable_green, disable_blue, 1);
+	}
+
 	IMB_refImBuf(postproc_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;
 }
 
-static ImBuf *movieclip_get_postprocessed_ibuf(MovieClip *clip, MovieClipUser *user, int flag)
+static ImBuf *movieclip_get_postprocessed_ibuf(MovieClip *clip, MovieClipUser *user, int flag, int postprocess_flag)
 {
 	ImBuf *ibuf= NULL;
 	int framenr= user->framenr, need_postprocess= 0;
@@ -613,8 +641,8 @@
 	BLI_lock_thread(LOCK_MOVIECLIP);
 
 	/* try to obtain cached postprocessed frame first */
-	if(need_postprocessed_frame(user, flag)) {
-		ibuf= get_postprocessed_cached_frame(clip, user, flag);
+	if(need_postprocessed_frame(user, flag, postprocess_flag)) {
+		ibuf= get_postprocessed_cached_frame(clip, user, flag, postprocess_flag);
 
 		if(!ibuf)
 			need_postprocess= 1;
@@ -647,7 +675,7 @@
 		/* postprocess frame and put to cache */
 		if(need_postprocess) {
 			ImBuf *tmpibuf= ibuf;
-			ibuf= put_postprocessed_frame_to_cache(clip, user, tmpibuf, flag);
+			ibuf= put_postprocessed_frame_to_cache(clip, user, tmpibuf, flag, postprocess_flag);
 			IMB_freeImBuf(tmpibuf);
 		}
 	}
@@ -664,9 +692,14 @@
 
 ImBuf *BKE_movieclip_get_ibuf_flag(MovieClip *clip, MovieClipUser *user, int flag)
 {
-	return movieclip_get_postprocessed_ibuf(clip, user, flag);
+	return movieclip_get_postprocessed_ibuf(clip, user, flag, 0);
 }
 
+ImBuf *BKE_movieclip_get_postprocessed_ibuf(MovieClip *clip, MovieClipUser *user, int postprocess_flag)
+{
+	return movieclip_get_postprocessed_ibuf(clip, user, clip->flag, postprocess_flag);
+}
+
 static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, int framenr)
 {
 	MovieClipCache *cache = clip->cache;
@@ -738,12 +771,12 @@
 	return stableibuf;
 }
 
-ImBuf *BKE_movieclip_get_stable_ibuf(MovieClip *clip, MovieClipUser *user, float loc[2], float *scale, float *angle)
+ImBuf *BKE_movieclip_get_stable_ibuf(MovieClip *clip, MovieClipUser *user, float loc[2], float *scale, float *angle, int postprocess_flag)
 {
 	ImBuf *ibuf, *stableibuf= NULL;
 	int framenr= user->framenr;
 
-	ibuf= BKE_movieclip_get_ibuf(clip, user);
+	ibuf= BKE_movieclip_get_postprocessed_ibuf(clip, user, postprocess_flag);
 
 	if(!ibuf)
 		return NULL;

Modified: trunk/blender/source/blender/blenkernel/intern/tracking.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/tracking.c	2012-01-15 13:31:40 UTC (rev 43399)
+++ trunk/blender/source/blender/blenkernel/intern/tracking.c	2012-01-15 13:31:58 UTC (rev 43400)
@@ -1010,19 +1010,19 @@
 /* zap channels from the imbuf that are disabled by the user. this can lead to
  * better tracks sometimes. however, instead of simply zeroing the channels
  * out, do a partial grayscale conversion so the display is better. */
-static void disable_imbuf_channels(ImBuf *ibuf, MovieTrackingTrack *track, int grayscale)
+void BKE_tracking_disable_imbuf_channels(ImBuf *ibuf, int disable_red, int disable_green, int disable_blue, int grayscale)
 {
 	int x, y;
 	float scale;
 
-	if((track->flag&(TRACK_DISABLE_RED|TRACK_DISABLE_GREEN|TRACK_DISABLE_BLUE))==0 && !grayscale)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list