From: Mark Thompson <s...@jkqxz.net> These only apply to obsolete drivers which do not work with the now-required libva 2.x.
Signed-off-by: Fei Wang <fei.w.w...@intel.com> --- 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 c1a67a36c7..d9e9f70445 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.34.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".