[FFmpeg-devel] [PATCH v2] vulkan_h264: fill correct ScalingList8x8 entries

Benjamin Cheng ben at bcheng.me
Tue Aug 1 17:18:01 EEST 2023


The Vulkan spec wants ScalingList8x8 as defined by ITU spec, which is in
a different order from how ffmpeg parses it.
---
 libavcodec/vulkan_h264.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/libavcodec/vulkan_h264.c b/libavcodec/vulkan_h264.c
index 84bcef7933..9d4ffa1f9d 100644
--- a/libavcodec/vulkan_h264.c
+++ b/libavcodec/vulkan_h264.c
@@ -43,6 +43,9 @@ typedef struct H264VulkanDecodePicture {
     VkVideoDecodeH264PictureInfoKHR h264_pic_info;
 } H264VulkanDecodePicture;
 
+const static int h264_scaling_list8_order[] = { 0, 3, 1, 4, 2, 5 };
+
+
 static int vk_h264_fill_pict(AVCodecContext *avctx, H264Picture **ref_src,
                              VkVideoReferenceSlotInfoKHR *ref_slot,       /* Main structure */
                              VkVideoPictureResourceInfoKHR *ref,          /* Goes in ^ */
@@ -147,9 +150,9 @@ static void set_sps(const SPS *sps,
                STD_VIDEO_H264_SCALING_LIST_4X4_NUM_ELEMENTS * sizeof(**sps->scaling_matrix4));
 
     for (int i = 0; i < STD_VIDEO_H264_SCALING_LIST_8X8_NUM_LISTS; i++)
-        memcpy(vksps_scaling->ScalingList8x8[i], sps->scaling_matrix8[i],
+        memcpy(vksps_scaling->ScalingList8x8[i], sps->scaling_matrix8[h264_scaling_list8_order[i]],
                STD_VIDEO_H264_SCALING_LIST_8X8_NUM_ELEMENTS * sizeof(**sps->scaling_matrix8));
-
+    
     *vksps_vui_header = (StdVideoH264HrdParameters) {
         .cpb_cnt_minus1 = sps->cpb_cnt - 1,
         .bit_rate_scale = sps->bit_rate_scale,
@@ -252,7 +255,7 @@ static void set_pps(const PPS *pps, const SPS *sps,
                STD_VIDEO_H264_SCALING_LIST_4X4_NUM_ELEMENTS * sizeof(**pps->scaling_matrix4));
 
     for (int i = 0; i < STD_VIDEO_H264_SCALING_LIST_8X8_NUM_LISTS; i++)
-        memcpy(vkpps_scaling->ScalingList8x8[i], pps->scaling_matrix8[i],
+        memcpy(vkpps_scaling->ScalingList8x8[i], pps->scaling_matrix8[h264_scaling_list8_order[i]],
                STD_VIDEO_H264_SCALING_LIST_8X8_NUM_ELEMENTS * sizeof(**pps->scaling_matrix8));
 
     *vkpps = (StdVideoH264PictureParameterSet) {
-- 
2.41.0



More information about the ffmpeg-devel mailing list