[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32780] trunk/blender/source/blender/ blenkernel: Sequence editor code cleanup
Janne Karhu
jhkarh at gmail.com
Sat Oct 30 23:55:17 CEST 2010
Revision: 32780
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32780
Author: jhk
Date: 2010-10-30 23:55:17 +0200 (Sat, 30 Oct 2010)
Log Message:
-----------
Sequence editor code cleanup
* The logic in some parts of the sequencer code was rather cryptic, so I cleaned it up a bit.
* There should be no functional changes what so ever from these changes.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/BKE_sequencer.h
trunk/blender/source/blender/blenkernel/intern/sequencer.c
Modified: trunk/blender/source/blender/blenkernel/BKE_sequencer.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_sequencer.h 2010-10-30 19:52:40 UTC (rev 32779)
+++ trunk/blender/source/blender/blenkernel/BKE_sequencer.h 2010-10-30 21:55:17 UTC (rev 32780)
@@ -46,6 +46,11 @@
#define BUILD_SEQAR_COUNT_CURRENT 1
#define BUILD_SEQAR_COUNT_CHILDREN 2
+#define EARLY_NO_INPUT -1
+#define EARLY_DO_EFFECT 0
+#define EARLY_USE_INPUT_1 1
+#define EARLY_USE_INPUT_2 2
+
/* sequence iterator */
typedef struct SeqIterator {
Modified: trunk/blender/source/blender/blenkernel/intern/sequencer.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/sequencer.c 2010-10-30 19:52:40 UTC (rev 32779)
+++ trunk/blender/source/blender/blenkernel/intern/sequencer.c 2010-10-30 21:55:17 UTC (rev 32780)
@@ -372,7 +372,7 @@
do_seq_count(seqbase, totseq);
if(*totseq==0) {
- *seqar= 0;
+ *seqar= NULL;
return;
}
*seqar= MEM_mallocN(sizeof(void *)* *totseq, "seqar");
@@ -411,8 +411,7 @@
seq->depth= depth;
if(seq->seqbase.first && (test & BUILD_SEQAR_COUNT_CHILDREN)) {
- do_build_seqar_cb(&seq->seqbase, seqar, depth+1,
- test_func);
+ do_build_seqar_cb(&seq->seqbase, seqar, depth+1, test_func);
}
if (test & BUILD_SEQAR_COUNT_CURRENT) {
**seqar= seq;
@@ -431,7 +430,7 @@
do_seq_count_cb(seqbase, totseq, test_func);
if(*totseq==0) {
- *seqar= 0;
+ *seqar= NULL;
return;
}
*seqar= MEM_mallocN(sizeof(void *)* *totseq, "seqar");
@@ -471,7 +470,7 @@
if(seq->type == SEQ_META) {
seq_update_sound_bounds_recursive(scene, seq);
}
- else if((seq->type == SEQ_SOUND) || (seq->type == SEQ_SCENE)) {
+ else if(ELEM(seq->type, SEQ_SOUND, SEQ_SCENE)) {
if(seq->scene_sound) {
int startofs = seq->startofs;
int endofs = seq->endofs;
@@ -502,8 +501,8 @@
if(seq->type & SEQ_EFFECT) {
/* pointers */
- if(seq->seq2==0) seq->seq2= seq->seq1;
- if(seq->seq3==0) seq->seq3= seq->seq1;
+ if(seq->seq2==NULL) seq->seq2= seq->seq1;
+ if(seq->seq3==NULL) seq->seq3= seq->seq1;
/* effecten go from seq1 -> seq2: test */
@@ -558,9 +557,7 @@
int prev_startdisp, prev_enddisp;
/* note: dont rename the strip, will break animation curves */
- if (!(seq->type == SEQ_MOVIE || seq->type == SEQ_IMAGE ||
- seq->type == SEQ_SOUND ||
- seq->type == SEQ_SCENE || seq->type == SEQ_META)) {
+ if (ELEM5(seq->type, SEQ_MOVIE, SEQ_IMAGE, SEQ_SOUND, SEQ_SCENE, SEQ_META)==0) {
return;
}
@@ -574,13 +571,14 @@
new_tstripdata(seq);
- if (seq->type != SEQ_SCENE && seq->type != SEQ_META &&
- seq->type != SEQ_IMAGE) {
+ if (ELEM3(seq->type, SEQ_SCENE, SEQ_META, SEQ_IMAGE)==0) {
BLI_join_dirfile(str, seq->strip->dir, seq->strip->stripdata->name);
BLI_path_abs(str, G.main->name);
}
- if (seq->type == SEQ_IMAGE) {
+ switch(seq->type) {
+ case SEQ_IMAGE:
+ {
/* Hack? */
size_t olen = MEM_allocN_len(seq->strip->stripdata)/sizeof(struct StripElem);
@@ -591,7 +589,9 @@
seq->len = 0;
}
seq->strip->len = seq->len;
- } else if (seq->type == SEQ_MOVIE) {
+ break;
+ }
+ case SEQ_MOVIE:
if(seq->anim) IMB_free_anim(seq->anim);
seq->anim = openanim(str, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0));
@@ -609,7 +609,7 @@
seq->len = 0;
}
seq->strip->len = seq->len;
- } else if (seq->type == SEQ_SOUND) {
+ case SEQ_SOUND:
seq->len = ceil(AUD_getInfo(seq->sound->playback_handle).length * FPS);
seq->len -= seq->anim_startofs;
seq->len -= seq->anim_endofs;
@@ -617,7 +617,9 @@
seq->len = 0;
}
seq->strip->len = seq->len;
- } else if (seq->type == SEQ_SCENE) {
+ break;
+ case SEQ_SCENE:
+ {
/* 'seq->scenenr' should be replaced with something more reliable */
Scene * sce = G.main->scene.first;
int nr = 1;
@@ -643,7 +645,9 @@
seq->len = 0;
}
seq->strip->len = seq->len;
+ break;
}
+ }
free_proxy_seq(seq);
@@ -804,7 +808,7 @@
case SEQ_MULTICAM: return "Multicam";
case SEQ_SPEED: return "Speed";
default:
- return 0;
+ return NULL;
}
}
@@ -896,19 +900,24 @@
static float give_stripelem_index(Sequence *seq, float cfra)
{
float nr;
+ int sta = seq->start;
+ int end = seq->start+seq->len-1;
if(seq->len == 0) return -1;
+
if(seq->flag&SEQ_REVERSE_FRAMES) {
/*reverse frame in this sequence */
- if(cfra <= seq->start) nr= seq->len-1;
- else if(cfra >= seq->start+seq->len-1) nr= 0;
- else nr= (seq->start + seq->len - 1) - cfra;
+ if(cfra <= sta) nr= seq->len-1;
+ else if(cfra >= end) nr= 0;
+ else nr= end - cfra;
} else {
- if(cfra <= seq->start) nr= 0;
- else if(cfra >= seq->start+seq->len-1) nr= seq->len-1;
- else nr= cfra-seq->start;
+ if(cfra <= sta) nr= 0;
+ else if(cfra >= end) nr= seq->len-1;
+ else nr= cfra - sta;
}
+
if (seq->strobe < 1.0) seq->strobe = 1.0;
+
if (seq->strobe > 1.0) {
nr -= fmod((double)nr, (double)seq->strobe);
}
@@ -920,14 +929,10 @@
{
StripElem *se= seq->strip->stripdata;
- if(seq->type == SEQ_MOVIE) {
- /* use the first */
- }
- else {
+ if(seq->type != SEQ_MOVIE) { /* movie use the first */
int nr = (int) give_stripelem_index(seq, cfra);
- if (nr == -1) return 0;
- if (se == 0) return 0;
+ if (nr == -1 || se == 0) return 0;
se += nr + seq->anim_startofs;
}
@@ -964,9 +969,7 @@
static int video_seq_is_rendered(Sequence * seq)
{
- return (seq
- && !(seq->flag & SEQ_MUTE)
- && seq->type != SEQ_SOUND);
+ return (seq && !(seq->flag & SEQ_MUTE) && seq->type != SEQ_SOUND);
}
static int get_shown_sequences( ListBase * seqbasep, int cfra, int chanshown, Sequence ** seq_arr_out)
@@ -1028,13 +1031,11 @@
return FALSE;
}
- if ((seq->flag & SEQ_USE_PROXY_CUSTOM_DIR)
- || (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE)) {
+ if (seq->flag & (SEQ_USE_PROXY_CUSTOM_DIR|SEQ_USE_PROXY_CUSTOM_FILE)) {
strcpy(dir, seq->strip->proxy->dir);
} else {
- if (seq->type == SEQ_IMAGE || seq->type == SEQ_MOVIE) {
- snprintf(dir, FILE_MAXDIR, "%s/BL_proxy",
- seq->strip->dir);
+ if (ELEM(seq->type, SEQ_IMAGE, SEQ_MOVIE)) {
+ snprintf(dir, FILE_MAXDIR, "%s/BL_proxy", seq->strip->dir);
} else {
return FALSE;
}
@@ -1049,30 +1050,25 @@
/* generate a separate proxy directory for each preview size */
- if (seq->type == SEQ_IMAGE) {
- StripElem * se = give_stripelem(seq, cfra);
- snprintf(name, PROXY_MAXFILE, "%s/images/%d/%s_proxy",
- dir, render_size, se->name);
+ switch(seq->type) {
+ case SEQ_IMAGE:
+ snprintf(name, PROXY_MAXFILE, "%s/images/%d/%s_proxy", dir,
+ render_size, give_stripelem(seq, cfra)->name);
frameno = 1;
- } else if (seq->type == SEQ_MOVIE) {
- frameno = (int) give_stripelem_index(seq, cfra)
- + seq->anim_startofs;
-
+ break;
+ case SEQ_MOVIE:
+ frameno = (int) give_stripelem_index(seq, cfra) + seq->anim_startofs;
snprintf(name, PROXY_MAXFILE, "%s/%s/%d/####", dir,
- seq->strip->stripdata->name,
- render_size);
- } else {
- frameno = (int) give_stripelem_index(seq, cfra)
- + seq->anim_startofs;
-
- snprintf(name, PROXY_MAXFILE, "%s/proxy_misc/%d/####", dir,
- render_size);
+ seq->strip->stripdata->name, render_size);
+ break;
+ default:
+ frameno = (int) give_stripelem_index(seq, cfra) + seq->anim_startofs;
+ snprintf(name, PROXY_MAXFILE, "%s/proxy_misc/%d/####", dir, render_size);
}
BLI_path_abs(name, G.main->name);
BLI_path_frame(name, frameno, 0);
-
strcat(name, ".jpg");
return TRUE;
@@ -1092,24 +1088,22 @@
}
if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) {
- int frameno = (int) give_stripelem_index(seq, cfra)
- + seq->anim_startofs;
- if (!seq->strip->proxy->anim) {
- if (!seq_proxy_get_fname(
- scene, seq, cfra, name, render_size)) {
+ int frameno = (int) give_stripelem_index(seq, cfra) + seq->anim_startofs;
+ if (seq->strip->proxy->anim == NULL) {
+ if (seq_proxy_get_fname(scene, seq, cfra, name, render_size)==0) {
return 0;
}
seq->strip->proxy->anim = openanim(name, IB_rect);
}
- if (!seq->strip->proxy->anim) {
+ if (seq->strip->proxy->anim==NULL) {
return 0;
}
return IMB_anim_absolute(seq->strip->proxy->anim, frameno);
}
- if (!seq_proxy_get_fname(scene, seq, cfra, name, render_size)) {
+ if (seq_proxy_get_fname(scene, seq, cfra, name, render_size)==0) {
return 0;
}
@@ -1378,8 +1372,7 @@
cb = calc_cb(seq->strip->color_balance);
for (c = 0; c < 3; c++) {
- make_cb_table_float(cb.lift[c], cb.gain[c], cb.gamma[c],
- cb_tab[c], mul);
+ make_cb_table_float(cb.lift[c], cb.gain[c], cb.gamma[c], cb_tab[c], mul);
}
for (i = 0; i < 256; i++) {
@@ -1446,13 +1439,8 @@
{
float mul;
- if ((seq->flag & SEQ_FILTERY) ||
- (seq->flag & SEQ_USE_CROP) ||
- (seq->flag & SEQ_USE_TRANSFORM) ||
- (seq->flag & SEQ_FLIPX) ||
- (seq->flag & SEQ_FLIPY) ||
- (seq->flag & SEQ_USE_COLOR_BALANCE) ||
- (seq->flag & SEQ_MAKE_PREMUL)) {
+ if (seq->flag & (SEQ_FILTERY|SEQ_USE_CROP|SEQ_USE_TRANSFORM|SEQ_FLIPX|
+ SEQ_FLIPY|SEQ_USE_COLOR_BALANCE|SEQ_MAKE_PREMUL)) {
return TRUE;
}
@@ -1474,8 +1462,7 @@
}
static ImBuf * input_preprocess(
- Scene *scene, Sequence *seq, float UNUSED(cfra), int seqrectx, int seqrecty,
- ImBuf * ibuf)
+ Scene *scene, Sequence *seq, float UNUSED(cfra), int seqrectx, int seqrecty, ImBuf * ibuf)
{
float mul;
@@ -1486,7 +1473,7 @@
IMB_filtery(ibuf);
}
- if(seq->flag & SEQ_USE_CROP || seq->flag & SEQ_USE_TRANSFORM) {
+ if(seq->flag & (SEQ_USE_CROP|SEQ_USE_TRANSFORM)) {
StripCrop c;
StripTransform t;
int sx,sy,dx,dy;
@@ -1511,23 +1498,13 @@
dy = scene->r.ysch;
}
- if (c.top + c.bottom >= ibuf->y ||
- c.left + c.right >= ibuf->x ||
- t.xofs >= dx || t.yofs >= dy) {
+ if (c.top + c.bottom >= ibuf->y || c.left + c.right >= ibuf->x ||
+ t.xofs >= dx || t.yofs >= dy) {
make_black_ibuf(ibuf);
} else {
- ImBuf * i;
+ ImBuf * i = IMB_allocImBuf(dx, dy,32, ibuf->rect_float ? IB_rectfloat : IB_rect);
- if (ibuf->rect_float) {
- i = IMB_allocImBuf(dx, dy,32, IB_rectfloat);
- } else {
- i = IMB_allocImBuf(dx, dy,32, IB_rect);
- }
-
- IMB_rectcpy(i, ibuf,
- t.xofs, t.yofs,
- c.left, c.bottom,
- sx, sy);
+ IMB_rectcpy(i, ibuf, t.xofs, t.yofs, c.left, c.bottom, sx, sy);
IMB_freeImBuf(ibuf);
@@ -1602,11 +1579,9 @@
if(ibuf->x != seqrectx || ibuf->y != seqrecty ) {
if(scene->r.mode & R_OSA) {
- IMB_scaleImBuf(ibuf,
- (short)seqrectx, (short)seqrecty);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list