Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Marvin Scholz <epirat07@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Marvin Scholz <epirat07@gmail.com>
Subject: [FFmpeg-devel] [PATCH v3 4/4] lavfi/vf_xfade_vulkan: add slide transitions
Date: Wed,  7 Jun 2023 00:23:02 +0200
Message-ID: <20230606222302.21495-4-epirat07@gmail.com> (raw)
In-Reply-To: <20230606222302.21495-1-epirat07@gmail.com>

---
 libavfilter/vf_xfade_vulkan.c | 58 +++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/libavfilter/vf_xfade_vulkan.c b/libavfilter/vf_xfade_vulkan.c
index 58552ab734..f1f248c288 100644
--- a/libavfilter/vf_xfade_vulkan.c
+++ b/libavfilter/vf_xfade_vulkan.c
@@ -72,6 +72,10 @@ enum XFadeTransitions {
     WIPERIGHT,
     WIPEUP,
     WIPEDOWN,
+    SLIDEDOWN,
+    SLIDEUP,
+    SLIDELEFT,
+    SLIDERIGHT,
     NB_TRANSITIONS,
 };
 
@@ -128,12 +132,62 @@ static const char transition_wipedown[] = {
     C(0, }                                                                     )
 };
 
+#define SHADER_SLIDE_COMMON                                                              \
+    C(0, void slide(int idx, ivec2 pos, float progress, ivec2 direction)               ) \
+    C(0, {                                                                             ) \
+    C(1,     ivec2 size = imageSize(output_images[idx]);                               ) \
+    C(1,     ivec2 pi = ivec2(progress * size);                                        ) \
+    C(1,     ivec2 p = pos + pi * direction;                                           ) \
+    C(1,     ivec2 f = p % size;                                                       ) \
+    C(1,     f = f + size * ivec2(f.x < 0, f.y < 0);                                   ) \
+    C(1,     vec4 a = texture(a_images[idx], f);                                       ) \
+    C(1,     vec4 b = texture(b_images[idx], f);                                       ) \
+    C(1,     vec4 r = (p.y >= 0 && p.x >= 0 && size.y > p.y &&  size.x > p.x) ? a : b; ) \
+    C(1,     imageStore(output_images[idx], pos, r);                                   ) \
+    C(0, }                                                                             )
+
+static const char transition_slidedown[] = {
+    SHADER_SLIDE_COMMON
+    C(0, void transition(int idx, ivec2 pos, float progress)                   )
+    C(0, {                                                                     )
+    C(1,     slide(idx, pos, progress, ivec2(0, -1));                          )
+    C(0, }                                                                     )
+};
+
+static const char transition_slideup[] = {
+    SHADER_SLIDE_COMMON
+    C(0, void transition(int idx, ivec2 pos, float progress)                   )
+    C(0, {                                                                     )
+    C(1,     slide(idx, pos, progress, ivec2(0, +1));                          )
+    C(0, }                                                                     )
+};
+
+static const char transition_slideleft[] = {
+    SHADER_SLIDE_COMMON
+    C(0, void transition(int idx, ivec2 pos, float progress)                   )
+    C(0, {                                                                     )
+    C(1,     slide(idx, pos, progress, ivec2(+1, 0));                          )
+    C(0, }                                                                     )
+};
+
+static const char transition_slideright[] = {
+    SHADER_SLIDE_COMMON
+    C(0, void transition(int idx, ivec2 pos, float progress)                   )
+    C(0, {                                                                     )
+    C(1,     slide(idx, pos, progress, ivec2(-1, 0));                          )
+    C(0, }                                                                     )
+};
+
 static const char* transitions_map[NB_TRANSITIONS] = {
     [FADE]      = transition_fade,
     [WIPELEFT]  = transition_wipeleft,
     [WIPERIGHT] = transition_wiperight,
     [WIPEUP]    = transition_wipeup,
     [WIPEDOWN]  = transition_wipedown,
+    [SLIDEDOWN] = transition_slidedown,
+    [SLIDEUP]   = transition_slideup,
+    [SLIDELEFT] = transition_slideleft,
+    [SLIDERIGHT]= transition_slideright,
 };
 
 static av_cold int init_vulkan(AVFilterContext *avctx)
@@ -481,6 +535,10 @@ static const AVOption xfade_vulkan_options[] = {
         { "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" },
+        { "slidedown", "slide down transition", 0, AV_OPT_TYPE_CONST, {.i64=SLIDEDOWN}, 0, 0, FLAGS, "transition" },
+        { "slideup",   "slide up transition", 0, AV_OPT_TYPE_CONST, {.i64=SLIDEUP}, 0, 0, FLAGS, "transition" },
+        { "slideleft", "slide left transition", 0, AV_OPT_TYPE_CONST, {.i64=SLIDELEFT}, 0, 0, FLAGS, "transition" },
+        { "slideright","slide right transition", 0, AV_OPT_TYPE_CONST, {.i64=SLIDERIGHT}, 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 }
-- 
2.37.0 (Apple Git-136)

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2023-06-06 22:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-30  1:33 [FFmpeg-devel] [PATCH] libavfilter: add vf_xfade_vulkan Marvin Scholz
2023-05-30  1:58 ` [FFmpeg-devel] [PATCH v2] " Marvin Scholz
2023-05-30 12:30   ` Niklas Haas
2023-06-06 22:22   ` [FFmpeg-devel] [PATCH v3 1/4] " Marvin Scholz
2023-06-06 22:23     ` [FFmpeg-devel] [PATCH v3 2/4] lavfi/vf_xfade_vulkan: add wipeup transition Marvin Scholz
2023-06-06 22:23     ` [FFmpeg-devel] [PATCH v3 3/4] lavfi/vf_xfade_vulkan: add wipedown transition Marvin Scholz
2023-06-06 22:23     ` Marvin Scholz [this message]
2023-05-30  8:05 ` [FFmpeg-devel] [PATCH] libavfilter: add vf_xfade_vulkan Paul B Mahol

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230606222302.21495-4-epirat07@gmail.com \
    --to=epirat07@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git