From: softworkz <ffmpegagent@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: softworkz <softworkz@hotmail.com> Subject: [FFmpeg-devel] [PATCH 08/11] avfilter/overlay_vaapi: precalculate blend_state, enable pixel alpha Date: Mon, 10 Oct 2022 10:54:38 +0000 Message-ID: <4fba07d9f978cdbad394c1ab4af763bcc2a2ad71.1665399281.git.ffmpegagent@gmail.com> (raw) In-Reply-To: <pull.42.ffstaging.FFmpeg.1665399281.ffmpegagent@gmail.com> From: softworkz <softworkz@hotmail.com> Signed-off-by: softworkz <softworkz@hotmail.com> --- libavfilter/vf_overlay_vaapi.c | 44 ++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_overlay_vaapi.c b/libavfilter/vf_overlay_vaapi.c index f4f9cc58ec..b2c254d9dd 100644 --- a/libavfilter/vf_overlay_vaapi.c +++ b/libavfilter/vf_overlay_vaapi.c @@ -36,6 +36,8 @@ typedef struct OverlayVAAPIContext { int overlay_ow; int overlay_oh; float alpha; + unsigned int blend_flags; + float blend_alpha; } OverlayVAAPIContext; static int overlay_vaapi_build_filter_params(AVFilterContext *avctx) @@ -246,8 +248,8 @@ static int overlay_vaapi_blend(FFFrameSync *fs) memcpy(&subpic_params, ¶ms, sizeof(subpic_params)); - blend_state.flags = VA_BLEND_GLOBAL_ALPHA; - blend_state.global_alpha = ctx->alpha; + blend_state.flags = ctx->blend_flags; + blend_state.global_alpha = ctx->blend_alpha; subpic_params.blend_state = &blend_state; subpic_params.surface = (VASurfaceID)(uintptr_t)input_overlay->data[3]; @@ -269,6 +271,43 @@ fail: return err; } +static int have_alpha_planar(AVFilterLink *link) +{ + enum AVPixelFormat pix_fmt = link->format; + const AVPixFmtDescriptor *desc; + AVHWFramesContext *fctx; + + if (link->format == AV_PIX_FMT_VAAPI) { + fctx = (AVHWFramesContext *)link->hw_frames_ctx->data; + pix_fmt = fctx->sw_format; + } + + desc = av_pix_fmt_desc_get(pix_fmt); + if (!desc) + return 0; + + return !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA); +} + +static int overlay_vaapi_config_input_overlay(AVFilterLink *inlink) +{ + AVFilterContext *avctx = inlink->dst; + OverlayVAAPIContext *ctx = avctx->priv; + + ctx->blend_flags = 0; + ctx->blend_alpha = 1.0f; + + if (ctx->alpha < 1.0f) { + ctx->blend_flags |= VA_BLEND_GLOBAL_ALPHA; + ctx->blend_alpha = ctx->alpha; + } + + if (have_alpha_planar(inlink)) + ctx->blend_flags |= VA_BLEND_PREMULTIPLIED_ALPHA; + + return 0; +} + static int overlay_vaapi_config_output(AVFilterLink *outlink) { AVFilterContext *avctx = outlink->src; @@ -353,6 +392,7 @@ static const AVFilterPad overlay_vaapi_inputs[] = { { .name = "overlay", .type = AVMEDIA_TYPE_VIDEO, + .config_props = overlay_vaapi_config_input_overlay, }, }; -- ffmpeg-codebot _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-10-10 10:56 UTC|newest] Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-10-10 10:54 [FFmpeg-devel] [PATCH 00/11] Fixes and Enhancements for VAAPI Overlay ffmpegagent 2022-10-10 10:54 ` [FFmpeg-devel] [PATCH 01/11] avfilter/overlay_vaapi: use FILTER_SINGLE_PIXFMT softworkz 2022-10-31 5:55 ` Xiang, Haihao 2022-10-10 10:54 ` [FFmpeg-devel] [PATCH 02/11] avfilter/overlay_vaapi: build filter params just once softworkz 2022-10-10 10:54 ` [FFmpeg-devel] [PATCH 03/11] avfilter/overlay_vaapi: remove double framesync init softworkz 2022-10-10 10:54 ` [FFmpeg-devel] [PATCH 04/11] avfilter/overlay_vaapi: handle secondary null input softworkz 2022-10-10 10:54 ` [FFmpeg-devel] [PATCH 05/11] avfilter/overlay_vaapi: reformat options softworkz 2022-10-10 10:54 ` [FFmpeg-devel] [PATCH 06/11] avfilter/overlay_vaapi: remove redundant .get_buffer assignments softworkz 2022-10-10 10:54 ` [FFmpeg-devel] [PATCH 07/11] avfilter/overlay_vaapi: add framesync options softworkz 2022-10-10 10:54 ` softworkz [this message] 2022-10-10 10:54 ` [FFmpeg-devel] [PATCH 09/11] avfilter/overlay_vaapi: enable expressions for overlay parameters softworkz 2022-10-31 5:43 ` Xiang, Haihao 2022-10-31 5:56 ` Soft Works 2022-10-10 10:54 ` [FFmpeg-devel] [PATCH 10/11] doc/filters.texi: remove incorrect statement softworkz 2022-10-10 10:54 ` [FFmpeg-devel] [PATCH 11/11] doc/filters.texi: update overlay_vaapi documentation softworkz 2022-10-10 11:08 ` Gyan Doshi 2022-10-10 11:25 ` Soft Works 2022-10-31 6:19 ` [FFmpeg-devel] [PATCH v2 00/11] Fixes and Enhancements for VAAPI Overlay ffmpegagent 2022-10-31 6:19 ` [FFmpeg-devel] [PATCH v2 01/11] avfilter/overlay_vaapi: use FILTER_SINGLE_PIXFMT softworkz 2022-11-04 2:07 ` Xiang, Haihao 2022-11-07 3:10 ` Xiang, Haihao 2022-10-31 6:19 ` [FFmpeg-devel] [PATCH v2 02/11] avfilter/overlay_vaapi: build filter params just once softworkz 2022-10-31 6:19 ` [FFmpeg-devel] [PATCH v2 03/11] avfilter/overlay_vaapi: remove double framesync init softworkz 2022-10-31 6:20 ` [FFmpeg-devel] [PATCH v2 04/11] avfilter/overlay_vaapi: handle secondary null input softworkz 2022-10-31 6:20 ` [FFmpeg-devel] [PATCH v2 05/11] avfilter/overlay_vaapi: reformat options softworkz 2022-10-31 6:20 ` [FFmpeg-devel] [PATCH v2 06/11] avfilter/overlay_vaapi: remove redundant .get_buffer assignments softworkz 2022-10-31 6:20 ` [FFmpeg-devel] [PATCH v2 07/11] avfilter/overlay_vaapi: add framesync options softworkz 2022-10-31 6:20 ` [FFmpeg-devel] [PATCH v2 08/11] avfilter/overlay_vaapi: precalculate blend_state, enable pixel alpha softworkz 2022-10-31 6:20 ` [FFmpeg-devel] [PATCH v2 09/11] avfilter/overlay_vaapi: enable expressions for overlay parameters softworkz 2022-10-31 6:20 ` [FFmpeg-devel] [PATCH v2 10/11] doc/filters.texi: remove incorrect statement softworkz 2022-10-31 6:20 ` [FFmpeg-devel] [PATCH v2 11/11] doc/filters.texi: update overlay_vaapi documentation softworkz
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=4fba07d9f978cdbad394c1ab4af763bcc2a2ad71.1665399281.git.ffmpegagent@gmail.com \ --to=ffmpegagent@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=softworkz@hotmail.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git