mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2024-12-05 00:05:25 +08:00
frontends/va: improve surface attribs processing
Instead of checking whether the attribute is settable for each
attrib type, check that once at the beginning of the loop.
Instead of having an if for each attrib type, use a switch.
Return an error if we encounter an unknown attribute. This allows
the caller to make sure settable attributes aren't ignored. The
intel media driver seems to just assert [1] that it doesn't encounter
unknown attributes.
[1]: 95d413e519/media_driver/linux/common/ddi/media_libva.cpp (L2530)
Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Leo Liu <leo.liu@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10104>
This commit is contained in:
parent
6c80b084f2
commit
ebab310987
@ -708,16 +708,16 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format,
|
||||
expected_fourcc = 0;
|
||||
|
||||
for (i = 0; i < num_attribs && attrib_list; i++) {
|
||||
if ((attrib_list[i].type == VASurfaceAttribPixelFormat) &&
|
||||
(attrib_list[i].flags & VA_SURFACE_ATTRIB_SETTABLE)) {
|
||||
if (!(attrib_list[i].flags & VA_SURFACE_ATTRIB_SETTABLE))
|
||||
continue;
|
||||
|
||||
switch (attrib_list[i].type) {
|
||||
case VASurfaceAttribPixelFormat:
|
||||
if (attrib_list[i].value.type != VAGenericValueTypeInteger)
|
||||
return VA_STATUS_ERROR_INVALID_PARAMETER;
|
||||
expected_fourcc = attrib_list[i].value.value.i;
|
||||
}
|
||||
|
||||
if ((attrib_list[i].type == VASurfaceAttribMemoryType) &&
|
||||
(attrib_list[i].flags & VA_SURFACE_ATTRIB_SETTABLE)) {
|
||||
|
||||
break;
|
||||
case VASurfaceAttribMemoryType:
|
||||
if (attrib_list[i].value.type != VAGenericValueTypeInteger)
|
||||
return VA_STATUS_ERROR_INVALID_PARAMETER;
|
||||
|
||||
@ -729,13 +729,14 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format,
|
||||
default:
|
||||
return VA_STATUS_ERROR_UNSUPPORTED_MEMORY_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
if ((attrib_list[i].type == VASurfaceAttribExternalBufferDescriptor) &&
|
||||
(attrib_list[i].flags == VA_SURFACE_ATTRIB_SETTABLE)) {
|
||||
break;
|
||||
case VASurfaceAttribExternalBufferDescriptor:
|
||||
if (attrib_list[i].value.type != VAGenericValueTypePointer)
|
||||
return VA_STATUS_ERROR_INVALID_PARAMETER;
|
||||
memory_attribute = (VASurfaceAttribExternalBuffers *)attrib_list[i].value.value.p;
|
||||
break;
|
||||
default:
|
||||
return VA_STATUS_ERROR_ATTR_NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user