== Sequencer / ImBuf ==

Fixed a long standing bug in IMB_dupImBuf: refcounter should be better 0
within the duplicated ImBuf...

Finally removed this strange STRIPELEM_META mumbo jumbo.

On a way to asset management: made METAs behave like true input strips:
* proxying should work
* input filter options should work (including transform and color balance :)
* IPOs now work in replace mode
This commit is contained in:
2008-03-23 17:56:44 +00:00
parent 096fcb3c8f
commit c52695bafe
6 changed files with 88 additions and 80 deletions

View File

@@ -478,6 +478,7 @@ struct ImBuf *IMB_dupImBuf(struct ImBuf *ibuf1)
// set malloc flag
tbuf.mall = ibuf2->mall;
tbuf.c_handle = 0;
tbuf.refcounter = 0;
// for now don't duplicate image info
tbuf.img_info = 0;

View File

@@ -71,7 +71,6 @@ char *give_seqname(struct Sequence *seq);
int evaluate_seq_frame(int cfra);
struct StripElem *give_stripelem(struct Sequence *seq, int cfra);
struct TStripElem *give_tstripelem(struct Sequence *seq, int cfra);
void set_meta_stripdata(struct Sequence *seqm);
struct ImBuf *give_ibuf_seq(int rectx, int recty, int cfra, int chansel);
/* chansel: render this channel. Default=0 (renders end result)*/
struct ImBuf *give_ibuf_seq_direct(int rectx, int recty, int cfra,

View File

@@ -293,7 +293,6 @@ typedef struct SpeedControlVars {
#define STRIPELEM_FAILED 0
#define STRIPELEM_OK 1
#define STRIPELEM_META 2
#define STRIPELEM_PREVIEW_DONE 1

View File

@@ -790,7 +790,8 @@ static void seq_panel_input()
if (last_seq->type == SEQ_MOVIE
|| last_seq->type == SEQ_IMAGE
|| last_seq->type == SEQ_SCENE) {
|| last_seq->type == SEQ_SCENE
|| last_seq->type == SEQ_META) {
uiDefButBitI(block, TOG, SEQ_USE_CROP,
B_SEQ_BUT_RELOAD, "Use Crop",
10,100,240,19, &last_seq->flag,
@@ -1229,7 +1230,8 @@ void sequencer_panels()
panels = SEQ_PANEL_EDITING;
if (type == SEQ_MOVIE || type == SEQ_IMAGE || type == SEQ_SCENE) {
if (type == SEQ_MOVIE || type == SEQ_IMAGE || type == SEQ_SCENE
|| type == SEQ_META) {
panels |= SEQ_PANEL_INPUT | SEQ_PANEL_FILTER | SEQ_PANEL_PROXY;
}

View File

@@ -2339,7 +2339,7 @@ static Sequence * cut_seq(Sequence * seq, int cutframe)
seqn = deep_dupli_seq(seq);
}
if (seqn) { /* should never fail */
if (seqn) {
seqn->flag |= SELECT;
/* Second Strip! */
@@ -2690,8 +2690,6 @@ void make_meta(void)
seqm->strip->len= seqm->len;
seqm->strip->us= 1;
set_meta_stripdata(seqm);
if( test_overlap_seq(seqm) ) shuffle_seq(seqm);
BIF_undo_push("Make Meta Strip, Sequencer");
@@ -2768,9 +2766,6 @@ void exit_meta(void)
ed->seqbasep= ms->oldbasep;
/* recalc entire meta */
set_meta_stripdata(ms->parseq);
/* recalc all: the meta can have effects connected to it */
seq= ed->seqbasep->first;
while(seq) {

View File

@@ -401,8 +401,10 @@ void calc_sequence(Sequence *seq)
if(seqm->enddisp > max) max= seqm->enddisp;
seqm= seqm->next;
}
seq->start= min;
seq->len= max-min;
seq->start= min + seq->anim_startofs;
seq->len = max-min;
seq->len -= seq->anim_startofs;
seq->len -= seq->anim_endofs;
if(seq->strip && seq->len!=seq->strip->len) {
new_tstripdata(seq);
@@ -713,14 +715,9 @@ static void do_effect(int cfra, Sequence *seq, TStripElem * se)
return;
}
if(se->se1->ok == STRIPELEM_META) se1= se->se1->se1;
else se1= se->se1;
if(se->se2->ok == STRIPELEM_META) se2= se->se2->se1;
else se2= se->se2;
if(se->se3->ok == STRIPELEM_META) se3= se->se3->se1;
else se3= se->se3;
se1= se->se1;
se2= se->se2;
se3= se->se3;
if ( (se1==0 || se2==0 || se3==0)
|| (se1->ibuf==0 || se2->ibuf==0 || se3->ibuf==0)) {
@@ -735,8 +732,7 @@ static void do_effect(int cfra, Sequence *seq, TStripElem * se)
return;
}
if(se->se1->ok == STRIPELEM_META) se1= se->se1->se1;
else se1= se->se1;
se1= se->se1;
if (se1 == 0 || se1->ibuf == 0) {
make_black_ibuf(se->ibuf);
@@ -755,8 +751,7 @@ static void do_effect(int cfra, Sequence *seq, TStripElem * se)
return;
}
if(se->se2->ok == STRIPELEM_META) se2= se->se2->se1;
else se2= se->se2;
se2= se->se2;
if (se2 == 0 || se2->ibuf == 0) {
make_black_ibuf(se->ibuf);
@@ -998,43 +993,6 @@ static int get_shown_sequences(
return cnt;
}
static int get_shown_seq_from_metastrip(Sequence * seqm, int cfra,
Sequence ** seq_arr_out)
{
return get_shown_sequences(&seqm->seqbase, cfra, 0, seq_arr_out);
}
void set_meta_stripdata(Sequence *seqm)
{
TStripElem *se;
int a, cfra;
se= seqm->strip->tstripdata;
if (se == 0 && seqm->len > 0) {
int i;
se = seqm->strip->tstripdata = MEM_callocN(
seqm->len*sizeof(TStripElem), "tstripelems");
for (i = 0; i < seqm->len; i++) {
se[i].ok = STRIPELEM_META;
}
}
/* sets all ->se1 pointers in stripdata, to read the ibuf from it */
for(a=0; a<seqm->len; a++, se++) {
int cnt;
Sequence *seq_arr[MAXSEQ+1];
cfra= a+seqm->start;
cnt = get_shown_seq_from_metastrip(seqm, cfra, seq_arr);
if (cnt) {
se->se1= give_tstripelem(seq_arr[cnt-1], cfra);
} else {
se->se1= 0;
}
}
}
/* **********************************************************************
proxy management
@@ -1266,7 +1224,7 @@ static StripColorBalance calc_cb(StripColorBalance * cb_)
if (!(cb.flag & SEQ_COLOR_BALANCE_INVERSE_GAMMA)) {
for (c = 0; c < 3; c++) {
if (cb.gain[c] != 0.0) {
if (cb.gamma[c] != 0.0) {
cb.gamma[c] = 1.0/cb.gamma[c];
} else {
cb.gamma[c] = 1000000; /* should be enough :) */
@@ -1419,6 +1377,38 @@ static void color_balance(Sequence * seq, TStripElem* se, float mul)
*/
static int input_have_to_preprocess(Sequence * seq, TStripElem* se, int cfra)
{
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) ||
(se->ibuf->x != seqrectx || se->ibuf->y != seqrecty)) {
return TRUE;
}
mul = seq->mul;
if(seq->blend_mode == SEQ_BLEND_REPLACE) {
if (seq->ipo && seq->ipo->curve.first) {
do_seq_ipo(seq, cfra);
mul *= seq->facf0;
}
mul *= seq->blend_opacity / 100.0;
}
if (mul != 1.0) {
return TRUE;
}
return FALSE;
}
static void input_preprocess(Sequence * seq, TStripElem* se, int cfra)
{
float mul;
@@ -1620,41 +1610,63 @@ static void do_build_seq_ibuf(Sequence * seq, TStripElem *se, int cfra,
int build_proxy_run)
{
char name[FILE_MAXDIR+FILE_MAXFILE];
int use_limiter = TRUE;
if (seq->type != SEQ_META) {
test_and_auto_discard_ibuf(se);
test_and_auto_discard_ibuf_stills(seq->strip);
}
test_and_auto_discard_ibuf(se);
test_and_auto_discard_ibuf_stills(seq->strip);
if(seq->type == SEQ_META) {
if(seq->seqbase.first) {
TStripElem * meta_se = 0;
use_limiter = FALSE;
if (!build_proxy_run && se->ibuf == 0) {
se->ibuf = seq_proxy_fetch(seq, cfra);
if (se->ibuf) {
use_limiter = TRUE;
}
}
if(!se->ibuf && seq->seqbase.first) {
if(cfra < seq->start) {
do_build_seq_array_recursively(
meta_se = do_build_seq_array_recursively(
&seq->seqbase,
seq->start, 0);
} else if(cfra > seq->start + seq->len - 1) {
do_build_seq_array_recursively(
meta_se = do_build_seq_array_recursively(
&seq->seqbase,
seq->start + seq->len - 1, 0);
} else {
do_build_seq_array_recursively(
meta_se = do_build_seq_array_recursively(
&seq->seqbase,
cfra, 0);
}
}
se->ok = STRIPELEM_META;
if(se->se1 == 0) set_meta_stripdata(seq);
if(se->se1) {
if(se->ibuf) {
IMB_freeImBuf(se->ibuf);
}
se->ibuf = se->se1->ibuf_comp;
if(se->ibuf) {
se->ok = STRIPELEM_OK;
if(!se->ibuf && meta_se) {
se->ibuf = meta_se->ibuf_comp;
if(se->ibuf &&
(!input_have_to_preprocess(seq, se, cfra) ||
build_proxy_run)) {
IMB_refImBuf(se->ibuf);
if (build_proxy_run) {
IMB_cache_limiter_unref(se->ibuf);
}
} else if (se->ibuf) {
struct ImBuf * i = IMB_dupImBuf(se->ibuf);
IMB_cache_limiter_unref(se->ibuf);
se->ibuf = i;
use_limiter = TRUE;
}
}
if (use_limiter) {
input_preprocess(seq, se, cfra);
}
} else if(seq->type & SEQ_EFFECT) {
/* should the effect be recalculated? */
@@ -1818,7 +1830,7 @@ static void do_build_seq_ibuf(Sequence * seq, TStripElem *se, int cfra,
}
}
if (!build_proxy_run) {
if (se->ibuf && seq->type != SEQ_META) {
if (se->ibuf && use_limiter) {
IMB_cache_limiter_insert(se->ibuf);
IMB_cache_limiter_ref(se->ibuf);
IMB_cache_limiter_touch(se->ibuf);