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
Unified · Split
| @@ -21,6 +21,7 @@ · 20 unmodified lines | ||
| 21 | 21 | #include "libavutil/opt.h" |
| 22 | 22 | #include "vulkan_filter.h" |
| 23 | 23 | #include "internal.h" |
| 24 | +#include "transpose.h" | |
| 24 | 25 | |
| 25 | 26 | #define CGS 32 |
| 26 | 27 | |
| @@ -33,6 +34,7 @@ typedef struct TransposeVulkanContext { · 6 unmodified lines | ||
| 33 | 34 | VkDescriptorImageInfo input_images[3]; |
| 34 | 35 | VkDescriptorImageInfo output_images[3]; |
| 35 | 36 | |
| 37 | + int dir; | |
| 36 | 38 | int initialized; |
| 37 | 39 | } TransposeVulkanContext; |
| 38 | 40 | |
| @@ -86,13 +88,20 @@ static av_cold int init_filter(AVFilterContext *ctx, AVFrame *in) · 47 unmodified lines | ||
| 86 | 88 | GLSLC(0, void main() ); |
| 87 | 89 | GLSLC(0, { ); |
| 88 | 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 | 92 | for (int i = 0; i < planes; i++) { |
| 91 | 93 | GLSLC(0, ); |
| 92 | − GLSLF(1, size = imageSize(output_images[%i]); ,i); | |
| 94 | + GLSLF(1, size = imageSize(output_images[%i]); ,i); | |
| 93 | 95 | 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); | |
| 96 | 105 | GLSLC(1, } ); |
| 97 | 106 | } |
| 98 | 107 | GLSLC(0, } ); |
| @@ -279,7 +288,15 @@ fail: · 180 unmodified lines | ||
| 279 | 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 | + | |
| 282 | 294 | 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" }, | |
| 283 | 300 | { NULL } |
| 284 | 301 | }; |
| 285 | 302 | |