== Sequencer ==
authorPeter Schlaile <peter@schlaile.de>
Sun, 25 Jul 2010 17:19:55 +0000 (17:19 +0000)
committerPeter Schlaile <peter@schlaile.de>
Sun, 25 Jul 2010 17:19:55 +0000 (17:19 +0000)
Some cleanup on effects:

- converted interface to float cfra
- made effects return their own ImBufs, which has the following
  advantages:
  * code in sequencer.c is a lot more readable.
  * multicam saves one memcpy of an image
  * prepares things for GPU-rendering

source/blender/blenkernel/BKE_sequencer.h
source/blender/blenkernel/intern/seqeffects.c
source/blender/blenkernel/intern/sequencer.c

index 81ae83c..b544b34 100644 (file)
@@ -107,15 +107,14 @@ struct SeqEffectHandle {
        0: no early out, 
        1: out = ibuf1, 
        2: out = ibuf2 */
-       int (*early_out)(struct Sequence *seq,
-                                        float facf0, float facf1); 
+       int (*early_out)(struct Sequence *seq, float facf0, float facf1); 
        
        /* stores the y-range of the effect IPO */
        void (*store_icu_yrange)(struct Sequence * seq,
                                  short adrcode, float *ymin, float *ymax);
        
        /* stores the default facf0 and facf1 if no IPO is present */
-       void (*get_default_fac)(struct Sequence *seq, int cfra,
+       void (*get_default_fac)(struct Sequence *seq, float cfra,
                                 float * facf0, float * facf1);
        
        /* execute the effect
@@ -123,11 +122,12 @@ struct SeqEffectHandle {
            float-rects or byte-rects 
            (mixed cases are handled one layer up...) */
        
-       void (*execute)(struct Scene *scene, struct Sequence *seq, int cfra,
-                        float facf0, float facf1,
-                        int x, int y, int preview_render_size,
-                        struct ImBuf *ibuf1, struct ImBuf *ibuf2,
-                        struct ImBuf *ibuf3, struct ImBuf *out);
+       struct ImBuf* (*execute)(
+               struct Scene *scene, struct Sequence *seq, float cfra,
+               float facf0, float facf1,
+               int x, int y, int preview_render_size,
+               struct ImBuf *ibuf1, struct ImBuf *ibuf2,
+               struct ImBuf *ibuf3);
 };
 
 /* ********************* prototypes *************** */
@@ -164,6 +164,10 @@ struct StripElem *give_stripelem(struct Sequence *seq, int cfra);
 // intern?
 void update_changed_seq_and_deps(struct Scene *scene, struct Sequence *changed_seq, int len_change, int ibuf_change);
 
+int input_have_to_preprocess(
+       struct Scene *scene, struct Sequence * seq, 
+       float cfra, int seqrectx, int seqrecty);
+
 /* seqcache.c */
 
 typedef enum {
index 151fc1c..c117f51 100644 (file)
@@ -67,6 +67,48 @@ enum {
        GlowA=3
 };
 
+static struct ImBuf * prepare_effect_imbufs(
+       int x, int y,
+       struct ImBuf *ibuf1, struct ImBuf *ibuf2,
+       struct ImBuf *ibuf3)
+{
+       struct ImBuf * out;
+
+       if (!ibuf1 && !ibuf2 && !ibuf3) {
+               /* hmmm, global float option ? */
+               out = IMB_allocImBuf((short)x, (short)y, 32, IB_rect, 0);
+       } else if ((ibuf1 && ibuf1->rect_float) || 
+                  (ibuf2 && ibuf2->rect_float) || 
+                  (ibuf3 && ibuf3->rect_float)) {
+               /* if any inputs are rectfloat, output is float too */
+
+               out = IMB_allocImBuf((short)x, (short)y, 32, IB_rectfloat, 0);
+       } else {
+               out = IMB_allocImBuf((short)x, (short)y, 32, IB_rect, 0);
+       }
+       
+       if (ibuf1 && !ibuf1->rect_float && out->rect_float) {
+               IMB_float_from_rect_simple(ibuf1);
+       }
+       if (ibuf2 && !ibuf2->rect_float && out->rect_float) {
+               IMB_float_from_rect_simple(ibuf2);
+       }
+       if (ibuf3 && !ibuf3->rect_float && out->rect_float) {
+               IMB_float_from_rect_simple(ibuf3);
+       }
+       
+       if (ibuf1 && !ibuf1->rect && !out->rect_float) {
+               IMB_rect_from_float(ibuf1);
+       }
+       if (ibuf2 && !ibuf2->rect && !out->rect_float) {
+               IMB_rect_from_float(ibuf2);
+       }
+       if (ibuf3 && !ibuf3->rect && !out->rect_float) {
+               IMB_rect_from_float(ibuf3);
+       }
+                       
+       return out;
+}
 
 /* **********************************************************************
    PLUGINS
@@ -229,11 +271,12 @@ static ImBuf * IMB_cast_away_list(ImBuf * i)
        return (ImBuf*) (((void**) i) + 2);
 }
 
-static void do_plugin_effect(Scene *scene, Sequence *seq, int cfra,
-                            float facf0, float facf1, int x, int y, 
-                            int preview_render_size,
-                            struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
-                            struct ImBuf *ibuf3, struct ImBuf *out)
+static struct ImBuf * do_plugin_effect(
+       Scene *scene, Sequence *seq, float cfra,
+       float facf0, float facf1, int x, int y, 
+       int preview_render_size,
+       struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
+       struct ImBuf *ibuf3)
 {
        char *cp;
        int float_rendering;
@@ -241,6 +284,8 @@ static void do_plugin_effect(Scene *scene, Sequence *seq, int cfra,
                                  old plugins) do very bad stuff
                                  with imbuf-internals */
 
+       struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3);
+
        if(seq->plugin && seq->plugin->doit) {
                
                if(seq->plugin->cfra) 
@@ -321,6 +366,7 @@ static void do_plugin_effect(Scene *scene, Sequence *seq, int cfra,
                        if (ibuf3) IMB_freeImBuf(ibuf3);
                }
        }
+       return out;
 }
 
 static int do_plugin_early_out(struct Sequence *seq,
@@ -476,12 +522,15 @@ static void do_alphaover_effect_float(float facf0, float facf1, int x, int y,
        }
 }
 
