== Sequencer ==
authorPeter Schlaile <peter@schlaile.de>
Wed, 26 Dec 2007 19:30:49 +0000 (19:30 +0000)
committerPeter Schlaile <peter@schlaile.de>
Wed, 26 Dec 2007 19:30:49 +0000 (19:30 +0000)
Moved status info bar into panels. It was always shown on the wrong place...
Added anim-startofs and anim-endofs, so that one can specify the range of
_input_ that should be used.

There is a subtle difference to start-ofs and end-ofs,
which will show, when you use "Reverse Frames" or "Speed Control". Both
effects operate on the input-range and _not_ on the display range! Now
you can control both in a comfortable way. Only thing missing: a button
to copy start-ofs and end-ofs to anim-startofs and anim-endofs.
(Andy: that was the feature you missed, when storyboarding with the sequencer
and the speed control effect :)

Also: added File-Name and Dir-Name to redirect input as needed.

source/blender/include/BSE_sequence.h
source/blender/include/butspace.h
source/blender/makesdna/DNA_sequence_types.h
source/blender/src/buttons_scene.c
source/blender/src/drawseq.c
source/blender/src/sequence.c

index 7bdf16e8e90f22161c563a8976bbabeba6a70af3..46e0aa6ff1f991707ba687271081ec12699a6c97 100644 (file)
@@ -60,6 +60,7 @@ void build_seqar_cb(struct ListBase *seqbase, struct Sequence  ***seqar,
 void free_editing(struct Editing *ed);
 void calc_sequence(struct Sequence *seq);
 void calc_sequence_disp(struct Sequence *seq);
+void reload_sequence_new_file(struct Sequence * seq);
 void sort_seq(void);
 void clear_scene_in_allseqs(struct Scene *sce);
 
index 7eabc36778255e3cc019fdda30d53428c04fe6ce..4de9064b0bd6e250df8476332a9d7cbb93f53044 100644 (file)
@@ -355,6 +355,7 @@ void curvemap_buttons(struct uiBlock *block, struct CurveMapping *cumap, char la
 #define B_SEQ_BUT_EFFECT       1693
 #define B_SEQ_BUT_RELOAD_ALL    1694
 #define B_SEQ_BUT_TRANSFORM     1695
+#define B_SEQ_BUT_RELOAD_FILE   1696
 
 /* *********************** */
 #define B_ARMATUREBUTS         1800
index db3790e6ea3cd195a48da04ed8ff96e4ef84f3e1..b401ee05433f1bcc755f1acdc32f336f0110aa18 100644 (file)
@@ -119,7 +119,6 @@ typedef struct Sequence {
        char name[24]; /* name, not set by default and dosnt need to be unique as with ID's */
 
        int flag, type; /*flags bitmap (see below) and the type of sequence*/
-       int pad;
        int len; /* the length of the contense of this strip - before handles are applied */
        int start, startofs, endofs;
        int startstill, endstill;
@@ -128,6 +127,7 @@ typedef struct Sequence {
        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;
 
        Strip *strip;
 
@@ -151,10 +151,11 @@ typedef struct Sequence {
 
        void *effectdata;       /* Struct pointer for effect settings */
 
-       int anim_preseek;
+       int anim_startofs;    /* only use part of animation file */
+       int anim_endofs;      /* is subtle different to startofs / endofs */
+
        int blend_mode;
        float blend_opacity;
-       int pad2;
 } Sequence;
 
 typedef struct MetaStack {
index b6b8805ba5ce59f895a5654ad3eb1a1e018d71f4..5c9cacdb2fcf6bccb1541b60f8ae6cfdf0f80aba 100644 (file)
@@ -500,6 +500,10 @@ static void seq_panel_editing()
                               "Snd RAM", "Snd HD",
                               "", "Effect" };
        uiBlock *block;
+       static char strdata[1024];
+       char * str = strdata;
+       char * p;
+       int yco;
 
        block = uiNewBlock(&curarea->uiblocks, "seq_panel_editing", 
                           UI_EMBOSS, UI_HELV, curarea->win);
@@ -578,6 +582,90 @@ static void seq_panel_editing()
                                  0.0, last_seq->len, 0.0, 0.0, "End offset");
                }
        }
+
+
+       if(last_seq->type & SEQ_EFFECT)
+               sprintf(str, "Len: %d\nFrom %d - %d\n", last_seq->len, last_seq->startdisp, last_seq->enddisp-1);
+       else
+               sprintf(str, "Len: %d(%d)\n", last_seq->enddisp-last_seq->startdisp, last_seq->len);
+
+       str += strlen(str);
+
+       if(last_seq->type==SEQ_IMAGE) {
+               if (last_seq->len > 1) {
+                       /* CURRENT */
+                       StripElem * se= give_stripelem(last_seq, CFRA);
+                       StripElem * last;
+
+                       /* FIRST AND LAST */
+       
+                       if(last_seq->strip) {
+                               se= last_seq->strip->stripdata;
+                               last= se+last_seq->len-1;
+                               if(last_seq->startofs) se+= last_seq->startofs;
+                               if(last_seq->endofs) last-= last_seq->endofs;
+       
+                               sprintf(str, "First: %s at %d\nLast: %s at %d\n", se->name, last_seq->startdisp, last->name, last_seq->enddisp-1);
+                       }
+               } else { /* single image */
+                       if (last_seq->strip) {
+                               sprintf(str, "Len: %d\n", last_seq->enddisp-last_seq->startdisp);
+                       }
+               }
+
+               str += strlen(str);
+
+               /* orig size */
+               if(last_seq->strip) {
+                       sprintf(str, "OrigSize: %d x %d\n", last_seq->strip->orx, last_seq->strip->ory);
+               }
+       }
+       else if(last_seq->type==SEQ_MOVIE) {
+               int sta= last_seq->startofs;
+               int end= last_seq->len-1-last_seq->endofs;
+
+               sprintf(str, "First: %d at %d\nLast: %d at %d\nCur: %d\n",
+                       sta, last_seq->startdisp, end, last_seq->enddisp-1,  
+                       (G.scene->r.cfra)-last_seq->startdisp);
+       }
+       else if(last_seq->type==SEQ_SCENE) {
+               TStripElem * se= give_tstripelem(last_seq,  (G.scene->r.cfra));
+               if(se && last_seq->scene) {
+                       sprintf(str, "First: %d\nLast: %d\nCur: %d\n", last_seq->sfra+se->nr, last_seq->sfra, last_seq->sfra+last_seq->len-1); 
+               }
+       }
+       else if(last_seq->type==SEQ_RAM_SOUND
+               || last_seq->type == SEQ_HD_SOUND) {
+
+               int sta= last_seq->startofs;
+               int end= last_seq->len-1-last_seq->endofs;
+
+               sprintf(str, "First: %d at %d\nLast: %d at %d\nCur: %d\n",
+                       sta, last_seq->startdisp, end, last_seq->enddisp-1,  
+                       (G.scene->r.cfra)-last_seq->startdisp);
+       }
+       else if(last_seq->type == SEQ_SPEED) {
+               SpeedControlVars * vars = 
+                       (SpeedControlVars*) last_seq->effectdata;
+
+               if (vars) {
+                       sprintf(str, "Last mapped frame: %d at %d\n", 
+                               vars->lastValidFrame, 
+                               vars->lastValidFrame 
+                               + last_seq->startdisp);
+               }
+       }
+
+       str = strdata;
+       yco = 40;
+
+       while ((p = strchr(str, '\n'))) {
+               *p = 0;
+               uiDefBut(block, LABEL, 0, str, 10,yco,240,19, 0, 
+                        0, 0, 0, 0, "");
+               str = p+1;
+               yco -= 20;
+       }
 }
 
 static void seq_panel_input()
