va: Avoid the array index overflow when filling 8x8 scaling list.

The VA API has not defined the scaling list entries for U/V planes
for the 4:4:4 stream. In fact, we do not meet the 4:4:4 format output
for H264 so far, and scaling list is not used frequently, so we just
print out some warning and ignore these scaling list values.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3749>
This commit is contained in:
He Junyan 2023-01-19 11:03:09 +08:00 committed by GStreamer Marge Bot
parent 6b30a5d987
commit 60731adea6

View file

@ -363,7 +363,7 @@ gst_va_h264_dec_start_picture (GstH264Decoder * decoder,
GstVaDecodePicture *va_pic; GstVaDecodePicture *va_pic;
VAIQMatrixBufferH264 iq_matrix = { 0, }; VAIQMatrixBufferH264 iq_matrix = { 0, };
VAPictureParameterBufferH264 pic_param; VAPictureParameterBufferH264 pic_param;
guint i, n; guint i;
GArray *ref_list = self->ref_list; GArray *ref_list = self->ref_list;
va_pic = gst_h264_picture_get_user_data (picture); va_pic = gst_h264_picture_get_user_data (picture);
@ -454,9 +454,15 @@ gst_va_h264_dec_start_picture (GstH264Decoder * decoder,
/* We need the first 2 entries (Y intra and Y inter for YCbCr 4:2:2 and /* We need the first 2 entries (Y intra and Y inter for YCbCr 4:2:2 and
* less, and the full 6 entries for 4:4:4, see Table 7-2 of the spec for * less, and the full 6 entries for 4:4:4, see Table 7-2 of the spec for
* more details */ * more details.
n = (pps->sequence->chroma_format_idc == 3) ? 6 : 2; * But VA API only define the first 2 entries, so we may lose scaling
for (i = 0; i < n; i++) { * list info for 4:4:4 stream. */
if (pps->sequence->chroma_format_idc == 3)
GST_WARNING_OBJECT (self, "We do not have scaling list entries "
"for U/V planes in 4:4:4 stream. It may have artifact if "
"those scaling lists are not default value.");
for (i = 0; i < 2; i++) {
gst_h264_quant_matrix_8x8_get_raster_from_zigzag (iq_matrix.ScalingList8x8 gst_h264_quant_matrix_8x8_get_raster_from_zigzag (iq_matrix.ScalingList8x8
[i], pps->scaling_lists_8x8[i]); [i], pps->scaling_lists_8x8[i]);
} }