Commit 7f32f9dccc for ffmpeg
commit 7f32f9dccc74d6afedcf32fd5595b05b9c9eee69
Author: Anton Kesy <anton.kesy@intel.com>
Date: Thu Nov 19 13:16:14 2026 +0100
avfilter/vpp_qsv: add AI super resolution
Expose the default oneVPL AI super resolution mode without raising
FFmpeg's minimum build dependency. Gate the option on API 2.13, where
the extension became stable, and omit the ordinary VPP scaling
extension because oneVPL rejects the two together at initialization.
Signed-off-by: Anton Kesy <anton.kesy@intel.com>
diff --git a/doc/filters.texi b/doc/filters.texi
index 3a516bc1cb..5ccdae0a3d 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -30579,6 +30579,34 @@ To enable compilation of these filters you need to configure FFmpeg with
To use QSV filters, you need to setup the QSV device correctly. For more information, please read @url{https://trac.ffmpeg.org/wiki/Hardware/QuickSync}
+@section vpp_qsv
+Apply Quick Sync Video VPP filters.
+
+The following options are relevant to AI super resolution:
+
+@table @option
+@item ai_sr
+Enable AI super resolution. The default is disabled. The option is available
+in builds compiled with oneVPL 2.13 or later headers. It requires a runtime
+supporting API 2.13 or later and a QSV device that supports AI super
+resolution. Set @option{w} and @option{h} to the desired output dimensions.
+Supported scale factors, pixel formats and combinations with other VPP filters
+depend on the implementation.
+When @option{ai_sr} is enabled, @option{scale_mode} is ignored.
+
+@item w
+@item h
+Set the output width and height expressions. @option{w} defaults to @code{cw},
+the width of the input crop area, and @option{h} defaults to @code{w*ch/cw},
+which keeps the aspect ratio of the crop area. Setting only @option{w}
+therefore also changes @option{h}.
+@end table
+
+For example, to upscale a 960x540 NV12 input to 1920x1080:
+@example
+vpp_qsv=ai_sr=1:w=1920:h=1080
+@end example
+
@section hstack_qsv
Stack input videos horizontally.
diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 4de99d6490..112a66a0f5 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -58,6 +58,9 @@ typedef struct VPPContext{
mfxExtVPPRotation rotation_conf;
mfxExtVPPMirroring mirroring_conf;
mfxExtVPPScaling scale_conf;
+#if QSV_VERSION_ATLEAST(2, 13)
+ mfxExtVPPAISuperResolution ai_sr_conf;
+#endif
#if QSV_ONEVPL
/** Video signal info attached on the input frame */
mfxExtVideoSignalInfo invsi_conf;
@@ -122,6 +125,7 @@ typedef struct VPPContext{
int has_passthrough; /* apply pass through mode if possible */
int field_rate; /* Generate output at frame rate or field rate for deinterlace mode, 0: frame, 1: field */
int tonemap; /* 1: perform tonemapping if the input has HDR metadata, 0: always disable tonemapping */
+ int ai_sr;
} VPPContext;
static const char *const var_names[] = {
@@ -687,7 +691,25 @@ static int config_output(AVFilterLink *outlink)
}
}
- if (inlink->w != outlink->w || inlink->h != outlink->h || in_format != vpp->out_format) {
+#if QSV_VERSION_ATLEAST(2, 13)
+ if (vpp->ai_sr) {
+ if (!inl->hw_frames_ctx && !ctx->hw_device_ctx) {
+ av_log(ctx, AV_LOG_ERROR, "AI super resolution requires a QSV device context.\n");
+ return AVERROR(EINVAL);
+ }
+
+ if (!QSV_RUNTIME_VERSION_ATLEAST(mfx_version, 2, 13)) {
+ av_log(ctx, AV_LOG_ERROR, "AI super resolution requires a oneVPL 2.13 or newer runtime.\n");
+ return AVERROR(ENOSYS);
+ }
+
+ INIT_MFX_EXTBUF(ai_sr_conf, MFX_EXTBUFF_VPP_AI_SUPER_RESOLUTION);
+ SET_MFX_PARAM_FIELD(ai_sr_conf, SRMode, MFX_AI_SUPER_RESOLUTION_MODE_DEFAULT);
+ }
+#endif
+
+ if ((inlink->w != outlink->w || inlink->h != outlink->h || in_format != vpp->out_format) &&
+ !vpp->ai_sr) {
if (QSV_RUNTIME_VERSION_ATLEAST(mfx_version, 1, 19)) {
int mode = vpp->scale_mode;
@@ -708,6 +730,7 @@ static int config_output(AVFilterLink *outlink)
if (vpp->use_frc || vpp->use_crop || vpp->deinterlace || vpp->denoise ||
vpp->detail || vpp->procamp || vpp->rotate || vpp->hflip ||
+ vpp->ai_sr ||
inlink->w != outlink->w || inlink->h != outlink->h || in_format != vpp->out_format ||
vpp->color_range != AVCOL_RANGE_UNSPECIFIED ||
vpp->color_primaries != AVCOL_PRI_UNSPECIFIED ||
@@ -929,6 +952,10 @@ static const AVOption vpp_options[] = {
{"tonemap", "Perform tonemapping (0=disable tonemapping, 1=perform tonemapping if the input has HDR metadata)", OFFSET(tonemap), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, .flags = FLAGS},
+#if QSV_VERSION_ATLEAST(2, 13)
+ { "ai_sr", "Enable AI super resolution", OFFSET(ai_sr), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, .flags = FLAGS },
+#endif
+
{ NULL }
};