@@ -590,7 +678,30 @@ static void seq_panel_input()
        if(uiNewPanel(curarea, block, "Input", "Sequencer", 
                      10, 230, 318, 204) == 0) return;
 
-       
+       uiDefBut(block, TEX, 
+                B_SEQ_BUT_RELOAD_FILE, "Dir: ", 
+                10,140,240,19, last_seq->strip->dir, 
+                0.0, 160.0, 100, 0, "");
+
+       if (last_seq->type == SEQ_IMAGE) {
+               StripElem * se = give_stripelem(last_seq, CFRA);
+
+               if (se) {
+                       uiDefBut(block, TEX, 
+                                B_SEQ_BUT_RELOAD_FILE, "File: ", 
+                                10, 120, 240,19, se->name, 
+                                0.0, 80.0, 100, 0, "");
+               }
+
+       } else if (last_seq->type == SEQ_MOVIE || 
+                  last_seq->type == SEQ_HD_SOUND ||
+                  last_seq->type == SEQ_RAM_SOUND) {
+               uiDefBut(block, TEX, 
+                        B_SEQ_BUT_RELOAD_FILE, "File: ", 
+                        10,120,240,19, last_seq->strip->stripdata->name, 
+                        0.0, 80.0, 100, 0, "");
+       }
+
        uiDefButBitI(block, TOG, SEQ_USE_CROP,
                     B_SEQ_BUT_RELOAD, "Use Crop",
                     10,100,240,19, &last_seq->flag,
@@ -645,8 +756,18 @@ static void seq_panel_input()
        }
 
        
