PR #25888 opened by DmitriiGershenkop URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25888 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25888.patch
Add initial support for Video Processing Engine (VPE) as a hardware accelerator option for AMF VPP. To be merged after #25887 >From c3268e44ed0e67acd389fb651a93dbfbff7ab7d7 Mon Sep 17 00:00:00 2001 From: Dmitrii Gershenkop <[email protected]> Date: Mon, 9 Nov 2026 16:53:39 +0100 Subject: [PATCH] avfilter/vf_vpp_amf: add VPE hardware path Add initial support for Video Processing Engine (VPE) as a hardware accelerator option for AMF VPP. --- doc/filters.texi | 26 ++++++++++++++++++++++++++ libavfilter/vf_amf_common.h | 1 + libavfilter/vf_vpp_amf.c | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/doc/filters.texi b/doc/filters.texi index ec23628067a..eb6a97ef96a 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -26577,6 +26577,32 @@ BT.2020 @end table +@item acceleration + +Select the preference for the hardware acceleration between compute hardware +path and Video Processing Engine (VPE) hardware path. The accepted values are: +@table @samp + +@item compute +Explicitly use the compute path. + +@item vpe +Use the Video Processing Engine (VPE) hardware path, falling back to the +compute path if VPE is unavailable or the configuration is unsupported. + +@end table + +Note: + +VPE 1.0/1.1 hardware supports a limited set of pixel formats: +@itemize +@item +Supported input pixel formats: bgra, rgba, argb, nv12, p010 + +@item +Supported output pixel formats: bgra, rgba, argb, rgbaf16 +@end itemize + @item in_trc Override input transfer characteristics. diff --git a/libavfilter/vf_amf_common.h b/libavfilter/vf_amf_common.h index 9af3d2ddda9..5b44555f619 100644 --- a/libavfilter/vf_amf_common.h +++ b/libavfilter/vf_amf_common.h @@ -50,6 +50,7 @@ typedef struct AMFFilterContext { int fill; int fill_color; int keep_ratio; + int acceleration; AVMasteringDisplayMetadata *master_display; AVContentLightMetadata *light_meta; diff --git a/libavfilter/vf_vpp_amf.c b/libavfilter/vf_vpp_amf.c index 1369c400124..5bde07dd468 100644 --- a/libavfilter/vf_vpp_amf.c +++ b/libavfilter/vf_vpp_amf.c @@ -189,6 +189,35 @@ static int amf_filter_config_output(AVFilterLink *outlink) AMF_ASSIGN_PROPERTY_INT64(res, ctx->component, AMF_VIDEO_CONVERTER_OUTPUT_TRANSFER_CHARACTERISTIC, ctx->out_trc); } + if (ctx->acceleration != AMF_VIDEO_CONVERTER_ACCELERATION_DEFAULT) { + AMFCaps *converter_caps = NULL; + int vpe_available = 0; + int supported = 0; + + res = AMF_IFACE_CALL(ctx->component, GetCaps, &converter_caps); + if (res == AMF_OK && converter_caps) { + AMFVariantStruct var; + AMFVariantInit(&var); + + res = AMF_IFACE_CALL(converter_caps, GetProperty, AMF_VIDEO_CONVERTER_CAP_VPE_AVAILABILITY, &var); + if (res == AMF_OK) { + supported = 1; + vpe_available = var.boolValue; + } + AMF_IFACE_CALL(converter_caps, Release); + } + + if (!supported) { + av_log(avctx, AV_LOG_WARNING, "Acceleration selection is not supported by the AMF runtime, the compute path will be used.\n"); + } else if (ctx->acceleration == AMF_VIDEO_CONVERTER_ACCELERATION_VPE_PREFERRED && !vpe_available) { + av_log(avctx, AV_LOG_WARNING, "VPE is unavailable on this device, the compute path will be used.\n"); + } else { + AMF_ASSIGN_PROPERTY_INT64(res, ctx->component, AMF_VIDEO_CONVERTER_ACCELERATION_TYPE, ctx->acceleration); + if (res != AMF_OK) + av_log(avctx, AV_LOG_WARNING, "Failed to set requested acceleration type, error: %d\n", res); + } + } + res = ctx->component->pVtbl->Init(ctx->component, av_av_to_amf_format(in_format), inlink->w, inlink->h); AMF_RETURN_IF_FALSE(avctx, res == AMF_OK, AVERROR_UNKNOWN, "AMFConverter-Init() failed with error %d\n", res); @@ -256,6 +285,10 @@ static const AVOption vpp_amf_options[] = { { "force_divisible_by", "enforce that the output resolution is divisible by a defined integer when force_original_aspect_ratio is used", OFFSET(force_divisible_by), AV_OPT_TYPE_INT, { .i64 = 1}, 1, 256, FLAGS }, { "reset_sar", "reset SAR to 1 and scale to square pixels if scaling proportionally", OFFSET(reset_sar), AV_OPT_TYPE_BOOL, { .i64 = 0}, 0, 1, FLAGS }, + { "acceleration", "Preferred converter acceleration path", OFFSET(acceleration), AV_OPT_TYPE_INT, { .i64 = AMF_VIDEO_CONVERTER_ACCELERATION_DEFAULT }, AMF_VIDEO_CONVERTER_ACCELERATION_DEFAULT, AMF_VIDEO_CONVERTER_ACCELERATION_VPE_PREFERRED, FLAGS, "acceleration" }, + { "compute", "Compute", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_CONVERTER_ACCELERATION_COMPUTE }, 0, 0, FLAGS, "acceleration" }, + { "vpe", "VPE preferred", 0, AV_OPT_TYPE_CONST, { .i64 = AMF_VIDEO_CONVERTER_ACCELERATION_VPE_PREFERRED }, 0, 0, FLAGS, "acceleration" }, + { NULL }, }; -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
