[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39181] branches/soc-2011-tomato: Camera tracking integration

Sergey Sharybin g.ulairi at gmail.com
Mon Aug 8 14:18:32 CEST 2011


Revision: 39181
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39181
Author:   nazgul
Date:     2011-08-08 12:18:32 +0000 (Mon, 08 Aug 2011)
Log Message:
-----------
Camera tracking integration
===========================

Initial integration of proxies into movie clip editor.

Known issue: marker preview area uses proxyed image,
             hopefully fix would be available soon.

Modified Paths:
--------------
    branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
    branches/soc-2011-tomato/source/blender/blenkernel/BKE_moviecache.h
    branches/soc-2011-tomato/source/blender/blenkernel/BKE_movieclip.h
    branches/soc-2011-tomato/source/blender/blenkernel/intern/moviecache.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
    branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
    branches/soc-2011-tomato/source/blender/blenloader/intern/readfile.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_draw.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_intern.h
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_ops.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c
    branches/soc-2011-tomato/source/blender/makesdna/DNA_movieclip_types.h
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_movieclip.c

Modified: branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py	2011-08-08 12:18:20 UTC (rev 39180)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py	2011-08-08 12:18:32 UTC (rev 39181)
@@ -406,6 +406,55 @@
         row.prop(stab, "influence_scale")
 
 
+class CLIP_PT_proxy(bpy.types.Panel):
+    bl_space_type = 'CLIP_EDITOR'
+    bl_region_type = 'UI'
+    bl_label = "Proxy / Timecode"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        sc = context.space_data
+
+        return sc.clip
+
+    def draw_header(self, context):
+        sc = context.space_data
+
+        self.layout.prop(sc.clip, "use_proxy", text="")
+
+    def draw(self, context):
+        layout = self.layout
+        sc = context.space_data
+        clip = sc.clip
+
+        layout.active = clip.use_proxy
+
+        layout.label(text="Build Sizes:")
+        row = layout.row()
+        row.prop(clip.proxy, "build_25")
+        row.prop(clip.proxy, "build_50")
+        row.prop(clip.proxy, "build_75")
+
+        layout.prop(clip.proxy, "quality")
+
+        layout.prop(clip, 'use_proxy_custom_directory')
+        if clip.use_proxy_custom_directory:
+           layout.prop(clip.proxy, "directory")
+
+        layout.operator("clip.rebuild_proxy", text="Rebuild Proxy")
+
+        if clip.source == 'MOVIE':
+            col = layout.column()
+
+            col.label(text="Use timecode index:")
+            col.prop(clip.proxy, "timecode", text="")
+
+        col = layout.column()
+        col.label(text="Proxy render size:")
+        col.prop(clip, "proxy_render_size", text="")
+
+
 class CLIP_PT_footage(bpy.types.Panel):
     bl_space_type = 'CLIP_EDITOR'
     bl_region_type = 'UI'

Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_moviecache.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_moviecache.h	2011-08-08 12:18:20 UTC (rev 39180)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_moviecache.h	2011-08-08 12:18:32 UTC (rev 39181)
@@ -44,7 +44,7 @@
 struct ImBuf;
 struct MovieCache;
 
-typedef void (*MovieCacheGetKeyDataFP) (void *userkey, int *framenr);
+typedef void (*MovieCacheGetKeyDataFP) (void *userkey, int *framenr, int *proxy);
 
 void BKE_moviecache_init(void);
 void BKE_moviecache_destruct(void);
@@ -53,6 +53,6 @@
 void BKE_moviecache_put(struct MovieCache *cache, void *userkey, struct ImBuf *ibuf);
 struct ImBuf* BKE_moviecache_get(struct MovieCache *cache, void *userkey);
 void BKE_moviecache_free(struct MovieCache *cache);
-void BKE_moviecache_get_cache_segments(struct MovieCache *cache, int *totseg_r, int **points_r);
+void BKE_moviecache_get_cache_segments(struct MovieCache *cache, int proxy, int *totseg_r, int **points_r);
 
 #endif

Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_movieclip.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_movieclip.h	2011-08-08 12:18:20 UTC (rev 39180)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_movieclip.h	2011-08-08 12:18:32 UTC (rev 39181)
@@ -49,6 +49,7 @@
 
 struct ImBuf *BKE_movieclip_acquire_ibuf(struct MovieClip *clip, struct MovieClipUser *user);
 struct ImBuf *BKE_movieclip_acquire_stable_ibuf(struct MovieClip *clip, struct MovieClipUser *user, float loc[2], float *scale);