-static void do_alphaover_effect(Scene *scene, Sequence *seq, int cfra,
-                               float facf0, float facf1, int x, int y, 
-                               int preview_render_size,
-                               struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
-                               struct ImBuf *ibuf3, struct ImBuf *out)
+static struct ImBuf * do_alphaover_effect(
+       Scene *scene, Sequence *seq, float cfra,
+       float facf0, float facf1, int x, int y, 
+       int preview_render_size,
+       struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
+       struct ImBuf *ibuf3)
 {
+       struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3);
+
        if (out->rect_float) {
                do_alphaover_effect_float(
                        facf0, facf1, x, y,
@@ -493,6 +542,7 @@ static void do_alphaover_effect(Scene *scene, Sequence *seq, int cfra,
                        (char*) ibuf1->rect, (char*) ibuf2->rect,
                        (char*) out->rect);
        }
+       return out;
 }
 
 
@@ -644,12 +694,15 @@ static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y,
        }
 }
 
-static void do_alphaunder_effect(Scene *scene, Sequence *seq, int cfra,
-                               float facf0, float facf1, int x, int y, 
-                                int preview_render_size,
-                               struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
-                               struct ImBuf *ibuf3, struct ImBuf *out)
+static struct ImBuf* do_alphaunder_effect(
+       Scene *scene, Sequence *seq, float cfra,
+       float facf0, float facf1, int x, int y, 
+       int preview_render_size,
+       struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
+       struct ImBuf *ibuf3)
 {
+       struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3);
+
        if (out->rect_float) {
                do_alphaunder_effect_float(
                        facf0, facf1, x, y,
@@ -661,6 +714,7 @@ static void do_alphaunder_effect(Scene *scene, Sequence *seq, int cfra,
                        (char*) ibuf1->rect, (char*) ibuf2->rect,
                        (char*) out->rect);
        }
+       return out;
 }
 
 
