Revision: 30722
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30722
Author:   schlaile
Date:     2010-07-25 19:19:55 +0200 (Sun, 25 Jul 2010)

Log Message:
-----------
== Sequencer ==

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

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_sequencer.h
    trunk/blender/source/blender/blenkernel/intern/seqeffects.c
    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-07-25 
14:40:18 UTC (rev 30721)
+++ trunk/blender/source/blender/blenkernel/BKE_sequencer.h     2010-07-25 
17:19:55 UTC (rev 30722)
@@ -107,15 +107,14 @@
        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 @@
            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 @@
 // 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 {

Modified: trunk/blender/source/blender/blenkernel/intern/seqeffects.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/seqeffects.c 2010-07-25 
14:40:18 UTC (rev 30721)
+++ trunk/blender/source/blender/blenkernel/intern/seqeffects.c 2010-07-25 
17:19:55 UTC (rev 30722)
@@ -67,7 +67,49 @@
        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 @@
        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 @@
                                  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 @@
                        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(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 @@
                        (char*) ibuf1->rect, (char*) ibuf2->rect,
                        (char*) out->rect);
        }
+       return out;
 }
 
 
@@ -644,12 +694,15 @@
        }
 }
 
-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 @@
                        (char*) ibuf1->rect, (char*) ibuf2->rect,
                        (char*) out->rect);
        }
+       return out;
 }
 
 
@@ -765,12 +819,15 @@
 
 /* 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 @@
                        (char*) ibuf1->rect, (char*) ibuf2->rect,
                        (char*) out->rect);
        }
+       return out;
 }
 
 
@@ -1028,12 +1086,15 @@
        }
 }
 
-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 @@
                        (unsigned char*) ibuf1->rect, (unsigned char*) 
ibuf2->rect,
                        (unsigned char*) out->rect);
        }
+       return out;
 }
 
 
@@ -1143,12 +1205,14 @@
        }
 }
 
-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 @@
                        (unsigned char*) ibuf1->rect, (unsigned char*) 
ibuf2->rect,
                        (unsigned char*) out->rect);
        }
+       return out;
 }
 
 
@@ -1256,12 +1321,15 @@
        }
 }
 
-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 @@
                        (char*) ibuf1->rect, (char*) ibuf2->rect,
                        (char*) out->rect);
        }
+       return out;
 }
 
 /* **********************************************************************
@@ -1284,8 +1353,8 @@
 #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 @@
        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

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to