[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47472] trunk/blender: Configurable start frame for movie clip datablocks as alternative to automatic start frame number

Sergey Sharybin sergey.vfx at gmail.com
Tue Jun 5 20:38:19 CEST 2012


Revision: 47472
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47472
Author:   nazgul
Date:     2012-06-05 18:38:09 +0000 (Tue, 05 Jun 2012)
Log Message:
-----------
Configurable start frame for movie clip datablocks as alternative to automatic start frame number

Number of start frame in opened image sequence used to be distinguished automatically
in a way that file name used on open would be displayed at scene frame #1.

But sometimes it's useful to have it manually configurable (like in cases when you're
processing image sequence and replacing clip's filepath to postprocessed image sequence
and want new clip to show at the same frame range as it was rendered from).

Added Custom Start Frame flag to movie clip (could be accessed from Footage panel in
clip editor) and Start Frame which means number of frame from sequence which would
be displayed at scene frame #1.

For example if you've got clip pointing to file render_00100.png and Start Frame of 100
this file would be displayed at scene frame #1, if Start Frame is 1 then this image
would be displayed at scene frame #100,

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/space_clip.py
    trunk/blender/source/blender/blenkernel/intern/movieclip.c
    trunk/blender/source/blender/editors/space_clip/clip_editor.c
    trunk/blender/source/blender/makesdna/DNA_movieclip_types.h
    trunk/blender/source/blender/makesrna/intern/rna_movieclip.c

Modified: trunk/blender/release/scripts/startup/bl_ui/space_clip.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_clip.py	2012-06-05 17:32:57 UTC (rev 47471)
+++ trunk/blender/release/scripts/startup/bl_ui/space_clip.py	2012-06-05 18:38:09 UTC (rev 47472)
@@ -958,13 +958,13 @@
         sc = context.space_data
         clip = sc.clip
 
-        if clip:
-            layout.template_movieclip(sc, "clip", compact=True)
-        else:
-            layout.operator("clip.open", icon='FILESEL')
+        col = layout.column()
+        col.template_movieclip(sc, "clip", compact=True)
+        col.prop(clip, "use_custom_start_frame")
+        if clip.use_custom_start_frame:
+            col.prop(clip, "start_frame")
 
 
-
 class CLIP_PT_tools_clip(CLIP_PT_clip_view_panel, Panel):
     bl_space_type = 'CLIP_EDITOR'
     bl_region_type = 'TOOLS'

Modified: trunk/blender/source/blender/blenkernel/intern/movieclip.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/movieclip.c	2012-06-05 17:32:57 UTC (rev 47471)
+++ trunk/blender/source/blender/blenkernel/intern/movieclip.c	2012-06-05 18:38:09 UTC (rev 47472)
@@ -153,9 +153,15 @@
 	BLI_strncpy(name, clip->name, sizeof(clip->name));
 	BLI_stringdec(name, head, tail, &numlen);
 
-	/* movieclips always points to first image from sequence,
-	 * autoguess offset for now. could be something smarter in the future */
-	offset = sequence_guess_offset(clip->name, strlen(head), numlen);
+	if (clip->flag & MCLIP_CUSTOM_START_FRAME) {
+		offset = clip->start_frame;
+	}
+	else {
+		/* movieclips always points to first image from sequence,
+		 * autoguess offset for now. could be something smarter in the future
+		 */
+		offset = sequence_guess_offset(clip->name, strlen(head), numlen);
+	}
 
 	if (numlen)
 		BLI_stringenc(name, head, tail, numlen, offset + framenr - 1);
@@ -250,6 +256,10 @@
 		dur = IMB_anim_get_duration(clip->anim, tc);
 		fra = framenr - 1;
 
+		if (clip->flag & MCLIP_CUSTOM_START_FRAME) {
+			fra += clip->start_frame - 1;
+		}
+
 		if (fra < 0)
 			fra = 0;
 
@@ -443,6 +453,8 @@
 	                            IMB_TC_RECORD_RUN_NO_GAPS;
 	clip->proxy.quality = 90;
 
+	clip->start_frame = 1;
+
 	return clip;
 }
 