@@ -765,12 +819,15 @@ void do_cross_effect_float(float facf0, float facf1, int x, int y,
 
 /* carefull: also used by speed effect! */
 
-static void do_cross_effect(Scene *scene, Sequence *seq, int cfra,
-                           float facf0, float facf1, int x, int y, 
-                           int preview_render_size,
-                           struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
-                           struct ImBuf *ibuf3, struct ImBuf *out)
+static struct ImBuf* do_cross_effect(
+       Scene *scene, Sequence *seq, float cfra,
+       float facf0, float facf1, int x, int y, 
+       int preview_render_size,
+       struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
+       struct ImBuf *ibuf3)
 {
+       struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3);
+
        if (out->rect_float) {
                do_cross_effect_float(
                        facf0, facf1, x, y,
@@ -782,6 +839,7 @@ static void do_cross_effect(Scene *scene, Sequence *seq, int cfra,
                        (char*) ibuf1->rect, (char*) ibuf2->rect,
                        (char*) out->rect);
        }
+       return out;
 }
 
 
@@ -1028,12 +1086,15 @@ static void do_gammacross_effect_float(float facf0, float facf1,
        }
 }
 
-static void do_gammacross_effect(Scene *scene, Sequence *seq, int cfra,
-                                float facf0, float facf1, int x, int y, 
-                                int preview_render_size,
-                                struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
-                                struct ImBuf *ibuf3, struct ImBuf *out)
+static struct ImBuf * do_gammacross_effect(
+       Scene *scene, Sequence *seq, float cfra,
+       float facf0, float facf1, int x, int y, 
+       int preview_render_size,
+       struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
+       struct ImBuf *ibuf3)
 {
+       struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3);
+
        build_gammatabs();
 
        if (out->rect_float) {
@@ -1047,6 +1108,7 @@ static void do_gammacross_effect(Scene *scene, Sequence *seq, int cfra,
                        (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect,
                        (unsigned char*) out->rect);
        }
+       return out;
 }
 
 
@@ -1143,12 +1205,14 @@ static void do_add_effect_float(float facf0, float facf1, int x, int y,
        }
 }
 
-static void do_add_effect(Scene *scene, Sequence *seq, int cfra,
-                         float facf0, float facf1, int x, int y, 
-                         int preview_render_size,
-                         struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
-                         struct ImBuf *ibuf3, struct ImBuf *out)
+static struct ImBuf * do_add_effect(Scene *scene, Sequence *seq, float cfra,
+                                   float facf0, float facf1, int x, int y, 
+                                   int preview_render_size,
+                                   struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
+                                   struct ImBuf *ibuf3)
 {
+       struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3);
+
        if (out->rect_float) {
                do_add_effect_float(
                        facf0, facf1, x, y,
@@ -1160,6 +1224,7 @@ static void do_add_effect(Scene *scene, Sequence *seq, int cfra,
                        (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect,
                        (unsigned char*) out->rect);
        }
+       return out;
 }
 
 
@@ -1256,12 +1321,15 @@ static void do_sub_effect_float(float facf0, float facf1, int x, int y,
        }
 }
 
