diff options
25 files changed, 303 insertions, 88 deletions
diff --git a/release/scripts/presets/interface_theme/back_to_black.xml b/release/scripts/presets/interface_theme/back_to_black.xml index 76c30bb293b..27ee9f8ca21 100644 --- a/release/scripts/presets/interface_theme/back_to_black.xml +++ b/release/scripts/presets/interface_theme/back_to_black.xml @@ -412,6 +412,7 @@ keyframe="#ff8500" meta_strip="#6d9183" movie_strip="#516987" + movieclip_strip="#20208f" plugin_strip="#7e7e50" scene_strip="#4e983e" transition_strip="#a25f6f" diff --git a/release/scripts/presets/interface_theme/blender_24x.xml b/release/scripts/presets/interface_theme/blender_24x.xml index 046a05982cf..5173244a167 100644 --- a/release/scripts/presets/interface_theme/blender_24x.xml +++ b/release/scripts/presets/interface_theme/blender_24x.xml @@ -412,6 +412,7 @@ keyframe="#ff8500" meta_strip="#6d9183" movie_strip="#516987" + movieclip_strip="#20208f" plugin_strip="#7e7e50" scene_strip="#4e983e" transition_strip="#a25f6f" diff --git a/release/scripts/presets/interface_theme/elsyiun.xml b/release/scripts/presets/interface_theme/elsyiun.xml index 270dbfd19a3..8720aeff727 100644 --- a/release/scripts/presets/interface_theme/elsyiun.xml +++ b/release/scripts/presets/interface_theme/elsyiun.xml @@ -412,6 +412,7 @@ keyframe="#ff8500" meta_strip="#6d9183" movie_strip="#516987" + movieclip_strip="#20208f" plugin_strip="#7e7e50" scene_strip="#4e983e" transition_strip="#a25f6f" diff --git a/release/scripts/presets/interface_theme/hexagon.xml b/release/scripts/presets/interface_theme/hexagon.xml index 07c05656c26..94648e258a1 100644 --- a/release/scripts/presets/interface_theme/hexagon.xml +++ b/release/scripts/presets/interface_theme/hexagon.xml @@ -412,6 +412,7 @@ keyframe="#ff8500" meta_strip="#6d9183" movie_strip="#516987" + movieclip_strip="#20208f" plugin_strip="#7e7e50" scene_strip="#4e983e" transition_strip="#a25f6f" diff --git a/release/scripts/presets/interface_theme/ubuntu_ambiance.xml b/release/scripts/presets/interface_theme/ubuntu_ambiance.xml index 40e311c552f..bea98620b7f 100644 --- a/release/scripts/presets/interface_theme/ubuntu_ambiance.xml +++ b/release/scripts/presets/interface_theme/ubuntu_ambiance.xml @@ -412,6 +412,7 @@ keyframe="#f47421" meta_strip="#6d9183" movie_strip="#516987" + movieclip_strip="#20208f" plugin_strip="#7e7e50" scene_strip="#4e983e" transition_strip="#a25f6f" diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index 723fbd2e3d4..2848b49ef2b 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -185,6 +185,12 @@ class SEQUENCER_MT_add(Menu): else: layout.operator_menu_enum("sequencer.scene_strip_add", "scene", text="Scene...") + if len(bpy.data.movieclips) > 10: + layout.operator_context = 'INVOKE_DEFAULT' + layout.operator("sequencer.movieclip_strip_add", text="Clips...") + else: + layout.operator_menu_enum("sequencer.movieclip_strip_add", "clip", text="Clip...") + layout.operator("sequencer.movie_strip_add", text="Movie") layout.operator("sequencer.image_strip_add", text="Image") layout.operator("sequencer.sound_strip_add", text="Sound") @@ -534,7 +540,7 @@ class SEQUENCER_PT_input(SequencerButtonsPanel, Panel): if not strip: return False - return strip.type in {'MOVIE', 'IMAGE', 'SCENE', 'META', + return strip.type in {'MOVIE', 'IMAGE', 'SCENE', 'MOVIECLIP', 'META', 'ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER', 'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP', 'PLUGIN', @@ -697,7 +703,7 @@ class SEQUENCER_PT_filter(SequencerButtonsPanel, Panel): if not strip: return False - return strip.type in {'MOVIE', 'IMAGE', 'SCENE', 'META', + return strip.type in {'MOVIE', 'IMAGE', 'SCENE', 'MOVIECLIP', 'META', 'ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER', 'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP', 'PLUGIN', @@ -713,6 +719,15 @@ class SEQUENCER_PT_filter(SequencerButtonsPanel, Panel): col.label(text="Video:") col.prop(strip, "strobe") + if strip.type == 'MOVIECLIP': + col = layout.column() + col.label(text="Tracker:") + col.prop(strip, "stabilize2d") + + col = layout.column() + col.label(text="Distortion:") + col.prop(strip, "undistort") + row = layout.row() row.label(text="Flip:") row.prop(strip, "use_flip_x", text="X") diff --git a/source/blender/blenkernel/BKE_movieclip.h b/source/blender/blenkernel/BKE_movieclip.h index 793ad4dca0e..27b377d8cd5 100644 --- a/source/blender/blenkernel/BKE_movieclip.h +++ b/source/blender/blenkernel/BKE_movieclip.h @@ -51,6 +51,7 @@ struct ImBuf *BKE_movieclip_get_postprocessed_ibuf(struct MovieClip *clip, struc 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, int cache_flag); void BKE_movieclip_get_size(struct MovieClip *clip, struct MovieClipUser *user, int *width, int *height); +int BKE_movieclip_get_duration(struct MovieClip *clip); void BKE_movieclip_aspect(struct MovieClip *clip, float *aspx, float *aspy); int BKE_movieclip_has_frame(struct MovieClip *clip, struct MovieClipUser *user); void BKE_movieclip_user_set_frame(struct MovieClipUser *user, int framenr); diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 4b3a15181c1..7a84e71c763 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -187,7 +187,6 @@ struct Editing *seq_give_editing(struct Scene *scene, int alloc); const char *give_seqname(struct Sequence *seq); void calc_sequence(struct Scene *scene, struct Sequence *seq); void calc_sequence_disp(struct Scene *scene, struct Sequence *seq); -void new_tstripdata(struct Sequence *seq); void reload_sequence_new_file(struct Scene *scene, struct Sequence * seq, int lock_range); void sort_seq(struct Scene *scene); void build_seqar_cb(struct ListBase *seqbase, struct Sequence ***seqar, int *totseq, diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 1b415f1654f..4ef6a69d05b 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -861,6 +861,11 @@ void BKE_movieclip_get_size(MovieClip *clip, MovieClipUser *user, int *width, in } } +int BKE_movieclip_get_duration(struct MovieClip *clip) +{ + return IMB_anim_get_duration(clip->anim, clip->proxy.tc); +} + void BKE_movieclip_aspect(MovieClip *clip, float *aspx, float *aspy) { *aspx= *aspy= 1.0; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index e10d29e1cc8..ed8361f0cfc 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -39,6 +39,7 @@ #include "MEM_CacheLimiterC-Api.h" #include "DNA_sequence_types.h" +#include "DNA_movieclip_types.h" #include "DNA_scene_types.h" #include "DNA_anim_types.h" #include "DNA_object_types.h" @@ -57,6 +58,7 @@ #include "BKE_image.h" #include "BKE_main.h" #include "BKE_sequencer.h" +#include "BKE_movieclip.h" #include "BKE_fcurve.h" #include "BKE_scene.h" #include "BKE_utildefines.h" @@ -127,16 +129,6 @@ int seq_recursive_apply(Sequence *seq, int (*apply_func)(Sequence *, void *), vo * alloc / free functions * ********************************************************************** */ - - -void new_tstripdata(Sequence *seq) -{ - if(seq->strip) { - seq->strip->len= seq->len; - } -} - - /* free */ static void free_proxy_seq(Sequence *seq) @@ -621,11 +613,6 @@ void calc_sequence(Scene *scene, Sequence *seq) else { calc_sequence_disp(scene, seq); } - - if(seq->strip && seq->len!=seq->strip->len) { - new_tstripdata(seq); - } - } else { if(seq->type==SEQ_META) { @@ -642,10 +629,6 @@ void calc_sequence(Scene *scene, Sequence *seq) seq->len = max-min; seq->len -= seq->anim_startofs; seq->len -= seq->anim_endofs; - - if(seq->strip && seq->len!=seq->strip->len) { - new_tstripdata(seq); - } } seq_update_sound_bounds_recursive(scene, seq); } @@ -671,14 +654,6 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range) prev_enddisp= seq->enddisp; } - - new_tstripdata(seq); - - if (ELEM3(seq->type, SEQ_SCENE, SEQ_META, SEQ_IMAGE)==0) { - BLI_join_dirfile(str, sizeof(str), seq->strip->dir, seq->strip->stripdata->name); - BLI_path_abs(str, G.main->name); - } - switch(seq->type) { case SEQ_IMAGE: { @@ -691,10 +666,13 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range) if (seq->len < 0) { seq->len = 0; } - seq->strip->len = seq->len; break; } case SEQ_MOVIE: + BLI_join_dirfile(str, sizeof(str), seq->strip->dir, + seq->strip->stripdata->name); + BLI_path_abs(str, G.main->name); + if(seq->anim) IMB_free_anim(seq->anim); seq->anim = openanim(str, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0), seq->streamindex); @@ -714,7 +692,6 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range) if (seq->len < 0) { seq->len = 0; } - seq->strip->len = seq->len; break; case SEQ_SOUND: #ifdef WITH_AUDASPACE @@ -726,36 +703,18 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range) if (seq->len < 0) { seq->len = 0; } - seq->strip->len = seq->len; #else return; #endif break; case SEQ_SCENE: { - /* 'seq->scenenr' should be replaced with something more reliable */ - Scene * sce = G.main->scene.first; - int nr = 1; - - while(sce) { - if(nr == seq->scenenr) { - break; - } - nr++; - sce= sce->id.next; - } - - if (sce) { - seq->scene = sce; - } - seq->len= (seq->scene)? seq->scene->r.efra - seq->scene->r.sfra + 1: 0; seq->len -= seq->anim_startofs; seq->len -= seq->anim_endofs; if (seq->len < 0) { seq->len = 0; } - seq->strip->len = seq->len; break; } } @@ -904,6 +863,7 @@ static const char *give_seqname_by_type(int type) case SEQ_IMAGE: return "Image"; case SEQ_SCENE: return "Scene"; case SEQ_MOVIE: return "Movie"; + case SEQ_MOVIECLIP: return "Clip"; case SEQ_SOUND: return "Audio"; case SEQ_CROSS: return "Cross"; case SEQ_GAMCROSS: return "Gamma Cross"; @@ -1642,7 +1602,7 @@ static void color_balance(Sequence * seq, ImBuf* ibuf, float mul) } /* - * input preprocessing for SEQ_IMAGE, SEQ_MOVIE and SEQ_SCENE + * input preprocessing for SEQ_IMAGE, SEQ_MOVIE, SEQ_MOVIECLIP and SEQ_SCENE * * Do all the things you can't really do afterwards using sequence effects * (read: before rescaling to render resolution has been done) @@ -1694,7 +1654,8 @@ static ImBuf * input_preprocess( ibuf = IMB_makeSingleUser(ibuf); - if((seq->flag & SEQ_FILTERY) && seq->type != SEQ_MOVIE) { + if((seq->flag & SEQ_FILTERY) + && !ELEM(seq->type, SEQ_MOVIE, SEQ_MOVIECLIP)) { IMB_filtery(ibuf); } @@ -1977,12 +1938,62 @@ static ImBuf* seq_render_effect_strip_impl( return out; } +static ImBuf * seq_render_movieclip_strip( + SeqRenderData context, Sequence * seq, float nr) +{ + ImBuf * ibuf = NULL; + MovieClipUser user; + float tloc[2], tscale, tangle; -static ImBuf * seq_render_scene_strip_impl( + if(!seq->clip) { + return NULL; + } + + memset(&user, 0, sizeof(MovieClipUser)); + + BKE_movieclip_user_set_frame(&user, nr + seq->anim_startofs); + + user.render_size = MCLIP_PROXY_RENDER_SIZE_FULL; + + switch (seq_rendersize_to_proxysize(context.preview_render_size)) { + case IMB_PROXY_NONE: + user.render_size = MCLIP_PROXY_RENDER_SIZE_FULL; + break; + case IMB_PROXY_100: + user.render_size = MCLIP_PROXY_RENDER_SIZE_100; + break; + case IMB_PROXY_75: + user.render_size = MCLIP_PROXY_RENDER_SIZE_75; + break; + case IMB_PROXY_50: + user.render_size = MCLIP_PROXY_RENDER_SIZE_50; + break; + case IMB_PROXY_25: + user.render_size = MCLIP_PROXY_RENDER_SIZE_25; + break; + } + + if (seq->clip_flag & SEQ_MOVIECLIP_RENDER_UNDISTORTED) { + user.render_flag = MCLIP_PROXY_RENDER_UNDISTORT; + } + + if (seq->clip_flag & SEQ_MOVIECLIP_RENDER_STABILIZED) { + ibuf = BKE_movieclip_get_stable_ibuf( + seq->clip, &user, tloc, &tscale, &tangle, + 0); + } else { + ibuf = BKE_movieclip_get_ibuf_flag( + seq->clip, &user, 0, MOVIECLIP_CACHE_SKIP); + } + + return ibuf; +} + +static ImBuf * seq_render_scene_strip( SeqRenderData context, Sequence * seq, float nr) { ImBuf * ibuf = NULL; - float frame= seq->sfra + nr + seq->anim_startofs; + float frame; float oldcfra; Object *camera; ListBase oldmarkers; @@ -2030,6 +2041,7 @@ static ImBuf * seq_render_scene_strip_impl( } scene= seq->scene; + frame= scene->r.sfra + nr + seq->anim_startofs; have_seq= (scene->r.scemode & R_DOSEQ) && scene->ed && scene->ed->seqbase.first; @@ -2071,7 +2083,7 @@ static ImBuf * seq_render_scene_strip_impl( ibuf = sequencer_view3d_cb(scene, camera, context.rectx, context.recty, IB_rect, context.scene->r.seq_prev_type, TRUE, err_out); if(ibuf == NULL) { - fprintf(stderr, "seq_render_scene_strip_impl failed to get opengl buffer: %s\n", err_out); + fprintf(stderr, "seq_render_scene_strip failed to get opengl buffer: %s\n", err_out); } } else { @@ -2153,7 +2165,8 @@ static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfr if (ibuf == NULL) ibuf = copy_from_ibuf_still(context, seq, nr); - if (ibuf == NULL) { + /* MOVIECLIPs have their own proxy management */ + if (ibuf == NULL && seq->type != SEQ_MOVIECLIP) { ibuf = seq_proxy_fetch(context, seq, cfra); is_proxy_image = (ibuf != NULL); } @@ -2267,7 +2280,7 @@ static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfr } case SEQ_SCENE: { // scene can be NULL after deletions - ibuf = seq_render_scene_strip_impl(context, seq, nr); + ibuf = seq_render_scene_strip(context, seq, nr); /* Scene strips update all animation, so we need to restore original state.*/ BKE_animsys_evaluate_all_animation(context.bmain, context.scene, cfra); @@ -2275,6 +2288,21 @@ static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfr copy_to_ibuf_still(context, seq, nr, ibuf); break; } + case SEQ_MOVIECLIP: + { + ibuf = seq_render_movieclip_strip(context, seq, nr); + + if(ibuf && use_preprocess) { + struct ImBuf * i = IMB_dupImBuf(ibuf); + + IMB_freeImBuf(ibuf); + + ibuf = i; + } + + copy_to_ibuf_still(context, seq, nr, ibuf); + break; + } } if (ibuf == NULL) @@ -3677,7 +3705,7 @@ Sequence *sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo /* basic defaults */ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); - strip->len = seq->len = seq_load->len ? seq_load->len : 1; + seq->len = seq_load->len ? seq_load->len : 1; strip->us= 1; strip->stripdata= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); BLI_strncpy(strip->dir, seq_load->path, sizeof(strip->dir)); @@ -3727,7 +3755,7 @@ Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo /* basic defaults */ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); - strip->len = seq->len = ceil(info.length * FPS); + seq->len = ceil(info.length * FPS); strip->us= 1; /* we only need 1 element to store the filename */ @@ -3735,7 +3763,7 @@ Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo BLI_split_dirfile(seq_load->path, strip->dir, se->name, sizeof(strip->dir), sizeof(se->name)); - seq->scene_sound = sound_add_scene_sound(scene, seq, seq_load->start_frame, seq_load->start_frame + strip->len, 0); + seq->scene_sound = sound_add_scene_sound(scene, seq, seq_load->start_frame, seq_load->start_frame + seq->len, 0); calc_sequence_disp(scene, seq); @@ -3786,7 +3814,7 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo /* basic defaults */ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); - strip->len = seq->len = IMB_anim_get_duration(an, IMB_TC_RECORD_RUN); + seq->len = IMB_anim_get_duration(an, IMB_TC_RECORD_RUN); strip->us= 1; /* we only need 1 element for MOVIE strips */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index b531d216584..99aa35f3355 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4818,6 +4818,9 @@ static void lib_link_scene(FileData *fd, Main *main) seq->scene_sound = sound_scene_add_scene_sound_defaults(sce, seq); } } + if(seq->clip) { + seq->clip = newlibadr(fd, sce->id.lib, seq->clip); + } if(seq->scene_camera) seq->scene_camera= newlibadr(fd, sce->id.lib, seq->scene_camera); if(seq->sound) { seq->scene_sound = NULL; diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index f676dcbdff2..c329a784d18 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -149,6 +149,7 @@ enum { TH_CONSOLE_CURSOR, TH_SEQ_MOVIE, + TH_SEQ_MOVIECLIP, TH_SEQ_IMAGE, TH_SEQ_SCENE, TH_SEQ_AUDIO, diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index c93e166baea..1875a098793 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -364,6 +364,8 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo case TH_SEQ_MOVIE: cp= ts->movie; break; + case TH_SEQ_MOVIECLIP: + cp= ts->movieclip; break; case TH_SEQ_IMAGE: cp= ts->image; break; case TH_SEQ_SCENE: @@ -754,6 +756,7 @@ void ui_theme_init_default(void) btheme->tseq= btheme->tv3d; rgba_char_args_set(btheme->tseq.back, 116, 116, 116, 255); rgba_char_args_set(btheme->tseq.movie, 81, 105, 135, 255); + rgba_char_args_set(btheme->tseq.movieclip, 32, 32, 143, 255); rgba_char_args_set(btheme->tseq.image, 109, 88, 129, 255); rgba_char_args_set(btheme->tseq.scene, 78, 152, 62, 255); rgba_char_args_set(btheme->tseq.audio, 46, 143, 143, 255); diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 30a8523b426..5249c74ba84 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -52,9 +52,9 @@ #include "BKE_global.h" #include "BKE_main.h" #include "BKE_sequencer.h" +#include "BKE_movieclip.h" #include "BKE_report.h" - #include "WM_api.h" #include "WM_types.h" @@ -224,19 +224,16 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) seq->blend_mode= SEQ_CROSS; /* so alpha adjustment fade to the strip below */ seq->scene= sce_seq; - seq->sfra= sce_seq->r.sfra; /* basic defaults */ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); - strip->len = seq->len = sce_seq->r.efra - sce_seq->r.sfra + 1; + seq->len = sce_seq->r.efra - sce_seq->r.sfra + 1; strip->us= 1; - strip->stripdata= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - BLI_strncpy(seq->name+2, sce_seq->id.name+2, sizeof(seq->name)-2); seqbase_unique_name_recursive(&ed->seqbase, seq); - seq->scene_sound = sound_scene_add_scene_sound(scene, seq, start_frame, start_frame + strip->len, 0); + seq->scene_sound = sound_scene_add_scene_sound(scene, seq, start_frame, start_frame + seq->len, 0); calc_sequence_disp(scene, seq); sort_seq(scene); @@ -298,6 +295,103 @@ void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot) ot->prop= prop; } +/* add movieclip operator */ +static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + Editing *ed= seq_give_editing(scene, TRUE); + + MovieClip *clip; + + Sequence *seq; /* generic strip vars */ + Strip *strip; + + int start_frame, channel; /* operator props */ + + start_frame= RNA_int_get(op->ptr, "frame_start"); + channel= RNA_int_get(op->ptr, "channel"); + + clip= BLI_findlink(&CTX_data_main(C)->movieclip, RNA_enum_get(op->ptr, "clip")); + + if (clip == NULL) { + BKE_report(op->reports, RPT_ERROR, "MovieClip not found"); + return OPERATOR_CANCELLED; + } + + seq = alloc_sequence(ed->seqbasep, start_frame, channel); + seq->type= SEQ_MOVIECLIP; + seq->blend_mode= SEQ_CROSS; + seq->clip = clip; + + /* basic defaults */ + seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); + seq->len = BKE_movieclip_get_duration(clip); + strip->us= 1; + + BLI_strncpy(seq->name+2, clip->id.name+2, sizeof(seq->name)-2); + seqbase_unique_name_recursive(&ed->seqbase, seq); + + calc_sequence_disp(scene, seq); + sort_seq(scene); + + if (RNA_boolean_get(op->ptr, "replace_sel")) { + deselect_all_seq(scene); + seq_active_set(scene, seq); + seq->flag |= SELECT; + } + + if(RNA_boolean_get(op->ptr, "overlap") == FALSE) { + if(seq_test_overlap(ed->seqbasep, seq)) shuffle_seq(ed->seqbasep, seq, scene); + } + + WM_event_add_notifier(C, NC_SCENE|ND_SEQUENCER, scene); + + return OPERATOR_FINISHED; +} + + +static int sequencer_add_movieclip_strip_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + if(!ED_operator_sequencer_active(C)) { + BKE_report(op->reports, RPT_ERROR, "Sequencer area not active"); + return OPERATOR_CANCELLED; + } + + if(!RNA_struct_property_is_set(op->ptr, "clip")) + return WM_enum_search_invoke(C, op, event); + + sequencer_generic_invoke_xy__internal(C, op, event, 0); + return sequencer_add_movieclip_strip_exec(C, op); + // needs a menu + // return WM_menu_invoke(C, op, event); +} + + +void SEQUENCER_OT_movieclip_strip_add(struct wmOperatorType *ot) +{ + PropertyRNA *prop; + + /* identifiers */ + ot->name= "Add MovieClip Strip"; + ot->idname= "SEQUENCER_OT_movieclip_strip_add"; + ot->description= "Add a movieclip strip to the sequencer"; + + /* api callbacks */ + ot->invoke= sequencer_add_movieclip_strip_invoke; + ot->exec= sequencer_add_movieclip_strip_exec; + + ot->poll= ED_operator_scene_editable; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); + prop= RNA_def_enum(ot->srna, "clip", DummyRNA_NULL_items, 0, "Clip", ""); + RNA_def_enum_funcs(prop, RNA_movieclip_itemf); + ot->prop= prop; +} + + static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoadFunc seq_load_func) { Scene *scene= CTX_data_scene(C); /* only for sound */ @@ -624,10 +718,7 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) /* basic defaults */ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); - strip->len = seq->len; strip->us= 1; - if(seq->len>0) - strip->stripdata= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); if (seq->type==SEQ_PLUGIN) { char path[FILE_MAX]; diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index a9c32b4dfde..99888ba4a37 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -93,6 +93,10 @@ static void get_seq_color3ubv(Scene *curscene, Sequence *seq, unsigned char col[ case SEQ_MOVIE: UI_GetThemeColor3ubv(TH_SEQ_MOVIE, col); break; + + case SEQ_MOVIECLIP: + UI_GetThemeColor3ubv(TH_SEQ_MOVIECLIP, col); + break; case SEQ_SCENE: UI_GetThemeColor3ubv(TH_SEQ_SCENE, col); @@ -534,6 +538,14 @@ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float BLI_snprintf(str, sizeof(str), "%d | %s", seq->len, name); } } + else if(seq->type == SEQ_MOVIECLIP) { + if(seq->clip && strcmp(name, seq->clip->id.name+2) != 0) { + BLI_snprintf(str, sizeof(str), "%d | %s: %s", seq->len, name, seq->clip->id.name+2); + } + else { + BLI_snprintf(str, sizeof(str), "%d | %s", seq->len, name); + } + } else if(seq->type == SEQ_MULTICAM) { BLI_snprintf(str, sizeof(str), "Cam | %s: %d", name, seq->multicam_source); } diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 62bbe09c4d8..d9f5b283d6a 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -660,7 +660,6 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence * seq, int cutframe) reload_sequence_new_file(scene, seq, FALSE); calc_sequence(scene, seq); - new_tstripdata(seq); if (!skip_dup) { /* Duplicate AFTER the first change */ @@ -701,7 +700,6 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence * seq, int cutframe) reload_sequence_new_file(scene, seqn, FALSE); calc_sequence(scene, seqn); - new_tstripdata(seqn); } return seqn; } @@ -754,7 +752,6 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence * seq, int cutframe) } calc_sequence(scene, seq); - new_tstripdata(seq); if (!skip_dup) { /* Duplicate AFTER the first change */ @@ -790,7 +787,6 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence * seq, int cutframe) } calc_sequence(scene, seqn); - new_tstripdata(seqn); } return seqn; } @@ -1632,7 +1628,6 @@ static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op)) /* free parent metas */ ms= ed->metastack.last; while(ms) { - ms->parseq->strip->len= 0; /* force new alloc */ calc_sequence(scene, ms->parseq); ms= ms->prev; } @@ -1752,7 +1747,6 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) /* new strip */ strip_new= seq_new->strip; - strip_new->len= 1; strip_new->us= 1; /* new stripdata */ @@ -1912,7 +1906,6 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) calc_sequence(scene, seqm); seqm->strip= MEM_callocN(sizeof(Strip), "metastrip"); - seqm->strip->len= seqm->len; seqm->strip->us= 1; seq_active_set(scene, seqm); diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index 2d98278e163..ef782832f13 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -136,6 +136,7 @@ void SEQUENCER_OT_select_grouped(struct wmOperatorType *ot); /* sequencer_select.c */ void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot); void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot); +void SEQUENCER_OT_movieclip_strip_add(struct wmOperatorType *ot); void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot); void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot); void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index e53d06c9786..1ebb8af321c 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -104,6 +104,7 @@ void sequencer_operatortypes(void) /* sequencer_add.c */ WM_operatortype_append(SEQUENCER_OT_scene_strip_add); + WM_operatortype_append(SEQUENCER_OT_movieclip_strip_add); WM_operatortype_append(SEQUENCER_OT_movie_strip_add); WM_operatortype_append(SEQUENCER_OT_sound_strip_add); WM_operatortype_append(SEQUENCER_OT_image_strip_add); diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index aeae840707d..ba64f332de5 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -40,6 +40,7 @@ struct Ipo; struct Scene; struct bSound; +struct MovieClip; /* strlens; 256= FILE_MAXFILE, 768= FILE_MAXDIR */ @@ -88,9 +89,11 @@ typedef struct StripProxy { typedef struct Strip { struct Strip *next, *prev; - int rt, len, us, done; + int us, done; int startstill, endstill; - StripElem *stripdata; + StripElem *stripdata; /* only used as an array in IMAGE sequences(!), + and as a 1-element array in MOVIE sequences, + NULL for all other strip-types */ char dir[768]; StripProxy *proxy; StripCrop *crop; @@ -137,10 +140,11 @@ typedef struct Sequence { int startdisp, enddisp; /*starting and ending points in the sequence*/ float sat; float mul, handsize; - /* is sfra needed anymore? - it looks like its only used in one place */ - int sfra; /* starting frame according to the timeline of the scene. */ - int anim_preseek; - int streamindex; /* streamindex for movie or sound files with several streams */ + + short anim_preseek; + short streamindex; /* streamindex for movie or sound files with several streams */ + int multicam_source; /* for multicam source selection */ + int clip_flag; /* MOVIECLIP render flags */ Strip *strip; @@ -148,7 +152,9 @@ typedef struct Sequence { struct Scene *scene; struct Object *scene_camera; /* override scene camera */ - struct anim *anim; + struct anim *anim; /* for MOVIE strips */ + struct MovieClip *clip; /* for MOVIECLIP strips */ + float effect_fader; float speed_fader; @@ -164,8 +170,6 @@ typedef struct Sequence { float volume; float pitch, pan; /* pitch (-0.1..10), pan -2..2 */ - int scenenr; /* for scene selection */ - int multicam_source; /* for multicam source selection */ float strobe; void *effectdata; /* Struct pointer for effect settings */ @@ -173,6 +177,7 @@ typedef struct Sequence { int anim_startofs; /* only use part of animation file */ int anim_endofs; /* is subtle different to startofs / endofs */ + int blend_mode; float blend_opacity; @@ -321,6 +326,7 @@ typedef struct SpeedControlVars { #define SEQ_RAM_SOUND 4 #define SEQ_HD_SOUND 5 #define SEQ_SOUND 4 +#define SEQ_MOVIECLIP 6 #define SEQ_EFFECT 8 #define SEQ_CROSS 8 @@ -346,6 +352,9 @@ typedef struct SpeedControlVars { #define STRIPELEM_PREVIEW_DONE 1 +#define SEQ_MOVIECLIP_RENDER_UNDISTORTED (1<<0) +#define SEQ_MOVIECLIP_RENDER_STABILIZED (1<<1) + #define SEQ_BLEND_REPLACE 0 /* all other BLEND_MODEs are simple SEQ_EFFECT ids and therefore identical * to the table above. (Only those effects that handle _exactly_ two inputs, diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 157a45f0f00..3dbe6f49ca9 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -205,7 +205,7 @@ typedef struct ThemeSpace { char grid[4]; char wire[4], select[4]; - char lamp[4], speaker[4], pad2[4]; + char lamp[4], speaker[4]; char active[4], group[4], group_active[4], transform[4]; char vertex[4], vertex_select[4]; char edge[4], edge_select[4]; @@ -236,7 +236,7 @@ typedef struct ThemeSpace { char syntaxl[4], syntaxn[4], syntaxb[4]; // syntax for textwindow and nodes char syntaxv[4], syntaxc[4]; - char movie[4], image[4], scene[4], audio[4]; // for sequence editor + char movie[4], movieclip[4], image[4], scene[4], audio[4]; // for sequence editor char effect[4], plugin[4], transition[4], meta[4]; char editmesh_active[4]; diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index f4c3e4ed86d..7d7629f8eef 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -336,6 +336,7 @@ extern StructRNA RNA_MotionPath; extern StructRNA RNA_MotionPathVert; extern StructRNA RNA_MouseSensor; extern StructRNA RNA_MovieSequence; +extern StructRNA RNA_MovieClipSequence; extern StructRNA RNA_MovieTrackingObject; extern StructRNA RNA_MulticamSequence; extern StructRNA RNA_MultiresModifier; diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index a333d9ace12..b544c59a403 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -136,5 +136,8 @@ EnumPropertyItem *RNA_image_itemf(struct bContext *C, struct PointerRNA *ptr, st EnumPropertyItem *RNA_image_local_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int *free); EnumPropertyItem *RNA_scene_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int *free); EnumPropertyItem *RNA_scene_local_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int *free); +EnumPropertyItem *RNA_movieclip_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int *free); +EnumPropertyItem *RNA_movieclip_local_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int *free); + #endif /* __RNA_ENUM_TYPES_H__ */ diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 1d95436cf37..5365c16cc3d 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -37,6 +37,7 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_sequence_types.h" +#include "DNA_movieclip_types.h" #include "BKE_animsys.h" #include "BKE_global.h" @@ -392,6 +393,8 @@ static StructRNA* rna_Sequence_refine(struct PointerRNA *ptr) return &RNA_SceneSequence; case SEQ_MOVIE: return &RNA_MovieSequence; + case SEQ_MOVIECLIP: + return &RNA_MovieClipSequence; case SEQ_SOUND: return &RNA_SoundSequence; case SEQ_CROSS: @@ -950,6 +953,7 @@ static void rna_def_sequence(BlenderRNA *brna) {SEQ_META, "META", 0, "Meta", ""}, {SEQ_SCENE, "SCENE", 0, "Scene", ""}, {SEQ_MOVIE, "MOVIE", 0, "Movie", ""}, + {SEQ_MOVIECLIP, "MOVIECLIP", 0, "Clip", ""}, {SEQ_SOUND, "SOUND", 0, "Sound", ""}, {SEQ_CROSS, "CROSS", 0, "Cross", ""}, {SEQ_ADD, "ADD", 0, "Add", ""}, @@ -1462,6 +1466,30 @@ static void rna_def_movie(BlenderRNA *brna) rna_def_input(srna); } +static void rna_def_movieclip(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "MovieClipSequence", "Sequence"); + RNA_def_struct_ui_text(srna, "MovieClip Sequence", "Sequence strip to load a video from the clip editor"); + RNA_def_struct_sdna(srna, "Sequence"); + + prop = RNA_def_property(srna, "undistort", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "clip_flag", SEQ_MOVIECLIP_RENDER_UNDISTORTED); + RNA_def_property_ui_text(prop, "Undistort Clip", "Use the undistorted version of the clip"); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + + prop = RNA_def_property(srna, "stabilize2d", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "clip_flag", SEQ_MOVIECLIP_RENDER_STABILIZED); + RNA_def_property_ui_text(prop, "Stabilize 2D Clip", "Use the 2D stabilized version of the clip"); + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + + rna_def_filter_video(srna); + rna_def_input(srna); +} + + static void rna_def_sound(BlenderRNA *brna) { StructRNA *srna; @@ -1811,6 +1839,7 @@ void RNA_def_sequencer(BlenderRNA *brna) rna_def_meta(brna); rna_def_scene(brna); rna_def_movie(brna); + rna_def_movieclip(brna); rna_def_sound(brna); rna_def_effect(brna); rna_def_multicam(brna); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 80ef320df65..b9bc7311303 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1724,6 +1724,12 @@ static void rna_def_userdef_theme_space_seq(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Movie Strip", ""); RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "movieclip_strip", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "movieclip"); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Clip Strip", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "image_strip", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "image"); RNA_def_property_array(prop, 3); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 8fe5bba3cc4..93aa362ec41 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -4024,3 +4024,12 @@ EnumPropertyItem *RNA_scene_local_itemf(bContext *C, PointerRNA *ptr, PropertyRN { return rna_id_itemf(C, ptr, do_free, C ? (ID *)CTX_data_main(C)->scene.first : NULL, TRUE); } + +EnumPropertyItem *RNA_movieclip_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *do_free) +{ + return rna_id_itemf(C, ptr, do_free, C ? (ID *)CTX_data_main(C)->movieclip.first : NULL, FALSE); +} +EnumPropertyItem *RNA_movieclip_local_itemf(bContext *C, PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *do_free) +{ + return rna_id_itemf(C, ptr, do_free, C ? (ID *)CTX_data_main(C)->movieclip.first : NULL, TRUE); +} |