frontends/va: handle protected slice data buffer
Add a function to handle VaProtectedSliceDataBuffer, which is used for sending decryption parameters. Also, for protected playback, there is no need to check start code since data is encrypted. Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7006>
This commit is contained in:
parent
5f0816eac0
commit
deb7dc82f6
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#include "util/u_handle_table.h"
|
#include "util/u_handle_table.h"
|
||||||
#include "util/u_video.h"
|
#include "util/u_video.h"
|
||||||
|
#include "util/u_memory.h"
|
||||||
|
|
||||||
#include "vl/vl_vlc.h"
|
#include "vl/vl_vlc.h"
|
||||||
#include "vl/vl_winsys.h"
|
#include "vl/vl_winsys.h"
|
||||||
|
@ -261,6 +262,18 @@ bufHasStartcode(vlVaBuffer *buf, unsigned int code, unsigned int bits)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
handleVAProtectedSliceDataBufferType(vlVaContext *context, vlVaBuffer *buf)
|
||||||
|
{
|
||||||
|
uint8_t* encrypted_data = (uint8_t*) buf->data;
|
||||||
|
|
||||||
|
unsigned int drm_key_size = 56 * 4;
|
||||||
|
|
||||||
|
context->desc.base.decrypt_key = CALLOC(1, drm_key_size);
|
||||||
|
memcpy(context->desc.base.decrypt_key, encrypted_data, drm_key_size);
|
||||||
|
context->desc.base.protected_playback = true;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handleVASliceDataBufferType(vlVaContext *context, vlVaBuffer *buf)
|
handleVASliceDataBufferType(vlVaContext *context, vlVaBuffer *buf)
|
||||||
{
|
{
|
||||||
|
@ -274,50 +287,52 @@ handleVASliceDataBufferType(vlVaContext *context, vlVaBuffer *buf)
|
||||||
static const uint8_t eoi_jpeg[] = { 0xff, 0xd9 };
|
static const uint8_t eoi_jpeg[] = { 0xff, 0xd9 };
|
||||||
|
|
||||||
format = u_reduce_video_profile(context->templat.profile);
|
format = u_reduce_video_profile(context->templat.profile);
|
||||||
switch (format) {
|
if (!context->desc.base.protected_playback) {
|
||||||
case PIPE_VIDEO_FORMAT_MPEG4_AVC:
|
switch (format) {
|
||||||
if (bufHasStartcode(buf, 0x000001, 24))
|
case PIPE_VIDEO_FORMAT_MPEG4_AVC:
|
||||||
break;
|
if (bufHasStartcode(buf, 0x000001, 24))
|
||||||
|
break;
|
||||||
|
|
||||||
buffers[num_buffers] = (void *const)&start_code_h264;
|
buffers[num_buffers] = (void *const)&start_code_h264;
|
||||||
sizes[num_buffers++] = sizeof(start_code_h264);
|
sizes[num_buffers++] = sizeof(start_code_h264);
|
||||||
break;
|
|
||||||
case PIPE_VIDEO_FORMAT_HEVC:
|
|
||||||
if (bufHasStartcode(buf, 0x000001, 24))
|
|
||||||
break;
|
break;
|
||||||
|
case PIPE_VIDEO_FORMAT_HEVC:
|
||||||
|
if (bufHasStartcode(buf, 0x000001, 24))
|
||||||
|
break;
|
||||||
|
|
||||||
buffers[num_buffers] = (void *const)&start_code_h265;
|
buffers[num_buffers] = (void *const)&start_code_h265;
|
||||||
sizes[num_buffers++] = sizeof(start_code_h265);
|
sizes[num_buffers++] = sizeof(start_code_h265);
|
||||||
break;
|
|
||||||
case PIPE_VIDEO_FORMAT_VC1:
|
|
||||||
if (bufHasStartcode(buf, 0x0000010d, 32) ||
|
|
||||||
bufHasStartcode(buf, 0x0000010c, 32) ||
|
|
||||||
bufHasStartcode(buf, 0x0000010b, 32))
|
|
||||||
break;
|
break;
|
||||||
|
case PIPE_VIDEO_FORMAT_VC1:
|
||||||
|
if (bufHasStartcode(buf, 0x0000010d, 32) ||
|
||||||
|
bufHasStartcode(buf, 0x0000010c, 32) ||
|
||||||
|
bufHasStartcode(buf, 0x0000010b, 32))
|
||||||
|
break;
|
||||||
|
|
||||||
if (context->decoder->profile == PIPE_VIDEO_PROFILE_VC1_ADVANCED) {
|
if (context->decoder->profile == PIPE_VIDEO_PROFILE_VC1_ADVANCED) {
|
||||||
buffers[num_buffers] = (void *const)&start_code_vc1;
|
buffers[num_buffers] = (void *const)&start_code_vc1;
|
||||||
sizes[num_buffers++] = sizeof(start_code_vc1);
|
sizes[num_buffers++] = sizeof(start_code_vc1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PIPE_VIDEO_FORMAT_MPEG4:
|
||||||
|
if (bufHasStartcode(buf, 0x000001, 24))
|
||||||
|
break;
|
||||||
|
|
||||||
|
vlVaDecoderFixMPEG4Startcode(context);
|
||||||
|
buffers[num_buffers] = (void *)context->mpeg4.start_code;
|
||||||
|
sizes[num_buffers++] = context->mpeg4.start_code_size;
|
||||||
|
break;
|
||||||
|
case PIPE_VIDEO_FORMAT_JPEG:
|
||||||
|
vlVaGetJpegSliceHeader(context);
|
||||||
|
buffers[num_buffers] = (void *)context->mjpeg.slice_header;
|
||||||
|
sizes[num_buffers++] = context->mjpeg.slice_header_size;
|
||||||
|
break;
|
||||||
|
case PIPE_VIDEO_FORMAT_VP9:
|
||||||
|
vlVaDecoderVP9BitstreamHeader(context, buf);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case PIPE_VIDEO_FORMAT_MPEG4:
|
|
||||||
if (bufHasStartcode(buf, 0x000001, 24))
|
|
||||||
break;
|
|
||||||
|
|
||||||
vlVaDecoderFixMPEG4Startcode(context);
|
|
||||||
buffers[num_buffers] = (void *)context->mpeg4.start_code;
|
|
||||||
sizes[num_buffers++] = context->mpeg4.start_code_size;
|
|
||||||
break;
|
|
||||||
case PIPE_VIDEO_FORMAT_JPEG:
|
|
||||||
vlVaGetJpegSliceHeader(context);
|
|
||||||
buffers[num_buffers] = (void *)context->mjpeg.slice_header;
|
|
||||||
sizes[num_buffers++] = context->mjpeg.slice_header_size;
|
|
||||||
break;
|
|
||||||
case PIPE_VIDEO_FORMAT_VP9:
|
|
||||||
vlVaDecoderVP9BitstreamHeader(context, buf);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buffers[num_buffers] = buf->data;
|
buffers[num_buffers] = buf->data;
|
||||||
|
@ -531,6 +546,7 @@ vlVaRenderPicture(VADriverContextP ctx, VAContextID context_id, VABufferID *buff
|
||||||
return VA_STATUS_ERROR_INVALID_CONTEXT;
|
return VA_STATUS_ERROR_INVALID_CONTEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Always process VAProtectedSliceDataBufferType first because it changes the state */
|
||||||
for (i = 0; i < num_buffers; ++i) {
|
for (i = 0; i < num_buffers; ++i) {
|
||||||
vlVaBuffer *buf = handle_table_get(drv->htab, buffers[i]);
|
vlVaBuffer *buf = handle_table_get(drv->htab, buffers[i]);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
|
@ -538,6 +554,13 @@ vlVaRenderPicture(VADriverContextP ctx, VAContextID context_id, VABufferID *buff
|
||||||
return VA_STATUS_ERROR_INVALID_BUFFER;
|
return VA_STATUS_ERROR_INVALID_BUFFER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (buf->type == VAProtectedSliceDataBufferType)
|
||||||
|
handleVAProtectedSliceDataBufferType(context, buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < num_buffers; ++i) {
|
||||||
|
vlVaBuffer *buf = handle_table_get(drv->htab, buffers[i]);
|
||||||
|
|
||||||
switch (buf->type) {
|
switch (buf->type) {
|
||||||
case VAPictureParameterBufferType:
|
case VAPictureParameterBufferType:
|
||||||
vaStatus = handlePictureParameterBuffer(drv, context, buf);
|
vaStatus = handlePictureParameterBuffer(drv, context, buf);
|
||||||
|
@ -554,6 +577,7 @@ vlVaRenderPicture(VADriverContextP ctx, VAContextID context_id, VABufferID *buff
|
||||||
case VASliceDataBufferType:
|
case VASliceDataBufferType:
|
||||||
handleVASliceDataBufferType(context, buf);
|
handleVASliceDataBufferType(context, buf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VAProcPipelineParameterBufferType:
|
case VAProcPipelineParameterBufferType:
|
||||||
vaStatus = vlVaHandleVAProcPipelineParameterBufferType(drv, context, buf);
|
vaStatus = vlVaHandleVAProcPipelineParameterBufferType(drv, context, buf);
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue