diff --git a/source/blender/src/seqeffects.c b/source/blender/src/seqeffects.c index 0099e5b9860..8c98fd47e09 100644 --- a/source/blender/src/seqeffects.c +++ b/source/blender/src/seqeffects.c @@ -786,9 +786,9 @@ static void do_cross_effect(Sequence * seq,int cfra, ********************************************************************** */ /* copied code from initrender.c */ -static unsigned short *gamtab = 0; -static unsigned short *igamtab1 = 0; -static int gamma_tabs_refcount = 0; +static unsigned short gamtab[65536]; +static unsigned short igamtab1[256]; +static int gamma_tabs_init = FALSE; #define RE_GAMMA_TABLE_SIZE 400 @@ -882,9 +882,6 @@ static void gamtabs(float gamma) float val, igamma= 1.0f/gamma; int a; - gamtab= MEM_mallocN(65536*sizeof(short), "initGaus2"); - igamtab1= MEM_mallocN(256*sizeof(short), "initGaus2"); - /* gamtab: in short, out short */ for(a=0; a<65536; a++) { val= a; @@ -907,36 +904,25 @@ static void gamtabs(float gamma) } -static void alloc_or_ref_gammatabs() +static void build_gammatabs() { - if (gamma_tabs_refcount == 0) { + if (gamma_tabs_init == FALSE) { gamtabs(2.0f); makeGammaTables(2.0f); + gamma_tabs_init = TRUE; } - gamma_tabs_refcount++; } static void init_gammacross(Sequence * seq) { - alloc_or_ref_gammatabs(); } static void load_gammacross(Sequence * seq) { - alloc_or_ref_gammatabs(); } static void free_gammacross(Sequence * seq) { - if (--gamma_tabs_refcount == 0) { - MEM_freeN(gamtab); - MEM_freeN(igamtab1); - gamtab = 0; - igamtab1 = 0; - } - if (gamma_tabs_refcount < 0) { - fprintf(stderr, "seqeffects: free_gammacross double free!\n"); - } } static void do_gammacross_effect_byte(float facf0, float facf1, @@ -1043,6 +1029,8 @@ static void do_gammacross_effect(Sequence * seq,int cfra, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3, struct ImBuf *out) { + build_gammatabs(); + if (out->rect_float) { do_gammacross_effect_float( facf0, facf1, x, y, diff --git a/source/blender/src/sequence.c b/source/blender/src/sequence.c index f3a42f3eb72..953e6b197c6 100644 --- a/source/blender/src/sequence.c +++ b/source/blender/src/sequence.c @@ -1498,7 +1498,7 @@ static TStripElem* do_build_seq_array_recursively( break; } - sh = get_sequence_blend(seq_arr[i]); + sh = get_sequence_blend(seq); seq->facf0 = seq->facf1 = 1.0; @@ -1549,7 +1549,7 @@ static TStripElem* do_build_seq_array_recursively( } break; } - + if (se->ibuf_comp) { break; } @@ -1568,6 +1568,7 @@ static TStripElem* do_build_seq_array_recursively( case 0: { int x= se2->ibuf->x; int y= se2->ibuf->y; + int swap_input = FALSE; if (se1->ibuf_comp->rect_float || se2->ibuf->rect_float) { @@ -1592,16 +1593,32 @@ static TStripElem* do_build_seq_array_recursively( if (!se1->ibuf_comp->rect && !se2->ibuf_comp->rect_float) { - IMB_rect_from_float(se1->ibuf); + IMB_rect_from_float(se1->ibuf_comp); } if (!se2->ibuf->rect && !se2->ibuf_comp->rect_float) { IMB_rect_from_float(se2->ibuf); } - sh.execute(seq, cfra, seq->facf0, seq->facf1, x, y, - se1->ibuf_comp, se2->ibuf, 0, - se2->ibuf_comp); + /* bad hack, to fix crazy input ordering of + those two effects */ + + if (seq->blend_mode == SEQ_ALPHAOVER || + seq->blend_mode == SEQ_ALPHAUNDER) { + swap_input = TRUE; + } + + if (swap_input) { + sh.execute(seq, cfra, + seq->facf0, seq->facf1, x, y, + se2->ibuf, se1->ibuf_comp, 0, + se2->ibuf_comp); + } else { + sh.execute(seq, cfra, + seq->facf0, seq->facf1, x, y, + se1->ibuf_comp, se2->ibuf, 0, + se2->ibuf_comp); + } IMB_cache_limiter_insert(se2->ibuf_comp); IMB_cache_limiter_ref(se2->ibuf_comp);