[Bf-blender-cvs] [44db9f192eb] master: Cleanup: Factor in VSE effect processing

Richard Antalik noreply at git.blender.org
Tue Dec 28 14:31:38 CET 2021


Commit: 44db9f192eba5ef3c2f3117457b45540d3ca3801
Author: Richard Antalik
Date:   Tue Dec 28 14:28:52 2021 +0100
Branches: master
https://developer.blender.org/rB44db9f192eba5ef3c2f3117457b45540d3ca3801

Cleanup: Factor in VSE effect processing

2 factor variables were passed to effects, but they were hard coded to
have same value.

Remove duplicate variable from arguments, rename single argument to
`fac`. Inverted factor variables were renamed to `mfac`. Any other
factor related variables are prefixed with `temp_`.

There should be no functional changes.

===================================================================

M	source/blender/sequencer/SEQ_effects.h
M	source/blender/sequencer/intern/effects.c
M	source/blender/sequencer/intern/render.c
M	source/blender/sequencer/intern/render.h

===================================================================

diff --git a/source/blender/sequencer/SEQ_effects.h b/source/blender/sequencer/SEQ_effects.h
index 4bd5b54b36b..87a8288a593 100644
--- a/source/blender/sequencer/SEQ_effects.h
+++ b/source/blender/sequencer/SEQ_effects.h
@@ -68,10 +68,10 @@ 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 fac);
 
-  /* stores the default facf0 and facf1 if no IPO is present */
-  void (*get_default_fac)(struct Sequence *seq, float timeline_frame, float *facf0, float *facf1);
+  /* sets the default `fac` value */
+  void (*get_default_fac)(struct Sequence *seq, float timeline_frame, float *fac);
 
   /* execute the effect
    * sequence effects are only required to either support
@@ -81,8 +81,7 @@ struct SeqEffectHandle {
   struct ImBuf *(*execute)(const struct SeqRenderData *context,
                            struct Sequence *seq,
                            float timeline_frame,
-                           float facf0,
-                           float facf1,
+                           float fac,
                            struct ImBuf *ibuf1,
                            struct ImBuf *ibuf2,
                            struct ImBuf *ibuf3);
@@ -95,8 +94,7 @@ struct SeqEffectHandle {
   void (*execute_slice)(const struct SeqRenderData *context,
                         struct Sequence *seq,
                         float timeline_frame,
-                        float facf0,
-                        float facf1,
+                        float fac,
                         struct ImBuf *ibuf1,
                         struct ImBuf *ibuf2,
                         struct ImBuf *ibuf3,
diff --git a/source/blender/sequencer/intern/effects.c b/source/blender/sequencer/intern/effects.c
index 05ce35deeec..1cf0d7bb34f 100644
--- a/source/blender/sequencer/intern/effects.c
+++ b/source/blender/sequencer/intern/effects.c
@@ -206,15 +206,9 @@ static void init_alpha_over_or_under(Sequence *seq)
   seq->seq1 = seq2;
 }
 
-static void do_alphaover_effect_byte(float facf0,
-                                     float facf1,
-                                     int x,
-                                     int y,
-                                     unsigned char *rect1,
-                                     unsigned char *rect2,
-                                     unsigned char *out)
-{
-  float fac2, mfac, fac, fac4;
+static void do_alphaover_effect_byte(
+    float fac, int x, int y, unsigned char *rect1, unsigned char *rect2, unsigned char *out)
+{
   int xo;
   unsigned char *cp1, *cp2, *rt;
   float tempc[4], rt1[4], rt2[4];
@@ -224,9 +218,6 @@ static void do_alphaover_effect_byte(float facf0,
   cp2 = rect2;
   rt = out;
 
-  fac2 = facf0;
-  fac4 = facf1;
-
   while (y--) {
     x = xo;
     while (x--) {
@@ -235,8 +226,7 @@ static void do_alphaover_effect_byte(float facf0,
       straight_uchar_to_premul_float(rt1, cp1);
       straight_uchar_to_premul_float(rt2, cp2);
 
-      fac = fac2;
-      mfac = 1.0f - fac2 * rt1[3];
+      float mfac = 1.0f - fac * rt1[3];
 
       if (fac <= 0.0f) {
         *((unsigned int *)rt) = *((unsigned int *)cp2);
@@ -267,8 +257,7 @@ static void do_alphaover_effect_byte(float facf0,
       straight_uchar_to_premul_float(rt1, cp1);
       straight_uchar_to_premul_float(rt2, cp2);
 
-      fac = fac4;
-      mfac = 1.0f - (fac4 * rt1[3]);
+      float mfac = 1.0f - (fac * rt1[3]);
 
       if (fac <= 0.0f) {
         *((unsigned int *)rt) = *((unsigned int *)cp2);
@@ -292,9 +281,8 @@ static void do_alphaover_effect_byte(float facf0,
 }
 
 static void do_alphaover_effect_float(
-    float facf0, float facf1, int x, int y, float *rect1, float *rect2, float *out)
+    float fac, int x, int y, float *rect1, float *rect2, float *out)
 {
-  float fac2, mfac, fac, fac4;
   int xo;
   float *rt1, *rt2, *rt;
 
@@ -303,16 +291,12 @@ static void do_alphaover_effect_float(
   rt2 = rect2;
   rt = out;
 
-  fac2 = facf0;
-  fac4 = facf1;
-
   while (y--) {
     x = xo;
     while (x--) {
       /* rt = rt1 over rt2  (alpha from rt1) */
 
