h264parse: drop patches merged upstream.

0003-h264parse-fix-and-optimize-NAL-collection-function.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
This commit is contained in:
Gwenole Beauchesne 2014-07-01 17:20:44 +02:00
parent cba9b97300
commit e6cdacee65
5 changed files with 0 additions and 384 deletions

View file

@ -1,41 +0,0 @@
From cf890efdb44feb4cfc728756bcf0ce1df17b8e9d Mon Sep 17 00:00:00 2001
From: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Date: Tue, 24 Jun 2014 13:55:13 +0200
Subject: [PATCH 3/8] h264parse: fix and optimize NAL collection function.
Use gst_h264_parser_identify_nalu_unchecked() to identify the next
NAL unit. We don't want to parse the full NAL unit, but only the
header bytes and possibly the first RBSP byte for identifying the
first_mb_in_slice syntax element.
Also fix check for failure when returning from that function. The
only success condition for that is GST_H264_PARSER_OK, so use it.
https://bugzilla.gnome.org/show_bug.cgi?id=732154
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
---
gst/vaapi/gsth264parse.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/gst/vaapi/gsth264parse.c b/gst/vaapi/gsth264parse.c
index fff1d48..7a88a07 100644
--- a/gst/vaapi/gsth264parse.c
+++ b/gst/vaapi/gsth264parse.c
@@ -668,10 +668,10 @@ gst_h264_parse_collect_nal (GstH264Parse * h264parse, const guint8 * data,
GstH264NalUnit nnalu;
GST_DEBUG_OBJECT (h264parse, "parsing collected nal");
- parse_res = gst_h264_parser_identify_nalu (h264parse->nalparser, data,
- nalu->offset + nalu->size, size, &nnalu);
+ parse_res = gst_h264_parser_identify_nalu_unchecked (h264parse->nalparser,
+ data, nalu->offset + nalu->size, size, &nnalu);
- if (parse_res == GST_H264_PARSER_ERROR)
+ if (parse_res != GST_H264_PARSER_OK)
return FALSE;
/* determine if AU complete */
--
1.7.9.5

View file

@ -1,135 +0,0 @@
From fcdf7736ca43b9847b22100042e19bf64005ee39 Mon Sep 17 00:00:00 2001
From: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Date: Wed, 25 Jun 2014 11:06:41 +0200
Subject: [PATCH 5/8] h264parse: introduce new state tracking variables.
Improve parser state tracking by introducing new flags reflecting
it: "got-sps", "got-pps" and "got-slice". This is an addition for
robustness purposes.
Older have_sps and have_pps variables are kept because they have
a different meaning. i.e. they are used for deciding on when to
submit updated caps or not, and rather mean "have new SPS/PPS to
be submitted?"
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
---
gst/vaapi/gsth264parse.c | 30 +++++++++++++++++++++++++++++-
gst/vaapi/gsth264parse.h | 3 +++
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/gst/vaapi/gsth264parse.c b/gst/vaapi/gsth264parse.c
index 4800c2b..1542a82 100644
--- a/gst/vaapi/gsth264parse.c
+++ b/gst/vaapi/gsth264parse.c
@@ -61,6 +61,22 @@ enum
GST_H264_PARSE_ALIGN_AU
};
+enum
+{
+ GST_H264_PARSE_STATE_GOT_SPS = 1 << 0,
+ GST_H264_PARSE_STATE_GOT_PPS = 1 << 1,
+ GST_H264_PARSE_STATE_GOT_SLICE = 1 << 2,
+
+ GST_H264_PARSE_STATE_VALID_PICTURE_HEADERS = (GST_H264_PARSE_STATE_GOT_SPS |
+ GST_H264_PARSE_STATE_GOT_PPS),
+ GST_H264_PARSE_STATE_VALID_PICTURE =
+ (GST_H264_PARSE_STATE_VALID_PICTURE_HEADERS |
+ GST_H264_PARSE_STATE_GOT_SLICE)
+};
+
+#define GST_H264_PARSE_STATE_VALID(parse, expected_state) \
+ (((parse)->state & (expected_state)) == (expected_state))
+
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
@@ -535,6 +551,9 @@ gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu)
switch (nal_type) {
case GST_H264_NAL_SPS:
+ /* reset state, everything else is obsolete */
+ h264parse->state = 0;
+
pres = gst_h264_parser_parse_sps (nalparser, nalu, &sps, TRUE);
/* arranged for a fallback sps.id, so use that one and only warn */
if (pres != GST_H264_PARSER_OK)
@@ -553,8 +572,11 @@ gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu)
}
gst_h264_parser_store_nal (h264parse, sps.id, nal_type, nalu);
+ h264parse->state |= GST_H264_PARSE_STATE_GOT_SPS;
break;
case GST_H264_NAL_PPS:
+ h264parse->state &= GST_H264_PARSE_STATE_GOT_SPS;
+
pres = gst_h264_parser_parse_pps (nalparser, nalu, &pps);
/* arranged for a fallback pps.id, so use that one and only warn */
if (pres != GST_H264_PARSER_OK)
@@ -576,6 +598,7 @@ gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu)
}
gst_h264_parser_store_nal (h264parse, pps.id, nal_type, nalu);
+ h264parse->state |= GST_H264_PARSE_STATE_GOT_PPS;
break;
case GST_H264_NAL_SEI:
gst_h264_parse_process_sei (h264parse, nalu);
@@ -595,6 +618,8 @@ gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu)
case GST_H264_NAL_SLICE_DPB:
case GST_H264_NAL_SLICE_DPC:
case GST_H264_NAL_SLICE_IDR:
+ h264parse->state &= GST_H264_PARSE_STATE_VALID_PICTURE_HEADERS;
+
/* don't need to parse the whole slice (header) here */
if (*(nalu->data + nalu->offset + 1) & 0x80) {
/* means first_mb_in_slice == 0 */
@@ -615,6 +640,7 @@ gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu)
if (GST_H264_IS_I_SLICE (&slice) || GST_H264_IS_SI_SLICE (&slice))
h264parse->keyframe |= TRUE;
+ h264parse->state |= GST_H264_PARSE_STATE_GOT_SLICE;
h264parse->field_pic_flag = slice.field_pic_flag;
}
}
@@ -964,7 +990,8 @@ gst_h264_parse_handle_frame (GstBaseParse * parse,
if (nalu.type == GST_H264_NAL_SPS ||
nalu.type == GST_H264_NAL_PPS ||
- (h264parse->have_sps && h264parse->have_pps)) {
+ GST_H264_PARSE_STATE_VALID (h264parse,
+ GST_H264_PARSE_STATE_VALID_PICTURE_HEADERS)) {
gst_h264_parse_process_nal (h264parse, &nalu);
} else {
GST_WARNING_OBJECT (h264parse,
@@ -1761,6 +1788,7 @@ gst_h264_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
h264parse->push_codec = FALSE;
h264parse->have_sps = FALSE;
h264parse->have_pps = FALSE;
+ h264parse->state &= GST_H264_PARSE_STATE_VALID_PICTURE_HEADERS;
}
}
diff --git a/gst/vaapi/gsth264parse.h b/gst/vaapi/gsth264parse.h
index 4c3fdd4..c9d188b 100644
--- a/gst/vaapi/gsth264parse.h
+++ b/gst/vaapi/gsth264parse.h
@@ -69,12 +69,15 @@ struct _GstH264Parse
/* state */
GstH264NalParser *nalparser;
+ guint state;
guint align;
guint format;
gint current_off;
GstClockTime last_report;
gboolean push_codec;
+ /* The following variables have a meaning in context of "have
+ * SPS/PPS to push downstream", e.g. to update caps */
gboolean have_sps;
gboolean have_pps;
--
1.7.9.5

View file

@ -1,146 +0,0 @@
From 2b3680eeaff91f611d8c8b0e74efc66b0d874c66 Mon Sep 17 00:00:00 2001
From: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Date: Wed, 25 Jun 2014 13:14:10 +0200
Subject: [PATCH 6/8] h264parse: improve conditions for skipping NAL units.
Carefully track cases when skipping broken or invalid NAL units is
necessary. In particular, always allow NAL units to be processed
and let that gst_h264_parse_process_nal() function decide on whether
the current NAL needs to be dropped or not.
This fixes parsing of streams with SEI NAL buffering_period() message
inserted between SPS and PPS, or SPS-Ext NAL following a traditional
SPS NAL unit, among other cases too.
Practical examples from the H.264 AVC conformance suite include
alphaconformanceG, CVSE2_Sony_B, CVSE3_Sony_H, CVSEFDFT3_Sony_E
when parsing in stream-format=byte-stream,alignment=au mode.
https://bugzilla.gnome.org/show_bug.cgi?id=732203
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
---
gst/vaapi/gsth264parse.c | 43 +++++++++++++++++++++++++++++++------------
1 file changed, 31 insertions(+), 12 deletions(-)
diff --git a/gst/vaapi/gsth264parse.c b/gst/vaapi/gsth264parse.c
index 1542a82..805c55f 100644
--- a/gst/vaapi/gsth264parse.c
+++ b/gst/vaapi/gsth264parse.c
@@ -528,7 +528,7 @@ gst_h264_parse_process_sei (GstH264Parse * h264parse, GstH264NalUnit * nalu)
}
/* caller guarantees 2 bytes of nal payload */
-static void
+static gboolean
gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu)
{
guint nal_type;
@@ -540,7 +540,7 @@ gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu)
/* nothing to do for broken input */
if (G_UNLIKELY (nalu->size < 2)) {
GST_DEBUG_OBJECT (h264parse, "not processing nal size %u", nalu->size);
- return;
+ return TRUE;
}
/* we have a peek as well */
@@ -556,8 +556,10 @@ gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu)
pres = gst_h264_parser_parse_sps (nalparser, nalu, &sps, TRUE);
/* arranged for a fallback sps.id, so use that one and only warn */
- if (pres != GST_H264_PARSER_OK)
+ if (pres != GST_H264_PARSER_OK) {
GST_WARNING_OBJECT (h264parse, "failed to parse SPS:");
+ return FALSE;
+ }
GST_DEBUG_OBJECT (h264parse, "triggering src caps check");
h264parse->update_caps = TRUE;
@@ -575,12 +577,18 @@ gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu)
h264parse->state |= GST_H264_PARSE_STATE_GOT_SPS;
break;
case GST_H264_NAL_PPS:
+ /* expected state: got-sps */
h264parse->state &= GST_H264_PARSE_STATE_GOT_SPS;
+ if (!GST_H264_PARSE_STATE_VALID (h264parse, GST_H264_PARSE_STATE_GOT_SPS))
+ return FALSE;
pres = gst_h264_parser_parse_pps (nalparser, nalu, &pps);
/* arranged for a fallback pps.id, so use that one and only warn */
- if (pres != GST_H264_PARSER_OK)
+ if (pres != GST_H264_PARSER_OK) {
GST_WARNING_OBJECT (h264parse, "failed to parse PPS:");
+ if (pres != GST_H264_PARSER_BROKEN_LINK)
+ return FALSE;
+ }
/* parameters might have changed, force caps check */
if (!h264parse->have_pps) {
@@ -601,6 +609,10 @@ gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu)
h264parse->state |= GST_H264_PARSE_STATE_GOT_PPS;
break;
case GST_H264_NAL_SEI:
+ /* expected state: got-sps */
+ if (!GST_H264_PARSE_STATE_VALID (h264parse, GST_H264_PARSE_STATE_GOT_SPS))
+ return FALSE;
+
gst_h264_parse_process_sei (h264parse, nalu);
/* mark SEI pos */
if (h264parse->sei_pos == -1) {
@@ -618,7 +630,11 @@ gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu)
case GST_H264_NAL_SLICE_DPB:
case GST_H264_NAL_SLICE_DPC:
case GST_H264_NAL_SLICE_IDR:
+ /* expected state: got-sps|got-pps (valid picture headers) */
h264parse->state &= GST_H264_PARSE_STATE_VALID_PICTURE_HEADERS;
+ if (!GST_H264_PARSE_STATE_VALID (h264parse,
+ GST_H264_PARSE_STATE_VALID_PICTURE_HEADERS))
+ return FALSE;
/* don't need to parse the whole slice (header) here */
if (*(nalu->data + nalu->offset + 1) & 0x80) {
@@ -668,7 +684,14 @@ gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu)
}
break;
default:
- gst_h264_parser_parse_nal (nalparser, nalu);
+ /* drop anything before the initial SPS */
+ if (!GST_H264_PARSE_STATE_VALID (h264parse, GST_H264_PARSE_STATE_GOT_SPS))
+ return FALSE;
+
+ pres = gst_h264_parser_parse_nal (nalparser, nalu);
+ if (pres != GST_H264_PARSER_OK)
+ return FALSE;
+ break;
}
/* if AVC output needed, collect properly prefixed nal in adapter,
@@ -681,6 +704,7 @@ gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu)
nalu->data + nalu->offset, nalu->size);
gst_adapter_push (h264parse->frame_out, buf);
}
+ return TRUE;
}
/* caller guarantees at least 2 bytes of nal payload for each nal
@@ -988,14 +1012,9 @@ gst_h264_parse_handle_frame (GstBaseParse * parse,
}
}
- if (nalu.type == GST_H264_NAL_SPS ||
- nalu.type == GST_H264_NAL_PPS ||
- GST_H264_PARSE_STATE_VALID (h264parse,
- GST_H264_PARSE_STATE_VALID_PICTURE_HEADERS)) {
- gst_h264_parse_process_nal (h264parse, &nalu);
- } else {
+ if (!gst_h264_parse_process_nal (h264parse, &nalu)) {
GST_WARNING_OBJECT (h264parse,
- "no SPS/PPS yet, nal Type: %d %s, Size: %u will be dropped",
+ "broken/invalid nal Type: %d %s, Size: %u will be dropped",
nalu.type, _nal_name (nalu.type), nalu.size);
*skipsize = nalu.size;
goto skip;
--
1.7.9.5

View file

@ -1,58 +0,0 @@
From def7c6b2a0fcd08969940349e458248dd0c7b3da Mon Sep 17 00:00:00 2001
From: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
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:
<SPS> <PPS> <invalid-NAL> <slice>
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 <gwenole.beauchesne@intel.com>
---
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

View file

@ -3,10 +3,6 @@
videoparsers_patches_base = \
0001-plugins-compile-the-built-in-video-parsers-as-vaapip.patch \
0002-h264parse-fix-build-with-GStreamer-1.2.patch \
0003-h264parse-fix-and-optimize-NAL-collection-function.patch \
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)