From 92c7d9e6a5f6a2f7d51f5e888c364037c0b2be8c Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Thu, 26 Jun 2014 14:49:53 +0200 Subject: [PATCH] h264parse: fix collection of access units to preserve config headers. Always use a GstAdapter when collecting access units (alignment="au") in either byte-stream or avcC format. This is required to properly preserve config headers like SPS and PPS when invalid or broken NAL units are subsequently parsed. More precisely, this fixes scenario like: where we used to reset the output frame buffer when an invalid or broken NAL is parsed, i.e. SPS and PPS NAL units were lost, thus preventing the next slice unit to be decoded, should this also represent any valid data. https://bugzilla.gnome.org/show_bug.cgi?id=732203 --- ...llection-of-access-units-to-preserve.patch | 58 +++++++++++++++++++ patches/videoparsers/series.frag | 1 + 2 files changed, 59 insertions(+) create mode 100644 patches/videoparsers/0007-h264parse-fix-collection-of-access-units-to-preserve.patch diff --git a/patches/videoparsers/0007-h264parse-fix-collection-of-access-units-to-preserve.patch b/patches/videoparsers/0007-h264parse-fix-collection-of-access-units-to-preserve.patch new file mode 100644 index 0000000000..7326d27d00 --- /dev/null +++ b/patches/videoparsers/0007-h264parse-fix-collection-of-access-units-to-preserve.patch @@ -0,0 +1,58 @@ +From def7c6b2a0fcd08969940349e458248dd0c7b3da Mon Sep 17 00:00:00 2001 +From: Gwenole Beauchesne +Date: Thu, 26 Jun 2014 09:44:26 +0200 +Subject: [PATCH 7/8] h264parse: fix collection of access units to preserve + config headers. + +Always use a GstAdapter when collecting access units (alignment="au") +in either byte-stream or avcC format. This is required to properly +preserve config headers like SPS and PPS when invalid or broken NAL +units are subsequently parsed. + +More precisely, this fixes scenario like: + + +where we used to reset the output frame buffer when an invalid or +broken NAL is parsed, i.e. SPS and PPS NAL units were lost, thus +preventing the next slice unit to be decoded, should this also +represent any valid data. + +https://bugzilla.gnome.org/show_bug.cgi?id=732203 + +Signed-off-by: Gwenole Beauchesne +--- + gst/vaapi/gsth264parse.c | 11 +++++++++-- + 1 file changed, 9 insertions(+), 2 deletions(-) + +diff --git a/gst/vaapi/gsth264parse.c b/gst/vaapi/gsth264parse.c +index 805c55f..413a227 100644 +--- a/gst/vaapi/gsth264parse.c ++++ b/gst/vaapi/gsth264parse.c +@@ -393,7 +393,8 @@ gst_h264_parse_negotiate (GstH264Parse * h264parse, gint in_format, + h264parse->format = format; + h264parse->align = align; + +- h264parse->transform = (in_format != h264parse->format); ++ h264parse->transform = in_format != h264parse->format || ++ align == GST_H264_PARSE_ALIGN_AU; + } + + static GstBuffer * +@@ -1054,7 +1055,13 @@ out: + + skip: + GST_DEBUG_OBJECT (h264parse, "skipping %d", *skipsize); +- gst_h264_parse_reset_frame (h264parse); ++ /* If we are collecting access units, we need to preserve the initial ++ * config headers (SPS, PPS et al.) and only reset the frame if another ++ * slice NAL was received. This means that broken pictures are discarded */ ++ if (h264parse->align != GST_H264_PARSE_ALIGN_AU || ++ !(h264parse->state & GST_H264_PARSE_STATE_VALID_PICTURE_HEADERS) || ++ (h264parse->state & GST_H264_PARSE_STATE_GOT_SLICE)) ++ gst_h264_parse_reset_frame (h264parse); + goto out; + + invalid_stream: +-- +1.7.9.5 + diff --git a/patches/videoparsers/series.frag b/patches/videoparsers/series.frag index b2a86ff604..46a7f5f9ed 100644 --- a/patches/videoparsers/series.frag +++ b/patches/videoparsers/series.frag @@ -7,5 +7,6 @@ videoparsers_patches_base = \ 0004-h264parse-default-to-byte-stream-nalu-format-Annex-B.patch \ 0005-h264parse-introduce-new-state-tracking-variables.patch \ 0006-h264parse-improve-conditions-for-skipping-NAL-units.patch \ + 0007-h264parse-fix-collection-of-access-units-to-preserve.patch \ 0003-h264parse-add-initial-support-for-MVC-NAL-units.patch \ $(NULL)