-static void do_sub_effect(Scene *scene, Sequence *seq, int cfra,
-                         float facf0, float facf1, int x, int y,
-                         int preview_render_size,
-                         struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
-                         struct ImBuf *ibuf3, struct ImBuf *out)
+static struct ImBuf * do_sub_effect(
+       Scene *scene, Sequence *seq, float cfra,
+       float facf0, float facf1, int x, int y,
+       int preview_render_size,
+       struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
+       struct ImBuf *ibuf3)
 {
+       struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3);
+
        if (out->rect_float) {
                do_sub_effect_float(
                        facf0, facf1, x, y,
@@ -1273,6 +1341,7 @@ static void do_sub_effect(Scene *scene, Sequence *seq, int cfra,
                        (char*) ibuf1->rect, (char*) ibuf2->rect,
                        (char*) out->rect);
        }
+       return out;
 }
 
 /* **********************************************************************
@@ -1284,8 +1353,8 @@ static void do_sub_effect(Scene *scene, Sequence *seq, int cfra,
 #define YOFF   8
 
 static void do_drop_effect_byte(float facf0, float facf1, int x, int y, 
-                               unsigned char *rect2i, unsigned char *rect1i, 
-                               unsigned char *outi)
+                               char *rect2i, char *rect1i, 
+                               char *outi)
 {
        int height, width, temp, fac, fac1, fac2;
        char *rt1, *rt2, *out;
@@ -1364,27 +1433,6 @@ static void do_drop_effect_float(float facf0, float facf1, int x, int y,
        memcpy(out, rt1, 4 * sizeof(float)*YOFF*width);
 }
 
-
-static void do_drop_effect(Scene *scene, Sequence *seq, int cfra,
-                          float facf0, float facf1, int x, int y, 
-                          int preview_render_size,
-                          struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
-                          struct ImBuf * ibuf3,
-                          struct ImBuf *out)
-{
-       if (out->rect_float) {
-               do_drop_effect_float(
-                       facf0, facf1, x, y,
-                       ibuf1->rect_float, ibuf2->rect_float,
-                       out->rect_float);
-       } else {
-               do_drop_effect_byte(
-                       facf0, facf1, x, y,
-                       (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect,
-                       (unsigned char*) out->rect);
-       }
-}
-
 /* **********************************************************************
    MUL
    ********************************************************************** */
@@ -1487,12 +1535,15 @@ static void do_mul_effect_float(float facf0, float facf1, int x, int y,
        }
 }
 
