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,
This commit is contained in:
Sergey Sharybin 2012-06-05 18:38:09 +00:00
parent da38a0348a
commit 0d61876ed0
5 changed files with 51 additions and 9 deletions

@ -958,11 +958,11 @@ class CLIP_PT_footage(CLIP_PT_clip_view_panel, Panel):
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):

@ -153,9 +153,15 @@ static void get_sequence_fname(MovieClip *clip, int framenr, char *name)
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 @@ static ImBuf *movieclip_load_movie_file(MovieClip *clip, MovieClipUser *user, in
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 @@ static MovieClip *movieclip_alloc(const char *name)
IMB_TC_RECORD_RUN_NO_GAPS;
clip->proxy.quality = 90;
clip->start_frame = 1;
return clip;
}

@ -544,7 +544,10 @@ typedef struct SpaceClipDrawContext {
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 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf)
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 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf)
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 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf)
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,

@ -85,6 +85,8 @@ typedef struct MovieClip {
int flag;
int len; /* length of movie */
int start_frame, pad;
} MovieClip;
typedef struct MovieClipScopes {
@ -121,6 +123,7 @@ typedef struct MovieClipScopes {
/* 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)

@ -284,6 +284,19 @@ static void rna_def_movieclip(BlenderRNA *brna)
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)