[FFmpeg-devel] [PATCH v4 5/5] hwcontext_vaapi: Deprecate quirks
Mark Thompson
sw at jkqxz.net
Sun May 5 22:01:47 EEST 2024
These only apply to obsolete drivers which do not work with the
now-required libva 2.x.
---
libavutil/hwcontext_vaapi.c | 123 ++++++++++--------------------------
libavutil/hwcontext_vaapi.h | 15 +++++
2 files changed, 50 insertions(+), 88 deletions(-)
diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
index caff43d1ae..8591fb88ac 100644
--- a/libavutil/hwcontext_vaapi.c
+++ b/libavutil/hwcontext_vaapi.c
@@ -243,8 +243,7 @@ static int vaapi_frames_get_constraints(AVHWDeviceContext *hwdev,
unsigned int fourcc;
int err, i, j, attr_count, pix_fmt_count;
- if (config &&
- !(hwctx->driver_quirks & AV_VAAPI_DRIVER_QUIRK_SURFACE_ATTRIBUTES)) {
+ if (config) {
attr_count = 0;
vas = vaQuerySurfaceAttributes(hwctx->display, config->config_id,
0, &attr_count);
@@ -367,23 +366,6 @@ fail:
return err;
}
-static const struct {
- const char *friendly_name;
- const char *match_string;
- unsigned int quirks;
-} vaapi_driver_quirks_table[] = {
- {
- "Intel iHD",
- "ubit",
- AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE,
- },
- {
- "VDPAU wrapper",
- "Splitted-Desktop Systems VDPAU backend for VA-API",
- AV_VAAPI_DRIVER_QUIRK_SURFACE_ATTRIBUTES,
- },
-};
-
static int vaapi_device_init(AVHWDeviceContext *hwdev)
{
VAAPIDeviceContext *ctx = hwdev->hwctx;
@@ -436,36 +418,6 @@ static int vaapi_device_init(AVHWDeviceContext *hwdev)
if (vendor_string)
av_log(hwdev, AV_LOG_VERBOSE, "VAAPI driver: %s.\n", vendor_string);
- if (hwctx->driver_quirks & AV_VAAPI_DRIVER_QUIRK_USER_SET) {
- av_log(hwdev, AV_LOG_VERBOSE, "Using quirks set by user (%#x).\n",
- hwctx->driver_quirks);
- } else {
- // Detect the driver in use and set quirk flags if necessary.
- hwctx->driver_quirks = 0;
- if (vendor_string) {
- for (i = 0; i < FF_ARRAY_ELEMS(vaapi_driver_quirks_table); i++) {
- if (strstr(vendor_string,
- vaapi_driver_quirks_table[i].match_string)) {
- av_log(hwdev, AV_LOG_VERBOSE, "Matched driver string "
- "as known nonstandard driver \"%s\", setting "
- "quirks (%#x).\n",
- vaapi_driver_quirks_table[i].friendly_name,
- vaapi_driver_quirks_table[i].quirks);
- hwctx->driver_quirks |=
- vaapi_driver_quirks_table[i].quirks;
- break;
- }
- }
- if (!(i < FF_ARRAY_ELEMS(vaapi_driver_quirks_table))) {
- av_log(hwdev, AV_LOG_VERBOSE, "Driver not found in known "
- "nonstandard list, using standard behaviour.\n");
- }
- } else {
- av_log(hwdev, AV_LOG_VERBOSE, "Driver has no vendor string, "
- "assuming standard behaviour.\n");
- }
- }
-
av_free(image_list);
return 0;
fail:
@@ -562,48 +514,43 @@ static int vaapi_frames_init(AVHWFramesContext *hwfc)
}
if (!hwfc->pool) {
- if (!(hwctx->driver_quirks & AV_VAAPI_DRIVER_QUIRK_SURFACE_ATTRIBUTES)) {
- int need_memory_type = !(hwctx->driver_quirks & AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE);
- int need_pixel_format = 1;
- for (i = 0; i < avfc->nb_attributes; i++) {
- if (avfc->attributes[i].type == VASurfaceAttribMemoryType)
- need_memory_type = 0;
- if (avfc->attributes[i].type == VASurfaceAttribPixelFormat)
- need_pixel_format = 0;
- }
- ctx->nb_attributes =
- avfc->nb_attributes + need_memory_type + need_pixel_format;
+ int need_memory_type = 1;
+ int need_pixel_format = 1;
+ for (i = 0; i < avfc->nb_attributes; i++) {
+ if (avfc->attributes[i].type == VASurfaceAttribMemoryType)
+ need_memory_type = 0;
+ if (avfc->attributes[i].type == VASurfaceAttribPixelFormat)
+ need_pixel_format = 0;
+ }
+ ctx->nb_attributes =
+ avfc->nb_attributes + need_memory_type + need_pixel_format;
- ctx->attributes = av_malloc(ctx->nb_attributes *
- sizeof(*ctx->attributes));
- if (!ctx->attributes) {
- err = AVERROR(ENOMEM);
- goto fail;
- }
+ ctx->attributes = av_malloc(ctx->nb_attributes *
+ sizeof(*ctx->attributes));
+ if (!ctx->attributes) {
+ err = AVERROR(ENOMEM);
+ goto fail;
+ }
- for (i = 0; i < avfc->nb_attributes; i++)
- ctx->attributes[i] = avfc->attributes[i];
- if (need_memory_type) {
- ctx->attributes[i++] = (VASurfaceAttrib) {
- .type = VASurfaceAttribMemoryType,
- .flags = VA_SURFACE_ATTRIB_SETTABLE,
- .value.type = VAGenericValueTypeInteger,
- .value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA,
- };
- }
- if (need_pixel_format) {
- ctx->attributes[i++] = (VASurfaceAttrib) {
- .type = VASurfaceAttribPixelFormat,
- .flags = VA_SURFACE_ATTRIB_SETTABLE,
- .value.type = VAGenericValueTypeInteger,
- .value.value.i = desc->fourcc,
- };
- }
- av_assert0(i == ctx->nb_attributes);
- } else {
- ctx->attributes = NULL;
- ctx->nb_attributes = 0;
+ for (i = 0; i < avfc->nb_attributes; i++)
+ ctx->attributes[i] = avfc->attributes[i];
+ if (need_memory_type) {
+ ctx->attributes[i++] = (VASurfaceAttrib) {
+ .type = VASurfaceAttribMemoryType,
+ .flags = VA_SURFACE_ATTRIB_SETTABLE,
+ .value.type = VAGenericValueTypeInteger,
+ .value.value.i = VA_SURFACE_ATTRIB_MEM_TYPE_VA,
+ };
+ }
+ if (need_pixel_format) {
+ ctx->attributes[i++] = (VASurfaceAttrib) {
+ .type = VASurfaceAttribPixelFormat,
+ .flags = VA_SURFACE_ATTRIB_SETTABLE,
+ .value.type = VAGenericValueTypeInteger,
+ .value.value.i = desc->fourcc,
+ };
}
+ av_assert0(i == ctx->nb_attributes);
ctx->rt_format = desc->rt_format;
diff --git a/libavutil/hwcontext_vaapi.h b/libavutil/hwcontext_vaapi.h
index 0b2e071cb3..acd72eee6d 100644
--- a/libavutil/hwcontext_vaapi.h
+++ b/libavutil/hwcontext_vaapi.h
@@ -37,18 +37,24 @@ enum {
/**
* The quirks field has been set by the user and should not be detected
* automatically by av_hwdevice_ctx_init().
+ *
+ * @deprecated Driver quirks are no longer used.
*/
AV_VAAPI_DRIVER_QUIRK_USER_SET = (1 << 0),
/**
* The driver does not destroy parameter buffers when they are used by
* vaRenderPicture(). Additional code will be required to destroy them
* separately afterwards.
+ *
+ * @deprecated Driver quirks are no longer used.
*/
AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS = (1 << 1),
/**
* The driver does not support the VASurfaceAttribMemoryType attribute,
* so the surface allocation code will not try to use it.
+ *
+ * @deprecated Driver quirks are no longer used.
*/
AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE = (1 << 2),
@@ -56,6 +62,8 @@ enum {
* The driver does not support surface attributes at all.
* The surface allocation code will never pass them to surface allocation,
* and the results of the vaQuerySurfaceAttributes() call will be faked.
+ *
+ * @deprecated Driver quirks are no longer used.
*/
AV_VAAPI_DRIVER_QUIRK_SURFACE_ATTRIBUTES = (1 << 3),
};
@@ -76,7 +84,14 @@ typedef struct AVVAAPIDeviceContext {
* AV_VAAPI_DRIVER_QUIRK_USER_SET bit is already present. The user
* may need to refer to this field when performing any later
* operations using VAAPI with the same VADisplay.
+ *
+ * @deprecated This was used with libva before the 2.x to support
+ * various drivers which had behaviour not fully
+ * matching the specification. Since libva 2.x this is
+ * no longer used; setting this field has no effect and
+ * new code must ignore it.
*/
+ attribute_deprecated
unsigned int driver_quirks;
} AVVAAPIDeviceContext;
--
2.43.0
More information about the ffmpeg-devel
mailing list