Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Mark Thompson <sw@jkqxz.net>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH v5 2/2] hwcontext_vaapi: Deprecate quirks
Date: Wed,  5 Jun 2024 21:13:04 +0100
Message-ID: <20240605201310.2343779-2-sw@jkqxz.net> (raw)
In-Reply-To: <20240605201310.2343779-1-sw@jkqxz.net>

These only apply to obsolete drivers which do not work with the
now-required libva 2.x.
---
Fixed checkheaders.


 libavutil/hwcontext_vaapi.c | 123 ++++++++++--------------------------
 libavutil/hwcontext_vaapi.h |  17 +++++
 2 files changed, 52 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..91d13d1f16 100644
--- a/libavutil/hwcontext_vaapi.h
+++ b/libavutil/hwcontext_vaapi.h
@@ -21,6 +21,8 @@
 
 #include <va/va.h>
 
+#include "attributes.h"
+
 /**
  * @file
  * API-specific header for AV_HWDEVICE_TYPE_VAAPI.
@@ -37,18 +39,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 +64,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 +86,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

_______________________________________________
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".

  reply	other threads:[~2024-06-05 20:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-05 20:13 [FFmpeg-devel] [PATCH v5 1/2] configure, lavu, lavc, lavfi: Remove libva 1.x support Mark Thompson
2024-06-05 20:13 ` Mark Thompson [this message]
2024-06-12  2:55 ` Xiang, Haihao

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=20240605201310.2343779-2-sw@jkqxz.net \
    --to=sw@jkqxz.net \
    --cc=ffmpeg-devel@ffmpeg.org \
    /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