-static void do_mul_effect(Scene *scene, Sequence *seq, int cfra,
-                         float facf0, float facf1, int x, int y, 
-                         int preview_render_size,
-                         struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
-                         struct ImBuf *ibuf3, struct ImBuf *out)
+static struct ImBuf * do_mul_effect(
+       Scene *scene, Sequence *seq, float cfra,
+       float facf0, float facf1, int x, int y, 
+       int preview_render_size,
+       struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
+       struct ImBuf *ibuf3)
 {
+       struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3);
+
        if (out->rect_float) {
                do_mul_effect_float(
                        facf0, facf1, x, y,
@@ -1504,6 +1555,8 @@ static void do_mul_effect(Scene *scene, Sequence *seq, int cfra,
                        (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect,
                        (unsigned char*) out->rect);
        }
+
+       return out;
 }
 
 /* **********************************************************************
@@ -1938,12 +1991,15 @@ static void do_wipe_effect_float(Sequence *seq, float facf0, float facf1,
        }
 }
 
-static void do_wipe_effect(Scene *scene, Sequence *seq, int cfra,
-                          float facf0, float facf1, int x, int y, 
-                          int preview_render_size,
-                          struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
-                          struct ImBuf *ibuf3, struct ImBuf *out)
+static struct ImBuf * do_wipe_effect(
+       Scene *scene, Sequence *seq, float cfra,
+       float facf0, float facf1, int x, int y, 
+       int preview_render_size,
+       struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
+       struct ImBuf *ibuf3)
 {
+       struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3);
+
        if (out->rect_float) {
                do_wipe_effect_float(seq,
                                         facf0, facf1, x, y,
@@ -1955,6 +2011,8 @@ static void do_wipe_effect(Scene *scene, Sequence *seq, int cfra,
                                        (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect,
                                        (unsigned char*) out->rect);
        }
+
+       return out;
 }
 /* **********************************************************************
    TRANSFORM
@@ -2084,13 +2142,18 @@ static void do_transform(Scene *scene, Sequence *seq, float facf0, int x, int y,
 }
 
 
-static void do_transform_effect(Scene *scene, Sequence *seq,int cfra,
-                               float facf0, float facf1, int x, int y, 
-                               int preview_render_size,
-                               struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
-                               struct ImBuf *ibuf3, struct ImBuf *out)
+static struct ImBuf * do_transform_effect(
+       Scene *scene, Sequence *seq,float cfra,
+       float facf0, float facf1, int x, int y, 
+       int preview_render_size,
+       struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
+       struct ImBuf *ibuf3)
 {
+       struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3);
+
        do_transform(scene, seq, facf0, x, y, ibuf1, out);
+
+       return out;
 }
 
 
@@ -2597,12 +2660,15 @@ static void do_glow_effect_float(Sequence *seq, float facf0, float facf1,
                RVAddBitmaps_float (inbuf , outbuf, outbuf, x, y);
 }
 
-static void do_glow_effect(Scene *scene, Sequence *seq, int cfra,
-                          float facf0, float facf1, int x, int y, 
-                          int preview_render_size,
-                          struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
-                          struct ImBuf *ibuf3, struct ImBuf *out)
+static struct ImBuf * do_glow_effect(
+       Scene *scene, Sequence *seq, float cfra,
+       float facf0, float facf1, int x, int y, 
+       int preview_render_size,
+       struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
+       struct ImBuf *ibuf3)
 {
+       struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3);
+
        if (out->rect_float) {
                do_glow_effect_float(seq,
                                         facf0, facf1, x, y,
@@ -2614,6 +2680,8 @@ static void do_glow_effect(Scene *scene, Sequence *seq, int cfra,
                                        (char*) ibuf1->rect, (char*) ibuf2->rect,
                                        (char*) out->rect);
        }
+
+       return out;
 }
 
 /* **********************************************************************
@@ -2653,12 +2721,15 @@ static int early_out_color(struct Sequence *seq,
        return -1;
 }
 
-static void do_solid_color(Scene *scene, Sequence *seq, int cfra,
-                          float facf0, float facf1, int x, int y, 
-                          int preview_render_size,
-                          struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
-                          struct ImBuf *ibuf3, struct ImBuf *out)
+static struct ImBuf * do_solid_color(
+       Scene *scene, Sequence *seq, float cfra,
+       float facf0, float facf1, int x, int y, 
+       int preview_render_size,
+       struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
+       struct ImBuf *ibuf3)
 {
+       struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3);
+
        SolidColorVars *cv = (SolidColorVars *)seq->effectdata;
 
        unsigned char *rect;
@@ -2728,6 +2799,7 @@ static void do_solid_color(Scene *scene, Sequence *seq, int cfra,
                        }
                }
        }
+       return out;
 }
 
 /* **********************************************************************
@@ -2745,48 +2817,45 @@ static int early_out_multicam(struct Sequence *seq, float facf0, float facf1)
        return -1;
 }
 
-static void do_multicam(Scene *scene, Sequence *seq, int cfra,
-                       float facf0, float facf1, int x, int y, 
-                       int preview_render_size,
-                       struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
-                       struct ImBuf *ibuf3, struct ImBuf *out)
+static struct ImBuf * do_multicam(
+       Scene *scene, Sequence *seq, float cfra,
+       float facf0, float facf1, int x, int y, 
+       int preview_render_size,
+       struct ImBuf *ibuf1, struct ImBuf *ibuf2, 
+       struct ImBuf *ibuf3)
 {
        struct ImBuf * i;
+       struct ImBuf * out;
        Editing * ed;
        ListBase * seqbasep;
 
        if (seq->multicam_source == 0 || seq->multicam_source >= seq->machine) {
-               return;
+               return 0;
        }
 
        ed = scene->ed;
        if (!ed) {
-               return;
+               return 0;
        }
        seqbasep = seq_seqbase(&ed->seqbase, seq);
        if (!seqbasep) {
-               return;
+               return 0;
        }
 
-       i = give_ibuf_seqbase(scene, 
-                             out->x, out->y, cfra, seq->multicam_source, 
+       i = give_ibuf_seqbase(scene, x, y, cfra, seq->multicam_source, 
                              preview_render_size, seqbasep);
        if (!i) {
-               return;
+               return 0;
        }
 
-       if (out->rect && i->rect) {
-               memcpy(out->rect, i->rect, out->x * out->y * 4);
-       } else if (out->rect_float && i->rect_float) {
-               memcpy(out->rect_float, i->rect_float, out->x * out->y *4*sizeof(float));
-       } else if (out->rect && i->rect_float) { 
-               IMB_rect_from_float(i);
-               memcpy(out->rect, i->rect, out->x * out->y * 4);
-       } else if (out->rect_float && i->rect) {
-               IMB_float_from_rect_simple(i);
-               memcpy(out->rect_float, i->rect_float, out->x * out->y *4*sizeof(float));
+       if (input_have_to_preprocess(scene, seq, cfra, x, y)) {
+               out = IMB_dupImBuf(i);
+               IMB_freeImBuf(i);
+       } else {
+               out = i;
        }
-       IMB_freeImBuf(i);
+       
+       return out;
 }
 
 /* **********************************************************************
@@ -3049,13 +3118,13 @@ static void store_icu_yrange_noop(struct Sequence * seq,
        /* defaults are fine */
 }
 
