From b4f0701358604df5283b6e2942dfbc9421cb19d4 Mon Sep 17 00:00:00 2001 From: Benjamin Cheng Date: Mon, 21 Aug 2023 10:05:03 -0400 Subject: [PATCH] vulkan_h264: send scaling lists in zig-zag order h264_ps turns the scaling lists into matrices with a raster scan order, but Vulkan wants the scaling lists as originally defined. --- libavcodec/vulkan_h264.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/libavcodec/vulkan_h264.c b/libavcodec/vulkan_h264.c index f38bb9057b..9fe0d194f5 100644 --- a/libavcodec/vulkan_h264.c +++ b/libavcodec/vulkan_h264.c @@ -145,12 +145,13 @@ static void set_sps(const SPS *sps, }; for (int i = 0; i < STD_VIDEO_H264_SCALING_LIST_4X4_NUM_LISTS; i++) - memcpy(vksps_scaling->ScalingList4x4[i], sps->scaling_matrix4[i], - STD_VIDEO_H264_SCALING_LIST_4X4_NUM_ELEMENTS * sizeof(**sps->scaling_matrix4)); + for (int j = 0; j < STD_VIDEO_H264_SCALING_LIST_4X4_NUM_ELEMENTS; j++) + vksps_scaling->ScalingList4x4[i][j] = sps->scaling_matrix4[i][ff_zigzag_scan[j]]; for (int i = 0; i < STD_VIDEO_H264_SCALING_LIST_8X8_NUM_LISTS; 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)); + for (int j = 0; j < STD_VIDEO_H264_SCALING_LIST_8X8_NUM_ELEMENTS; j++) + vksps_scaling->ScalingList8x8[i][j] = + sps->scaling_matrix8[h264_scaling_list8_order[i]][ff_zigzag_direct[j]]; *vksps_vui_header = (StdVideoH264HrdParameters) { .cpb_cnt_minus1 = sps->cpb_cnt - 1, @@ -250,12 +251,13 @@ static void set_pps(const PPS *pps, const SPS *sps, }; for (int i = 0; i < STD_VIDEO_H264_SCALING_LIST_4X4_NUM_LISTS; i++) - memcpy(vkpps_scaling->ScalingList4x4[i], pps->scaling_matrix4[i], - STD_VIDEO_H264_SCALING_LIST_4X4_NUM_ELEMENTS * sizeof(**pps->scaling_matrix4)); + for (int j = 0; j < STD_VIDEO_H264_SCALING_LIST_4X4_NUM_ELEMENTS; j++) + vkpps_scaling->ScalingList4x4[i][j] = pps->scaling_matrix4[i][ff_zigzag_scan[j]]; for (int i = 0; i < STD_VIDEO_H264_SCALING_LIST_8X8_NUM_LISTS; 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)); + for (int j = 0; j < STD_VIDEO_H264_SCALING_LIST_8X8_NUM_ELEMENTS; j++) + vkpps_scaling->ScalingList8x8[i][j] = + pps->scaling_matrix8[h264_scaling_list8_order[i]][ff_zigzag_direct[j]]; *vkpps = (StdVideoH264PictureParameterSet) { .seq_parameter_set_id = pps->sps_id,