summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2014-05-09 17:55:05 +0200
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2014-06-02 19:30:43 +0200
commit9200fe231e1ffe249e17c8146303eeae6338aa06 (patch)
tree1b47d81c0f4ee1eb68ee350ff75ef128e7d93f7f
parent0f2e2a97a33881ab3a7f0c079391651c8a0fca78 (diff)
config: fix vaCreateConfig() to not override user chroma format.
Only validate the user-defined chroma format (VAConfigAttribRTFormat) attribute, if any. Don't override it. i.e. append a pre-defined value only if it was not defined by the user beforehand. Propertly return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT if the supplied chroma format is not supported. Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
-rwxr-xr-xsrc/i965_drv_video.c90
1 files changed, 66 insertions, 24 deletions
diff --git a/src/i965_drv_video.c b/src/i965_drv_video.c
index 15d65e5..1d4a65c 100755
--- a/src/i965_drv_video.c
+++ b/src/i965_drv_video.c
@@ -438,6 +438,20 @@ i965_validate_config(VADriverContextP ctx, VAProfile profile,
return va_status;
}
+static uint32_t
+i965_get_default_chroma_formats(VADriverContextP ctx, VAProfile profile,
+ VAEntrypoint entrypoint)
+{
+ struct i965_driver_data * const i965 = i965_driver_data(ctx);
+ uint32_t chroma_formats = VA_RT_FORMAT_YUV420;
+
+ switch (profile) {
+ default:
+ break;
+ }
+ return chroma_formats;
+}
+
VAStatus
i965_GetConfigAttributes(VADriverContextP ctx,
VAProfile profile,
@@ -457,7 +471,8 @@ i965_GetConfigAttributes(VADriverContextP ctx,
for (i = 0; i < num_attribs; i++) {
switch (attrib_list[i].type) {
case VAConfigAttribRTFormat:
- attrib_list[i].value = VA_RT_FORMAT_YUV420;
+ attrib_list[i].value = i965_get_default_chroma_formats(ctx,
+ profile, entrypoint);
break;
case VAConfigAttribRateControl:
@@ -498,29 +513,49 @@ i965_destroy_config(struct object_heap *heap, struct object_base *obj)
object_heap_free(heap, obj);
}
-static VAStatus
-i965_update_attribute(struct object_config *obj_config, VAConfigAttrib *attrib)
+static VAConfigAttrib *
+i965_lookup_config_attribute(struct object_config *obj_config,
+ VAConfigAttribType type)
{
int i;
- /* Check existing attrbiutes */
for (i = 0; i < obj_config->num_attribs; i++) {
- if (obj_config->attrib_list[i].type == attrib->type) {
- /* Update existing attribute */
- obj_config->attrib_list[i].value = attrib->value;
- return VA_STATUS_SUCCESS;
- }
+ VAConfigAttrib * const attrib = &obj_config->attrib_list[i];
+ if (attrib->type == type)
+ return attrib;
}
+ return NULL;
+}
- if (obj_config->num_attribs < I965_MAX_CONFIG_ATTRIBUTES) {
- i = obj_config->num_attribs;
- obj_config->attrib_list[i].type = attrib->type;
- obj_config->attrib_list[i].value = attrib->value;
- obj_config->num_attribs++;
+static VAStatus
+i965_append_config_attribute(struct object_config *obj_config,
+ const VAConfigAttrib *new_attrib)
+{
+ VAConfigAttrib *attrib;
+
+ if (obj_config->num_attribs >= I965_MAX_CONFIG_ATTRIBUTES)
+ return VA_STATUS_ERROR_MAX_NUM_EXCEEDED;
+
+ attrib = &obj_config->attrib_list[obj_config->num_attribs++];
+ attrib->type = new_attrib->type;
+ attrib->value = new_attrib->value;
+ return VA_STATUS_SUCCESS;
+}
+
+static VAStatus
+i965_ensure_config_attribute(struct object_config *obj_config,
+ const VAConfigAttrib *new_attrib)
+{
+ VAConfigAttrib *attrib;
+
+ /* Check for existing attributes */
+ attrib = i965_lookup_config_attribute(obj_config, new_attrib->type);
+ if (attrib) {
+ /* Update existing attribute */
+ attrib->value = new_attrib->value;
return VA_STATUS_SUCCESS;
}
-
- return VA_STATUS_ERROR_MAX_NUM_EXCEEDED;
+ return i965_append_config_attribute(obj_config, new_attrib);
}
VAStatus
@@ -552,16 +587,23 @@ i965_CreateConfig(VADriverContextP ctx,
obj_config->profile = profile;
obj_config->entrypoint = entrypoint;
- obj_config->attrib_list[0].type = VAConfigAttribRTFormat;
- obj_config->attrib_list[0].value = VA_RT_FORMAT_YUV420;
- obj_config->num_attribs = 1;
+ obj_config->num_attribs = 0;
- for(i = 0; i < num_attribs; i++) {
- vaStatus = i965_update_attribute(obj_config, &(attrib_list[i]));
-
- if (VA_STATUS_SUCCESS != vaStatus) {
+ for (i = 0; i < num_attribs; i++) {
+ vaStatus = i965_ensure_config_attribute(obj_config, &attrib_list[i]);
+ if (vaStatus != VA_STATUS_SUCCESS)
break;
- }
+ }
+
+ if (vaStatus == VA_STATUS_SUCCESS) {
+ VAConfigAttrib attrib, *attrib_found;
+ attrib.type = VAConfigAttribRTFormat;
+ attrib.value = i965_get_default_chroma_formats(ctx, profile, entrypoint);
+ attrib_found = i965_lookup_config_attribute(obj_config, attrib.type);
+ if (!attrib_found || !attrib_found->value)
+ vaStatus = i965_append_config_attribute(obj_config, &attrib);
+ else if (!(attrib_found->value & attrib.value))
+ vaStatus = VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;
}
/* Error recovery */