From 0db9cd8aa54bd81c048cc2a4a29a75d254550cf9 Mon Sep 17 00:00:00 2001 From: Mark Thompson Date: Tue, 13 Feb 2018 19:44:54 +0000 Subject: [PATCH] Fix packed headers attribute test in vaCreateConfig() If packed headers are supported, then the provided value must be some (possibly empty) subset of the supported headers. This fixes config creation with an empty packed header set, which the user may pass if they don't want to provide any packed headers. This pattern is used in at least libavcodec, where VP9 encoding is broken prior to this change. Since there is intent to deprecate this behaviour in future, also add warnings to this case and the other possible failure modes here. Fixes #362. Signed-off-by: Mark Thompson --- src/i965_drv_video.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c index d87cdc158..0104a92f2 100644 --- a/src/i965_drv_video.c +++ b/src/i965_drv_video.c @@ -1432,8 +1432,21 @@ i965_CreateConfig(VADriverContextP ctx, if (attrib_found) { uint32_t enc_packed_attribs = i965_get_enc_packed_attributes(ctx, profile, entrypoint); - if (!(attrib_found->value & enc_packed_attribs)) + if (enc_packed_attribs == VA_ATTRIB_NOT_SUPPORTED) { + i965_log_info(ctx, "vaCreateConfig: invalid EncPackedHeaders attribute %#x: " + "packed headers are not supported.\n", attrib_found->value); vaStatus = VA_STATUS_ERROR_INVALID_VALUE; + } else if (attrib_found->value == 0) { + i965_log_info(ctx, "vaCreateConfig: setting the EncPackedHeaders attribute to zero to " + "indicate that no packed headers will be used is deprecated.\n"); + } else { + if (attrib_found->value & ~enc_packed_attribs) { + i965_log_info(ctx, "vaCreateConfig: invalid EncPackedHeaders attribute %#x: " + "some packed headers are not supported (supported set %#x).\n", + attrib_found->value, enc_packed_attribs); + vaStatus = VA_STATUS_ERROR_INVALID_VALUE; + } + } } }