From 86c6a43a7c6fdcef519eb4382c985b1f768749a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Qian=20Hu=20=28=E8=83=A1=E9=AA=9E=29?= Date: Mon, 22 Jul 2024 21:29:38 +0800 Subject: [PATCH] h26xparse: bypass check for length_size_minus_one fix playback fail, when some file with length_size_minus_one == 2 According to the spec 2 cannot be a valid value, so that stream has a bad config record. but breaking the decoding because of that, perhaps is too much. and ffmpeg seem not check this Part-of: --- .../gst-libs/gst/codecparsers/gsth264parser.c | 2 -- .../gst-libs/gst/codecparsers/gsth265parser.c | 2 -- subprojects/gst-plugins-bad/tests/check/libs/h264parser.c | 8 +++++--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth264parser.c b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth264parser.c index 85119713eb..386fe5a1bb 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth264parser.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth264parser.c @@ -3781,8 +3781,6 @@ gst_h264_parser_parse_decoder_config_record (GstH264NalParser * nalparser, if (ret->length_size_minus_one == 2) { /* "length_size_minus_one + 1" should be 1, 2, or 4 */ GST_WARNING ("Wrong nal-length-size"); - result = GST_H264_PARSER_ERROR; - goto error; } /* reserved 3bits */ diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.c b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.c index eaf35852ee..9d126080f2 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/codecparsers/gsth265parser.c @@ -5093,8 +5093,6 @@ gst_h265_parser_parse_decoder_config_record (GstH265Parser * parser, if (ret->length_size_minus_one == 2) { /* "length_size_minus_one + 1" should be 1, 2, or 4 */ GST_WARNING ("Wrong nal-length-size"); - result = GST_H265_PARSER_ERROR; - goto error; } READ_CONFIG_UINT8 (num_of_arrays, 8); diff --git a/subprojects/gst-plugins-bad/tests/check/libs/h264parser.c b/subprojects/gst-plugins-bad/tests/check/libs/h264parser.c index f42fd31ac5..04fd1dc092 100644 --- a/subprojects/gst-plugins-bad/tests/check/libs/h264parser.c +++ b/subprojects/gst-plugins-bad/tests/check/libs/h264parser.c @@ -845,12 +845,14 @@ GST_START_TEST (test_h264_decoder_config_record) assert_equals_int (ret, GST_H264_PARSER_ERROR); fail_unless (config == NULL); - /* wrong length size, return error with null config data */ + /* wrong length size, since we still try to use it. so return ok */ ret = gst_h264_parser_parse_decoder_config_record (parser, h264_wrong_length_size_codec_data, sizeof (h264_wrong_length_size_codec_data), &config); - assert_equals_int (ret, GST_H264_PARSER_ERROR); - fail_unless (config == NULL); + assert_equals_int (ret, GST_H264_PARSER_OK); + fail_unless (config != NULL); + assert_equals_int (config->length_size_minus_one, 2); + g_clear_pointer (&config, gst_h264_decoder_config_record_free); gst_h264_nal_parser_free (parser); }