Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] vulkan_h264: fill correct ScalingList8x8 entries
@ 2023-07-31 22:53 Benjamin Cheng
  0 siblings, 0 replies; only message in thread
From: Benjamin Cheng @ 2023-07-31 22:53 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Benjamin Cheng

The Vulkan spec wants ScalingList8x8 as defined by ITU spec. The latter
only defines ScalingList8x8[0] and ScalingList8x8[1] when
chroma_format_idc != 3.
---
 libavcodec/vulkan_h264.c | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/libavcodec/vulkan_h264.c b/libavcodec/vulkan_h264.c
index 84bcef7933..0d81ae8a3c 100644
--- a/libavcodec/vulkan_h264.c
+++ b/libavcodec/vulkan_h264.c
@@ -146,9 +146,17 @@ static void set_sps(const SPS *sps,
         memcpy(vksps_scaling->ScalingList4x4[i], sps->scaling_matrix4[i],
                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],
+    if (sps->chroma_format_idc == 3 /* yuv444 */) {
+        for (int i = 0; i < STD_VIDEO_H264_SCALING_LIST_8X8_NUM_LISTS; i++)
+            memcpy(vksps_scaling->ScalingList8x8[i], sps->scaling_matrix8[i],
+                   STD_VIDEO_H264_SCALING_LIST_8X8_NUM_ELEMENTS * sizeof(**sps->scaling_matrix8));
+    } else {
+        /* All other chroma formats have only 2 scaling 8x8 matrices. */
+        memcpy(vksps_scaling->ScalingList8x8[0], sps->scaling_matrix8[0],
                STD_VIDEO_H264_SCALING_LIST_8X8_NUM_ELEMENTS * sizeof(**sps->scaling_matrix8));
+        memcpy(vksps_scaling->ScalingList8x8[1], sps->scaling_matrix8[3],
+               STD_VIDEO_H264_SCALING_LIST_8X8_NUM_ELEMENTS * sizeof(**sps->scaling_matrix8));
+    }
 
     *vksps_vui_header = (StdVideoH264HrdParameters) {
         .cpb_cnt_minus1 = sps->cpb_cnt - 1,
@@ -251,9 +259,17 @@ static void set_pps(const PPS *pps, const SPS *sps,
         memcpy(vkpps_scaling->ScalingList4x4[i], pps->scaling_matrix4[i],
                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],
+    if (sps->chroma_format_idc == 3 /* yuv444 */) {
+        for (int i = 0; i < STD_VIDEO_H264_SCALING_LIST_8X8_NUM_LISTS; i++)
+            memcpy(vkpps_scaling->ScalingList8x8[i], pps->scaling_matrix8[i],
+                   STD_VIDEO_H264_SCALING_LIST_8X8_NUM_ELEMENTS * sizeof(**pps->scaling_matrix8));
+    } else {
+        /* All other chroma formats have only 2 scaling 8x8 matrices. */
+        memcpy(vkpps_scaling->ScalingList8x8[0], pps->scaling_matrix8[0],
                STD_VIDEO_H264_SCALING_LIST_8X8_NUM_ELEMENTS * sizeof(**pps->scaling_matrix8));
+        memcpy(vkpps_scaling->ScalingList8x8[1], pps->scaling_matrix8[3],
+               STD_VIDEO_H264_SCALING_LIST_8X8_NUM_ELEMENTS * sizeof(**pps->scaling_matrix8));
+    }
 
     *vkpps = (StdVideoH264PictureParameterSet) {
         .seq_parameter_set_id = pps->sps_id,
-- 
2.41.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-07-31 23:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-31 22:53 [FFmpeg-devel] [PATCH] vulkan_h264: fill correct ScalingList8x8 entries Benjamin Cheng

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git