From d4f5fc709ed7ee3f7a5f4189d222bf754204a346 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 25 May 2023 09:37:39 +1000 Subject: [PATCH] radv/video: use correct h264 levels This should be set to the enum, ffmpeg has it wrong so far, but the sample decoder has it right. convert radv to the proper answer. Fixes: 1693c03a3963 ("radv/video: add initial h264 decoder for VCN") Reviewed-by: Bas Nieuwenhuizen Part-of: (cherry picked from commit ea2eade57b6a99d6db26d9571b3d2901e7106001) --- .pick_status.json | 2 +- src/amd/vulkan/radv_video.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 86b8dce9f2c..a899404eef6 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -589,7 +589,7 @@ "description": "radv/video: use correct h264 levels", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "1693c03a39630a43e179b84b6cb4dadba72721c0" }, diff --git a/src/amd/vulkan/radv_video.c b/src/amd/vulkan/radv_video.c index 8678a783807..a21e9138401 100644 --- a/src/amd/vulkan/radv_video.c +++ b/src/amd/vulkan/radv_video.c @@ -591,6 +591,15 @@ static void rvcn_dec_message_feedback(void *ptr) header->num_buffers = 0; } +static const uint8_t h264_levels[] = { 10, 11, 12, 13, 20, 21, 22, + 30, 31, 32, 40, 41, 42, + 50, 51, 52, 60, 61, 62 }; +static uint8_t get_h264_level(StdVideoH264LevelIdc level) +{ + assert (level <= STD_VIDEO_H264_LEVEL_IDC_6_2); + return h264_levels[level]; +} + static rvcn_dec_message_avc_t get_h264_msg(struct radv_video_session *vid, struct radv_video_session_params *params, const struct VkVideoDecodeInfoKHR *frame_info, @@ -629,7 +638,7 @@ static rvcn_dec_message_avc_t get_h264_msg(struct radv_video_session *vid, *height_in_samples = (sps->pic_height_in_map_units_minus1 + 1) * 16; if (!sps->flags.frame_mbs_only_flag) *height_in_samples *= 2; - result.level = sps->level_idc; + result.level = get_h264_level(sps->level_idc); result.sps_info_flags = 0; @@ -1094,7 +1103,7 @@ static struct ruvd_h264 get_uvd_h264_msg(struct radv_video_session *vid, *height_in_samples = (sps->pic_height_in_map_units_minus1 + 1) * 16; if (!sps->flags.frame_mbs_only_flag) *height_in_samples *= 2; - result.level = sps->level_idc; + result.level = get_h264_level(sps->level_idc); result.sps_info_flags = 0;