[FFmpeg-cvslog] avfilter/vf_transpose_vulkan: add clock and cclock option

Wu Jianhua git at videolan.org
Fri Dec 10 22:03:06 EET 2021


ffmpeg | branch: master | Wu Jianhua <jianhua.wu at intel.com> | Sat Dec 11 03:05:00 2021 +0800| [f106c7228503241d044fb404d1012047d6452f74] | committer: Lynne

avfilter/vf_transpose_vulkan: add clock and cclock option

The following command is on how to apply cclock option:

ffmpeg -init_hw_device vulkan -i input.264 -vf \
hwupload=extra_hw_frames=16,transpose_vulkan=dir=cclock,hwdownload,format=yuv420p \
output.264

The following command is on how to apply clock_flip option:

ffmpeg -init_hw_device vulkan -i input.264 -vf \
hwupload=extra_hw_frames=16,transpose_vulkan=dir=clock_flip,hwdownload,format=yuv420p \
output.264

The following command is on how to apply clock option:

ffmpeg -init_hw_device vulkan -i input.264 -vf \
hwupload=extra_hw_frames=16,transpose_vulkan=dir=clock,hwdownload,format=yuv420p \
output.264

Signed-off-by: Wu Jianhua <jianhua.wu at intel.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f106c7228503241d044fb404d1012047d6452f74
---

 libavfilter/vf_transpose_vulkan.c | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vf_transpose_vulkan.c b/libavfilter/vf_transpose_vulkan.c
index c9bae413c3..eceb9b9011 100644
--- a/libavfilter/vf_transpose_vulkan.c
+++ b/libavfilter/vf_transpose_vulkan.c
@@ -21,6 +21,7 @@
 #include "libavutil/opt.h"
 #include "vulkan_filter.h"
 #include "internal.h"
+#include "transpose.h"
 
 #define CGS 32
 
@@ -33,6 +34,7 @@ typedef struct TransposeVulkanContext {
     VkDescriptorImageInfo input_images[3];
     VkDescriptorImageInfo output_images[3];
 
+    int dir;
     int initialized;
 } TransposeVulkanContext;
 
@@ -86,13 +88,20 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in)
         GLSLC(0, void main()                                               );
         GLSLC(0, {                                                         );
         GLSLC(1,     ivec2 size;                                           );
-        GLSLC(1,     const ivec2 pos = ivec2(gl_GlobalInvocationID.xy);    );
+        GLSLC(1,     ivec2 pos = ivec2(gl_GlobalInvocationID.xy);          );
         for (int i = 0; i < planes; i++) {
             GLSLC(0,                                                       );
-            GLSLF(1, size = imageSize(output_images[%i]);                 ,i);
+            GLSLF(1, size = imageSize(output_images[%i]);                ,i);
             GLSLC(1, if (IS_WITHIN(pos, size)) {                           );
-            GLSLF(2,     vec4 res = texture(input_images[%i], pos.yx);    ,i);
-            GLSLF(2,     imageStore(output_images[%i], pos, res);         ,i);
+            if (s->dir == TRANSPOSE_CCLOCK)
+                GLSLF(2, vec4 res = texture(input_images[%i], ivec2(size.y - pos.y, pos.x)); ,i);
+            else if (s->dir == TRANSPOSE_CLOCK_FLIP || s->dir == TRANSPOSE_CLOCK) {
+                GLSLF(2, vec4 res = texture(input_images[%i], ivec2(size.yx - pos.yx));      ,i);
+                if (s->dir == TRANSPOSE_CLOCK)
+                    GLSLC(2, pos = ivec2(pos.x, size.y - pos.y);           );
+            } else
+                GLSLF(2, vec4 res = texture(input_images[%i], pos.yx);   ,i);
+            GLSLF(2,     imageStore(output_images[%i], pos, res);        ,i);
             GLSLC(1, }                                                     );
         }
         GLSLC(0, }                                                         );
@@ -279,7 +288,15 @@ fail:
     return err;
 }
 
+#define OFFSET(x) offsetof(TransposeVulkanContext, x)
+#define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
+
 static const AVOption transpose_vulkan_options[] = {
+    { "dir", "set transpose direction", OFFSET(dir), AV_OPT_TYPE_INT, { .i64 = TRANSPOSE_CCLOCK_FLIP }, 0, 7, FLAGS, "dir" },
+        { "cclock_flip", "rotate counter-clockwise with vertical flip", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK_FLIP }, .flags=FLAGS, .unit = "dir" },
+        { "clock",       "rotate clockwise",                            0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK       }, .flags=FLAGS, .unit = "dir" },
+        { "cclock",      "rotate counter-clockwise",                    0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK      }, .flags=FLAGS, .unit = "dir" },
+        { "clock_flip",  "rotate clockwise with vertical flip",         0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK_FLIP  }, .flags=FLAGS, .unit = "dir" },
     { NULL }
 };
 



More information about the ffmpeg-cvslog mailing list