From 4f0fc9a16fe0e340c48107cf62d17f75302d30d0 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Mon, 20 Jan 2014 17:24:54 -0300 Subject: [PATCH] h264parser: remove trailling 0x00 bytes as the spec doesn't allow them The spec states that the last byte of a NAL 'shall not' be 0x00 and it is allowed for byte-stream format to add padding 0x00 for alignment. So our parser should strip any trailling 0x00. https://bugzilla.gnome.org/show_bug.cgi?id=721384 --- gst-libs/gst/codecparsers/gsth264parser.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/codecparsers/gsth264parser.c b/gst-libs/gst/codecparsers/gsth264parser.c index 93bea97354..4f0f986cc4 100644 --- a/gst-libs/gst/codecparsers/gsth264parser.c +++ b/gst-libs/gst/codecparsers/gsth264parser.c @@ -1283,7 +1283,10 @@ gst_h264_parser_identify_nalu (GstH264NalParser * nalparser, return GST_H264_PARSER_NO_NAL_END; } - if (off2 > 0 && data[nalu->offset + off2 - 1] == 00) + /* Mini performance improvement: + * We could have a way to store how many 0s were skipped to avoid + * parsing them again on the next NAL */ + while (off2 > 0 && data[nalu->offset + off2 - 1] == 00) off2--; nalu->size = off2;