-       uiDefButI(block, NUM, B_SEQ_BUT_RELOAD, "Preseek:",
-                 10,0,150,19, &last_seq->anim_preseek, 
+       uiDefButI(block, NUM, 
+                 B_SEQ_BUT_RELOAD_FILE, "A-Start", 
+                 10, 0, 120, 20, &last_seq->anim_startofs, 
+                 0.0, MAXFRAMEF, 0.0, 0.0, "Animation start offset in file");
+       uiDefButI(block, NUM, 
+                 B_SEQ_BUT_RELOAD_FILE, "A-End", 
+                 130, 0, 120, 20, &last_seq->anim_endofs, 
+                 0.0, MAXFRAMEF, 0.0, 0.0, "Animation end offset in file");
+
+
+       uiDefButI(block, NUM, B_SEQ_BUT_RELOAD, "MPEG-Preseek:",
+                 10, -20, 240,19, &last_seq->anim_preseek, 
                  0.0, 50.0, 100,0,"On MPEG-seeking preseek this many frames");
 
 }
@@ -948,7 +1069,9 @@ void do_sequencer_panels(unsigned short event)
        case B_SEQ_BUT_EFFECT:
                update_changed_seq_and_deps(last_seq, 0, 1);
                break;
-
+       case B_SEQ_BUT_RELOAD_FILE:
+               reload_sequence_new_file(last_seq);
+               break;
        case B_SEQ_BUT_RELOAD:
        case B_SEQ_BUT_RELOAD_ALL:
                update_seq_ipo_rect(last_seq);
index b70a62cb65b5d95209651d47b7de9974f3dc11b8..156a6c7b6c95beb037381be0c24881dc04f3885e 100644 (file)
@@ -861,143 +861,6 @@ static void draw_image_seq(ScrArea *sa)
        sa->win_swap= WIN_BACK_OK;
 }
 