-static void get_default_fac_noop(struct Sequence *seq, int cfra,
+static void get_default_fac_noop(struct Sequence *seq, float cfra,
                                 float * facf0, float * facf1)
 {
        *facf0 = *facf1 = 1.0;
 }
 
-static void get_default_fac_fade(struct Sequence *seq, int cfra,
+static void get_default_fac_fade(struct Sequence *seq, float cfra,
                                 float * facf0, float * facf1)
 {
        *facf0 = (float)(cfra - seq->startdisp);
@@ -3064,21 +3133,38 @@ static void get_default_fac_fade(struct Sequence *seq, int cfra,
        *facf1 /= seq->len;
 }
 
-static void do_overdrop_effect(Scene *scene, Sequence *seq, int cfra,
-                              float fac, float facf, 
-                              int x, int y, 
-                              int preview_render_size,
-                              struct ImBuf * ibuf1, 
-                              struct ImBuf * ibuf2, 
-                              struct ImBuf * ibuf3, 
-                              struct ImBuf * out)
-{
-       do_drop_effect(scene, seq, cfra, fac, facf, x, y, 
-                      preview_render_size,
-                      ibuf1, ibuf2, ibuf3, out);
-       do_alphaover_effect(scene, seq, cfra, fac, facf, x, y, 
-                           preview_render_size,
-                           ibuf1, ibuf2, ibuf3, out);
+static struct ImBuf * do_overdrop_effect(Scene *scene, Sequence *seq, float cfra,
+                                        float facf0, float facf1, 
+                                        int x, int y, 
+                                        int preview_render_size,
+                                        struct ImBuf * ibuf1, 
+                                        struct ImBuf * ibuf2, 
+                                        struct ImBuf * ibuf3)
+{
+       struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3);
+
+       if (out->rect_float) {
+               do_drop_effect_float(
+                       facf0, facf1, x, y,
+                       ibuf1->rect_float, ibuf2->rect_float,
+                       out->rect_float);
+               do_alphaover_effect_float(
+                       facf0, facf1, x, y,
+                       ibuf1->rect_float, ibuf2->rect_float,
+                       out->rect_float);
+       } else {
+               do_drop_effect_byte(
+                       facf0, facf1, x, y,
+                       (char*) ibuf1->rect, 
+                       (char*) ibuf2->rect,
+                       (char*) out->rect);
+               do_alphaover_effect_byte(
+                       facf0, facf1, x, y,
+                       (char*) ibuf1->rect, (char*) ibuf2->rect,
+                       (char*) out->rect);
+       }
+
+       return out;
 }
 
 static struct SeqEffectHandle get_sequence_effect_impl(int seq_type)
index bbc5049..0651f1a 100644 (file)
@@ -1443,7 +1443,7 @@ static void color_balance(Sequence * seq, ImBuf* ibuf, float mul)
 
 */
 
-static int input_have_to_preprocess(
+int input_have_to_preprocess(
        Scene *scene, Sequence * seq, float cfra, int seqrectx, int seqrecty)
 {
        float mul;
@@ -1708,13 +1708,9 @@ static ImBuf* seq_render_effect_strip_impl(
        early_out = sh.early_out(seq, fac, facf);
 
        if (early_out == -1) { /* no input needed */
-               /* hmmm, global float option ? */
-               out = IMB_allocImBuf(
-                       (short)seqrectx, (short)seqrecty, 32, IB_rect, 0);
-
-               sh.execute(scene, seq, cfra, fac, facf, 
-                          out->x, out->y, render_size,
-                          0, 0, 0, out);
+               out = sh.execute(scene, seq, cfra, fac, facf, 
+                                seqrectx, seqrecty, render_size,
+                                0, 0, 0);
                goto finish;
        }
 
@@ -1781,31 +1777,9 @@ static ImBuf* seq_render_effect_strip_impl(
                goto finish;
        }
 
-       /* if any inputs are rectfloat, output is float too */
-       if((ibuf[0] && ibuf[0]->rect_float) || 
-          (ibuf[1] && ibuf[1]->rect_float) || 
-          (ibuf[2] && ibuf[2]->rect_float)) {
-               out = IMB_allocImBuf(
-                       (short)seqrectx, (short)seqrecty, 32, IB_rectfloat, 0);
-       } else {
-               out = IMB_allocImBuf(
-                       (short)seqrectx, (short)seqrecty, 32, IB_rect, 0);
-       }
-
-       for (i = 0; i < 3; i++) {
-               ImBuf * b = ibuf[i];
-               if (b) {
-                       if (!b->rect_float && out->rect_float) {
-                               IMB_float_from_rect_simple(b);
-                       }
-                       if (!b->rect && !out->rect_float) {
-                               IMB_rect_from_float(b);
-                       }
-               }
-       }
-
-       sh.execute(scene, seq, cfra, fac, facf, out->x, out->y, render_size,
-                  ibuf[0], ibuf[1], ibuf[2], out);
+       out = sh.execute(scene, seq, cfra, fac, facf, seqrectx, seqrecty, 
+                        render_size,
+                        ibuf[0], ibuf[1], ibuf[2]);
 
 finish:
        for (i = 0; i < 3; i++) {
@@ -2271,41 +2245,17 @@ static ImBuf* seq_render_strip_stack(
                        int swap_input 
                                = seq_must_swap_input_in_blend_mode(seq);
 
-                       int x= out->x;
-                       int y= out->y;
+                       int x= seqrectx;
+                       int y= seqrecty;
 
-                       if (ibuf1->rect_float || ibuf2->rect_float) {
-                               out = IMB_allocImBuf(
-                                       (short)seqrectx, (short)seqrecty, 
-                                       32, IB_rectfloat, 0);
-                       } else {
-                               out = IMB_allocImBuf(
-                                       (short)seqrectx, (short)seqrecty, 
-                                       32, IB_rect, 0);
-                       }
-
-                       if (!ibuf1->rect_float && out->rect_float) {
-                               IMB_float_from_rect_simple(ibuf1);
-                       }
-                       if (!ibuf2->rect_float && out->rect_float) {
-                               IMB_float_from_rect_simple(ibuf2);
-                       }
-
-                       if (!ibuf1->rect && !out->rect_float) {
-                               IMB_rect_from_float(ibuf1);
-                       }
-                       if (!ibuf2->rect && !out->rect_float) {
-                               IMB_rect_from_float(ibuf2);
-                       }
-                       
                        if (swap_input) {
-                               sh.execute(scene, seq, cfra, 
-                                          facf, facf, x, y, render_size,
-                                          ibuf2, ibuf1, 0, out);
+                               out = sh.execute(scene, seq, cfra, 
+                                                facf, facf, x, y, render_size,
+                                                ibuf2, ibuf1, 0);
                        } else {
-                               sh.execute(scene, seq, cfra, 
-                                          facf, facf, x, y, render_size,
-                                          ibuf1, ibuf2, 0, out);
+                               out = sh.execute(scene, seq, cfra, 
+                                                facf, facf, x, y, render_size,
+                                                ibuf1, ibuf2, 0);
                        }
                
                        IMB_freeImBuf(ibuf1);