From a31dec3712d0b03168fc29987bf088935fedb367 Mon Sep 17 00:00:00 2001 From: Roel Spruit Date: Fri, 18 Jun 2004 22:53:06 +0000 Subject: [PATCH] added a new Sequence Effect: Sweep. this consists of 22 different ways to sweep from 1 strip to another. For you windows lovers: it's like "Blinds" in Powerpoint :) - in the NKEY menu you can choose which type you want perform, vertical, horizontal, in/out etc. it's too much to decribe. Credits for this go to Kent 'Sirdude" Mein who coded the sequence plugin I stole the code from. To allow certain sequence effects to have settings, I also added a "varstr" void pointer to the Sequence DNA, that can point to a special struct for each effect. This is similar to how plugins are handles. more neat effects to come.... --- source/blender/include/BSE_sequence.h | 14 +- source/blender/makesdna/DNA_sequence_types.h | 37 +- source/blender/src/drawseq.c | 12 + source/blender/src/editseq.c | 508 +++++++------- source/blender/src/header_seq.c | 28 +- source/blender/src/sequence.c | 701 ++++++++++++------- 6 files changed, 768 insertions(+), 532 deletions(-) diff --git a/source/blender/include/BSE_sequence.h b/source/blender/include/BSE_sequence.h index 43a8a627824..dcef4b8f4f3 100644 --- a/source/blender/include/BSE_sequence.h +++ b/source/blender/include/BSE_sequence.h @@ -28,7 +28,7 @@ * Contributor(s): none yet. * * ***** END GPL/BL DUAL LICENSE BLOCK ***** - * + * */ #ifndef BSE_SEQUENCE_H @@ -95,6 +95,18 @@ void do_mul_effect(float facf0, float facf1, int x, int y, unsigned int *rect1, unsigned int *rect2, unsigned int *out); +/* Sweep effect */ +enum {DO_LEFT_RIGHT, DO_RIGHT_LEFT, DO_DOWN_UP, DO_UP_DOWN, + DO_LOWER_LEFT_UPPER_RIGHT, DO_UPPER_RIGHT_LOWER_LEFT, + DO_UPPER_LEFT_LOWER_RIGHT, DO_LOWER_RIGHT_UPPER_LEFT, + DO_HORZ_OUT, DO_HORZ_IN, DO_VERT_OUT, DO_VERT_IN, + DO_HORZ_VERT_OUT, DO_HORZ_VERT_IN, DO_LEFT_DOWN_RIGHT_UP_OUT, + DO_LEFT_DOWN_RIGHT_UP_IN, DO_LEFT_UP_RIGHT_DOWN_OUT, + DO_LEFT_UP_RIGHT_DOWN_IN, DO_DIAG_OUT, DO_DIAG_IN, DO_DIAG_OUT_2, + DO_DIAG_IN_2}; +int check_zone(int x, int y, int xo, int yo, struct Sequence *seq, float facf0); +void do_sweep_effect(struct Sequence *seq, float facf0, float facf1, int x, int y, unsigned int *rect1, unsigned int *rect2, unsigned int *out); + void make_black_ibuf(struct ImBuf *ibuf); void multibuf(struct ImBuf *ibuf, float fmul); void do_effect(int cfra, struct Sequence *seq, struct StripElem *se); diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index efc145da8f6..9659defb755 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -1,7 +1,7 @@ /** * blenlib/DNA_sequence_types.h (mar-2001 nzc) - * - * $Id$ + * + * $Id$ * * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** * @@ -48,7 +48,7 @@ typedef struct StripElem { struct StripElem *se1, *se2, *se3; short ok, nr; int pad; - + } StripElem; typedef struct Strip { @@ -58,21 +58,21 @@ typedef struct Strip { char dir[80]; short orx, ory; int pad; - + } Strip; typedef struct PluginSeq { char name[80]; void *handle; - + char *pname; - + int vars, version; void *varstr; float *cfra; - + float data[32]; void (*doit)(void); @@ -88,7 +88,7 @@ typedef struct Sequence { struct Sequence *next, *prev, *newseq; void *lib; char name[24]; - + short flag, type; int len; int start, startofs, endofs; @@ -97,28 +97,30 @@ typedef struct Sequence { int startdisp, enddisp; float mul, handsize; int sfra; - + Strip *strip; StripElem *curelem; - + struct Ipo *ipo; struct Scene *scene; struct anim *anim; float facf0, facf1; - + PluginSeq *plugin; /* pointers for effects: */ struct Sequence *seq1, *seq2, *seq3; - + /* meta */ ListBase seqbase; - + struct bSound *sound; /* the linked "bSound" object */ float level, pan; /* level in dB (0=full), pan -1..1 */ int curpos; /* last sample position in audio_fill() */ int pad; - + + void *varstr; /* Struct pointer for effect settings */ + } Sequence; # # @@ -136,6 +138,12 @@ typedef struct Editing { int pad; } Editing; +/* ************* Effect Variable Structs ********* */ +typedef struct SweepVars { + short sweeptype; +} SweepVars; + + /* ***************** SEQUENCE ****************** */ /* seq->flag */ @@ -162,6 +170,7 @@ typedef struct Editing { #define SEQ_MUL 14 #define SEQ_OVERDROP 15 #define SEQ_PLUGIN 24 +#define SEQ_SWEEP 25 #endif diff --git a/source/blender/src/drawseq.c b/source/blender/src/drawseq.c index bcfd50f7123..46c94a56eba 100644 --- a/source/blender/src/drawseq.c +++ b/source/blender/src/drawseq.c @@ -120,6 +120,7 @@ static char *give_seqname(Sequence *seq) else if(seq->type==SEQ_ALPHAOVER) return "ALPHAOVER"; else if(seq->type==SEQ_ALPHAUNDER) return "ALPHAUNDER"; else if(seq->type==SEQ_OVERDROP) return "OVER DROP"; + else if(seq->type==SEQ_SWEEP) return "SWEEP"; else if(seq->type==SEQ_PLUGIN) { if(seq->plugin && seq->plugin->doit) return seq->plugin->pname; return "PLUGIN"; @@ -164,6 +165,8 @@ static unsigned int seq_color(Sequence *seq) return 0x9080A0; case SEQ_OVERDROP: return 0x5080B0; + case SEQ_SWEEP: + return 0x2080B0; case SEQ_PLUGIN: return 0x906000; case SEQ_SOUND: @@ -701,6 +704,15 @@ static void seq_panel_properties(short cntrl) // SEQ_HANDLER_PROPERTIES uiDefBut(block, LABEL, 0, "Striptype: Effect", 10,140,150,20, 0, 0, 0, 0, 0, ""); uiDefBut(block, TEX, 0, "Stripname: ", 10,120,150,19, last_seq->name+2, 0.0, 21.0, 100, 0, ""); + if(last_seq->type==SEQ_SWEEP){ + SweepVars *sweep = (SweepVars *)last_seq->varstr; + char formatstring[1024]; + + strcpy(formatstring, "Select Sweep Type %t|Left to Right %x0|Right to Left %x1|Bottom to Top %x2|Top to Bottom %x3|Top left to Bottom right%x4|Bottom right to Top left %x5|Bottom left to Top right %x6|Top right to Bottom left %x7|Horizontal out %x8|Horizontal in %x9|Vertical out %x10|Vertical in %x11|Hor/Vert out %x12|Hor/Vert in %x13|Bottom left to Top right out %x14|Top left to Bottom right in %x15|Top left to Bottom right out %x16|Bottom left to Top right in %x17|Diagonal out %x18|Diagonal in %x19|Diagonal out 2 %x20|Diagonal in 2 %x21|"); + + uiDefButS(block, MENU,SEQ_BUT_MOVIE, formatstring, 10,90,220,22, &sweep->sweeptype, 0, 0, 0, 0, "What type of sweep should be performed"); + } + } diff --git a/source/blender/src/editseq.c b/source/blender/src/editseq.c index adc31eb0b52..1ac23530d03 100644 --- a/source/blender/src/editseq.c +++ b/source/blender/src/editseq.c @@ -43,7 +43,7 @@ #else #include #include "BLI_winstuff.h" -#endif +#endif #include #include "MEM_guardedalloc.h" @@ -96,7 +96,7 @@ Sequence *last_seq=0; char last_imagename[80]= "/"; -char last_sounddir[80]= ""; +char last_sounddir[80]= ""; /* void transform_seq(int mode); already in BIF_editseq.h */ @@ -108,13 +108,13 @@ static void shuffle_seq(Sequence *); static void change_plugin_seq(char *str) /* called from fileselect */ { /* extern Sequence *last_seq; already done few lines before !!!*/ - + if(last_seq && last_seq->type!=SEQ_PLUGIN) return; - + free_plugin_seq(last_seq->plugin); - + last_seq->plugin= (PluginSeq *)add_plugin_seq(str, last_seq->name+2); - + last_seq->machine= MAX3(last_seq->seq1->machine, last_seq->seq2->machine, last_seq->seq3->machine); if( test_overlap_seq(last_seq) ) shuffle_seq(last_seq); } @@ -125,30 +125,30 @@ void boundbox_seq(void) Sequence *seq; Editing *ed; float min[2], max[2]; - + ed= G.scene->ed; if(ed==0) return; - + min[0]= 0.0; max[0]= EFRA+1; min[1]= 0.0; max[1]= 8.0; - + seq= ed->seqbasep->first; while(seq) { - + if( min[0] > seq->startdisp-1) min[0]= seq->startdisp-1; if( max[0] < seq->enddisp+1) max[0]= seq->enddisp+1; if( max[1] < seq->machine+2.0) max[1]= seq->machine+2.0; - + seq= seq->next; } - + G.v2d->tot.xmin= min[0]; G.v2d->tot.xmax= max[0]; G.v2d->tot.ymin= min[1]; G.v2d->tot.ymax= max[1]; - + } Sequence *find_nearest_seq(int *hand) @@ -157,20 +157,20 @@ Sequence *find_nearest_seq(int *hand) Editing *ed; float x, y, facx, facy; short mval[2]; - + *hand= 0; - + ed= G.scene->ed; if(ed==0) return 0; - + getmouseco_areawin(mval); areamouseco_to_ipoco(G.v2d, mval, &x, &y); - + seq= ed->seqbasep->first; while(seq) { if(seq->machine == (int)y) { if(seq->startdisp<=x && seq->enddisp>=x) { - + if(seq->type < SEQ_EFFECT) { if( seq->handsize+seq->startdisp >=x ) { /* within triangle? */ @@ -183,7 +183,7 @@ Sequence *find_nearest_seq(int *hand) facy= (y - 0.5 - (int)y)/0.3; if( facx+facy < 1.0 ) *hand= 1; } - + } else if( -seq->handsize+seq->enddisp <=x ) { /* within triangle? */ @@ -198,7 +198,7 @@ Sequence *find_nearest_seq(int *hand) } } } - + return seq; } } @@ -214,12 +214,12 @@ void clear_last_seq(void) Editing *ed; StripElem *se; int a; - + if(last_seq) { - + ed= G.scene->ed; if(ed==0) return; - + WHILE_SEQ(&ed->seqbase) { if(seq==last_seq || (last_seq->ipo && seq->ipo==last_seq->ipo)) { a= seq->len; @@ -245,7 +245,7 @@ static int test_overlap_seq(Sequence *test) ed= G.scene->ed; if(ed==0) return 0; - + seq= ed->seqbasep->first; while(seq) { if(seq!=test) { @@ -277,10 +277,10 @@ static void shuffle_seq(Sequence *test) if(seq->flag & SELECT) a++; seq= seq->next; } - + if(a<2 && test->type==SEQ_IMAGE) { start= test->start; - + for(a= 1; a<50; a++) { test->start= start+a; calc_sequence(test); @@ -291,13 +291,13 @@ static void shuffle_seq(Sequence *test) } test->start= start; } - + test->machine++; calc_sequence(test); while( test_overlap_seq(test) ) { if(test->machine >= MAXSEQ) { error("There is no more space to add a sequence strip"); - + BLI_remlink(ed->seqbasep, test); free_sequence(test); return; @@ -314,7 +314,7 @@ static void deselect_all_seq(void) ed= G.scene->ed; if(ed==0) return; - + WHILE_SEQ(ed->seqbasep) { seq->flag &= SEQ_DESEL; } @@ -324,16 +324,16 @@ static void deselect_all_seq(void) static void recurs_sel_seq(Sequence *seqm) { Sequence *seq; - + seq= seqm->seqbase.first; while(seq) { - + if(seqm->flag & (SEQ_LEFTSEL+SEQ_RIGHTSEL)) seq->flag &= SEQ_DESEL; else if(seqm->flag & SELECT) seq->flag |= SELECT; else seq->flag &= SEQ_DESEL; - + if(seq->seqbase.first) recurs_sel_seq(seq); - + seq= seq->next; } } @@ -343,22 +343,22 @@ void swap_select_seq(void) Sequence *seq; Editing *ed; int sel=0; - + ed= G.scene->ed; if(ed==0) return; - + WHILE_SEQ(ed->seqbasep) { if(seq->flag & SELECT) sel= 1; } END_SEQ - + WHILE_SEQ(ed->seqbasep) { /* always deselect all to be sure */ seq->flag &= SEQ_DESEL; if(sel==0) seq->flag |= SELECT; } END_SEQ - + allqueue(REDRAWSEQ, 0); } @@ -366,14 +366,14 @@ void mouse_select_seq(void) { Sequence *seq; int hand; - + seq= find_nearest_seq(&hand); - + if(G.qual==0) deselect_all_seq(); - + if(seq) { last_seq= seq; - + if ((seq->type == SEQ_IMAGE) || (seq->type == SEQ_MOVIE)) { if(seq->strip) { strcpy(last_imagename, seq->strip->dir); @@ -384,7 +384,7 @@ void mouse_select_seq(void) strcpy(last_sounddir, seq->strip->dir); } } - + if(G.qual==0) { seq->flag |= SELECT; if(hand==1) seq->flag |= SEQ_LEFTSEL; @@ -410,11 +410,11 @@ void mouse_select_seq(void) } recurs_sel_seq(seq); } - + force_draw(); - + if(last_seq) allqueue(REDRAWIPO, 0); - + std_rmouse_transform(transform_seq); } @@ -422,21 +422,21 @@ static Sequence *alloc_sequence(int cfra, int machine) { Editing *ed; Sequence *seq; - + ed= G.scene->ed; - + seq= MEM_callocN( sizeof(Sequence), "addseq"); BLI_addtail(ed->seqbasep, seq); - + last_seq= seq; - + *( (short *)seq->name )= ID_SEQ; seq->name[2]= 0; - + seq->flag= SELECT; seq->start= cfra; seq->machine= machine; - + return seq; } @@ -456,25 +456,25 @@ static Sequence *sfile_to_sequence(SpaceFile *sfile, int cfra, int machine, int } } } - + if(last) { - /* if not, a file handed to us? */ + /* if not, a file handed to us? */ if(totsel==0 && sfile->file[0]) totsel= 1; } - + if(totsel==0) return 0; - + /* make seq */ seq= alloc_sequence(cfra, machine); seq->len= totsel; - + if(totsel==1) { seq->startstill= 25; seq->endstill= 24; } calc_sequence(seq); - + /* strip and stripdata */ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); strip->len= totsel; @@ -511,21 +511,21 @@ static void sfile_to_mv_sequence(SpaceFile *sfile, int cfra, int machine) StripElem *se; int totframe, a; char str[256]; - + totframe= 0; strcpy(str, sfile->dir); strcat(str, sfile->file); - + /* is it a movie? */ anim = openanim(str, IB_rect); if(anim==0) { error("The selected file is not a movie"); return; } - + totframe= IMB_anim_get_duration(anim); - + /* make seq */ seq= alloc_sequence(cfra, machine); seq->len= totframe; @@ -533,7 +533,7 @@ static void sfile_to_mv_sequence(SpaceFile *sfile, int cfra, int machine) seq->anim= anim; calc_sequence(seq); - + /* strip and stripdata */ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); strip->len= totframe; @@ -567,7 +567,7 @@ static Sequence *sfile_to_snd_sequence(SpaceFile *sfile, int cfra, int machine) strcpy(str, sfile->dir); strcat(str, sfile->file); - + sound= sound_new_sound(str); if (!sound || sound->sample->type == SAMPLE_INVALID) { error("Unsupported audio format"); @@ -580,7 +580,7 @@ static Sequence *sfile_to_snd_sequence(SpaceFile *sfile, int cfra, int machine) sound->id.us=1; sound->flags |= SOUND_FLAGS_SEQUENCE; audio_makestream(sound); - + totframe= (int) ( ((float)(sound->streamlen-1)/( (float)G.scene->audio.mixrate*4.0 ))* (float)G.scene->r.frs_sec); /* make seq */ @@ -590,7 +590,7 @@ static Sequence *sfile_to_snd_sequence(SpaceFile *sfile, int cfra, int machine) seq->sound = sound; calc_sequence(seq); - + /* strip and stripdata */ seq->strip= strip= MEM_callocN(sizeof(Strip), "strip"); strip->len= totframe; @@ -609,7 +609,7 @@ static Sequence *sfile_to_snd_sequence(SpaceFile *sfile, int cfra, int machine) /* last active name */ strcpy(last_sounddir, seq->strip->dir); - + return seq; } @@ -619,10 +619,10 @@ static void add_image_strips(char *name) struct direntry *files; float x, y; int a, totfile, cfra, machine; - short mval[2]; + short mval[2]; deselect_all_seq(); - + /* restore windowmatrices */ areawinset(curarea->win); drawseqspace(curarea, curarea->spacedata.first); @@ -651,38 +651,38 @@ static void add_image_strips(char *name) strcat(sfile->dir, files[a].relname); strcat(sfile->dir,"/"); read_dir(sfile); - + /* select all */ swapselect_file(sfile); - + if ( sfile_to_sequence(sfile, cfra, machine, 0) ) machine++; - + parent(sfile); } } } - + sfile->filelist= files; sfile->totfile= totfile; - + /* read directory itself */ sfile_to_sequence(sfile, cfra, machine, 1); waitcursor(0); - + transform_seq('g'); -} +} static void add_movie_strip(char *name) { SpaceFile *sfile; float x, y; int cfra, machine; - short mval[2]; + short mval[2]; deselect_all_seq(); - + /* restore windowmatrices */ areawinset(curarea->win); drawseqspace(curarea, curarea->spacedata.first); @@ -703,10 +703,10 @@ static void add_movie_strip(char *name) sfile_to_mv_sequence(sfile, cfra, machine); waitcursor(0); - + transform_seq('g'); -} +} static void add_sound_strip(char *name) { @@ -746,7 +746,7 @@ static void reload_sound_strip(char *name) if(last_seq==0 || last_seq->type!=SEQ_SOUND) return; seqact= last_seq; /* last_seq changes in alloc_sequence */ - + /* search sfile */ sfile= scrarea_find_space_of_type(curarea, SPACE_FILE); if(sfile==0) return; @@ -760,10 +760,10 @@ static void reload_sound_strip(char *name) free_strip(seqact->strip); seqact->strip= seq->strip; - + seqact->len= seq->len; calc_sequence(seqact); - + seq->strip= 0; free_sequence(seq); BLI_remlink(ed->seqbasep, seq); @@ -788,7 +788,7 @@ static void reload_image_strip(char *name) if(last_seq==0 || last_seq->type!=SEQ_IMAGE) return; seqact= last_seq; /* last_seq changes in alloc_sequence */ - + /* search sfile */ sfile= scrarea_find_space_of_type(curarea, SPACE_FILE); if(sfile==0) return; @@ -800,10 +800,10 @@ static void reload_image_strip(char *name) free_strip(seqact->strip); seqact->strip= seq->strip; - + seqact->len= seq->len; calc_sequence(seqact); - + seq->strip= 0; free_sequence(seq); BLI_remlink(ed->seqbasep, seq); @@ -823,9 +823,9 @@ static void reload_image_strip(char *name) waitcursor(0); allqueue(REDRAWSEQ, 0); -} +} -static int event_to_efftype(int event) +static int event_to_efftype(int event) { if(event==2) return SEQ_CROSS; if(event==3) return SEQ_GAMCROSS; @@ -836,6 +836,7 @@ static int event_to_efftype(int event) if(event==8) return SEQ_ALPHAUNDER; if(event==9) return SEQ_OVERDROP; if(event==10) return SEQ_PLUGIN; + if(event==13) return SEQ_SWEEP; return 0; } @@ -846,7 +847,7 @@ static int add_seq_effect(int type) Strip *strip; float x, y; int cfra, machine; - short mval[2]; + short mval[2]; if(G.scene->ed==0) return 0; ed= G.scene->ed; @@ -857,7 +858,7 @@ static int add_seq_effect(int type) seq= ed->seqbasep->first; while(seq) { if(seq->flag & SELECT) { - if (seq->type == SEQ_SOUND) { error("Can't apply effects to audio sequence strips"); return 0; } + if (seq->type == SEQ_SOUND) { error("Can't apply effects to audio sequence strips"); return 0; } if(seq != seq2) { if(seq1==0) seq1= seq; else if(seq3==0) seq3= seq; @@ -869,8 +870,8 @@ static int add_seq_effect(int type) } seq= seq->next; } - - if(type==10) { /* plugin: minimal 1 select */ + + if(type==10 || type==13) { /* plugin: minimal 1 select */ if(seq2==0) { error("Need at least one selected sequence strip"); return 0; @@ -885,7 +886,7 @@ static int add_seq_effect(int type) } if(seq3==0) seq3= seq2; } - + deselect_all_seq(); /* where will it be (cfra is not realy needed) */ @@ -895,9 +896,14 @@ static int add_seq_effect(int type) machine= (int)(y+0.5); seq= alloc_sequence(cfra, machine); - + seq->type= event_to_efftype(type); - + + /* Allocate variable structs for effects with settings */ + if(seq->type==SEQ_SWEEP){ + seq->varstr = MEM_callocN(sizeof(struct SweepVars), "sweepvars"); + } + if(seq->type==SEQ_ALPHAUNDER || seq->type==SEQ_ALPHAOVER) { seq->seq2= seq1; seq->seq1= seq2; @@ -908,25 +914,25 @@ static int add_seq_effect(int type) } seq->seq3= seq3; calc_sequence(seq); - + 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"); - + return 1; } static void load_plugin_seq(char *str) /* called from fileselect */ { Editing *ed; - + add_seq_effect(10); /* this sets last_seq */ - + free_plugin_seq(last_seq->plugin); - + last_seq->plugin= (PluginSeq *)add_plugin_seq(str, last_seq->name+2); - + if(last_seq->plugin==0) { ed= G.scene->ed; BLI_remlink(ed->seqbasep, last_seq); @@ -936,7 +942,7 @@ static void load_plugin_seq(char *str) /* called from fileselect */ else { last_seq->machine= MAX3(last_seq->seq1->machine, last_seq->seq2->machine, last_seq->seq3->machine); if( test_overlap_seq(last_seq) ) shuffle_seq(last_seq); - + transform_seq('g'); } } @@ -949,7 +955,7 @@ void add_sequence(int type) Scene *sce; float x, y; int cfra, machine; - short nr, event, mval[2]; + short nr, event, mval[2]; char *str; if (type >= 0){ @@ -994,36 +1000,39 @@ void add_sequence(int type) case SEQ_OVERDROP: event = 9; break; + case SEQ_SWEEP: + event = 13; + break; default: event = 0; break; } } else { - event= pupmenu("Add Sequence Strip%t|Images%x1|Movie%x102|Audio%x103|Scene%x101|Plugin%x10|Cross%x2|Gamma Cross%x3|Add%x4|Sub%x5|Mul%x6|Alpha Over%x7|Alpha Under%x8|Alpha Over Drop%x9"); + event= pupmenu("Add Sequence Strip%t|Images%x1|Movie%x102|Audio%x103|Scene%x101|Plugin%x10|Cross%x2|Gamma Cross%x3|Add%x4|Sub%x5|Mul%x6|Alpha Over%x7|Alpha Under%x8|Alpha Over Drop%x9|Sweep%x13"); } if(event<1) return; - + if(G.scene->ed==0) { ed= G.scene->ed= MEM_callocN( sizeof(Editing), "addseq"); ed->seqbasep= &ed->seqbase; } else ed= G.scene->ed; - + switch(event) { case 1: - + activate_fileselect(FILE_SPECIAL, "Select Images", last_imagename, add_image_strips); break; case 102: - + activate_fileselect(FILE_SPECIAL, "Select Movie", last_imagename, add_movie_strip); break; case 101: /* new menu: */ IDnames_to_pupstring(&str, NULL, NULL, &G.main->scene, (ID *)G.scene, NULL); - + event= pupmenu_col(str, 20); if(event> -1) { @@ -1035,31 +1044,31 @@ void add_sequence(int type) 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(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"); strip->len= seq->len; strip->us= 1; if(seq->len>0) strip->stripdata= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - + transform_seq('g'); } } MEM_freeN(str); - + break; case 2: case 3: @@ -1070,7 +1079,8 @@ void add_sequence(int type) case 8: case 9: case 10: - + case 13: + if(last_seq==0) error("Need at least one active sequence strip"); else if(event==10) { activate_fileselect(FILE_SPECIAL, "Select Plugin", U.plugseqdir, load_plugin_seq); @@ -1078,20 +1088,20 @@ void add_sequence(int type) else { if( add_seq_effect(event) ) transform_seq('g'); } - + break; case 103: if (!last_sounddir[0]) strcpy(last_sounddir, U.sounddir); activate_fileselect(FILE_SPECIAL, "Select Wav", last_sounddir, add_sound_strip); break; - } + } } void change_sequence(void) { Scene *sce; short event; - + if(last_seq==0) return; if(last_seq->type & SEQ_EFFECT) { @@ -1104,7 +1114,7 @@ void change_sequence(void) SWAP(Sequence *, last_seq->seq2, last_seq->seq3); } else if(event==11) { - activate_fileselect(FILE_SPECIAL, "Select Plugin", U.plugseqdir, change_plugin_seq); + activate_fileselect(FILE_SPECIAL, "Select Plugin", U.plugseqdir, change_plugin_seq); } else if(event==12); /* recalculate: only new_stripdata */ else { @@ -1127,15 +1137,15 @@ void change_sequence(void) } else if(last_seq->type == SEQ_SCENE) { event= pupmenu("Change Scene%t|Update Start and End"); - + if(event==1) { sce= last_seq->scene; - + last_seq->len= sce->r.efra - sce->r.sfra + 1; last_seq->sfra= sce->r.sfra; new_stripdata(last_seq); calc_sequence(last_seq); - + allqueue(REDRAWSEQ, 0); } } @@ -1146,16 +1156,16 @@ static int is_a_sequence(Sequence *test) { Sequence *seq; Editing *ed; - + ed= G.scene->ed; if(ed==0 || test==0) return 0; - + seq= ed->seqbasep->first; while(seq) { if(seq==test) return 1; seq= seq->next; } - + return 0; } @@ -1167,7 +1177,7 @@ static void recurs_del_seq(ListBase *lb) while(seq) { seqn= seq->next; if(seq->flag & SELECT) { - if(seq->type==SEQ_SOUND && seq->sound) seq->sound->id.us--; + if(seq->type==SEQ_SOUND && seq->sound) seq->sound->id.us--; BLI_remlink(lb, seq); if(seq==last_seq) last_seq= 0; if(seq->type==SEQ_META) recurs_del_seq(&seq->seqbase); @@ -1184,14 +1194,14 @@ void del_seq(void) MetaStack *ms; Editing *ed; int doit; - + if(okee("Erase selected")==0) return; ed= G.scene->ed; if(ed==0) return; - + recurs_del_seq(ed->seqbasep); - + /* test effects */ doit= 1; while(doit) { @@ -1210,14 +1220,14 @@ void del_seq(void) seq= seqn; } } - + /* updates lengths etc */ seq= ed->seqbasep->first; while(seq) { calc_sequence(seq); seq= seq->next; } - + /* free parent metas */ ms= ed->metastack.last; while(ms) { @@ -1225,7 +1235,7 @@ void del_seq(void) calc_sequence(ms->parseq); ms= ms->prev; } - + allqueue(REDRAWSEQ, 0); } @@ -1236,38 +1246,38 @@ static void recurs_dupli_seq(ListBase *old, ListBase *new) Sequence *seq, *seqn; StripElem *se; int a; - + seq= old->first; - + while(seq) { seq->newseq= 0; if(seq->flag & SELECT) { - + if(seq->type==SEQ_META) { seqn= MEM_dupallocN(seq); seq->newseq= seqn; BLI_addtail(new, seqn); - + seqn->strip= MEM_dupallocN(seq->strip); - + if(seq->len>0) seq->strip->stripdata= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - + seq->flag &= SEQ_DESEL; seqn->flag &= ~(SEQ_LEFTSEL+SEQ_RIGHTSEL); seqn->seqbase.first= seqn->seqbase.last= 0; recurs_dupli_seq(&seq->seqbase, &seqn->seqbase); - + } else if(seq->type == SEQ_SCENE) { seqn= MEM_dupallocN(seq); seq->newseq= seqn; BLI_addtail(new, seqn); - + seqn->strip= MEM_dupallocN(seq->strip); - + if(seq->len>0) seqn->strip->stripdata= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - + seq->flag &= SEQ_DESEL; seqn->flag &= ~(SEQ_LEFTSEL+SEQ_RIGHTSEL); } @@ -1275,10 +1285,10 @@ static void recurs_dupli_seq(ListBase *old, ListBase *new) seqn= MEM_dupallocN(seq); seq->newseq= seqn; BLI_addtail(new, seqn); - + seqn->strip= MEM_dupallocN(seq->strip); seqn->anim= 0; - + if(seqn->len>0) { seqn->strip->stripdata= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); /* copy first elem */ @@ -1290,7 +1300,7 @@ static void recurs_dupli_seq(ListBase *old, ListBase *new) se++; } } - + seq->flag &= SEQ_DESEL; seqn->flag &= ~(SEQ_LEFTSEL+SEQ_RIGHTSEL); } @@ -1298,11 +1308,11 @@ static void recurs_dupli_seq(ListBase *old, ListBase *new) seqn= MEM_dupallocN(seq); seq->newseq= seqn; BLI_addtail(new, seqn); - + seqn->strip= MEM_dupallocN(seq->strip); seqn->anim= 0; seqn->sound->id.us++; - + if(seqn->len>0) { seqn->strip->stripdata= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); /* copy first elem */ @@ -1314,43 +1324,43 @@ static void recurs_dupli_seq(ListBase *old, ListBase *new) se++; } } - + seq->flag &= SEQ_DESEL; seqn->flag &= ~(SEQ_LEFTSEL+SEQ_RIGHTSEL); - } + } else if(seq->type < SEQ_EFFECT) { seqn= MEM_dupallocN(seq); seq->newseq= seqn; BLI_addtail(new, seqn); - + seqn->strip->us++; seq->flag &= SEQ_DESEL; - + seqn->flag &= ~(SEQ_LEFTSEL+SEQ_RIGHTSEL); } else { if(seq->seq1->newseq) { - + seqn= MEM_dupallocN(seq); seq->newseq= seqn; BLI_addtail(new, seqn); - + seqn->seq1= seq->seq1->newseq; if(seq->seq2 && seq->seq2->newseq) seqn->seq2= seq->seq2->newseq; if(seq->seq3 && seq->seq3->newseq) seqn->seq3= seq->seq3->newseq; - + if(seqn->ipo) seqn->ipo->id.us++; - + if(seq->plugin) { seqn->plugin= MEM_dupallocN(seq->plugin); open_plugin_seq(seqn->plugin, seqn->name+2); } seqn->strip= MEM_dupallocN(seq->strip); - + if(seq->len>0) seq->strip->stripdata= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); - + seq->flag &= SEQ_DESEL; - + seqn->flag &= ~(SEQ_LEFTSEL+SEQ_RIGHTSEL); } } @@ -1364,15 +1374,15 @@ void add_duplicate_seq(void) { Editing *ed; ListBase new; - + ed= G.scene->ed; if(ed==0) return; - + new.first= new.last= 0; - + recurs_dupli_seq(ed->seqbasep, &new); addlisttolist(ed->seqbasep, &new); - + transform_seq('g'); } @@ -1381,11 +1391,11 @@ int insert_gap(int gap, int cfra) Sequence *seq; Editing *ed; int done=0; - + /* all strips >= cfra are shifted */ ed= G.scene->ed; if(ed==0) return 0; - + WHILE_SEQ(ed->seqbasep) { if(seq->startdisp >= cfra) { seq->start+= gap; @@ -1394,7 +1404,7 @@ int insert_gap(int gap, int cfra) } } END_SEQ - + return done; } @@ -1403,15 +1413,15 @@ void touch_seq_files(void) Sequence *seq; Editing *ed; char str[256]; - + /* touch all strips with movies */ ed= G.scene->ed; if(ed==0) return; - + if(okee("Touch and print selected movies")==0) return; - + waitcursor(1); - + WHILE_SEQ(ed->seqbasep) { if(seq->flag & SELECT) { if(seq->type==SEQ_MOVIE) { @@ -1420,11 +1430,11 @@ void touch_seq_files(void) BLI_touch(seq->name); } } - + } } END_SEQ - + waitcursor(0); } @@ -1432,18 +1442,18 @@ void set_filter_seq(void) { Sequence *seq; Editing *ed; - + ed= G.scene->ed; if(ed==0) return; - + if(okee("Set FilterY")==0) return; - + WHILE_SEQ(ed->seqbasep) { if(seq->flag & SELECT) { if(seq->type==SEQ_MOVIE) { seq->flag |= SEQ_FILTERY; } - + } } END_SEQ @@ -1456,10 +1466,10 @@ void no_gaps(void) { Editing *ed; int cfra, first= 0, done; - + ed= G.scene->ed; if(ed==0) return; - + for(cfra= CFRA; cfra<=EFRA; cfra++) { if(first==0) { if( evaluate_seq_frame(cfra) ) first= 1; @@ -1484,7 +1494,7 @@ void make_meta(void) Sequence *seq, *seqm, *next; Editing *ed; int tot; - + ed= G.scene->ed; if(ed==0) return; @@ -1499,9 +1509,9 @@ void make_meta(void) seq= seq->next; } if(tot < 2) return; - + if(okee("Make Meta Strip")==0) return; - + /* test relationships */ seq= ed->seqbasep->first; while(seq) { @@ -1530,7 +1540,7 @@ void make_meta(void) seqm= alloc_sequence(1, 1); seqm->type= SEQ_META; seqm->flag= SELECT; - + seq= ed->seqbasep->first; while(seq) { next= seq->next; @@ -1541,14 +1551,14 @@ void make_meta(void) seq= next; } calc_sequence(seqm); - + seqm->strip= MEM_callocN(sizeof(Strip), "metastrip"); seqm->strip->len= seqm->len; seqm->strip->us= 1; if(seqm->len) seqm->strip->stripdata= MEM_callocN(seqm->len*sizeof(StripElem), "metastripdata"); - + set_meta_stripdata(seqm); - + allqueue(REDRAWSEQ, 0); } @@ -1557,19 +1567,19 @@ void un_meta(void) Editing *ed; Sequence *seq, *seqn; int doit; - + ed= G.scene->ed; if(ed==0) return; - + if(last_seq==0 || last_seq->type!=SEQ_META) return; - + if(okee("Un Meta")==0) return; addlisttolist(ed->seqbasep, &last_seq->seqbase); - + last_seq->seqbase.first= 0; last_seq->seqbase.last= 0; - + BLI_remlink(ed->seqbasep, last_seq); free_sequence(last_seq); @@ -1603,9 +1613,9 @@ void un_meta(void) } } END_SEQ; - + allqueue(REDRAWSEQ, 0); - + } void exit_meta(void) @@ -1613,13 +1623,13 @@ void exit_meta(void) Sequence *seq; MetaStack *ms; Editing *ed; - + ed= G.scene->ed; if(ed==0) return; - + if(ed->metastack.first==0) return; - - ms= ed->metastack.last; + + ms= ed->metastack.last; BLI_remlink(&ed->metastack, ms); ed->seqbasep= ms->oldbasep; @@ -1635,10 +1645,10 @@ void exit_meta(void) } last_seq= ms->parseq; - + last_seq->flag= SELECT; recurs_sel_seq(last_seq); - + MEM_freeN(ms); allqueue(REDRAWSEQ, 0); } @@ -1648,22 +1658,22 @@ void enter_meta(void) { MetaStack *ms; Editing *ed; - + ed= G.scene->ed; if(ed==0) return; - + if(last_seq==0 || last_seq->type!=SEQ_META || last_seq->flag==0) { exit_meta(); return; } - + ms= MEM_mallocN(sizeof(MetaStack), "metastack"); BLI_addtail(&ed->metastack, ms); ms->parseq= last_seq; ms->oldbasep= ed->seqbasep; - + ed->seqbasep= &last_seq->seqbase; - + last_seq= 0; allqueue(REDRAWSEQ, 0); } @@ -1688,13 +1698,13 @@ void transform_seq(int mode) unsigned short event = 0; short mval[2], val, xo, yo, xn, yn; char str[32]; - + if(mode!='g') return; /* from gesture */ - + /* which seqs are involved */ ed= G.scene->ed; if(ed==0) return; - + WHILE_SEQ(ed->seqbasep) { if(seq->flag & SELECT) tot++; } @@ -1705,41 +1715,41 @@ void transform_seq(int mode) G.moving= 1; ts=transmain= MEM_callocN(tot*sizeof(TransSeq), "transseq"); - + WHILE_SEQ(ed->seqbasep) { - + if(seq->flag & SELECT) { - + ts->start= seq->start; ts->machine= seq->machine; ts->startstill= seq->startstill; ts->endstill= seq->endstill; ts->startofs= seq->startofs; ts->endofs= seq->endofs; - + ts++; } } END_SEQ - + getmouseco_areawin(mval); xo=xn= mval[0]; yo=yn= mval[1]; dvec[0]= dvec[1]= 0.0; - + while(afbreek==0) { getmouseco_areawin(mval); if(mval[0]!=xo || mval[1]!=yo || firsttime) { firsttime= 0; - + if(mode=='g') { - + dx= mval[0]- xo; dy= mval[1]- yo; - + div= G.v2d->mask.xmax-G.v2d->mask.xmin; dx= (G.v2d->cur.xmax-G.v2d->cur.xmin)*(dx)/div; - + div= G.v2d->mask.ymax-G.v2d->mask.ymin; dy= (G.v2d->cur.ymax-G.v2d->cur.ymin)*(dy)/div; @@ -1749,14 +1759,14 @@ void transform_seq(int mode) dvec[0]+= dx; dvec[1]+= dy; - + if(midtog) dvec[proj]= 0.0; ix= floor(dvec[0]+0.5); iy= floor(dvec[1]+0.5); - - + + ts= transmain; - + WHILE_SEQ(ed->seqbasep) { if(seq->flag & SELECT) { if(seq->flag & SEQ_LEFTSEL) { @@ -1807,29 +1817,29 @@ void transform_seq(int mode) } if( (seq->flag & (SEQ_LEFTSEL+SEQ_RIGHTSEL))==0 ) { if(seq->typestart= ts->start+ ix; - + if(seq->depth==0) seq->machine= ts->machine+ iy; - + if(seq->machine<1) seq->machine= 1; else if(seq->machine>= MAXSEQ) seq->machine= MAXSEQ; } - + calc_sequence(seq); - + ts++; } } END_SEQ - + sprintf(str, "X: %d Y: %d ", ix, iy); headerprint(str); } - + xo= mval[0]; yo= mval[1]; - + /* test for effect and overlap */ - + WHILE_SEQ(ed->seqbasep) { if(seq->flag & SELECT) { seq->flag &= ~SEQ_OVERLAP; @@ -1844,11 +1854,11 @@ void transform_seq(int mode) } } END_SEQ; - + force_draw(); } else BIF_wait_for_statechange(); - + while(qtest()) { event= extern_qread(&val); if(val) { @@ -1873,9 +1883,9 @@ void transform_seq(int mode) if(afbreek) break; } } - + if(event==ESCKEY) { - + ts= transmain; WHILE_SEQ(ed->seqbasep) { if(seq->flag & SELECT) { @@ -1888,7 +1898,7 @@ void transform_seq(int mode) calc_sequence(seq); seq->flag &= ~SEQ_OVERLAP; - + ts++; } else if(seq->type & SEQ_EFFECT) { if(seq->seq1->flag & SELECT) calc_sequence(seq); @@ -1906,7 +1916,7 @@ void transform_seq(int mode) if(seq->type == SEQ_META) { calc_sequence(seq); seq->flag &= ~SEQ_OVERLAP; - if( test_overlap_seq(seq) ) shuffle_seq(seq); + if( test_overlap_seq(seq) ) shuffle_seq(seq); } else if(seq->flag & SELECT) { calc_sequence(seq); @@ -1916,14 +1926,14 @@ void transform_seq(int mode) else if(seq->type & SEQ_EFFECT) calc_sequence(seq); } END_SEQ - + /* as last: */ sort_seq(); } - + G.moving= 0; MEM_freeN(transmain); - + allqueue(REDRAWSEQ, 0); } @@ -1934,18 +1944,18 @@ void clever_numbuts_seq(void) StripElem *se; VarStruct *varstr; int a; - + if(last_seq==0) return; if(last_seq->type==SEQ_PLUGIN) { pis= last_seq->plugin; if(pis->vars==0) return; - + varstr= pis->varstr; if(varstr) { for(a=0; avars; a++, varstr++) { add_numbut(a, varstr->type, varstr->name, varstr->min, varstr->max, &(pis->data[a]), varstr->tip); } - + if( do_clever_numbuts(pis->pname, pis->vars, REDRAW) ) { new_stripdata(last_seq); free_imbuf_effect_spec(CFRA); @@ -1983,7 +1993,7 @@ void clever_numbuts_seq(void) se= last_seq->curelem; allqueue(REDRAWSEQ, 0); } - } + } else if(last_seq->type==SEQ_META) { add_numbut(0, TEX, "Name:", 0.0, 21.0, last_seq->name+2, 0); @@ -1997,7 +2007,7 @@ void clever_numbuts_seq(void) void seq_snap_menu(void) { short event; - + event= pupmenu("Snap %t|To Current Frame%x1"); if(event < 1) return; @@ -2008,7 +2018,7 @@ void seq_snap(short event) { Editing *ed; Sequence *seq; - + ed= G.scene->ed; if(ed==0) return; @@ -2022,8 +2032,8 @@ void seq_snap(short event) } } END_SEQ - - + + /* test for effects and overlap */ WHILE_SEQ(ed->seqbasep) { if(seq->flag & SELECT) { @@ -2042,7 +2052,7 @@ void seq_snap(short event) /* as last: */ sort_seq(); - + allqueue(REDRAWSEQ, 0); } @@ -2057,7 +2067,7 @@ void borderselect_seq(void) ed= G.scene->ed; if(ed==0) return; - + val= get_border(&rect, 3); if(val) { @@ -2070,14 +2080,14 @@ void borderselect_seq(void) seq= ed->seqbasep->first; while(seq) { - + if(seq->startstill) rq.xmin= seq->start; else rq.xmin= seq->startdisp; rq.ymin= seq->machine+0.2; if(seq->endstill) rq.xmax= seq->start+seq->len; else rq.xmax= seq->enddisp; rq.ymax= seq->machine+0.8; - + if(BLI_isect_rctf(&rq, &rectf, 0)) { if(val==LEFTMOUSE) { seq->flag |= SELECT; @@ -2086,7 +2096,7 @@ void borderselect_seq(void) seq->flag &= ~SELECT; } } - + seq= seq->next; } diff --git a/source/blender/src/header_seq.c b/source/blender/src/header_seq.c index 7aa981969ac..22d54cb4d20 100644 --- a/source/blender/src/header_seq.c +++ b/source/blender/src/header_seq.c @@ -3,7 +3,7 @@ * * Functions to draw the "Video Sequence Editor" window header * and handle user events sent to it. - * + * * $Id$ * * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** @@ -79,7 +79,7 @@ extern Sequence *last_seq; static void do_seq_viewmenu(void *arg, int event) { extern int play_anim(int mode); - + switch(event) { case 1: /* Play Back Animation */ @@ -110,7 +110,7 @@ static uiBlock *seq_viewmenu(void *arg_unused) block= uiNewBlock(&curarea->uiblocks, "seq_viewmenu", UI_EMBOSSP, UI_HELV, curarea->headwin); uiBlockSetButmFunc(block, do_seq_viewmenu, NULL); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Back Animation|Alt A", 0, yco-=20, + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Back Animation|Alt A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Play Back Animation in 3D View|Alt Shift A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); @@ -206,6 +206,9 @@ static void do_seq_addmenu_effectmenu(void *arg, int event) case 8: add_sequence(SEQ_PLUGIN); break; + case 9: + add_sequence(SEQ_SWEEP); + break; } } @@ -225,13 +228,14 @@ static uiBlock *seq_addmenu_effectmenu(void *arg_unused) uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Alpha Over", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 5, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Alpha Under", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Alpha Over Drop", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Sweep", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Plugin...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, ""); uiBlockSetDirection(block, UI_RIGHT); uiTextBoundsBlock(block, 60); - + return block; } @@ -263,7 +267,7 @@ static uiBlock *seq_addmenu(void *arg_unused) block= uiNewBlock(&curarea->uiblocks, "seq_addmenu", UI_EMBOSSP, UI_HELV, curarea->headwin); uiBlockSetButmFunc(block, do_seq_addmenu, NULL); - uiDefIconTextBlockBut(block, seq_addmenu_effectmenu, NULL, ICON_RIGHTARROW_THIN, "Effect", 0, yco-=20, 120, 19, ""); + uiDefIconTextBlockBut(block, seq_addmenu_effectmenu, NULL, ICON_RIGHTARROW_THIN, "Effect", 0, yco-=20, 120, 19, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); @@ -271,7 +275,7 @@ static uiBlock *seq_addmenu(void *arg_unused) uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Scene", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Images", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Movie", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, ""); - + if(curarea->headertype==HEADERTOP) { uiBlockSetDirection(block, UI_DOWN); } @@ -470,23 +474,23 @@ void seq_buttons() xmax= GetButStringLength("View"); uiDefBlockBut(block,seq_viewmenu, NULL, "View", xco, -2, xmax-3, 24, ""); xco+=xmax; - + xmax= GetButStringLength("Select"); uiDefBlockBut(block,seq_selectmenu, NULL, "Select", xco, -2, xmax-3, 24, ""); xco+=xmax; - + xmax= GetButStringLength("Add"); uiDefBlockBut(block, seq_addmenu, NULL, "Add", xco, -2, xmax-3, 24, ""); xco+= xmax; - + xmax= GetButStringLength("Strip"); uiDefBlockBut(block, seq_editmenu, NULL, "Strip", xco, -2, xmax-3, 24, ""); xco+= xmax; - + /* end of pull down menus */ uiBlockSetEmboss(block, UI_EMBOSS); } - + /* IMAGE */ uiDefIconButS(block, TOG, B_REDR, ICON_IMAGE_COL, xco,0,XIC,YIC, &sseq->mainb, 0, 0, 0, 0, "Shows the sequence output image preview"); @@ -498,6 +502,6 @@ void seq_buttons() /* CLEAR MEM */ xco+= 8; uiDefBut(block, BUT, B_SEQCLEAR, "Refresh", xco+=XIC,0,3*XIC,YIC, 0, 0, 0, 0, 0, "Clears all buffered images in memory"); - + uiDrawBlock(block); } diff --git a/source/blender/src/sequence.c b/source/blender/src/sequence.c index 14370cafb1c..1f5a29b5089 100644 --- a/source/blender/src/sequence.c +++ b/source/blender/src/sequence.c @@ -81,29 +81,29 @@ void open_plugin_seq(PluginSeq *pis, char *seqname) { int (*version)(); char *cp; - + /* to be sure: (is tested for) */ pis->doit= 0; pis->pname= 0; pis->varstr= 0; pis->cfra= 0; pis->version= 0; - + /* clear the error list */ PIL_dynlib_get_error_as_string(NULL); - + /* if(pis->handle) PIL_dynlib_close(pis->handle); */ /* pis->handle= 0; */ /* open the needed object */ pis->handle= PIL_dynlib_open(pis->name); if(test_dlerr(pis->name, pis->name)) return; - + if (pis->handle != 0) { /* find the address of the version function */ version= (int (*)())PIL_dynlib_find_symbol(pis->handle, "plugin_seq_getversion"); if (test_dlerr(pis->name, "plugin_seq_getversion")) return; - + if (version != 0) { pis->version= version(); if (pis->version==2 || pis->version==3) { @@ -143,19 +143,19 @@ PluginSeq *add_plugin_seq(char *str, char *seqname) PluginSeq *pis; VarStruct *varstr; int a; - + pis= MEM_callocN(sizeof(PluginSeq), "PluginSeq"); - + strcpy(pis->name, str); open_plugin_seq(pis, seqname); - + if(pis->doit==0) { if(pis->handle==0) error("no plugin: %s", str); else error("in plugin: %s", str); MEM_freeN(pis); return 0; } - + /* default values */ varstr= pis->varstr; for(a=0; avars; a++, varstr++) { @@ -172,9 +172,9 @@ void free_plugin_seq(PluginSeq *pis) { if(pis==0) return; - + /* no PIL_dynlib_close: same plugin can be opened multiple times with 1 handle */ - MEM_freeN(pis); + MEM_freeN(pis); } /* ***************** END PLUGIN ************************ */ @@ -185,7 +185,7 @@ void free_stripdata(int len, StripElem *se) int a; seo= se; - + for(a=0; aibuf && se->ok!=2) IMB_freeImBuf(se->ibuf); } @@ -202,7 +202,7 @@ void free_strip(Strip *strip) printf("error: negative users in strip\n"); return; } - + if(strip->stripdata) { free_stripdata(strip->len, strip->stripdata); } @@ -223,22 +223,23 @@ void new_stripdata(Sequence *seq) void free_sequence(Sequence *seq) { extern Sequence *last_seq; - + if(seq->strip) free_strip(seq->strip); + if(seq->varstr) MEM_freeN(seq->varstr); if(seq->anim) IMB_free_anim(seq->anim); - + free_plugin_seq(seq->plugin); - + if(seq==last_seq) last_seq= 0; - + MEM_freeN(seq); } void do_seq_count(ListBase *seqbase, int *totseq) { Sequence *seq; - + seq= seqbase->first; while(seq) { (*totseq)++; @@ -250,7 +251,7 @@ void do_seq_count(ListBase *seqbase, int *totseq) void do_build_seqar(ListBase *seqbase, Sequence ***seqar, int depth) { Sequence *seq; - + seq= seqbase->first; while(seq) { seq->depth= depth; @@ -264,17 +265,17 @@ void do_build_seqar(ListBase *seqbase, Sequence ***seqar, int depth) void build_seqar(ListBase *seqbase, Sequence ***seqar, int *totseq) { Sequence **tseqar; - + *totseq= 0; do_seq_count(seqbase, totseq); - + if(*totseq==0) { *seqar= 0; return; } *seqar= MEM_mallocN(sizeof(void *)* *totseq, "seqar"); tseqar= *seqar; - + do_build_seqar(seqbase, seqar, 0); *seqar= tseqar; } @@ -283,19 +284,19 @@ void free_editing(Editing *ed) { MetaStack *ms; Sequence *seq; - + if(ed==0) return; WHILE_SEQ(&ed->seqbase) { free_sequence(seq); } END_SEQ - + while( (ms= ed->metastack.first) ) { BLI_remlink(&ed->metastack, ms); MEM_freeN(ms); } - + MEM_freeN(ed); } @@ -303,32 +304,32 @@ void calc_sequence(Sequence *seq) { Sequence *seqm; int min, max; - + /* check all metas recursively */ seqm= seq->seqbase.first; while(seqm) { if(seqm->seqbase.first) calc_sequence(seqm); seqm= seqm->next; } - + /* effects and meta: automatic start and end */ - + if(seq->type & SEQ_EFFECT) { /* pointers */ if(seq->seq2==0) seq->seq2= seq->seq1; if(seq->seq3==0) seq->seq3= seq->seq1; - + /* effecten go from seq1 -> seq2: test */ - + /* we take the largest start and smallest end */ - + // seq->start= seq->startdisp= MAX2(seq->seq1->startdisp, seq->seq2->startdisp); // seq->enddisp= MIN2(seq->seq1->enddisp, seq->seq2->enddisp); seq->start= seq->startdisp= MAX3(seq->seq1->startdisp, seq->seq2->startdisp, seq->seq3->startdisp); seq->enddisp= MIN3(seq->seq1->enddisp, seq->seq2->enddisp, seq->seq3->enddisp); seq->len= seq->enddisp - seq->startdisp; - + if(seq->strip && seq->len!=seq->strip->len) { new_stripdata(seq); } @@ -347,20 +348,20 @@ void calc_sequence(Sequence *seq) } seq->start= min; seq->len= max-min; - + if(seq->strip && seq->len!=seq->strip->len) { new_stripdata(seq); } } } - - + + if(seq->startofs && seq->startstill) seq->startstill= 0; if(seq->endofs && seq->endstill) seq->endstill= 0; - + seq->startdisp= seq->start + seq->startofs - seq->startstill; seq->enddisp= seq->start+seq->len - seq->endofs + seq->endstill; - + seq->handsize= 10.0; /* 10 frames */ if( seq->enddisp-seq->startdisp < 20 ) { seq->handsize= (float)(0.5*(seq->enddisp-seq->startdisp)); @@ -377,16 +378,16 @@ void sort_seq() ListBase seqbase, effbase; Editing *ed; Sequence *seq, *seqt; - + ed= G.scene->ed; if(ed==0) return; - + seqbase.first= seqbase.last= 0; effbase.first= effbase.last= 0; - + while( (seq= ed->seqbasep->first) ) { BLI_remlink(ed->seqbasep, seq); - + if(seq->type & SEQ_EFFECT) { seqt= effbase.first; while(seqt) { @@ -410,7 +411,7 @@ void sort_seq() if(seqt==0) BLI_addtail(&seqbase, seq); } } - + addlisttolist(&seqbase, &effbase); *(ed->seqbasep)= seqbase; } @@ -421,22 +422,22 @@ void clear_scene_in_allseqs(Scene *sce) Scene *sce1; Editing *ed; Sequence *seq; - + /* when a scene is deleted: test all seqs */ - + sce1= G.main->scene.first; while(sce1) { if(sce1!=sce && sce1->ed) { ed= sce1->ed; - + WHILE_SEQ(&ed->seqbase) { - + if(seq->scene==sce) seq->scene= 0; - + } END_SEQ } - + sce1= sce1->id.next; } } @@ -448,25 +449,25 @@ void do_alphaover_effect(float facf0, float facf1, int x, int y, unsigned int *r int fac2, mfac, fac, fac4; int xo, tempc; char *rt1, *rt2, *rt; - + xo= x; rt1= (char *)rect1; rt2= (char *)rect2; rt= (char *)out; - + fac2= (int)(256.0*facf0); fac4= (int)(256.0*facf1); while(y--) { - + x= xo; while(x--) { - - /* rt = rt1 over rt2 (alpha from rt1) */ - + + /* rt = rt1 over rt2 (alpha from rt1) */ + fac= fac2; mfac= 256 - ( (fac2*rt1[3])>>8 ); - + if(fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2); else if(mfac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt1); else { @@ -481,16 +482,16 @@ void do_alphaover_effect(float facf0, float facf1, int x, int y, unsigned int *r } rt1+= 4; rt2+= 4; rt+= 4; } - + if(y==0) break; y--; - + x= xo; while(x--) { - + fac= fac4; mfac= 256 - ( (fac4*rt1[3])>>8 ); - + if(fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2); else if(mfac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt1); else { @@ -513,23 +514,23 @@ void do_alphaunder_effect(float facf0, float facf1, int x, int y, unsigned int * int fac2, mfac, fac, fac4; int xo; char *rt1, *rt2, *rt; - + xo= x; rt1= (char *)rect1; rt2= (char *)rect2; rt= (char *)out; - + fac2= (int)(256.0*facf0); fac4= (int)(256.0*facf1); while(y--) { - + x= xo; while(x--) { - + /* rt = rt1 under rt2 (alpha from rt2) */ - - /* this complex optimalisation is because the + + /* this complex optimalisation is because the * 'skybuf' can be crossed in */ if(rt2[3]==0 && fac2==256) *( (unsigned int *)rt) = *( (unsigned int *)rt1); @@ -537,7 +538,7 @@ void do_alphaunder_effect(float facf0, float facf1, int x, int y, unsigned int * else { mfac= rt2[3]; fac= (fac2*(256-mfac))>>8; - + if(fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2); else { rt[0]= ( fac*rt1[0] + mfac*rt2[0])>>8; @@ -560,7 +561,7 @@ void do_alphaunder_effect(float facf0, float facf1, int x, int y, unsigned int * else { mfac= rt2[3]; fac= (fac4*(256-mfac))>>8; - + if(fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2); else { rt[0]= ( fac*rt1[0] + mfac*rt2[0])>>8; @@ -580,44 +581,44 @@ void do_cross_effect(float facf0, float facf1, int x, int y, unsigned int *rect1 int fac1, fac2, fac3, fac4; int xo; char *rt1, *rt2, *rt; - + xo= x; rt1= (char *)rect1; rt2= (char *)rect2; rt= (char *)out; - + fac2= (int)(256.0*facf0); fac1= 256-fac2; fac4= (int)(256.0*facf1); fac3= 256-fac4; - + while(y--) { - + x= xo; while(x--) { - + rt[0]= (fac1*rt1[0] + fac2*rt2[0])>>8; rt[1]= (fac1*rt1[1] + fac2*rt2[1])>>8; rt[2]= (fac1*rt1[2] + fac2*rt2[2])>>8; rt[3]= (fac1*rt1[3] + fac2*rt2[3])>>8; - + rt1+= 4; rt2+= 4; rt+= 4; } - + if(y==0) break; y--; - + x= xo; while(x--) { - + rt[0]= (fac3*rt1[0] + fac4*rt2[0])>>8; rt[1]= (fac3*rt1[1] + fac4*rt2[1])>>8; rt[2]= (fac3*rt1[2] + fac4*rt2[2])>>8; rt[3]= (fac3*rt1[3] + fac4*rt2[3])>>8; - + rt1+= 4; rt2+= 4; rt+= 4; } - + } } @@ -627,20 +628,20 @@ void do_gammacross_effect(float facf0, float facf1, int x, int y, unsigned int * int fac1, fac2, col; int xo; char *rt1, *rt2, *rt; - + xo= x; rt1= (char *)rect1; rt2= (char *)rect2; rt= (char *)out; - + fac2= (int)(256.0*facf0); fac1= 256-fac2; - + while(y--) { - + x= xo; while(x--) { - + col= (fac1*igamtab1[rt1[0]] + fac2*igamtab1[rt2[0]])>>8; if(col>65535) rt[0]= 255; else rt[0]= ( (char *)(gamtab+col))[MOST_SIG_BYTE]; col=(fac1*igamtab1[rt1[1]] + fac2*igamtab1[rt2[1]])>>8; @@ -649,16 +650,16 @@ void do_gammacross_effect(float facf0, float facf1, int x, int y, unsigned int * if(col>65535) rt[2]= 255; else rt[2]= ( (char *)(gamtab+col))[MOST_SIG_BYTE]; col= (fac1*igamtab1[rt1[3]] + fac2*igamtab1[rt2[3]])>>8; if(col>65535) rt[3]= 255; else rt[3]= ( (char *)(gamtab+col))[MOST_SIG_BYTE]; - + rt1+= 4; rt2+= 4; rt+= 4; } - + if(y==0) break; y--; - + x= xo; while(x--) { - + col= (fac1*igamtab1[rt1[0]] + fac2*igamtab1[rt2[0]])>>8; if(col>65535) rt[0]= 255; else rt[0]= ( (char *)(gamtab+col))[MOST_SIG_BYTE]; col= (fac1*igamtab1[rt1[1]] + fac2*igamtab1[rt2[1]])>>8; @@ -667,10 +668,10 @@ void do_gammacross_effect(float facf0, float facf1, int x, int y, unsigned int * if(col>65535) rt[2]= 255; else rt[2]= ( (char *)(gamtab+col))[MOST_SIG_BYTE]; col= (fac1*igamtab1[rt1[3]] + fac2*igamtab1[rt2[3]])>>8; if(col>65535) rt[3]= 255; else rt[3]= ( (char *)(gamtab+col))[MOST_SIG_BYTE]; - + rt1+= 4; rt2+= 4; rt+= 4; } - + } } @@ -678,17 +679,17 @@ void do_add_effect(float facf0, float facf1, int x, int y, unsigned int *rect1, { int col, xo, fac1, fac3; char *rt1, *rt2, *rt; - + xo= x; rt1= (char *)rect1; rt2= (char *)rect2; rt= (char *)out; - + fac1= (int)(256.0*facf0); fac3= (int)(256.0*facf1); - + while(y--) { - + x= xo; while(x--) { @@ -700,16 +701,16 @@ void do_add_effect(float facf0, float facf1, int x, int y, unsigned int *rect1, if(col>255) rt[2]= 255; else rt[2]= col; col= rt1[3]+ ((fac1*rt2[3])>>8); if(col>255) rt[3]= 255; else rt[3]= col; - + rt1+= 4; rt2+= 4; rt+= 4; } if(y==0) break; y--; - + x= xo; while(x--) { - + col= rt1[0]+ ((fac3*rt2[0])>>8); if(col>255) rt[0]= 255; else rt[0]= col; col= rt1[1]+ ((fac3*rt2[1])>>8); @@ -718,7 +719,7 @@ void do_add_effect(float facf0, float facf1, int x, int y, unsigned int *rect1, if(col>255) rt[2]= 255; else rt[2]= col; col= rt1[3]+ ((fac3*rt2[3])>>8); if(col>255) rt[3]= 255; else rt[3]= col; - + rt1+= 4; rt2+= 4; rt+= 4; } } @@ -728,17 +729,17 @@ void do_sub_effect(float facf0, float facf1, int x, int y, unsigned int *rect1, { int col, xo, fac1, fac3; char *rt1, *rt2, *rt; - + xo= x; rt1= (char *)rect1; rt2= (char *)rect2; rt= (char *)out; - + fac1= (int)(256.0*facf0); fac3= (int)(256.0*facf1); - + while(y--) { - + x= xo; while(x--) { @@ -750,16 +751,16 @@ void do_sub_effect(float facf0, float facf1, int x, int y, unsigned int *rect1, if(col<0) rt[2]= 0; else rt[2]= col; col= rt1[3]- ((fac1*rt2[3])>>8); if(col<0) rt[3]= 0; else rt[3]= col; - + rt1+= 4; rt2+= 4; rt+= 4; } if(y==0) break; y--; - + x= xo; while(x--) { - + col= rt1[0]- ((fac3*rt2[0])>>8); if(col<0) rt[0]= 0; else rt[0]= col; col= rt1[1]- ((fac3*rt2[1])>>8); @@ -768,7 +769,7 @@ void do_sub_effect(float facf0, float facf1, int x, int y, unsigned int *rect1, if(col<0) rt[2]= 0; else rt[2]= col; col= rt1[3]- ((fac3*rt2[3])>>8); if(col<0) rt[3]= 0; else rt[3]= col; - + rt1+= 4; rt2+= 4; rt+= 4; } } @@ -783,18 +784,18 @@ void do_drop_effect(float facf0, float facf1, int x, int y, unsigned int *rect2i int height, width, temp, fac, fac1, fac2; char *rt1, *rt2, *out; int field= 1; - + width= x; height= y; - + fac1= (int)(70.0*facf0); fac2= (int)(70.0*facf1); - + rt2= (char*) (rect2i + YOFF*width); rt1= (char*) rect1i; out= (char*) outi; for (y=0; y 0) { - + temp= y-yofs; if(temp > 0 && temp < yo) { - + x= xo; while(x--) { - + temp= x+xofs; if(temp > 0 && temp < xo) { - + temp= ((fac1*rt2[3])>>8); - + col= rt1[0]- temp; if(col<0) rt[0]= 0; else rt[0]= col; col= rt1[1]- temp; @@ -856,33 +857,33 @@ void do_drop_effect2(float facf0, float facf1, int x, int y, unsigned int *rect2 col= rt1[3]- temp; if(col<0) rt[3]= 0; else rt[3]= col; } - else *( (unsigned int *)rt) = *( (unsigned int *)rt1); - + else *( (unsigned int *)rt) = *( (unsigned int *)rt1); + rt1+= 4; rt2+= 4; rt+= 4; } } else { x= xo; while(x--) { - *( (unsigned int *)rt) = *( (unsigned int *)rt1); + *( (unsigned int *)rt) = *( (unsigned int *)rt1); rt1+= 4; rt2+= 4; rt+= 4; } } - + if(y==0) break; y--; - + temp= y-yofs; if(temp > 0 && temp < yo) { - + x= xo; while(x--) { - + temp= x+xofs; if(temp > 0 && temp < xo) { - + temp= ((fac3*rt2[3])>>8); - + col= rt1[0]- temp; if(col<0) rt[0]= 0; else rt[0]= col; col= rt1[1]- temp; @@ -892,15 +893,15 @@ void do_drop_effect2(float facf0, float facf1, int x, int y, unsigned int *rect2 col= rt1[3]- temp; if(col<0) rt[3]= 0; else rt[3]= col; } - else *( (unsigned int *)rt) = *( (unsigned int *)rt1); - + else *( (unsigned int *)rt) = *( (unsigned int *)rt1); + rt1+= 4; rt2+= 4; rt+= 4; } } else { x= xo; while(x--) { - *( (unsigned int *)rt) = *( (unsigned int *)rt1); + *( (unsigned int *)rt) = *( (unsigned int *)rt1); rt1+= 4; rt2+= 4; rt+= 4; } } @@ -912,24 +913,24 @@ void do_mul_effect(float facf0, float facf1, int x, int y, unsigned int *rect1, { int xo, fac1, fac3; char *rt1, *rt2, *rt; - + xo= x; rt1= (char *)rect1; rt2= (char *)rect2; rt= (char *)out; - + fac1= (int)(256.0*facf0); fac3= (int)(256.0*facf1); - + /* formula: * fac*(a*b) + (1-fac)*a => fac*a*(b-1)+a */ - + while(y--) { - + x= xo; while(x--) { - + rt[0]= rt1[0] + ((fac1*rt1[0]*(rt2[0]-256))>>16); rt[1]= rt1[1] + ((fac1*rt1[1]*(rt2[1]-256))>>16); rt[2]= rt1[2] + ((fac1*rt1[2]*(rt2[2]-256))>>16); @@ -940,44 +941,229 @@ void do_mul_effect(float facf0, float facf1, int x, int y, unsigned int *rect1, if(y==0) break; y--; - + x= xo; while(x--) { - + rt[0]= rt1[0] + ((fac3*rt1[0]*(rt2[0]-256))>>16); rt[1]= rt1[1] + ((fac3*rt1[1]*(rt2[1]-256))>>16); rt[2]= rt1[2] + ((fac3*rt1[2]*(rt2[2]-256))>>16); rt[3]= rt1[3] + ((fac3*rt1[3]*(rt2[3]-256))>>16); - + rt1+= 4; rt2+= 4; rt+= 4; } } } + + +int check_zone(int x, int y, int xo, int yo, Sequence *seq, float facf0) { + + float posx, posy; + float halfx = xo/2; + float halfy = yo/2; + SweepVars *sweep = (SweepVars *)seq->varstr; + + //printf("facf0: %f xo: %d\n", facf0, x); + posx = facf0 * xo; + posy = facf0 * yo; + + switch (sweep->sweeptype) { + case DO_LEFT_RIGHT: + if (x > posx) return 1; + return 0; + break; + case DO_RIGHT_LEFT: + if (x < (xo - posx)) return 1; + return 0; + break; + case DO_DOWN_UP: + if (y > posy ) return 1; + return 0; + break; + case DO_UP_DOWN: + if (y < (yo - posy)) return 1; + return 0; + break; + case DO_LOWER_LEFT_UPPER_RIGHT: + if (posy < posx) posx = posy; + if ((x + yo - y) < posx*2) return 0; + return 1; + break; + case DO_UPPER_RIGHT_LOWER_LEFT: + if (posy < posx) posx = posy; + if ((xo - x + y) < posx*2) return 0; + return 1; + break; + case DO_UPPER_LEFT_LOWER_RIGHT: + if (posy < posx) posx = posy; + if ((x + y) < posx*2 ) return 0; + return 1; + break; + case DO_LOWER_RIGHT_UPPER_LEFT: + if (posy < posx) posx = posy; + if ((xo - x + yo - y) < posx*2) return 0; + return 1; + break; + case DO_HORZ_OUT: + if ((x < (halfx - (posx/2)) ) || (x > (halfx + posx/2) )) return 1; + return 0; + break; + case DO_HORZ_IN: + if ((x >posx/2) && (x < (xo - posx/2))) return 1; + return 0; + break; + case DO_VERT_OUT: + if ((y < (halfy - posy/2)) || (y > (halfy + posy/2))) return 1; + return 0; + break; + case DO_VERT_IN: + if ((y >posy/2) && (y < (yo - posy/2))) return 1; + return 0; + break; + case DO_HORZ_VERT_OUT: + if (posy < posx) posx = posy; + if (((x > (halfx - posx/2)) && (x < (halfx + posx/2))) || + ((y > (halfy - posx/2)) && (y < (halfy + posx/2)))) return 0; + return 1; + break; + case DO_HORZ_VERT_IN: + if (posy < posx) posx = posy; + if ((x rect==0) return; - + tot= ibuf->x*ibuf->y; rect= ibuf->rect; while(tot--) *(rect++)= 0; - + } void multibuf(ImBuf *ibuf, float fmul) { char *rt; int a, mul, icol; - + mul= (int)(256.0*fmul); a= ibuf->x*ibuf->y; rt= (char *)ibuf->rect; while(a--) { - + icol= (mul*rt[0])>>8; if(icol>254) rt[0]= 255; else rt[0]= icol; icol= (mul*rt[1])>>8; @@ -986,7 +1172,7 @@ void multibuf(ImBuf *ibuf, float fmul) if(icol>254) rt[2]= 255; else rt[2]= icol; icol= (mul*rt[3])>>8; if(icol>254) rt[3]= 255; else rt[3]= icol; - + rt+= 4; } } @@ -997,36 +1183,36 @@ void do_effect(int cfra, Sequence *seq, StripElem *se) float fac, facf; int x, y; char *cp; - + if(se->se1==0 || se->se2==0 || se->se3==0) { make_black_ibuf(se->ibuf); return; } - + /* if metastrip: other se's */ if(se->se1->ok==2) se1= se->se1->se1; else se1= se->se1; if(se->se2->ok==2) se2= se->se2->se1; else se2= se->se2; - + if(se->se3->ok==2) se3= se->se3->se1; else se3= se->se3; - + if(se1==0 || se2==0 || se3==0 || se1->ibuf==0 || se2->ibuf==0 || se3->ibuf==0) { make_black_ibuf(se->ibuf); return; } - + x= se2->ibuf->x; y= se2->ibuf->y; - + if(seq->ipo && seq->ipo->curve.first) { do_seq_ipo(seq); fac= seq->facf0; facf= seq->facf1; } - else if ELEM3( seq->type, SEQ_CROSS, SEQ_GAMCROSS, SEQ_PLUGIN) { + else if ( seq->type==SEQ_CROSS || seq->type==SEQ_GAMCROSS || seq->type==SEQ_PLUGIN || seq->type==SEQ_SWEEP) { fac= (float)(cfra - seq->startdisp); facf= (float)(fac+0.5); fac /= seq->len; @@ -1035,9 +1221,9 @@ void do_effect(int cfra, Sequence *seq, StripElem *se) else { fac= facf= 1.0; } - + if( G.scene->r.mode & R_FIELDS ); else facf= fac; - + switch(seq->type) { case SEQ_CROSS: do_cross_effect(fac, facf, x, y, se1->ibuf->rect, se2->ibuf->rect, se->ibuf->rect); @@ -1064,9 +1250,12 @@ void do_effect(int cfra, Sequence *seq, StripElem *se) case SEQ_ALPHAUNDER: do_alphaunder_effect(fac, facf, x, y, se1->ibuf->rect, se2->ibuf->rect, se->ibuf->rect); break; + case SEQ_SWEEP: + do_sweep_effect(seq, fac, facf, x, y, se1->ibuf->rect, se2->ibuf->rect, se->ibuf->rect); + break; case SEQ_PLUGIN: if(seq->plugin && seq->plugin->doit) { - + if((G.f & G_PLAYANIM)==0) waitcursor(1); if(seq->plugin->cfra) *(seq->plugin->cfra)= frame_to_float(CFRA); @@ -1080,8 +1269,8 @@ void do_effect(int cfra, Sequence *seq, StripElem *se) if(se3->ibuf) IMB_convert_rgba_to_abgr(se3->ibuf->x*se3->ibuf->y, se3->ibuf->rect); } - ((SeqDoit)seq->plugin->doit)(seq->plugin->data, fac, facf, x, y, - se1->ibuf, se2->ibuf, se->ibuf, se3->ibuf); + ((SeqDoit)seq->plugin->doit)(seq->plugin->data, fac, facf, x, y, + se1->ibuf, se2->ibuf, se->ibuf, se3->ibuf); if (seq->plugin->version<=2) { if(se1->ibuf) IMB_convert_rgba_to_abgr(se1->ibuf->x*se1->ibuf->y, se1->ibuf->rect); @@ -1094,7 +1283,7 @@ void do_effect(int cfra, Sequence *seq, StripElem *se) } break; } - + } int evaluate_seq_frame(int cfra) @@ -1102,12 +1291,12 @@ int evaluate_seq_frame(int cfra) Sequence *seq; Editing *ed; int totseq=0; - + memset(seq_arr, 0, 4*MAXSEQ); - + ed= G.scene->ed; if(ed==0) return 0; - + seq= ed->seqbasep->first; while(seq) { if(seq->startdisp <=cfra && seq->enddisp > cfra) { @@ -1116,7 +1305,7 @@ int evaluate_seq_frame(int cfra) } seq= seq->next; } - + return totseq; } @@ -1125,20 +1314,20 @@ StripElem *give_stripelem(Sequence *seq, int cfra) Strip *strip; StripElem *se; int nr; - + strip= seq->strip; se= strip->stripdata; - + if(se==0) return 0; if(seq->startdisp >cfra || seq->enddisp <= cfra) return 0; - + if(cfra <= seq->start) nr= 0; else if(cfra >= seq->start+seq->len-1) nr= seq->len-1; else nr= cfra-seq->start; - + se+= nr; se->nr= nr; - + return se; } @@ -1149,23 +1338,23 @@ void set_meta_stripdata(Sequence *seqm) ListBase *tempbase; StripElem *se; int a, cfra, b; - + /* sets all ->se1 pointers in stripdata, to read the ibuf from it */ - + ed= G.scene->ed; if(ed==0) return; - + tempbase= ed->seqbasep; ed->seqbasep= &seqm->seqbase; - + se= seqm->strip->stripdata; for(a=0; alen; a++, se++) { cfra= a+seqm->start; if(evaluate_seq_frame(cfra)) { - + /* we take the upper effect strip or the lowest imagestrip/metastrip */ seqim= seqeff= 0; - + for(b=1; bse1= give_stripelem(seq, cfra); } @@ -1200,13 +1389,13 @@ void set_meta_stripdata(Sequence *seqm) void do_seq_count_cfra(ListBase *seqbase, int *totseq, int cfra) { Sequence *seq; - + seq= seqbase->first; while(seq) { if(seq->startdisp <=cfra && seq->enddisp > cfra) { if(seq->seqbase.first) { - + if(cfra< seq->start) do_seq_count_cfra(&seq->seqbase, totseq, seq->start); else if(cfra> seq->start+seq->len-1) do_seq_count_cfra(&seq->seqbase, totseq, seq->start+seq->len-1); else do_seq_count_cfra(&seq->seqbase, totseq, cfra); @@ -1226,18 +1415,18 @@ void do_build_seqar_cfra(ListBase *seqbase, Sequence ***seqar, int cfra) unsigned int *rectot; int oldx, oldy, oldcfra, doseq; char name[FILE_MAXDIR]; - + seq= seqbase->first; while(seq) { - + /* set at zero because free_imbuf_seq... */ seq->curelem= 0; if ((seq->type == SEQ_SOUND) && (seq->ipo) &&(seq->startdisp<=cfra+2) && (seq->enddisp>cfra)) do_seq_ipo(seq); - + if(seq->startdisp <=cfra && seq->enddisp > cfra) { - + if(seq->seqbase.first) { if(cfra< seq->start) do_build_seqar_cfra(&seq->seqbase, seqar, seq->start); else if(cfra> seq->start+seq->len-1) do_build_seqar_cfra(&seq->seqbase, seqar, seq->start+seq->len-1); @@ -1246,7 +1435,7 @@ void do_build_seqar_cfra(ListBase *seqbase, Sequence ***seqar, int cfra) **seqar= seq; (*seqar)++; - + se=seq->curelem= give_stripelem(seq, cfra); if(se) { @@ -1259,9 +1448,9 @@ void do_build_seqar_cfra(ListBase *seqbase, Sequence ***seqar, int cfra) } else if(seq->type == SEQ_SOUND) { se->ok= 2; - } + } else if(seq->type & SEQ_EFFECT) { - + /* test if image is too small: reload */ if(se->ibuf) { if(se->ibuf->x < seqrectx || se->ibuf->y < seqrecty) { @@ -1269,31 +1458,31 @@ void do_build_seqar_cfra(ListBase *seqbase, Sequence ***seqar, int cfra) se->ibuf= 0; } } - + /* does the effect should be recalculated? */ - + if(se->ibuf==0 || (se->se1 != seq->seq1->curelem) || (se->se2 != seq->seq2->curelem) || (se->se3 != seq->seq3->curelem)) { se->se1= seq->seq1->curelem; se->se2= seq->seq2->curelem; se->se3= seq->seq3->curelem; - + if(se->ibuf==0) se->ibuf= IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rect, 0); - + do_effect(cfra, seq, se); } - + /* test size */ if(se->ibuf) { if(se->ibuf->x != seqrectx || se->ibuf->y != seqrecty ) { - if(G.scene->r.mode & R_OSA) + if(G.scene->r.mode & R_OSA) IMB_scaleImBuf(se->ibuf, (short)seqrectx, (short)seqrecty); - else + else IMB_scalefastImBuf(se->ibuf, (short)seqrectx, (short)seqrecty); } } } else if(seq->type < SEQ_EFFECT) { - + if(se->ibuf) { /* test if image too small: reload */ if(se->ibuf->x < seqrectx || se->ibuf->y < seqrecty) { @@ -1305,17 +1494,17 @@ void do_build_seqar_cfra(ListBase *seqbase, Sequence ***seqar, int cfra) if(seq->type==SEQ_IMAGE) { if(se->ok && se->ibuf==0) { - + /* if playanim or render: no waitcursor */ if((G.f & G_PLAYANIM)==0) waitcursor(1); - + strcpy(name, seq->strip->dir); strcat(name, se->name); BLI_convertstringcode(name, G.sce, G.scene->r.cfra); se->ibuf= IMB_loadiffname(name, IB_rect); if((G.f & G_PLAYANIM)==0) waitcursor(0); - + if(se->ibuf==0) se->ok= 0; else { if(se->ibuf->depth==32 && se->ibuf->zbuf==0) converttopremul(se->ibuf); @@ -1326,21 +1515,21 @@ void do_build_seqar_cfra(ListBase *seqbase, Sequence ***seqar, int cfra) } else if(seq->type==SEQ_MOVIE) { if(se->ok && se->ibuf==0) { - + /* if playanim r render: no waitcursor */ if((G.f & G_PLAYANIM)==0) waitcursor(1); - + if(seq->anim==0) { strcpy(name, seq->strip->dir); strcat(name, seq->strip->stripdata->name); BLI_convertstringcode(name, G.sce, G.scene->r.cfra); - + seq->anim = openanim(name, IB_rect); } if(seq->anim) { se->ibuf = IMB_anim_absolute(seq->anim, se->nr); } - + if(se->ibuf==0) se->ok= 0; else { if(se->ibuf->depth==32) converttopremul(se->ibuf); @@ -1350,34 +1539,34 @@ void do_build_seqar_cfra(ListBase *seqbase, Sequence ***seqar, int cfra) if(seq->mul==0.0) seq->mul= 1.0; if(seq->mul != 1.0) multibuf(se->ibuf, seq->mul); } - if((G.f & G_PLAYANIM)==0) waitcursor(0); + if((G.f & G_PLAYANIM)==0) waitcursor(0); } } else if(seq->type==SEQ_SCENE && se->ibuf==0) { View3D *vd; - + oldsce= G.scene; set_scene_bg(seq->scene); - + /* prevent eternal loop */ doseq= G.scene->r.scemode & R_DOSEQ; G.scene->r.scemode &= ~R_DOSEQ; - + /* store stuffies */ oldcfra= CFRA; CFRA= seq->sfra + se->nr; waitcursor(1); - + rectot= R.rectot; R.rectot= 0; oldx= R.rectx; oldy= R.recty; /* needed because current 3D window cannot define the layers, like in a background render */ vd= G.vd; G.vd= 0; - + RE_initrender(NULL); if (!G.background) { if(R.r.mode & R_FIELDS) update_for_newframe_muted(); R.flag= 0; - + free_filesel_spec(G.scene->r.pic); } @@ -1389,10 +1578,10 @@ void do_build_seqar_cfra(ListBase *seqbase, Sequence ***seqar, int cfra) se->ibuf->mall |= IB_zbuf; R.rectz= 0; } - + /* and restore */ G.vd= vd; - + if((G.f & G_PLAYANIM)==0) waitcursor(0); CFRA= oldcfra; if(R.rectot) MEM_freeN(R.rectot); @@ -1400,38 +1589,38 @@ void do_build_seqar_cfra(ListBase *seqbase, Sequence ***seqar, int cfra) R.rectx=oldx; R.recty=oldy; G.scene->r.scemode |= doseq; set_scene_bg(oldsce); - + /* restore!! */ R.rectx= seqrectx; R.recty= seqrecty; - + /* added because this flag is checked for * movie writing when rendering an anim. * very convoluted. fix. -zr */ R.r.imtype= G.scene->r.imtype; } - + /* size test */ if(se->ibuf) { if(se->ibuf->x != seqrectx || se->ibuf->y != seqrecty ) { - + if (G.scene->r.mode & R_FIELDS) { - + if (seqrecty > 288) IMB_scalefieldImBuf(se->ibuf, (short)seqrectx, (short)seqrecty); else { IMB_de_interlace(se->ibuf); - if(G.scene->r.mode & R_OSA) + if(G.scene->r.mode & R_OSA) IMB_scaleImBuf(se->ibuf, (short)seqrectx, (short)seqrecty); - else + else IMB_scalefastImBuf(se->ibuf, (short)seqrectx, (short)seqrecty); } } else { - if(G.scene->r.mode & R_OSA) + if(G.scene->r.mode & R_OSA) IMB_scaleImBuf(se->ibuf,(short)seqrectx, (short)seqrecty); - else + else IMB_scalefastImBuf(se->ibuf, (short)seqrectx, (short)seqrecty); } } @@ -1463,7 +1652,7 @@ ImBuf *give_ibuf_seq(int cfra) do_seq_count_cfra(ed->seqbasep, &totseq, cfra); if(totseq==0) return 0; - + seqrectx= (G.scene->r.size*G.scene->r.xsch)/100; if(G.scene->r.mode & R_PANORAMA) seqrectx*= G.scene->r.xparts; seqrecty= (G.scene->r.size*G.scene->r.ysch)/100; @@ -1471,47 +1660,47 @@ ImBuf *give_ibuf_seq(int cfra) /* tseqar is neede because in do_build_... the pointer changes */ seqar= tseqar= MEM_callocN(sizeof(void *)*totseq, "seqar"); - + /* this call loads and makes the ibufs */ do_build_seqar_cfra(ed->seqbasep, &seqar, cfra); seqar= tseqar; - + for(seqnr=0; seqnrcurelem; if((seq->type != SEQ_SOUND) && (se)) { if(seq->type==SEQ_META) { - + /* bottom strip! */ if(seqfirst==0) seqfirst= seq; else if(seqfirst->depth > seq->depth) seqfirst= seq; else if(seqfirst->machine > seq->machine) seqfirst= seq; - + } else if(seq->type & SEQ_EFFECT) { - + /* top strip! */ if(seqfirst==0) seqfirst= seq; else if(seqfirst->depth > seq->depth) seqfirst= seq; else if(seqfirst->machine < seq->machine) seqfirst= seq; - + } else if(seq->type < SEQ_EFFECT) { /* images */ - + /* bottom strip! a feature that allows you to store junk in locations above */ - + if(seqfirst==0) seqfirst= seq; else if(seqfirst->depth > seq->depth) seqfirst= seq; else if(seqfirst->machine > seq->machine) seqfirst= seq; - + } } } - - MEM_freeN(seqar); - + + MEM_freeN(seqar); + if(!seqfirst) return 0; if(!seqfirst->curelem) return 0; return seqfirst->curelem->ibuf; @@ -1524,14 +1713,14 @@ void free_imbuf_effect_spec(int cfra) StripElem *se; Editing *ed; int a; - + ed= G.scene->ed; if(ed==0) return; - - WHILE_SEQ(&ed->seqbase) { - + + WHILE_SEQ(&ed->seqbase) { + if(seq->strip) { - + if(seq->type & SEQ_EFFECT) { se= seq->strip->stripdata; for(a=0; alen; a++, se++) { @@ -1554,14 +1743,14 @@ void free_imbuf_seq_except(int cfra) StripElem *se; Editing *ed; int a; - + ed= G.scene->ed; if(ed==0) return; - - WHILE_SEQ(&ed->seqbase) { - + + WHILE_SEQ(&ed->seqbase) { + if(seq->strip) { - + if( seq->type==SEQ_META ) { ; } @@ -1576,7 +1765,7 @@ void free_imbuf_seq_except(int cfra) } } } - + if(seq->type==SEQ_MOVIE) { if(seq->startdisp > cfra || seq->enddisp < cfra) { if(seq->anim) { @@ -1596,14 +1785,14 @@ void free_imbuf_seq() StripElem *se; Editing *ed; int a; - + ed= G.scene->ed; if(ed==0) return; - - WHILE_SEQ(&ed->seqbase) { - + + WHILE_SEQ(&ed->seqbase) { + if(seq->strip) { - + if( seq->type==SEQ_META ) { ; } @@ -1618,7 +1807,7 @@ void free_imbuf_seq() } } } - + if(seq->type==SEQ_MOVIE) { if(seq->anim) { IMB_free_anim(seq->anim); @@ -1634,23 +1823,23 @@ void do_render_seq() { /* static ImBuf *lastibuf=0; */ ImBuf *ibuf; - + /* copy image into R.rectot */ - + G.f |= G_PLAYANIM; /* waitcursor patch */ - + ibuf= give_ibuf_seq(CFRA); if(ibuf) { - + memcpy(R.rectot, ibuf->rect, 4*R.rectx*R.recty); - + /* if (ibuf->zbuf) { */ /* if (R.rectz) freeN(R.rectz); */ /* R.rectz = BLI_dupallocN(ibuf->zbuf); */ /* } */ - + free_imbuf_seq_except(CFRA); } G.f &= ~G_PLAYANIM; - + }