diff mbox series

[FFmpeg-devel,v3,3/4] lavfi/vf_xfade_vulkan: add wipedown transition

Message ID 20230606222302.21495-3-epirat07@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,v3,1/4] libavfilter: add vf_xfade_vulkan | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Marvin Scholz June 6, 2023, 10:23 p.m. UTC
---
 libavfilter/vf_xfade_vulkan.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff mbox series

Patch

diff --git a/libavfilter/vf_xfade_vulkan.c b/libavfilter/vf_xfade_vulkan.c
index 0244802e9c..58552ab734 100644
--- a/libavfilter/vf_xfade_vulkan.c
+++ b/libavfilter/vf_xfade_vulkan.c
@@ -71,6 +71,7 @@  enum XFadeTransitions {
     WIPELEFT,
     WIPERIGHT,
     WIPEUP,
+    WIPEDOWN,
     NB_TRANSITIONS,
 };
 
@@ -116,11 +117,23 @@  static const char transition_wipeup[] = {
     C(0, }                                                                     )
 };
 
+static const char transition_wipedown[] = {
+    C(0, void transition(int idx, ivec2 pos, float progress)                   )
+    C(0, {                                                                     )
+    C(1,     ivec2 size = imageSize(output_images[idx]);                       )
+    C(1,     int  s = int(size.y * progress);                                  )
+    C(1,     vec4 a = texture(a_images[idx], pos);                             )
+    C(1,     vec4 b = texture(b_images[idx], pos);                             )
+    C(1,     imageStore(output_images[idx], pos, pos.y > s ? a : b);           )
+    C(0, }                                                                     )
+};
+
 static const char* transitions_map[NB_TRANSITIONS] = {
     [FADE]      = transition_fade,
     [WIPELEFT]  = transition_wipeleft,
     [WIPERIGHT] = transition_wiperight,
     [WIPEUP]    = transition_wipeup,
+    [WIPEDOWN]  = transition_wipedown,
 };
 
 static av_cold int init_vulkan(AVFilterContext *avctx)
@@ -467,6 +480,7 @@  static const AVOption xfade_vulkan_options[] = {
         { "wipeleft",  "wipe left transition", 0, AV_OPT_TYPE_CONST, {.i64=WIPELEFT}, 0, 0, FLAGS, "transition" },
         { "wiperight", "wipe right transition", 0, AV_OPT_TYPE_CONST, {.i64=WIPERIGHT}, 0, 0, FLAGS, "transition" },
         { "wipeup",    "wipe up transition", 0, AV_OPT_TYPE_CONST, {.i64=WIPEUP}, 0, 0, FLAGS, "transition" },
+        { "wipedown",  "wipe down transition", 0, AV_OPT_TYPE_CONST, {.i64=WIPEDOWN}, 0, 0, FLAGS, "transition" },
     { "duration", "set cross fade duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64=1000000}, 0, 60000000, FLAGS },
     { "offset",   "set cross fade start relative to first input stream", OFFSET(offset), AV_OPT_TYPE_DURATION, {.i64=0}, INT64_MIN, INT64_MAX, FLAGS },
     { NULL }