Modified: trunk/blender/source/blender/editors/space_clip/clip_editor.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/clip_editor.c	2012-06-05 17:32:57 UTC (rev 47471)
+++ trunk/blender/source/blender/editors/space_clip/clip_editor.c	2012-06-05 18:38:09 UTC (rev 47472)
@@ -544,7 +544,10 @@
 	struct ImBuf *texture_ibuf;	/* image buffer for which texture was created */
 	int image_width, image_height;	/* image width and height for which texture was created */
 	unsigned last_texture;		/* ID of previously used texture, so it'll be restored after clip drawing */
-	int framenr;
+
+	/* fields to check if cache is still valid */
+	int framenr, start_frame;
+	short custom_start_frame;
 } SpaceClipDrawContext;
 
 int ED_space_clip_texture_buffer_supported(SpaceClip *sc)
@@ -574,6 +577,7 @@
 	SpaceClipDrawContext *context = sc->draw_context;
 	MovieClip *clip = ED_space_clip(sc);
 	int need_rebind = 0;
+	short custom_start_frame = FALSE;
 
 	context->last_texture = glaGetOneInteger(GL_TEXTURE_2D);
 
@@ -583,6 +587,14 @@
 	need_rebind |= context->texture_ibuf != ibuf;
 	need_rebind |= context->framenr != sc->user.framenr;
 
+	if (clip->flag & MCLIP_CUSTOM_START_FRAME) {
+		need_rebind |= context->custom_start_frame != TRUE;
+		need_rebind |= context->start_frame != clip->start_frame;
+	}
+	else {
+		need_rebind |= context->custom_start_frame != FALSE;
+	}
+
 	if (need_rebind) {
 		int width = ibuf->x, height = ibuf->y;
 		int need_recreate = 0;
@@ -636,6 +648,8 @@
 		context->image_width = ibuf->x;
 		context->image_height = ibuf->y;
 		context->framenr = sc->user.framenr;
+		context->start_frame = clip->start_frame;
+		context->custom_start_frame = (clip->flag & MCLIP_CUSTOM_START_FRAME) ? TRUE : FALSE;
 	}
 	else {
 		/* displaying exactly the same image which was loaded t oa texture,

Modified: trunk/blender/source/blender/makesdna/DNA_movieclip_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_movieclip_types.h	2012-06-05 17:32:57 UTC (rev 47471)
+++ trunk/blender/source/blender/makesdna/DNA_movieclip_types.h	2012-06-05 18:38:09 UTC (rev 47472)
@@ -85,6 +85,8 @@
 	int flag;
 
 	int len;	/* length of movie */
+
+	int start_frame, pad;
 } MovieClip;
 
 typedef struct MovieClipScopes {
@@ -121,6 +123,7 @@
 /* MovieClip->flag */
 #define MCLIP_USE_PROXY					(1<<0)
 #define MCLIP_USE_PROXY_CUSTOM_DIR		(1<<1)
+#define MCLIP_CUSTOM_START_FRAME		(1<<2)
 
 #define MCLIP_TIMECODE_FLAGS			(MCLIP_USE_PROXY|MCLIP_USE_PROXY_CUSTOM_DIR)
 

Modified: trunk/blender/source/blender/makesrna/intern/rna_movieclip.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_movieclip.c	2012-06-05 17:32:57 UTC (rev 47471)
+++ trunk/blender/source/blender/makesrna/intern/rna_movieclip.c	2012-06-05 18:38:09 UTC (rev 47472)
@@ -284,6 +284,19 @@
 	RNA_def_property_flag(prop, PROP_EDITABLE);
 	RNA_def_property_struct_type(prop, "GreasePencil");
 	RNA_def_property_ui_text(prop, "Grease Pencil", "Grease pencil data for this movie clip");
+
+	/* use custom offset */
+	prop = RNA_def_property(srna, "use_custom_start_frame", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", MCLIP_CUSTOM_START_FRAME);
+	RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+	RNA_def_property_ui_text(prop, "Custom Start Frame", "Use custom first frame offset instead of automatic frame number");
+	RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_reload_update");
+
+	/* frame offset */
+	prop = RNA_def_property(srna, "start_frame", PROP_INT, PROP_NONE);
+	RNA_def_property_int_sdna(prop, NULL, "start_frame");
+	RNA_def_property_ui_text(prop, "Start Frame", "Number of frame from sequence or movie displaying at scene frame #1");
+	RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, "rna_MovieClip_reload_update");
 }
 
 void RNA_def_movieclip(BlenderRNA *brna)




More information about the Bf-blender-cvs mailing list