radeon/vcn: clean the message buffers and their indexes logic

So the new buffer and index can be added sequentially.

Signed-off-by: Leo Liu <leo.liu@amd.com>
Reviewed-by: Boyuan Zhang <boyuan.zhang@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8851>
This commit is contained in:
Leo Liu 2021-02-02 21:22:00 -05:00
parent 5f6cd7bba9
commit 480d1436fe

View file

@ -1319,44 +1319,41 @@ static struct pb_buffer *rvcn_dec_message_decode(struct radeon_decoder *dec,
(struct si_texture *)((struct vl_video_buffer *)target)->resources[1];
ASSERTED struct si_screen *sscreen = (struct si_screen *)dec->screen;
rvcn_dec_message_header_t *header;
rvcn_dec_message_index_t *index_drm;
rvcn_dec_message_index_t *index;
rvcn_dec_message_index_t *index_codec;
rvcn_dec_message_index_t *index_drm = NULL;
rvcn_dec_message_decode_t *decode;
unsigned sizes = 0, offset_decode, offset_codec;
unsigned int offset_drm;
unsigned offset_drm = 0;
void *codec;
rvcn_dec_message_drm_t *drm = NULL;
header = dec->msg;
sizes += sizeof(rvcn_dec_message_header_t);
index_codec = (void*)header + sizes;
sizes += sizeof(rvcn_dec_message_index_t);
if (encrypted) {
index_drm = (void*)header + sizeof(rvcn_dec_message_header_t);
sizes += sizeof(rvcn_dec_message_index_t);
index = (void*)index_drm + sizeof(rvcn_dec_message_index_t);
sizes += sizeof(rvcn_dec_message_index_t);
} else {
index = (void*)header + sizeof(rvcn_dec_message_header_t);
index_drm = (void*)header + sizes;
sizes += sizeof(rvcn_dec_message_index_t);
}
offset_decode = sizes;
decode = (void *)index + sizeof(rvcn_dec_message_index_t);
decode = (void*)header + sizes;
sizes += sizeof(rvcn_dec_message_decode_t);
if (encrypted) {
offset_drm = sizes;
drm = (void*)decode + sizeof(rvcn_dec_message_decode_t);
drm = (void*)header + sizes;
sizes += sizeof(rvcn_dec_message_drm_t);
codec = (void*)drm + sizeof(rvcn_dec_message_drm_t);
} else
codec = (void*)decode + sizeof(rvcn_dec_message_decode_t);
}
offset_codec = sizes;
codec = (void*)header + sizes;
memset(dec->msg, 0, sizes);
header->header_size = sizeof(rvcn_dec_message_header_t);
header->total_size = sizes;
if (encrypted)
header->num_buffers = 3;
else
header->num_buffers = 2;
header->msg_type = RDECODE_MSG_DECODE;
header->stream_handle = dec->stream_handle;
header->status_report_feedback_number = dec->frame_number;
@ -1365,17 +1362,21 @@ static struct pb_buffer *rvcn_dec_message_decode(struct radeon_decoder *dec,
header->index[0].offset = offset_decode;
header->index[0].size = sizeof(rvcn_dec_message_decode_t);
header->index[0].filled = 0;
header->num_buffers = 1;
index_codec->offset = offset_codec;
index_codec->size = sizeof(rvcn_dec_message_avc_t);
index_codec->filled = 0;
++header->num_buffers;
if (encrypted) {
index_drm->message_id = RDECODE_MESSAGE_DRM;
index_drm->offset = offset_drm;
index_drm->size = sizeof(rvcn_dec_message_drm_t);
index_drm->filled = 0;
++header->num_buffers;
}
index->offset = offset_codec;
index->size = sizeof(rvcn_dec_message_avc_t);
index->filled = 0;
decode->stream_type = dec->stream_type;
decode->decode_flags = 0;
decode->width_in_samples = dec->base.width;
@ -1536,7 +1537,7 @@ static struct pb_buffer *rvcn_dec_message_decode(struct radeon_decoder *dec,
case PIPE_VIDEO_FORMAT_MPEG4_AVC: {
rvcn_dec_message_avc_t avc = get_h264_msg(dec, (struct pipe_h264_picture_desc *)picture);
memcpy(codec, (void *)&avc, sizeof(rvcn_dec_message_avc_t));
index->message_id = RDECODE_MESSAGE_AVC;
index_codec->message_id = RDECODE_MESSAGE_AVC;
break;
}
case PIPE_VIDEO_FORMAT_HEVC: {
@ -1544,7 +1545,7 @@ static struct pb_buffer *rvcn_dec_message_decode(struct radeon_decoder *dec,
get_h265_msg(dec, target, (struct pipe_h265_picture_desc *)picture);
memcpy(codec, (void *)&hevc, sizeof(rvcn_dec_message_hevc_t));
index->message_id = RDECODE_MESSAGE_HEVC;
index_codec->message_id = RDECODE_MESSAGE_HEVC;
break;
}
case PIPE_VIDEO_FORMAT_VC1: {
@ -1556,7 +1557,7 @@ static struct pb_buffer *rvcn_dec_message_decode(struct radeon_decoder *dec,
decode->width_in_samples = align(decode->width_in_samples, 16) / 16;
decode->height_in_samples = align(decode->height_in_samples, 16) / 16;
}
index->message_id = RDECODE_MESSAGE_VC1;
index_codec->message_id = RDECODE_MESSAGE_VC1;
break;
}
case PIPE_VIDEO_FORMAT_MPEG12: {
@ -1564,7 +1565,7 @@ static struct pb_buffer *rvcn_dec_message_decode(struct radeon_decoder *dec,
get_mpeg2_msg(dec, (struct pipe_mpeg12_picture_desc *)picture);
memcpy(codec, (void *)&mpeg2, sizeof(rvcn_dec_message_mpeg2_vld_t));
index->message_id = RDECODE_MESSAGE_MPEG2_VLD;
index_codec->message_id = RDECODE_MESSAGE_MPEG2_VLD;
break;
}
case PIPE_VIDEO_FORMAT_MPEG4: {
@ -1572,7 +1573,7 @@ static struct pb_buffer *rvcn_dec_message_decode(struct radeon_decoder *dec,
get_mpeg4_msg(dec, (struct pipe_mpeg4_picture_desc *)picture);
memcpy(codec, (void *)&mpeg4, sizeof(rvcn_dec_message_mpeg4_asp_vld_t));
index->message_id = RDECODE_MESSAGE_MPEG4_ASP_VLD;
index_codec->message_id = RDECODE_MESSAGE_MPEG4_ASP_VLD;
break;
}
case PIPE_VIDEO_FORMAT_VP9: {
@ -1580,7 +1581,7 @@ static struct pb_buffer *rvcn_dec_message_decode(struct radeon_decoder *dec,
get_vp9_msg(dec, target, (struct pipe_vp9_picture_desc *)picture);
memcpy(codec, (void *)&vp9, sizeof(rvcn_dec_message_vp9_t));
index->message_id = RDECODE_MESSAGE_VP9;
index_codec->message_id = RDECODE_MESSAGE_VP9;
break;
}
case PIPE_VIDEO_FORMAT_AV1: {
@ -1588,7 +1589,7 @@ static struct pb_buffer *rvcn_dec_message_decode(struct radeon_decoder *dec,
get_av1_msg(dec, target, (struct pipe_av1_picture_desc *)picture);
memcpy(codec, (void *)&av1, sizeof(rvcn_dec_message_av1_t));
index->message_id = RDECODE_MESSAGE_AV1;
index_codec->message_id = RDECODE_MESSAGE_AV1;
if (dec->ctx.res == NULL) {
unsigned ctx_size = (9 + 4) * align(sizeof(rvcn_av1_hw_frame_context_t), 2048) +