From fd9db17021064552cdecbcfadce4255257d71e17 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Tue, 29 Jan 2008 12:26:42 +0000 Subject: [PATCH] == Sequencer == This fixes several crashes with the new tstripdata_start/endstill. dupli_seq was cleaned up as well as add_scene_strip (moved to a seperate function) New features: * opacity can be used in replace blend mode * the scene within in a scene track can be changed now within the panel Also: * [#7842] Note: setCodec in FormatTab disappeared... should be fixed by this. (Not a big change, so I just commit and see :) http://peter.schlaile.de/blender/sequencer/codec_buttons.diff --- source/blender/blenloader/intern/readfile.c | 2 + source/blender/makesdna/DNA_sequence_types.h | 3 + source/blender/src/buttons_scene.c | 66 +++++- source/blender/src/editseq.c | 229 ++++++++----------- source/blender/src/sequence.c | 36 ++- 5 files changed, 187 insertions(+), 149 deletions(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index f3a3a3478ac..3d1a9822ecb 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3396,6 +3396,8 @@ static void direct_link_scene(FileData *fd, Scene *sce) if(seq->strip && seq->strip->done==0) { seq->strip->done= 1; seq->strip->tstripdata = 0; + seq->strip->tstripdata_startstill = 0; + seq->strip->tstripdata_endstill = 0; if(seq->type == SEQ_IMAGE || seq->type == SEQ_MOVIE || diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index d9e87837f0f..6798e726ce8 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -160,6 +160,9 @@ typedef struct Sequence { int blend_mode; float blend_opacity; + + int scenenr; /* for scene selection */ + int pad; } Sequence; typedef struct MetaStack { diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c index 785855410bb..ca9a1b31f88 100644 --- a/source/blender/src/buttons_scene.c +++ b/source/blender/src/buttons_scene.c @@ -514,6 +514,43 @@ static char* seq_panel_blend_modes() return string; } +static char* seq_panel_scenes() +{ + static char rstr[8192]; + char * str; + + IDnames_to_pupstring(&str, NULL, NULL, + &G.main->scene, (ID *)G.scene, NULL); + + strncpy(rstr, str, 8192); + MEM_freeN(str); + + return rstr; +} + +static void seq_update_scenenr(Sequence * seq) +{ + Scene * sce; + int nr; + if (seq->type != SEQ_SCENE) { + return; + } + + seq->scenenr = 0; + + sce = G.main->scene.first; + nr = 1; + while(sce) { + if (sce == seq->scene) { + seq->scenenr = nr; + break; + } + nr++; + sce = sce->id.next; + } +} + + static void seq_panel_editing() { Sequence *last_seq = get_last_seq(); @@ -543,12 +580,10 @@ static void seq_panel_editing() 10, 120, 120, 19, &last_seq->blend_mode, 0,0,0,0, "Strip Blend Mode"); - if (last_seq->blend_mode > 0) { - uiDefButF(block, NUM, B_SEQ_BUT_RELOAD, "Blend:", - 130, 120, 120, 19, &last_seq->blend_opacity, - 0.0, 100.0, 100.0, 0, - "Blend opacity"); - } + uiDefButF(block, NUM, B_SEQ_BUT_RELOAD, "Blend:", + 130, 120, 120, 19, &last_seq->blend_opacity, + 0.0, 100.0, 100.0, 0, + "Blend opacity"); uiDefButBitI(block, TOG, SEQ_MUTE, B_SEQ_BUT_RELOAD_ALL, "Mute", @@ -716,7 +751,7 @@ static void seq_panel_input() if (se) { uiDefBut(block, TEX, B_SEQ_BUT_RELOAD_FILE, "File: ", - 10, 120, 240,19, se->name, + 10, 120, 190,19, se->name, 0.0, 80.0, 100, 0, ""); } @@ -725,10 +760,21 @@ static void seq_panel_input() last_seq->type == SEQ_RAM_SOUND) { uiDefBut(block, TEX, B_SEQ_BUT_RELOAD_FILE, "File: ", - 10,120,240,19, last_seq->strip->stripdata->name, + 10,120,190,19, last_seq->strip->stripdata->name, 0.0, 80.0, 100, 0, ""); + } else if (last_seq->type == SEQ_SCENE) { + seq_update_scenenr(last_seq); + uiDefButI(block, MENU, B_SEQ_BUT_RELOAD_FILE, + seq_panel_scenes(), + 10, 120, 190, 19, &last_seq->scenenr, + 0,0,0,0, "Linked Scene"); } + uiDefBut(block, BUT, B_SEQ_BUT_RELOAD_FILE, + "Reload", + 200,120,50,19, 0, 0, 0, 0, 0, + "Reload files/scenes from disk and update strip length."); + if (last_seq->type == SEQ_MOVIE || last_seq->type == SEQ_IMAGE || last_seq->type == SEQ_SCENE) { @@ -2306,11 +2352,7 @@ static void render_panel_format(void) if(G.scene->r.quality==0) G.scene->r.quality= 90; -#ifdef WITH_QUICKTIME if (G.scene->r.imtype == R_AVICODEC || G.scene->r.imtype == R_QUICKTIME) { -#else /* WITH_QUICKTIME */ - if (0) { -#endif if(G.scene->r.imtype == R_QUICKTIME) { #ifdef WITH_QUICKTIME #if defined (_WIN32) || defined (__APPLE__) diff --git a/source/blender/src/editseq.c b/source/blender/src/editseq.c index a3bdbd0f7ab..e5e5a960f0c 100644 --- a/source/blender/src/editseq.c +++ b/source/blender/src/editseq.c @@ -1458,6 +1458,50 @@ static void add_sound_strip_hd(char *name) transform_seq_nomarker('g', 0); } +static void add_scene_strip(short event) +{ + Sequence *seq; + Strip *strip; + float x, y; + int cfra, machine; + short mval[2]; + + if(event> -1) { + int nr= 1; + Scene * sce= G.main->scene.first; + while(sce) { + if( event==nr) break; + nr++; + sce= sce->id.next; + } + if(sce) { + + deselect_all_seq(); + + /* where ? */ + getmouseco_areawin(mval); + areamouseco_to_ipoco(G.v2d, mval, &x, &y); + cfra= (int)(x+0.5); + machine= (int)(y+0.5); + + seq= alloc_sequence(((Editing *)G.scene->ed)->seqbasep, cfra, machine); + seq->type= SEQ_SCENE; + seq->scene= sce; + seq->sfra= sce->r.sfra; + seq->len= sce->r.efra - sce->r.sfra + 1; + + seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); + strncpy(seq->name + 2, sce->id.name + 2, + sizeof(seq->name) - 2); + strip->len= seq->len; + strip->us= 1; + + BIF_undo_push("Add Scene Strip, Sequencer"); + transform_seq_nomarker('g', 0); + } + } +} + #if 0 static void reload_sound_strip(char *name) { @@ -1713,12 +1757,7 @@ static void load_plugin_seq(char *str) /* called from fileselect */ void add_sequence(int type) { Editing *ed; - Sequence *seq; - Strip *strip; - Scene *sce; - float x, y; - int cfra, machine; - short nr, event, mval[2]; + short event; char *str; if (type >= 0){ @@ -1844,43 +1883,8 @@ void add_sequence(int type) /* new menu: */ IDnames_to_pupstring(&str, NULL, NULL, &G.main->scene, (ID *)G.scene, NULL); - event= pupmenu_col(str, 20); + add_scene_strip(pupmenu_col(str, 20)); - if(event> -1) { - nr= 1; - sce= G.main->scene.first; - while(sce) { - if( event==nr) break; - nr++; - sce= sce->id.next; - } - if(sce) { - - deselect_all_seq(); - - /* where ? */ - getmouseco_areawin(mval); - areamouseco_to_ipoco(G.v2d, mval, &x, &y); - cfra= (int)(x+0.5); - machine= (int)(y+0.5); - - seq= alloc_sequence(((Editing *)G.scene->ed)->seqbasep, cfra, machine); - seq->type= SEQ_SCENE; - seq->scene= sce; - seq->sfra= sce->r.sfra; - seq->len= sce->r.efra - sce->r.sfra + 1; - - seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); - strncpy(seq->name + 2, sce->id.name + 2, - sizeof(seq->name) - 2); - strip->len= seq->len; - strip->us= 1; - if(seq->len>0) strip->stripdata= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - - BIF_undo_push("Add Scene Strip, Sequencer"); - transform_seq_nomarker('g', 0); - } - } MEM_freeN(str); break; @@ -2161,97 +2165,19 @@ void del_seq(void) allqueue(REDRAWSEQ, 0); } -static Sequence *dupli_seq(Sequence *seq) { - Sequence *seqn = NULL; - - if(seq->type==SEQ_META) { - seqn= MEM_dupallocN(seq); - seq->tmp= seqn; +static Sequence *dupli_seq(Sequence *seq) +{ + Sequence *seqn = MEM_dupallocN(seq); + + seq->tmp = seqn; - seqn->strip= MEM_dupallocN(seq->strip); - seqn->strip->stripdata = 0; - seqn->strip->tstripdata = 0; + seqn->strip= MEM_dupallocN(seq->strip); - seqn->seqbase.first= seqn->seqbase.last= 0; - /* WATCH OUT!!! - This metastrip is not recursively duplicated here - do this after!!! */ - /* - recurs_dupli_seq(&seq->seqbase,&seqn->seqbase);*/ - } - else if(seq->type == SEQ_SCENE) { - seqn= MEM_dupallocN(seq); - seq->tmp= seqn; + if(seqn->ipo) seqn->ipo->id.us++; - seqn->strip= MEM_dupallocN(seq->strip); - seqn->strip->stripdata = 0; - seqn->strip->tstripdata = 0; - } - else if(seq->type == SEQ_MOVIE) { - seqn= MEM_dupallocN(seq); - seq->tmp= seqn; - - seqn->strip= MEM_dupallocN(seq->strip); - seqn->strip->stripdata = - MEM_dupallocN(seq->strip->stripdata); - seqn->strip->tstripdata = 0; - seqn->anim= 0; - } - else if(seq->type == SEQ_RAM_SOUND) { - seqn= MEM_dupallocN(seq); - seq->tmp= seqn; - - seqn->strip= MEM_dupallocN(seq->strip); - seqn->strip->stripdata = - MEM_dupallocN(seq->strip->stripdata); - seqn->strip->tstripdata = 0; - - seqn->anim= 0; - seqn->sound->id.us++; - if(seqn->ipo) seqn->ipo->id.us++; - } - else if(seq->type == SEQ_HD_SOUND) { - seqn= MEM_dupallocN(seq); - seq->tmp= seqn; - - seqn->strip= MEM_dupallocN(seq->strip); - seqn->strip->stripdata = - MEM_dupallocN(seq->strip->stripdata); - seqn->strip->tstripdata = 0; - seqn->anim= 0; - seqn->hdaudio = 0; - if(seqn->ipo) seqn->ipo->id.us++; - } else if(seq->type == SEQ_IMAGE) { - seqn= MEM_dupallocN(seq); - seq->tmp= seqn; - - seqn->strip= MEM_dupallocN(seq->strip); - seqn->strip->stripdata = - MEM_dupallocN(seq->strip->stripdata); - seqn->strip->tstripdata = 0; - } else if(seq->type >= SEQ_EFFECT) { - seqn= MEM_dupallocN(seq); - seq->tmp= seqn; - - if(seq->seq1 && seq->seq1->tmp) seqn->seq1= seq->seq1->tmp; - if(seq->seq2 && seq->seq2->tmp) seqn->seq2= seq->seq2->tmp; - if(seq->seq3 && seq->seq3->tmp) seqn->seq3= seq->seq3->tmp; - - if(seqn->ipo) seqn->ipo->id.us++; - - if (seq->type & SEQ_EFFECT) { - struct SeqEffectHandle sh; - sh = get_sequence_effect(seq); - if(sh.copy) - sh.copy(seq, seqn); - } - - seqn->strip= MEM_dupallocN(seq->strip); - seqn->strip->stripdata = 0; - seqn->strip->tstripdata = 0; - - } else { - fprintf(stderr, "Aiiiiekkk! sequence type not " - "handled in duplicate!\nExpect a crash" - " now...\n"); - } + seqn->strip->tstripdata = 0; + seqn->strip->tstripdata_startstill = 0; + seqn->strip->tstripdata_endstill = 0; if (seq->strip->crop) { seqn->strip->crop = MEM_dupallocN(seq->strip->crop); @@ -2265,6 +2191,49 @@ static Sequence *dupli_seq(Sequence *seq) { seqn->strip->proxy = MEM_dupallocN(seq->strip->proxy); } + if(seq->type==SEQ_META) { + seqn->strip->stripdata = 0; + + seqn->seqbase.first= seqn->seqbase.last= 0; + /* WATCH OUT!!! - This metastrip is not recursively duplicated here - do this after!!! */ + /* - recurs_dupli_seq(&seq->seqbase,&seqn->seqbase);*/ + } else if(seq->type == SEQ_SCENE) { + seqn->strip->stripdata = 0; + } else if(seq->type == SEQ_MOVIE) { + seqn->strip->stripdata = + MEM_dupallocN(seq->strip->stripdata); + seqn->anim= 0; + } else if(seq->type == SEQ_RAM_SOUND) { + seqn->strip->stripdata = + MEM_dupallocN(seq->strip->stripdata); + seqn->sound->id.us++; + } else if(seq->type == SEQ_HD_SOUND) { + seqn->strip->stripdata = + MEM_dupallocN(seq->strip->stripdata); + seqn->hdaudio = 0; + } else if(seq->type == SEQ_IMAGE) { + seqn->strip->stripdata = + MEM_dupallocN(seq->strip->stripdata); + } else if(seq->type >= SEQ_EFFECT) { + if(seq->seq1 && seq->seq1->tmp) seqn->seq1= seq->seq1->tmp; + if(seq->seq2 && seq->seq2->tmp) seqn->seq2= seq->seq2->tmp; + if(seq->seq3 && seq->seq3->tmp) seqn->seq3= seq->seq3->tmp; + + if (seq->type & SEQ_EFFECT) { + struct SeqEffectHandle sh; + sh = get_sequence_effect(seq); + if(sh.copy) + sh.copy(seq, seqn); + } + + seqn->strip->stripdata = 0; + + } else { + fprintf(stderr, "Aiiiiekkk! sequence type not " + "handled in duplicate!\nExpect a crash" + " now...\n"); + } + return seqn; } diff --git a/source/blender/src/sequence.c b/source/blender/src/sequence.c index e10d78abd89..003c2c0e491 100644 --- a/source/blender/src/sequence.c +++ b/source/blender/src/sequence.c @@ -401,8 +401,10 @@ void reload_sequence_new_file(Sequence * seq) return; } - strncpy(str, seq->strip->dir, FILE_MAXDIR-1); - strncat(str, seq->strip->stripdata->name, FILE_MAXFILE-1); + if (seq->type != SEQ_SCENE) { + strncpy(str, seq->strip->dir, FILE_MAXDIR-1); + strncat(str, seq->strip->stripdata->name, FILE_MAXFILE-1); + } if (seq->type == SEQ_MOVIE) { if(seq->anim) IMB_free_anim(seq->anim); @@ -433,6 +435,23 @@ void reload_sequence_new_file(Sequence * seq) seq->strip->len = seq->len = sound_hdaudio_get_duration(seq->hdaudio, FPS); } else if (seq->type == SEQ_SCENE) { + 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; + } + + strncpy(seq->name + 2, sce->id.name + 2, + sizeof(seq->name) - 2); + seq->len= seq->scene->r.efra - seq->scene->r.sfra + 1; seq->len -= seq->anim_startofs; seq->len -= seq->anim_endofs; @@ -849,7 +868,7 @@ TStripElem *give_tstripelem(Sequence *seq, int cfra) se->nr= nr; - + return se; } @@ -1085,11 +1104,14 @@ static void input_preprocess(Sequence * seq, TStripElem* se, int cfra) mul = seq->mul; - if(seq->blend_mode == SEQ_BLEND_REPLACE - && seq->ipo && seq->ipo->curve.first) { - do_seq_ipo(seq, cfra); - mul *= seq->facf0; + if(seq->blend_mode == SEQ_BLEND_REPLACE) { + if (seq->ipo && seq->ipo->curve.first) { + do_seq_ipo(seq, cfra); + mul *= seq->facf0; + } + mul *= seq->blend_opacity / 100.0; } + if(mul != 1.0) { multibuf(se->ibuf, mul); }