mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 09:55:36 +00:00
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
This commit is contained in:
parent
9604342af3
commit
c4d987b6d3
2 changed files with 51 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue