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>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32677>
This commit is contained in:
David Rosca
2024-12-17 12:11:00 +01:00
committed by Marge Bot
parent 6e911cf252
commit 42e765d48b
+13 -1
View File
@@ -979,6 +979,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]);
@@ -1127,6 +1132,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);
@@ -1138,7 +1151,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);