== Sequencer ==
authorPeter Schlaile <peter@schlaile.de>
Tue, 29 Jan 2008 12:26:42 +0000 (12:26 +0000)
committerPeter Schlaile <peter@schlaile.de>
Tue, 29 Jan 2008 12:26:42 +0000 (12:26 +0000)
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
source/blender/makesdna/DNA_sequence_types.h
source/blender/src/buttons_scene.c
source/blender/src/editseq.c
source/blender/src/sequence.c

index f3a3a3478acb97e007a63f869a6745a3452ee259..3d1a9822ecbc4e7286d7b0082db134e3d73c26d0 100644 (file)
@@ -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 ||
index d9e87837f0fa937617e0aa939b622a600163f464..6798e726ce802ac206a5c92ffed21daf1ae9f15b 100644 (file)
@@ -160,6 +160,9 @@ typedef struct Sequence {
 
        int blend_mode;
        float blend_opacity;
+
+       int scenenr;          /* for scene selection */
+       int pad;
 } Sequence;
 
 typedef struct MetaStack {
index 785855410bb9d147af2a78c8d80ca624c730c35c..ca9a1b31f8840679b0e25939658f3b6f56403310 100644 (file)
@@ -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__)
index a3bdbd0f7ab47606f9c7b4ad8933354ad79bed74..e5e5a960f0c016243516f03a0377bc81aa5ad86d 100644 (file)
@@ -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,81 +2165,60 @@ void del_seq(void)
        allqueue(REDRAWSEQ, 0);
 }
 
-static Sequence *dupli_seq(Sequence *seq) {
-       Sequence *seqn = NULL;
+static Sequence *dupli_seq(Sequence *seq) 
+{
+       Sequence *seqn = MEM_dupallocN(seq);
+
+       seq->tmp = seqn;
+               
+       seqn->strip= MEM_dupallocN(seq->strip);
+
+       if(seqn->ipo) seqn->ipo->id.us++;
+
+       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);
+       }
+
+       if (seq->strip->transform) {
+               seqn->strip->transform = MEM_dupallocN(seq->strip->transform);
+       }
+
+       if (seq->strip->proxy) {
+               seqn->strip->proxy = MEM_dupallocN(seq->strip->proxy);
+       }
        
        if(seq->type==SEQ_META) {
-               seqn= MEM_dupallocN(seq);
-               seq->tmp= seqn;
-               
-               seqn->strip= MEM_dupallocN(seq->strip);
                seqn->strip->stripdata = 0;
-               seqn->strip->tstripdata = 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= MEM_dupallocN(seq);
-               seq->tmp= seqn;
-
-               seqn->strip= MEM_dupallocN(seq->strip);
+       } else if(seq->type == SEQ_SCENE) {
                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);
+       } else if(seq->type == SEQ_MOVIE) {
                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);
+       } else if(seq->type == SEQ_RAM_SOUND) {
                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);
+       } else if(seq->type == SEQ_HD_SOUND) {
                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);
@@ -2243,27 +2226,13 @@ static Sequence *dupli_seq(Sequence *seq) {
                                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");
        }
-
-       if (seq->strip->crop) {
-               seqn->strip->crop = MEM_dupallocN(seq->strip->crop);
-       }
-
-       if (seq->strip->transform) {
-               seqn->strip->transform = MEM_dupallocN(seq->strip->transform);
-       }
-
-       if (seq->strip->proxy) {
-               seqn->strip->proxy = MEM_dupallocN(seq->strip->proxy);
-       }
        
        return seqn;
 }
index e10d78abd89dbfa2d2eedef165a1e114ed727679..003c2c0e491e5d4d6978f136d9cba4cc62528b00 100644 (file)
@@ -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);
        }