summaryrefslogtreecommitdiff
path: root/gst-libs
diff options
context:
space:
mode:
authorEdward Hervey <edward.hervey@collabora.co.uk>2011-12-05 11:47:57 +0100
committerEdward Hervey <edward.hervey@collabora.co.uk>2011-12-05 19:03:05 +0100
commitc4d987b6d391a7fc8c32f6abea819452b4dd9882 (patch)
tree6b011cefb800a4fa0a34fa1a0a2ea52b14c7d2b9 /gst-libs
parent9604342af3b6bbedeb3b2b7548105f591b5684eb (diff)
codecparsers: Variant of _identify_nalu without checks
This is useful for cases where the caller *knows* that the provided input contains a whole NALU and can therefore avoid: * the expensive checks for the next start code (which won't be present) * delaying the input parsing (since we would need the next incoming NALU in order for the parsing code to detect the next start code) https://bugzilla.gnome.org/show_bug.cgi?id=665584
Diffstat (limited to 'gst-libs')
-rw-r--r--gst-libs/gst/codecparsers/gsth264parser.c52
-rw-r--r--gst-libs/gst/codecparsers/gsth264parser.h4
2 files changed, 51 insertions, 5 deletions
diff --git a/gst-libs/gst/codecparsers/gsth264parser.c b/gst-libs/gst/codecparsers/gsth264parser.c
index a75713e4b..0e14546b8 100644
--- a/gst-libs/gst/codecparsers/gsth264parser.c
+++ b/gst-libs/gst/codecparsers/gsth264parser.c
@@ -1150,22 +1150,28 @@ gst_h264_nal_parser_free (GstH264NalParser * nalparser)
}
/**
- * gst_h264_parser_identify_nalu:
+ * gst_h264_parser_identify_nalu_unchecked:
* @nalparser: a #GstH264NalParser
* @data: The data to parse
* @offset: the offset from which to parse @data
* @size: the size of @data
* @nalu: The #GstH264NalUnit where to store parsed nal headers
*
- * Parses @data and fills @nalu from the next nalu data from @data
+ * Parses @data and fills @nalu from the next nalu data from @data.
+ *
+ * This differs from @gst_h264_parser_identify_nalu in that it doesn't
+ * check whether the packet is complete or not.
+ *
+ * Note: Only use this function if you already know the provided @data
+ * is a complete NALU, else use @gst_h264_parser_identify_nalu.
*
* Returns: a #GstH264ParserResult
*/
GstH264ParserResult
-gst_h264_parser_identify_nalu (GstH264NalParser * nalparser,
+gst_h264_parser_identify_nalu_unchecked (GstH264NalParser * nalparser,
const guint8 * data, guint offset, gsize size, GstH264NalUnit * nalu)
{
- gint off1, off2;
+ gint off1;
if (size < offset + 4) {
GST_DEBUG ("Can't parse, buffer has too small size %" G_GSIZE_FORMAT
@@ -1188,12 +1194,14 @@ gst_h264_parser_identify_nalu (GstH264NalParser * nalparser,
nalu->valid = TRUE;
nalu->sc_offset = offset + off1;
+
/* sc might have 2 or 3 0-bytes */
if (nalu->sc_offset > 0 && data[nalu->sc_offset - 1] == 00)
nalu->sc_offset--;
nalu->offset = offset + off1 + 3;
nalu->data = (guint8 *) data;
+
set_nalu_datas (nalu);
if (nalu->type == GST_H264_NAL_SEQ_END ||
@@ -1203,6 +1211,37 @@ gst_h264_parser_identify_nalu (GstH264NalParser * nalparser,
return GST_H264_PARSER_OK;
}
+ nalu->size = size - nalu->offset;
+
+ return GST_H264_PARSER_OK;
+}
+
+/**
+ * gst_h264_parser_identify_nalu:
+ * @nalparser: a #GstH264NalParser
+ * @data: The data to parse
+ * @offset: the offset from which to parse @data
+ * @size: the size of @data
+ * @nalu: The #GstH264NalUnit where to store parsed nal headers
+ *
+ * Parses @data and fills @nalu from the next nalu data from @data
+ *
+ * Returns: a #GstH264ParserResult
+ */
+GstH264ParserResult
+gst_h264_parser_identify_nalu (GstH264NalParser * nalparser,
+ const guint8 * data, guint offset, gsize size, GstH264NalUnit * nalu)
+{
+ GstH264ParserResult res;
+ gint off2;
+
+ res =
+ gst_h264_parser_identify_nalu_unchecked (nalparser, data, offset, size,
+ nalu);
+
+ if (res != GST_H264_PARSER_OK || nalu->size == 0)
+ goto beach;
+
off2 = scan_for_start_codes (data + nalu->offset, size - nalu->offset);
if (off2 < 0) {
GST_DEBUG ("Nal start %d, No end found", nalu->offset);
@@ -1218,9 +1257,12 @@ gst_h264_parser_identify_nalu (GstH264NalParser * nalparser,
return GST_H264_PARSER_BROKEN_DATA;
GST_DEBUG ("Complete nal found. Off: %d, Size: %d", nalu->offset, nalu->size);
- return GST_H264_PARSER_OK;
+
+beach:
+ return res;
}
+
/**
* gst_h264_parser_identify_nalu_avc:
* @nalparser: a #GstH264NalParser
diff --git a/gst-libs/gst/codecparsers/gsth264parser.h b/gst-libs/gst/codecparsers/gsth264parser.h
index 4daf3e171..d58f1b07d 100644
--- a/gst-libs/gst/codecparsers/gsth264parser.h
+++ b/gst-libs/gst/codecparsers/gsth264parser.h
@@ -678,6 +678,10 @@ GstH264ParserResult gst_h264_parser_identify_nalu (GstH264NalParser *nalpars
const guint8 *data, guint offset,
gsize size, GstH264NalUnit *nalu);
+GstH264ParserResult gst_h264_parser_identify_nalu_unchecked (GstH264NalParser *nalparser,
+ const guint8 *data, guint offset,
+ gsize size, GstH264NalUnit *nalu);
+
GstH264ParserResult gst_h264_parser_identify_nalu_avc (GstH264NalParser *nalparser, const guint8 *data,
guint offset, gsize size, guint8 nal_length_size,
GstH264NalUnit *nalu);