+struct ImBuf *BKE_movieclip_acquire_ibuf_flag(struct MovieClip *clip, struct MovieClipUser *user, int flag);
 void BKE_movieclip_acquire_size(struct MovieClip *clip, struct MovieClipUser *user, int *width, int *height);
 void BKE_movieclip_aspect(struct MovieClip *clip, float *aspx, float *aspy);
 int BKE_movieclip_has_frame(struct MovieClip *clip, struct MovieClipUser *user);
@@ -63,6 +64,8 @@
 
 void BKE_movieclip_get_cache_segments(struct MovieClip *clip, int *totseg_r, int **points_r);
 
+void BKE_movieclip_build_proxy_frame(struct MovieClip *clip, int cfra, int proxy_render_size);
+
 #define TRACK_CLEAR_UPTO		0
 #define TRACK_CLEAR_REMAINED	1
 #define TRACK_CLEAR_ALL			2

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/moviecache.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/moviecache.c	2011-08-08 12:18:20 UTC (rev 39180)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/moviecache.c	2011-08-08 12:18:32 UTC (rev 39181)
@@ -58,7 +58,8 @@
 	int keysize;
 	unsigned long curtime;
 
-	int totseg, *points;	/* for visual statistics optimization */
+	int totseg, *points, points_proxy;	/* for visual statistics optimization */
+	int pad;
 } MovieCache;
 
 typedef struct MovieCacheKey {
@@ -211,6 +212,7 @@
 	cache->hashfp= hashfp;
 	cache->cmpfp= cmpfp;
 	cache->getdatafp= getdatafp;
+	cache->points_proxy= -1;
 
 	return cache;
 }
@@ -292,7 +294,7 @@
 }
 
 /* get segments of cached frames. useful for debugging cache policies */