-static void draw_extra_seqinfo(void)
-{
-       Sequence *last_seq = get_last_seq();
-       StripElem *se, *last;
-       float xco, xfac, yco, yfac;
-       int sta, end;
-       char str[256];
-
-       if(last_seq==0) return;
-
-       /* xfac: size of 1 pixel */
-       xfac= G.v2d->cur.xmax - G.v2d->cur.xmin;
-       xfac/= (float)(G.v2d->mask.xmax-G.v2d->mask.xmin);
-       xco= G.v2d->cur.xmin+10*xfac;
-
-       yfac= G.v2d->cur.ymax - G.v2d->cur.ymin;
-       yfac/= (float)(G.v2d->mask.ymax-G.v2d->mask.ymin);
-       yco= G.v2d->cur.ymin+40*yfac;
-       
-       BIF_ThemeColor(TH_TEXT_HI);
-
-       /* NAME */
-       glRasterPos3f(xco,  yco, 0.0);
-       strncpy(str, give_seqname(last_seq), 255);
-       BMF_DrawString(G.font, str);
-       xco += xfac*BMF_GetStringWidth(G.font, str) +10.0*xfac;
-
-       if(last_seq->type==SEQ_SCENE && last_seq->scene) {
-               glRasterPos3f(xco,  yco, 0.0);
-               BMF_DrawString(G.font, last_seq->scene->id.name+2);
-               xco += xfac*BMF_GetStringWidth(G.font, last_seq->scene->id.name+2) +30.0*xfac;
-       }
-
-       /* LEN, dont bother with single images */
-       if (check_single_seq(last_seq)==0) {
-               if(last_seq->type & SEQ_EFFECT)
-                       sprintf(str, "len: %d   From %d - %d", last_seq->len, last_seq->startdisp, last_seq->enddisp-1);
-               else
-                       sprintf(str, "len: %d (%d)", last_seq->enddisp-last_seq->startdisp, last_seq->len);
-               
-               glRasterPos3f(xco,  yco, 0.0);
-       
-               BMF_DrawString(G.font, str);
-               xco += xfac*BMF_GetStringWidth(G.font, str) +10.0*xfac;
-       }
-
-
-       if(last_seq->type==SEQ_IMAGE) {
-               if (last_seq->len > 1) {
-                       /* CURRENT */
-                       se= give_stripelem(last_seq,  (G.scene->r.cfra));
-                       if(se) {
-                               sprintf(str, "Cur: %s%s", last_seq->strip->dir, se->name);
-                               glRasterPos3f(xco,  yco, 0.0);
-                               BMF_DrawString(G.font, str);
-                               xco += xfac*BMF_GetStringWidth(G.font, str) +10.0*xfac;
-                       }
-       
-                       /* FIRST AND LAST */
-       
-                       if(last_seq->strip) {
-                               se= last_seq->strip->stripdata;
-                               last= se+last_seq->len-1;
-                               if(last_seq->startofs) se+= last_seq->startofs;
-                               if(last_seq->endofs) last-= last_seq->endofs;
-       
-                               sprintf(str, "First: %s at %d   Last: %s at %d", se->name, last_seq->startdisp, last->name, last_seq->enddisp-1);
-                               glRasterPos3f(xco,  yco, 0.0);
-                               BMF_DrawString(G.font, str);
-                               xco += xfac*BMF_GetStringWidth(G.font, str) +30.0*xfac;
-                       }
-               } else { /* single image */
-                       if (last_seq->strip) {
-                               sprintf(str, "Single: %s%s   len: %d", last_seq->strip->dir, last_seq->strip->stripdata->name, last_seq->enddisp-last_seq->startdisp);
-                               glRasterPos3f(xco,  yco, 0.0);
-                               BMF_DrawString(G.font, str);
-                               xco += xfac*BMF_GetStringWidth(G.font, str) +30.0*xfac;
-                       }
-               }
-               /* orig size */
-               if(last_seq->strip) {
-                       sprintf(str, "OrigSize: %d x %d", last_seq->strip->orx, last_seq->strip->ory);
-                       glRasterPos3f(xco,  yco, 0.0);
-                       BMF_DrawString(G.font, str);
-                       xco += xfac*BMF_GetStringWidth(G.font, str) +30.0*xfac;
-               }
-       }
-       else if(last_seq->type==SEQ_MOVIE) {
-
-               sta= last_seq->startofs;
-               end= last_seq->len-1-last_seq->endofs;
-
-               sprintf(str, "%s   %s%s  First: %d at %d   Last: %d at %d   Cur: %d",
-                               last_seq->name+2, last_seq->strip->dir, last_seq->strip->stripdata->name,
-                               sta, last_seq->startdisp, end, last_seq->enddisp-1,  (G.scene->r.cfra)-last_seq->startdisp);
-
-               glRasterPos3f(xco,  yco, 0.0);
-               BMF_DrawString(G.font, str);
-       }
-       else if(last_seq->type==SEQ_SCENE) {
-               TStripElem * se= give_tstripelem(last_seq,  (G.scene->r.cfra));
-               if(se && last_seq->scene) {
-                       sprintf(str, "Cur: %d  First: %d  Last: %d", last_seq->sfra+se->nr, last_seq->sfra, last_seq->sfra+last_seq->len-1); 
-                       glRasterPos3f(xco,  yco, 0.0);
-                       BMF_DrawString(G.font, str);
-               }
-       }
-       else if(last_seq->type==SEQ_RAM_SOUND
-               || last_seq->type == SEQ_HD_SOUND) {
-
-               sta= last_seq->startofs;
-               end= last_seq->len-1-last_seq->endofs;
-
-               sprintf(str, "%s   %s%s  First: %d at %d   Last: %d at %d   Cur: %d   Gain: %.2f dB   Pan: %.2f",
-                               last_seq->name+2, last_seq->strip->dir, last_seq->strip->stripdata->name,
-                               sta, last_seq->startdisp, end, last_seq->enddisp-1,  (G.scene->r.cfra)-last_seq->startdisp,
-                               last_seq->level, last_seq->pan);
-
-               glRasterPos3f(xco,  yco, 0.0);
-               BMF_DrawString(G.font, str);
-       }
-       else if(last_seq->type == SEQ_SPEED) {
-               SpeedControlVars * vars = 
-                       (SpeedControlVars*) last_seq->effectdata;
-
-               if (vars) {
-                       sprintf(str, "Last mapped frame: %d at %d", 
-                               vars->lastValidFrame, 
-                               vars->lastValidFrame 
-                               + last_seq->startdisp);
-
-                       glRasterPos3f(xco,  yco, 0.0);
-                       BMF_DrawString(G.font, str);
-               }
-       }
-}
-
 void seq_reset_imageofs(SpaceSeq *sseq)
 {
        sseq->xof = sseq->yof = sseq->zoom = 0;
@@ -1200,8 +1063,6 @@ void drawseqspace(ScrArea *sa, void *spacedata)
                }
        }
 
