diff options
author | Peter Schlaile <peter@schlaile.de> | 2012-03-21 22:02:29 +0400 |
---|---|---|
committer | Peter Schlaile <peter@schlaile.de> | 2012-03-21 22:02:29 +0400 |
commit | d8623da305b81523f938b0cc0ebc942670cf0b97 (patch) | |
tree | 0d1fdf1b71b5853b3642e2df8daae8ccf73686d9 /source/blender/editors/space_sequencer/sequencer_add.c | |
parent | ee1dc842397efc37d09778dae2c61ba23831b205 (diff) |
== Sequencer ==
This adds movieclip input support to the sequencer, thereby making
undistorted and stabilized footage available without a seperate render step.
Also: removes some old cruft code from the sequencer:
* new_tstripdata wasn't used anymore
* StripElems were allocated for SCENE strips on full length, wasting memory
Added a comment, that hopefully makes things a little bit clearer:
StripElems are *only* usefull for MOVIE + IMAGE strips for all other strip
types one can set this pointer to NULL. (If that should cause otherwise
problems, then the code that doesn't check for NULL is to blame!)
Diffstat (limited to 'source/blender/editors/space_sequencer/sequencer_add.c')
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_add.c | 109 |
1 files changed, 100 insertions, 9 deletions
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]; |