History

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

Wu Jianhua committed 4 years ago

Commit f106c721 parent 0c1d47a1 file · +21 −4Browse files

Unified · Split

libavfilter/vf_transpose_vulkan.c+21−4
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121 #include "libavutil/opt.h"
2222 #include "vulkan_filter.h"
2323 #include "internal.h"
24+#include "transpose.h"
2425
2526 #define CGS 32
2627
@@ -33,6 +34,7 @@ typedef struct TransposeVulkanContext { · 6 unmodified lines
3334 VkDescriptorImageInfo input_images[3];
3435 VkDescriptorImageInfo output_images[3];
3536
37+ int dir;
3638 int initialized;
3739 } TransposeVulkanContext;
3840
@@ -86,13 +88,20 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) · 47 unmodified lines
8688 GLSLC(0, void main() );
8789 GLSLC(0, { );
8890 GLSLC(1, ivec2 size; );
89− GLSLC(1, const ivec2 pos = ivec2(gl_GlobalInvocationID.xy); );
91+ GLSLC(1, ivec2 pos = ivec2(gl_GlobalInvocationID.xy); );
9092 for (int i = 0; i < planes; i++) {
9193 GLSLC(0, );
92− GLSLF(1, size = imageSize(output_images[%i]); ,i);
94+ GLSLF(1, size = imageSize(output_images[%i]); ,i);
9395 GLSLC(1, if (IS_WITHIN(pos, size)) { );
94− GLSLF(2, vec4 res = texture(input_images[%i], pos.yx); ,i);
95− GLSLF(2, imageStore(output_images[%i], pos, res); ,i);
96+ if (s->dir == TRANSPOSE_CCLOCK)
97+ GLSLF(2, vec4 res = texture(input_images[%i], ivec2(size.y - pos.y, pos.x)); ,i);
98+ else if (s->dir == TRANSPOSE_CLOCK_FLIP || s->dir == TRANSPOSE_CLOCK) {
99+ GLSLF(2, vec4 res = texture(input_images[%i], ivec2(size.yx - pos.yx)); ,i);
100+ if (s->dir == TRANSPOSE_CLOCK)
101+ GLSLC(2, pos = ivec2(pos.x, size.y - pos.y); );
102+ } else
103+ GLSLF(2, vec4 res = texture(input_images[%i], pos.yx); ,i);
104+ GLSLF(2, imageStore(output_images[%i], pos, res); ,i);
96105 GLSLC(1, } );
97106 }
98107 GLSLC(0, } );
@@ -279,7 +288,15 @@ fail: · 180 unmodified lines
279288 return err;
280289 }
281290
291+#define OFFSET(x) offsetof(TransposeVulkanContext, x)
292+#define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
293+
282294 static const AVOption transpose_vulkan_options[] = {
295+ { "dir", "set transpose direction", OFFSET(dir), AV_OPT_TYPE_INT, { .i64 = TRANSPOSE_CCLOCK_FLIP }, 0, 7, FLAGS, "dir" },
296+ { "cclock_flip", "rotate counter-clockwise with vertical flip", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK_FLIP }, .flags=FLAGS, .unit = "dir" },
297+ { "clock", "rotate clockwise", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK }, .flags=FLAGS, .unit = "dir" },
298+ { "cclock", "rotate counter-clockwise", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK }, .flags=FLAGS, .unit = "dir" },
299+ { "clock_flip", "rotate clockwise with vertical flip", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK_FLIP }, .flags=FLAGS, .unit = "dir" },
283300 { NULL }
284301 };
285302

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t