diff options
author | Wu Jianhua <jianhua.wu@intel.com> | 2022-01-12 12:41:33 +0800 |
---|---|---|
committer | Lynne <dev@lynne.ee> | 2022-02-22 05:46:06 +0100 |
commit | 8f470133f6304aae11c3c93053dd5982507ec0e8 (patch) | |
tree | fedb153a4b5f02412428a564d24206a3781f54d5 /libavfilter | |
parent | 0aa714244235f55cb31755cbda3714971082ff7d (diff) | |
download | ffmpeg-8f470133f6304aae11c3c93053dd5982507ec0e8.tar.gz |
avfilter/vf_blend_vulkan: add multiply blend mode
Use the commands below to test: (href: https://trac.ffmpeg.org/wiki/Blend)
I. make an image for test
ffmpeg -f lavfi -i color=s=256x256,geq=r='H-1-Y':g='H-1-Y':b='H-1-Y' -frames 1 \
-y -pix_fmt yuv420p test.jpg
II. blend in sw
ffmpeg -i test.jpg -vf "split[a][b];[b]transpose[b];[a][b]blend=all_mode=multiply,\
pseudocolor=preset=turbo" -y multiply_sw.jpg
III. blend in vulkan
ffmpeg -init_hw_device vulkan -i test.jpg -vf "split[a][b];[b]transpose[b];\
[a]hwupload[a];[b]hwupload[b];[a][b]blend_vulkan=all_mode=multiply,hwdownload,\
format=yuv420p,pseudocolor=preset=turbo" -y multiply_vulkan.jpg
Signed-off-by: Wu Jianhua <jianhua.wu@intel.com>
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/vf_blend_vulkan.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libavfilter/vf_blend_vulkan.c b/libavfilter/vf_blend_vulkan.c index f3560332b5..fcc21cbc8d 100644 --- a/libavfilter/vf_blend_vulkan.c +++ b/libavfilter/vf_blend_vulkan.c @@ -1,5 +1,5 @@ /* - * copyright (c) 2021 Wu Jianhua <jianhua.wu@intel.com> + * copyright (c) 2021-2022 Wu Jianhua <jianhua.wu@intel.com> * The blend modes are based on the blend.c. * * This file is part of FFmpeg. @@ -68,7 +68,10 @@ static const char blend_##MODE##_func[] = { \ #define A top #define B bottom +#define FN(EXPR) A + ((EXPR) - A) * opacity + DEFINE_BLEND_MODE(NORMAL, A * opacity + B * (1.0f - opacity)) +DEFINE_BLEND_MODE(MULTIPLY, FN(1.0f * A * B / 1.0f)) static inline void init_blend_func(FilterParamsVulkan *param) { @@ -79,6 +82,7 @@ static inline void init_blend_func(FilterParamsVulkan *param) switch (param->mode) { CASE(NORMAL) + CASE(MULTIPLY) default: param->blend = NULL; break; } @@ -448,7 +452,8 @@ static const AVOption blend_vulkan_options[] = { { "c2_mode", "set component #2 blend mode", OFFSET(params[2].mode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, BLEND_NB - 1, FLAGS, "mode" }, { "c3_mode", "set component #3 blend mode", OFFSET(params[3].mode), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, BLEND_NB - 1, FLAGS, "mode" }, { "all_mode", "set blend mode for all components", OFFSET(all_mode), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, BLEND_NB - 1, FLAGS, "mode" }, - { "normal", "", 0, AV_OPT_TYPE_CONST, { .i64 = BLEND_NORMAL }, 0, 0, FLAGS, "mode" }, + { "normal", "", 0, AV_OPT_TYPE_CONST, { .i64 = BLEND_NORMAL }, 0, 0, FLAGS, "mode" }, + { "multiply", "", 0, AV_OPT_TYPE_CONST, { .i64 = BLEND_MULTIPLY }, 0, 0, FLAGS, "mode" }, { "c0_opacity", "set color component #0 opacity", OFFSET(params[0].opacity), AV_OPT_TYPE_DOUBLE, { .dbl = 1 }, 0, 1, FLAGS }, { "c1_opacity", "set color component #1 opacity", OFFSET(params[1].opacity), AV_OPT_TYPE_DOUBLE, { .dbl = 1 }, 0, 1, FLAGS }, |