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
21#include "libavutil/opt.h"21#include "libavutil/opt.h"
22#include "vulkan_filter.h"22#include "vulkan_filter.h"
23#include "internal.h"23#include "internal.h"
24#include "transpose.h"
24 25
25#define CGS 3226#define CGS 32
26 27
@@ -33,6 +34,7 @@ typedef struct TransposeVulkanContext { · 6 unmodified lines
33 VkDescriptorImageInfo input_images[3];34 VkDescriptorImageInfo input_images[3];
34 VkDescriptorImageInfo output_images[3];35 VkDescriptorImageInfo output_images[3];
35 36
37 int dir;
36 int initialized;38 int initialized;
37} TransposeVulkanContext;39} TransposeVulkanContext;
38 40
@@ -86,13 +88,20 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) · 47 unmodified lines
86 GLSLC(0, void main() );88 GLSLC(0, void main() );
87 GLSLC(0, { );89 GLSLC(0, { );
88 GLSLC(1, ivec2 size; );90 GLSLC(1, ivec2 size; );
89 GLSLC(1, const ivec2 pos = ivec2(gl_GlobalInvocationID.xy); );91 GLSLC(1, ivec2 pos = ivec2(gl_GlobalInvocationID.xy); );
90 for (int i = 0; i < planes; i++) {92 for (int i = 0; i < planes; i++) {
91 GLSLC(0, );93 GLSLC(0, );
92 GLSLF(1, size = imageSize(output_images[%i]); ,i);94 GLSLF(1, size = imageSize(output_images[%i]); ,i);
93 GLSLC(1, if (IS_WITHIN(pos, size)) { );95 GLSLC(1, if (IS_WITHIN(pos, size)) { );
94 GLSLF(2, vec4 res = texture(input_images[%i], pos.yx); ,i);96 if (s->dir == TRANSPOSE_CCLOCK)
95 GLSLF(2, imageStore(output_images[%i], pos, res); ,i);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);
96 GLSLC(1, } );105 GLSLC(1, } );
97 }106 }
98 GLSLC(0, } );107 GLSLC(0, } );
@@ -279,7 +288,15 @@ fail: · 180 unmodified lines
279 return err;288 return err;
280}289}
281 290
291#define OFFSET(x) offsetof(TransposeVulkanContext, x)
292#define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
293
282static const AVOption transpose_vulkan_options[] = {294static 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" },
283 { NULL }300 { NULL }
284};301};
285 302

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