mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-03 05:00:09 +01:00
frontends/va: Require protected context for VAProtectedSliceDataBuffer
Instead of switching the protected playback flag on when processing first VAProtectedSliceDataBuffer, require the context to be created as protected. Reviewed-by: David (Ming Qiang) Wu <David.Wu3@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33136>
This commit is contained in:
parent
33c47da3fe
commit
62919ef9d0
1 changed files with 20 additions and 26 deletions
|
|
@ -387,22 +387,25 @@ bufHasStartcode(vlVaBuffer *buf, unsigned int code, unsigned int bits)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
static VAStatus
|
||||
handleVAProtectedSliceDataBufferType(vlVaContext *context, vlVaBuffer *buf)
|
||||
{
|
||||
uint8_t* encrypted_data = (uint8_t*) buf->data;
|
||||
uint8_t* drm_key;
|
||||
uint8_t *encrypted_data = (uint8_t*)buf->data;
|
||||
uint8_t *drm_key;
|
||||
unsigned int drm_key_size = buf->size;
|
||||
|
||||
unsigned int drm_key_size = buf->size;
|
||||
if (!context->desc.base.protected_playback)
|
||||
return VA_STATUS_ERROR_INVALID_CONTEXT;
|
||||
|
||||
drm_key = REALLOC(context->desc.base.decrypt_key,
|
||||
context->desc.base.key_size, drm_key_size);
|
||||
if (!drm_key)
|
||||
return;
|
||||
context->desc.base.decrypt_key = drm_key;
|
||||
memcpy(context->desc.base.decrypt_key, encrypted_data, drm_key_size);
|
||||
context->desc.base.key_size = drm_key_size;
|
||||
context->desc.base.protected_playback = true;
|
||||
drm_key = REALLOC(context->desc.base.decrypt_key,
|
||||
context->desc.base.key_size, drm_key_size);
|
||||
if (!drm_key)
|
||||
return VA_STATUS_ERROR_ALLOCATION_FAILED;
|
||||
context->desc.base.decrypt_key = drm_key;
|
||||
memcpy(context->desc.base.decrypt_key, encrypted_data, drm_key_size);
|
||||
context->desc.base.key_size = drm_key_size;
|
||||
|
||||
return VA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static VAStatus
|
||||
|
|
@ -479,8 +482,7 @@ handleVASliceDataBufferType(vlVaContext *context, vlVaBuffer *buf)
|
|||
context->bs.sizes[context->bs.num_buffers++] = context->mjpeg.slice_header_size;
|
||||
break;
|
||||
case PIPE_VIDEO_FORMAT_VP9:
|
||||
if (false == context->desc.base.protected_playback)
|
||||
vlVaDecoderVP9BitstreamHeader(context, buf);
|
||||
vlVaDecoderVP9BitstreamHeader(context, buf);
|
||||
break;
|
||||
case PIPE_VIDEO_FORMAT_AV1:
|
||||
break;
|
||||
|
|
@ -994,18 +996,6 @@ vlVaRenderPicture(VADriverContextP ctx, VAContextID context_id, VABufferID *buff
|
|||
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]);
|
||||
if (!buf) {
|
||||
mtx_unlock(&drv->mutex);
|
||||
return VA_STATUS_ERROR_INVALID_BUFFER;
|
||||
}
|
||||
|
||||
if (buf->type == VAProtectedSliceDataBufferType)
|
||||
handleVAProtectedSliceDataBufferType(context, buf);
|
||||
}
|
||||
|
||||
for (i = 0; i < num_buffers && vaStatus == VA_STATUS_SUCCESS; ++i) {
|
||||
vlVaBuffer *buf = handle_table_get(drv->htab, buffers[i]);
|
||||
if (!buf) {
|
||||
|
|
@ -1070,6 +1060,10 @@ vlVaRenderPicture(VADriverContextP ctx, VAContextID context_id, VABufferID *buff
|
|||
handleVAStatsStatisticsBufferType(ctx, context, buf);
|
||||
break;
|
||||
|
||||
case VAProtectedSliceDataBufferType:
|
||||
vaStatus = handleVAProtectedSliceDataBufferType(context, buf);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue