radv/video: fix h265 decode with unaligned w/h

This is similiar to the h264 fix done previously.

Fixes decoding with the nvpro samples app and a test video.

Fixes: db62c38091 ("radv: add vcn h265 decode.")
Reviewed-by: Lynne <dev@lynne.ee>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28359>
This commit is contained in:
Dave Airlie 2024-03-25 14:23:08 +10:00 committed by Marge Bot
parent dcc2e596c1
commit 4fc2ab43c0

View file

@ -1032,7 +1032,10 @@ update_h265_scaling(void *it_ptr, const StdVideoH265ScalingLists *scaling_lists)
static rvcn_dec_message_hevc_t
get_h265_msg(struct radv_device *device, struct radv_video_session *vid, struct radv_video_session_params *params,
const struct VkVideoDecodeInfoKHR *frame_info, void *it_ptr)
const struct VkVideoDecodeInfoKHR *frame_info,
uint32_t *width_in_samples,
uint32_t *height_in_samples,
void *it_ptr)
{
rvcn_dec_message_hevc_t result;
int i, j;
@ -1064,6 +1067,8 @@ get_h265_msg(struct radv_device *device, struct radv_video_session *vid, struct
}
result.st_rps_bits = h265_pic_info->pStdPictureInfo->NumBitsForSTRefPicSetInSlice;
*width_in_samples = sps->pic_width_in_luma_samples;
*height_in_samples = sps->pic_height_in_luma_samples;
result.chroma_format = sps->chroma_format_idc;
result.bit_depth_luma_minus8 = sps->bit_depth_luma_minus8;
result.bit_depth_chroma_minus8 = sps->bit_depth_chroma_minus8;
@ -2216,7 +2221,10 @@ rvcn_dec_message_decode(struct radv_cmd_buffer *cmd_buffer, struct radv_video_se
}
case VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR: {
index_codec->size = sizeof(rvcn_dec_message_hevc_t);
rvcn_dec_message_hevc_t hevc = get_h265_msg(device, vid, params, frame_info, it_probs_ptr);
rvcn_dec_message_hevc_t hevc = get_h265_msg(device, vid, params, frame_info,
&decode->width_in_samples,
&decode->height_in_samples,
it_probs_ptr);
memcpy(codec, (void *)&hevc, sizeof(rvcn_dec_message_hevc_t));
index_codec->message_id = RDECODE_MESSAGE_HEVC;
break;
@ -2416,7 +2424,8 @@ get_uvd_h264_msg(struct radv_video_session *vid, struct radv_video_session_param
static struct ruvd_h265
get_uvd_h265_msg(struct radv_device *device, struct radv_video_session *vid, struct radv_video_session_params *params,
const struct VkVideoDecodeInfoKHR *frame_info, void *it_ptr)
const struct VkVideoDecodeInfoKHR *frame_info, uint32_t *width_in_samples,
uint32_t *height_in_samples, void *it_ptr)
{
struct ruvd_h265 result;
int i, j;
@ -2444,6 +2453,8 @@ get_uvd_h265_msg(struct radv_device *device, struct radv_video_session *vid, str
if (device->physical_device->rad_info.family == CHIP_CARRIZO)
result.sps_info_flags |= 1 << 9;
*width_in_samples = sps->pic_width_in_luma_samples;
*height_in_samples = sps->pic_height_in_luma_samples;
result.chroma_format = sps->chroma_format_idc;
result.bit_depth_luma_minus8 = sps->bit_depth_luma_minus8;
result.bit_depth_chroma_minus8 = sps->bit_depth_chroma_minus8;
@ -2617,7 +2628,10 @@ ruvd_dec_message_decode(struct radv_device *device, struct radv_video_session *v
break;
}
case VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR: {
msg->body.decode.codec.h265 = get_uvd_h265_msg(device, vid, params, frame_info, it_ptr);
msg->body.decode.codec.h265 = get_uvd_h265_msg(device, vid, params, frame_info,
&msg->body.decode.width_in_samples,
&msg->body.decode.height_in_samples,
it_ptr);
if (vid->ctx.mem)
msg->body.decode.dpb_reserved = vid->ctx.size;