Module: Mesa
Branch: main
Commit: 45a92f14b2c7dbe91ba3f1ff1ef456534045baec
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=45a92f14b2c7dbe91ba3f1ff1ef456534045baec

Author: Dave Airlie <[email protected]>
Date:   Tue May 30 10:59:07 2023 +1000

vk/video: add a common function to get block alignments for profiles

This is to be used by drivers for internal image alignments.

This just adds a common profile to alignment helper.

Cc: mesa-stable
Reviewed-by: Lynne <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23227>

---

 src/vulkan/runtime/vk_video.c | 19 +++++++++++++++++++
 src/vulkan/runtime/vk_video.h |  9 +++++++++
 2 files changed, 28 insertions(+)

diff --git a/src/vulkan/runtime/vk_video.c b/src/vulkan/runtime/vk_video.c
index 1348dfdca64..e9cc5ab5649 100644
--- a/src/vulkan/runtime/vk_video.c
+++ b/src/vulkan/runtime/vk_video.c
@@ -817,3 +817,22 @@ vk_video_parse_h265_slice_header(const struct 
VkVideoDecodeInfoKHR *frame_info,
    unsigned header_bits = (slice_size * 8 - 24 /* start code */) - 
vl_vlc_bits_left(&rbsp.nal);
    params->slice_data_bytes_offset = (header_bits + 8) / 8;
 }
+
+void
+vk_video_get_profile_alignments(const VkVideoProfileListInfoKHR *profile_list,
+                                uint32_t *width_align_out, uint32_t 
*height_align_out)
+{
+   uint32_t width_align = 1, height_align = 1;
+   for (unsigned i = 0; i < profile_list->profileCount; i++) {
+      if (profile_list->pProfiles[i].videoCodecOperation == 
VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR) {
+         width_align = MAX2(width_align, VK_VIDEO_H264_MACROBLOCK_WIDTH);
+         height_align = MAX2(height_align, VK_VIDEO_H264_MACROBLOCK_HEIGHT);
+      }
+      if (profile_list->pProfiles[i].videoCodecOperation == 
VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR) {
+         width_align = MAX2(width_align, VK_VIDEO_H265_CTU_MAX_WIDTH);
+         height_align = MAX2(height_align, VK_VIDEO_H265_CTU_MAX_HEIGHT);
+      }
+   }
+   *width_align_out = width_align;
+   *height_align_out = height_align;
+}
diff --git a/src/vulkan/runtime/vk_video.h b/src/vulkan/runtime/vk_video.h
index ebda196d503..d266339a052 100644
--- a/src/vulkan/runtime/vk_video.h
+++ b/src/vulkan/runtime/vk_video.h
@@ -178,6 +178,15 @@ void vk_fill_video_h265_reference_info(const 
VkVideoDecodeInfoKHR *frame_info,
                                        const struct vk_video_h265_slice_params 
*slice_params,
                                        struct vk_video_h265_reference 
ref_slots[][8]);
 
+#define VK_VIDEO_H264_MACROBLOCK_WIDTH 16
+#define VK_VIDEO_H264_MACROBLOCK_HEIGHT 16
+
+#define VK_VIDEO_H265_CTU_MAX_WIDTH 64
+#define VK_VIDEO_H265_CTU_MAX_HEIGHT 64
+
+void
+vk_video_get_profile_alignments(const VkVideoProfileListInfoKHR *profile_list,
+                                uint32_t *width_align_out, uint32_t 
*height_align_out);
 #ifdef __cplusplus
 }
 #endif

Reply via email to