-void BKE_moviecache_get_cache_segments(MovieCache *cache, int *totseg_r, int **points_r)
+void BKE_moviecache_get_cache_segments(MovieCache *cache, int proxy, int *totseg_r, int **points_r)
 {
 	*totseg_r= 0;
 	*points_r= NULL;
@@ -300,6 +302,13 @@
 	if(!cache->getdatafp)
 		return;
 
+	if(cache->points_proxy!=proxy) {
+		if(cache->points)
+			MEM_freeN(cache->points);
+
+		cache->points= NULL;
+	}
+
 	if(cache->points) {
 		*totseg_r= cache->totseg;
 		*points_r= cache->points;
@@ -314,12 +323,13 @@
 		while(!BLI_ghashIterator_isDone(iter)) {
 			MovieCacheKey *key= BLI_ghashIterator_getKey(iter);
 			MovieCacheItem *item= BLI_ghashIterator_getValue(iter);
-			int framenr;
+			int framenr, curproxy;
 
 			if(item->ibuf) {
-				cache->getdatafp(key->userkey, &framenr);
+				cache->getdatafp(key->userkey, &framenr, &curproxy);
 
-				frames[a++]= framenr;
+				if(curproxy==proxy)
+					frames[a++]= framenr;
 			}
 
 			BLI_ghashIterator_step(iter);

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c	2011-08-08 12:18:20 UTC (rev 39180)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c	2011-08-08 12:18:32 UTC (rev 39181)
@@ -87,14 +87,62 @@
 	return atoi(num);
 }
 
-static ImBuf *movieclip_load_sequence_file(MovieClip *clip, int framenr)
+static int rendersize_to_proxy(MovieClip *clip, int flag)
 {
-	struct ImBuf *ibuf;
+	if((flag&MCLIP_USE_PROXY)==0)
+		return IMB_PROXY_NONE;
+
+	switch(clip->render_size) {
+		case MCLIP_PROXY_RENDER_SIZE_25:
+			return IMB_PROXY_25;
+
+		case MCLIP_PROXY_RENDER_SIZE_50:
+			return IMB_PROXY_50;
+
+		case MCLIP_PROXY_RENDER_SIZE_75:
+			return IMB_PROXY_75;
+
+		case MCLIP_PROXY_RENDER_SIZE_FULL:
+			return IMB_PROXY_NONE;
+	}
+
+	return IMB_PROXY_NONE;
+}
+
+static int rendersize_to_number(int render_size)
+{
+	switch(render_size) {
+		case MCLIP_PROXY_RENDER_SIZE_25:
+			return 25;
+
+		case MCLIP_PROXY_RENDER_SIZE_50:
+			return 50;
+
+		case MCLIP_PROXY_RENDER_SIZE_75:
+			return 75;
+
+		case MCLIP_PROXY_RENDER_SIZE_FULL:
+			return 100;
+	}
+
+	return 100;
+}
+
+static int get_timecode(MovieClip *clip, int flag)
+{
+	if((flag&MCLIP_USE_PROXY)==0)
+		return IMB_TC_NONE;
+
+	return clip->proxy.tc;
+}
+
+static void get_sequence_fname(MovieClip *clip, int framenr, char *name)
+{
 	unsigned short numlen;
-	char name[FILE_MAX], head[FILE_MAX], tail[FILE_MAX];
-	int flag, offset;
+	char head[FILE_MAX], tail[FILE_MAX];
+	int offset;
 
-	BLI_strncpy(name, clip->name, sizeof(name));
+	BLI_strncpy(name, clip->name, sizeof(clip->name));
 	BLI_stringdec(name, head, tail, &numlen);
 
 	/* movieclips always points to first image from sequence,
@@ -108,18 +156,55 @@
 		BLI_path_abs(name, clip->id.lib->filepath);
 	else
 		BLI_path_abs(name, G.main->name);
+}
 
-	flag= IB_rect|IB_multilayer;
+/* supposed to work with sequences only */
+static void get_proxy_fname(MovieClip *clip, int proxy_render_size, int framenr, char *name)
+{
+	int size= rendersize_to_number(proxy_render_size);
+	char dir[FILE_MAX], curname[FILE_MAX], clipdir[FILE_MAX], clipfile[FILE_MAX];
 
+	get_sequence_fname(clip, framenr, curname);
+	BLI_split_dirfile(curname, clipdir, clipfile);
+
+	if(clip->flag&MCLIP_USE_PROXY_CUSTOM_DIR) {
+		strcpy(dir, clip->proxy.dir);
+	} else {
+		snprintf(dir, FILE_MAX, "%s/BL_proxy", clipdir);
+	}
+
+	snprintf(name, FILE_MAX, "%s/images/%d/%s_proxy", dir, size,  clipfile);
+
+	BLI_path_abs(name, G.main->name);
+	BLI_path_frame(name, 1, 0);
+
+	strcat(name, ".jpg");
+}
+
+static ImBuf *movieclip_load_sequence_file(MovieClip *clip, int framenr, int flag)
+{
+	struct ImBuf *ibuf;
+	char name[FILE_MAX];
+	int loadflag, size;
+
+	size= rendersize_to_number(clip->render_size);
+
+	if(flag&MCLIP_USE_PROXY && size!=100) get_proxy_fname(clip, clip->render_size, framenr, name);
+	else get_sequence_fname(clip, framenr, name);
+
+	loadflag= IB_rect|IB_multilayer;
+
 	/* read ibuf */
-	ibuf= IMB_loadiffname(name, flag);
+	ibuf= IMB_loadiffname(name, loadflag);
 
 	return ibuf;
 }
 
-static ImBuf *movieclip_load_movie_file(MovieClip *clip, int framenr)
+static ImBuf *movieclip_load_movie_file(MovieClip *clip, int framenr, int flag)
 {
 	ImBuf *ibuf= NULL;
+	int tc= get_timecode(clip, flag);
+	int proxy= rendersize_to_proxy(clip, flag);
 	char str[FILE_MAX];
 
 	if(!clip->anim) {
@@ -131,19 +216,32 @@
 			BLI_path_abs(str, G.main->name);
 
 		clip->anim= openanim(str, IB_rect);
+
+
+		if(clip->anim) {
+			if(clip->flag&MCLIP_USE_PROXY_CUSTOM_DIR) {
+				char dir[FILE_MAX];
+				strcpy(dir, clip->proxy.dir);
+				BLI_path_abs(dir, G.main->name);
+				IMB_anim_set_index_dir(clip->anim, dir);
+			}
+		}
 	}
 
 	if(clip->anim) {
-		int dur= IMB_anim_get_duration(clip->anim, IMB_TC_NONE);
+		int dur= IMB_anim_get_duration(clip->anim, tc);
 		int fra= framenr-1;
 
+		dur= IMB_anim_get_duration(clip->anim, tc);
+		fra= framenr-1;
+
 		if(fra<0)
 			fra= 0;
 
 		if(fra>(dur-1))
 			fra= dur-1;
 
-		ibuf= IMB_anim_absolute(clip->anim, fra, IMB_TC_NONE, IMB_PROXY_NONE);
+		ibuf= IMB_anim_absolute(clip->anim, fra, tc, proxy);
 	}
 
 	return ibuf;
@@ -163,13 +261,15 @@
 
 typedef struct MovieClipImBufCacheKey {
 	int framenr;
+	int proxy;
 } MovieClipImBufCacheKey;
 
-static void moviecache_keydata(void *userkey, int *framenr)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list