frontends/va: Don't allow Render/EndPicture without BeginPicture

It's not valid to call RenderPicture and EndPicture without calling
BeginPicture or when BeginPicture fails. FFmpeg will however call
EndPicture when BeginPicture fails, so we need to handle this.
Use target_id, which is assigned in BeginPicture, as an indication
whether we are inside the Begin - End picture sequence.

Cc: mesa-stable
Reviewed-by: Ruijing Dong <ruijing.dong@amd.com>
(cherry picked from commit 42e765d48b)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32852>
This commit is contained in:
David Rosca
2024-12-17 12:11:00 +01:00
committed by Dylan Baker
parent e716ff323b
commit 6d33b742b0
2 changed files with 14 additions and 2 deletions

View File

@@ -2214,7 +2214,7 @@
"description": "frontends/va: Don't allow Render/EndPicture without BeginPicture",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View File

@@ -1005,6 +1005,11 @@ vlVaRenderPicture(VADriverContextP ctx, VAContextID context_id, VABufferID *buff
return VA_STATUS_ERROR_INVALID_CONTEXT;
}
if (!context->target_id) {
mtx_unlock(&drv->mutex);
return VA_STATUS_ERROR_OPERATION_FAILED;
}
/* Always process VAProtectedSliceDataBufferType first because it changes the state */
for (i = 0; i < num_buffers; ++i) {
vlVaBuffer *buf = handle_table_get(drv->htab, buffers[i]);
@@ -1155,6 +1160,14 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id)
return VA_STATUS_ERROR_INVALID_CONTEXT;
}
if (!context->target_id) {
mtx_unlock(&drv->mutex);
return VA_STATUS_ERROR_OPERATION_FAILED;
}
output_id = context->target_id;
context->target_id = 0;
if (!context->decoder) {
if (context->templat.profile != PIPE_VIDEO_PROFILE_UNKNOWN) {
mtx_unlock(&drv->mutex);
@@ -1166,7 +1179,6 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id)
return VA_STATUS_SUCCESS;
}
output_id = context->target_id;
out_target = &context->target;
apply_av1_fg = vlVaQueryApplyFilmGrainAV1(context, &output_id, &out_target);