frontends/va: Move slice_data_offset to context

Before it only worked correctly if application sends all data/parameter
buffers in one RenderPicture call, which most applications do but it's
also valid to use multiple RenderPicture calls.

Reviewed-by: Ruijing Dong <ruijing.dong@amd.com>
Reviewed-by: Boyuan Zhang <Boyuan.Zhang@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30011>
This commit is contained in:
David Rosca 2024-07-02 14:41:00 +02:00 committed by Marge Bot
parent 7b6749224f
commit e0c15579f3
3 changed files with 11 additions and 8 deletions

View file

@ -136,6 +136,8 @@ vlVaBeginPicture(VADriverContextP ctx, VAContextID context_id, VASurfaceID rende
if (context->decoder->entrypoint != PIPE_VIDEO_ENTRYPOINT_ENCODE)
context->needs_begin_frame = true;
context->slice_data_offset = 0;
mtx_unlock(&drv->mutex);
return VA_STATUS_SUCCESS;
}
@ -299,7 +301,7 @@ handleIQMatrixBuffer(vlVaContext *context, vlVaBuffer *buf)
}
static void
handleSliceParameterBuffer(vlVaContext *context, vlVaBuffer *buf, unsigned slice_offset)
handleSliceParameterBuffer(vlVaContext *context, vlVaBuffer *buf)
{
switch (u_reduce_video_profile(context->templat.profile)) {
case PIPE_VIDEO_FORMAT_MPEG12:
@ -331,7 +333,7 @@ handleSliceParameterBuffer(vlVaContext *context, vlVaBuffer *buf, unsigned slice
break;
case PIPE_VIDEO_FORMAT_AV1:
vlVaHandleSliceParameterBufferAV1(context, buf, slice_offset);
vlVaHandleSliceParameterBufferAV1(context, buf);
break;
default:
@ -972,7 +974,6 @@ vlVaRenderPicture(VADriverContextP ctx, VAContextID context_id, VABufferID *buff
unsigned i;
unsigned slice_idx = 0;
unsigned slice_offset = 0;
vlVaBuffer *seq_param_buf = NULL;
if (!ctx)
@ -1022,14 +1023,14 @@ vlVaRenderPicture(VADriverContextP ctx, VAContextID context_id, VABufferID *buff
break;
case VASliceParameterBufferType:
handleSliceParameterBuffer(context, buf, slice_offset);
handleSliceParameterBuffer(context, buf);
slice_idx += buf->num_elements;
break;
case VASliceDataBufferType:
vaStatus = handleVASliceDataBufferType(context, buf);
if (slice_idx)
slice_offset += buf->size;
context->slice_data_offset += buf->size;
break;
case VAProcPipelineParameterBufferType:

View file

@ -396,7 +396,7 @@ void vlVaHandlePictureParameterBufferAV1(vlVaDriver *drv, vlVaContext *context,
context->desc.av1.slice_parameter.slice_count = 0;
}
void vlVaHandleSliceParameterBufferAV1(vlVaContext *context, vlVaBuffer *buf, unsigned slice_offset)
void vlVaHandleSliceParameterBufferAV1(vlVaContext *context, vlVaBuffer *buf)
{
VASliceParameterBufferAV1 *av1 = buf->data;
@ -407,7 +407,8 @@ void vlVaHandleSliceParameterBufferAV1(vlVaContext *context, vlVaBuffer *buf, un
assert(slice_index < max_pipe_av1_slices);
context->desc.av1.slice_parameter.slice_data_size[slice_index] = av1->slice_data_size;
context->desc.av1.slice_parameter.slice_data_offset[slice_index] = slice_offset + av1->slice_data_offset;
context->desc.av1.slice_parameter.slice_data_offset[slice_index] =
context->slice_data_offset + av1->slice_data_offset;
context->desc.av1.slice_parameter.slice_data_row[slice_index] = av1->tile_row;
context->desc.av1.slice_parameter.slice_data_col[slice_index] = av1->tile_column;
context->desc.av1.slice_parameter.slice_data_anchor_frame_idx[slice_index] = av1->anchor_frame_idx;

View file

@ -386,6 +386,7 @@ typedef struct {
int packed_header_type;
bool packed_header_emulation_bytes;
struct set *surfaces;
unsigned slice_data_offset;
struct {
void **buffers;
@ -556,7 +557,7 @@ void vlVaHandlePictureParameterBufferVP9(vlVaDriver *drv, vlVaContext *context,
void vlVaHandleSliceParameterBufferVP9(vlVaContext *context, vlVaBuffer *buf);
void vlVaDecoderVP9BitstreamHeader(vlVaContext *context, vlVaBuffer *buf);
void vlVaHandlePictureParameterBufferAV1(vlVaDriver *drv, vlVaContext *context, vlVaBuffer *buf);
void vlVaHandleSliceParameterBufferAV1(vlVaContext *context, vlVaBuffer *buf, unsigned slice_offset);
void vlVaHandleSliceParameterBufferAV1(vlVaContext *context, vlVaBuffer *buf);
void getEncParamPresetH264(vlVaContext *context);
void getEncParamPresetH265(vlVaContext *context);
void getEncParamPresetAV1(vlVaContext *context);