Commit 40a5422339 for ffmpeg
commit 40a54223398d1ed0d120896ac05306891e7e8b92
Author: Dmitrii Gershenkop <bortengineer@protonmail.com>
Date: Mon Nov 9 16:53:39 2026 +0100
avfilter/vf_vpp_amf: add VPE hardware path
Add initial support for Video Processing Engine (VPE) as a hardware accelerator option for AMF VPP.
diff --git a/doc/filters.texi b/doc/filters.texi
index ec23628067..eb6a97ef96 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 9af3d2ddda..5b44555f61 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 1369c40012..5bde07dd46 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 },
};