-      fac = fac2;
-      mfac = 1.0f - (fac2 * rt1[3]);
+      float mfac = 1.0f - (fac * rt1[3]);
 
       if (fac <= 0.0f) {
         memcpy(rt, rt2, sizeof(float[4]));
@@ -338,8 +322,7 @@ static void do_alphaover_effect_float(
 
     x = xo;
     while (x--) {
-      fac = fac4;
-      mfac = 1.0f - (fac4 * rt1[3]);
+      float mfac = 1.0f - (fac * rt1[3]);
 
       if (fac <= 0.0f) {
         memcpy(rt, rt2, sizeof(float[4]));
@@ -363,8 +346,7 @@ static void do_alphaover_effect_float(
 static void do_alphaover_effect(const SeqRenderData *context,
                                 Sequence *UNUSED(seq),
                                 float UNUSED(timeline_frame),
-                                float facf0,
-                                float facf1,
+                                float fac,
                                 ImBuf *ibuf1,
                                 ImBuf *ibuf2,
                                 ImBuf *UNUSED(ibuf3),
@@ -378,7 +360,7 @@ static void do_alphaover_effect(const SeqRenderData *context,
     slice_get_float_buffers(
         context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out);
 
-    do_alphaover_effect_float(facf0, facf1, context->rectx, total_lines, rect1, rect2, rect_out);
+    do_alphaover_effect_float(fac, context->rectx, total_lines, rect1, rect2, rect_out);
   }
   else {
     unsigned char *rect1 = NULL, *rect2 = NULL, *rect_out = NULL;
@@ -386,21 +368,15 @@ static void do_alphaover_effect(const SeqRenderData *context,
     slice_get_byte_buffers(
         context, ibuf1, ibuf2, NULL, out, start_line, &rect1, &rect2, NULL, &rect_out);
 
-    do_alphaover_effect_byte(facf0, facf1, context->rectx, total_lines, rect1, rect2, rect_out);
+    do_alphaover_effect_byte(fac, context->rectx, total_lines, rect1, rect2, rect_out);
   }
 }
 
 /*********************** Alpha Under *************************/
 
-static void do_alphaunder_effect_byte(float facf0,
-                                      float facf1,
-                                      int x,
-                                      int y,
-                                      unsigned char *rect1,
-                                      unsigned char *rect2,
-                                      unsigned char *out)
+static void do_alphaunder_effect_byte(
+    float fac, int x, int y, unsigned char *rect1, unsigned char *rect2, unsigned char *out)
 {
-  float fac2, fac, fac4;
   int xo;
   unsigned char *cp1, *cp2, *rt;
   float tempc[4], rt1[4], rt2[4];
@@ -410,9 +386,6 @@ static void do_alphaunder_effect_byte(float facf0,
   cp2 = rect2;
   rt = out;
 
-  fac2 = facf0;
-  fac4 = facf1;
-
   while (y--) {
     x = xo;
     while (x--) {
@@ -423,23 +396,23 @@ static void do_alphaunder_effect_byte(float facf0,
       /* this complex optimization is because the
        * 'skybuf' can be crossed in
        */
-      if (rt2[3] <= 0.0f && fac2 >= 1.0f) {
+      if (rt2[3] <= 0.0f && fac >= 1.0f) {
         *((unsigned int *)rt) = *((unsigned int *)cp1);
       }
       else if (rt2[3] >= 1.0f) {
         *((unsigned int *)rt) = *((unsigned int *)cp2);
       }
       else {
-        fac = (fac2 * (1.0f - rt2[3]));
+        float temp_fac = (fac * (1.0f - rt2[3]));
 
         if (fac <= 0) {
           *((unsigned int *)rt) = *((unsigned int *)cp2);
         }
         else {
-          tempc[0] = (fac * rt1[0] + rt2[0]);
-          tempc[1] = (fac * rt1[1] + rt2[1]);
-          tempc[2] = (fac * rt1[2] + rt2[2]);
-          tempc[3] = (fac * rt1[3] + rt2[3]);
+          tempc[0] = (temp_fac * rt1[0] + rt2[0]);
+          tempc[1] = (temp_fac * rt1[1] + rt2[1]);
+          tempc[2] = (temp_fac * rt1[2] + rt2[2]);
+          tempc[3] = (temp_fac * rt1[3] + rt2[3]);
 
           premul_float_to_straight_uchar(rt, tempc);
         }
@@ -459,23 +432,23 @@ static void do_alphaunder_effect_byte(float facf0,
       straight_uchar_to_premul_float(rt1, cp1);
       straight_uchar_to_premul_float(rt2, cp2);
 
-      if (rt2[3] <= 0.0f && fac4 >= 1.0f) {
+      if (rt2[3] <= 0.0f && fac >= 1.0f) {
         *((unsigned int *)rt) = *((unsigned int *)cp1);
       }
       else if (rt2[3] >= 1.0f) {
         *((unsigned int *)rt) = *((unsigned int *)cp2);
       }
       else {
-        fac = (fac4 * (1.0f - rt2[3]));
+        float temp_fac = (fac * (1.0f - rt2[3]));
 
         if (fac <= 0) {
           *((unsigned int *)rt) = *((unsigned int *)cp2);
         }
         else {
-          tempc[0] = (fac * rt1[0] + rt2[0]);
-          tempc[1] = (fac * rt1[1] + rt2[1]);
-          tempc[2] = (fac * rt1[2] + rt2[2]);
-          tempc[3] = (fac * rt1[3] + rt2[3]);
+          tempc[0] = (temp_fac * rt1[0] + rt2[0]);
+          tempc[1] = (temp_fac * rt1[1] + rt2[1]);
+          tempc[2] = (temp_fac * rt1[2] + rt2[2]);
+          tempc[3] = (temp_fac * rt1[3] + rt2[3]);
 
           premul_float_to_straight_uchar(rt, tempc);
         }
@@ -488,9 +461,8 @@ static void do_alphaunder_effect_byte(float facf0,
 }
 
 static void do_alphaunder_effect_float(
-    float facf0, float facf1, int x, int y, float *rect1, float *rect2, float *out)
+    float fac, int x, int y, float *rect1, float *rect2, float *out)
 {
-  float fac2, fac, fac4;
   int xo;
   float *rt1, *rt2, *rt;
 
@@ -499,9 +471,6 @@ static void do_alphaunder_effect_float(
   rt2 = rect2;
   rt = out;
 
-  fac2 = facf0;
-  fac4 = facf1;
-
   while (y--) {
     x = xo;
     while (x--) {
@@ -510,23 +479,23 @@ static void do_alphaunder_effect_float(
       /* this complex optimization is because the
        * 'skybuf' can be crossed in
        */
-      if (rt2[3] <= 0 && fac2 >= 1.0f) {
+      if (rt2[3] <= 0 && fac >= 1.0f) {
         memcpy(rt, rt1, sizeof(float[4]));
       }
       else if (rt2[3] >= 1.0f) {
         memcpy(rt, rt2, sizeof(float[4]));
       }
       else {
-        fac = fac2 * (1.0f - rt2[3]);
+        float temp_fac = fac * (1.0f - rt2[3]);
 
         if (fac == 0) {
           memcpy(rt, rt2, sizeof(float[4]));
         }
         else {
-          rt[0] = fac * rt1[0]

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list