-       draw_extra_seqinfo();
-
        /* Draw markers */
        draw_markers_timespace(1);
        
index 5faffb38107c89617050cc8bc6907b85bd3fc18f..3d7ac3021a19f3f771aff624ca55462e2658a344 100644 (file)
@@ -132,7 +132,10 @@ void free_strip(Strip *strip)
 void new_tstripdata(Sequence *seq)
 {
        if(seq->strip) {
-               free_tstripdata(seq->strip->len, seq->strip->tstripdata);
+               if (seq->strip->tstripdata) {
+                       free_tstripdata(seq->strip->len, 
+                                       seq->strip->tstripdata);
+               }
                seq->strip->tstripdata= 0;
                seq->strip->len= seq->len;
        }
@@ -372,6 +375,58 @@ void calc_sequence(Sequence *seq)
        }
 }
 
+void reload_sequence_new_file(Sequence * seq)
+{
+       char str[FILE_MAXDIR+FILE_MAXFILE];
+
+       if (!(seq->type == SEQ_MOVIE || seq->type == SEQ_IMAGE ||
+             seq->type == SEQ_HD_SOUND)) {
+               return;
+       }
+
+       new_tstripdata(seq);
+
+       if (seq->type == SEQ_IMAGE) {
+               return;
+       }
+
+       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);
+               seq->anim = openanim(str, IB_rect);
+
+               if (!seq->anim) {
+                       return;
+               }
+       
+               seq->len = IMB_anim_get_duration(seq->anim);
+               
+               seq->anim_preseek = IMB_anim_get_preseek(seq->anim);
+
+               seq->len -= seq->anim_startofs;
+               seq->len -= seq->anim_endofs;
+               if (seq->len < 0) {
+                       seq->len = 0;
+               }
+               seq->strip->len = seq->len;
+       } else if (seq->type == SEQ_HD_SOUND) {
+               if(seq->hdaudio) sound_close_hdaudio(seq->hdaudio);
+               seq->hdaudio = sound_open_hdaudio(str);
+
+               if (!seq->hdaudio) {
+                       return;
+               }
+
+               seq->strip->len = seq->len 
+                       = sound_hdaudio_get_duration(seq->hdaudio, FPS);
+       }
+
+
+       calc_sequence(seq);
+}
+
 void sort_seq()
 {
        /* all strips together per kind, and in order of y location ("machine") */
@@ -685,7 +740,7 @@ StripElem *give_stripelem(Sequence *seq, int cfra)
        if (nr == -1) return 0;
        if (se == 0) return 0;
 
-       se += nr; 
+       se += nr + seq->anim_startofs
        
        return se;
 }
@@ -991,7 +1046,7 @@ static void do_build_seq_ibuf(Sequence * seq, TStripElem *se, int cfra)
                                }
                                if(seq->anim) {
                                        IMB_anim_set_preseek(seq->anim, seq->anim_preseek);
-                                       se->ibuf = IMB_anim_absolute(seq->anim, se->nr);
+                                       se->ibuf = IMB_anim_absolute(seq->anim, se->nr + seq->anim_startofs);
                                }
                                
                                if(se->ibuf == 0) {