diff mbox series

[FFmpeg-devel] avfilter/vf_xfade: fixed slideleft/slideright/slideup/slidedown bug

Message ID cc200165-4b73-705a-6869-804fbd8fe834@gmail.com
State New
Headers show
Series [FFmpeg-devel] avfilter/vf_xfade: fixed slideleft/slideright/slideup/slidedown bug | expand

Checks

Context Check Description
yinshiyou/configure_loongarch64 warning Failed to apply patch
andriy/configure_x86 warning Failed to apply patch
andriy/configure_armv7_RPi4 warning Failed to apply patch

Commit Message

George Floarea July 12, 2022, 2:18 p.m. UTC
zx and zy comparison were wrong when zx=0 or zy=0. This resulted in the 
wrong column/row being chosen.
This can be seen best when using xfade on streams with transparency.

For example: in case of a slideleft transition, the first column from 
the first input will overwrite the first column of the second stream 
throught the transition.
https://www.youtube.com/shorts/qSMuDSg_K9g

Signed-off-by: George Floarea <floareageorge@gmail.com>
---
  libavfilter/vf_xfade.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)

-                dst[x] = (zx > 0) && (zx < width) ? xf1[zz] : xf0[zz]; 
               \
+                dst[x] = (zx >= 0) && (zx < width) ? xf1[zz] : xf0[zz]; 
              \
              } 
                \
 
                \
              dst += out->linesize[p] / div; 
                \
@@ -466,7 +466,7 @@ static void 
slideright##name##_transition(AVFilterContext *ctx,
              for (int x = 0; x < out->width; x++) { 
                \
                  const int zx = z + x; 
                \
                  const int zz = zx % width + width * (zx < 0); 
                \
-                dst[x] = (zx > 0) && (zx < width) ? xf1[zz] : xf0[zz]; 
               \
+                dst[x] = (zx >= 0) && (zx < width) ? xf1[zz] : xf0[zz]; 
              \
              } 
                \
 
                \
              dst += out->linesize[p] / div; 
                \
@@ -499,7 +499,7 @@ static void 
slideup##name##_transition(AVFilterContext *ctx,
              const type *xf1 = (const type *)(b->data[p] + zz * 
b->linesize[p]);     \
 
               \
              for (int x = 0; x < out->width; x++) { 
               \
-                dst[x] = (zy > 0) && (zy < height) ? xf1[x] : xf0[x]; 
              \
+                dst[x] = (zy >= 0) && (zy < height) ? xf1[x] : xf0[x]; 
              \
              } 
               \
 
               \
              dst += out->linesize[p] / div; 
               \
@@ -530,7 +530,7 @@ static void 
slidedown##name##_transition(AVFilterContext *ctx,
              const type *xf1 = (const type *)(b->data[p] + zz * 
b->linesize[p]);     \
 
               \
              for (int x = 0; x < out->width; x++) { 
               \
-                dst[x] = (zy > 0) && (zy < height) ? xf1[x] : xf0[x]; 
              \
+                dst[x] = (zy >= 0) && (zy < height) ? xf1[x] : xf0[x]; 
              \
              } 
               \
 
               \
              dst += out->linesize[p] / div; 
               \
diff mbox series

Patch

diff --git a/libavfilter/vf_xfade.c b/libavfilter/vf_xfade.c
index 294928c134..9f66927365 100644
--- a/libavfilter/vf_xfade.c
+++ b/libavfilter/vf_xfade.c
@@ -433,7 +433,7 @@  static void 
slideleft##name##_transition(AVFilterContext *ctx,
              for (int x = 0; x < width; x++) { 
                \
                  const int zx = z + x; 
                \
                  const int zz = zx % width + width * (zx < 0); 
                \