codecparsers: h264: fix skipping of unsupported SEI messages.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Fri, 21 Mar 2014 16:07:19 +0000 (17:07 +0100)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Mon, 24 Mar 2014 17:09:27 +0000 (18:09 +0100)
The payloadSize does not account for emulation prevention bytes. So,
just use nal_reader_skip() for skipping payload_size bits. It should
be possible to further optimize this code since the NAL reader shall
be aligned to byte boundary already.

Kill the now unused nal_reader_skip_to_next_byte() function.

https://bugzilla.gnome.org/show_bug.cgi?id=726829

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
gst-libs/gst/codecparsers/gsth264parser.c
gst-libs/gst/codecparsers/nalutils.c
gst-libs/gst/codecparsers/nalutils.h

index 63312d6..99f0835 100644 (file)
@@ -882,10 +882,14 @@ gst_h264_parser_parse_sei_message (GstH264NalParser * nalparser,
     res = gst_h264_parser_parse_pic_timing (nalparser,
         &sei->payload.pic_timing, nr);
   } else {
-    /* Just consume payloadSize */
-    guint32 i;
-    for (i = 0; i < payloadSize; i++)
-      nal_reader_skip_to_next_byte (nr);
+    /* Just consume payloadSize bytes, which does not account for
+       emulation prevention bytes */
+    guint nbits = payload_size % 8;
+    while (payload_size > 0) {
+      nal_reader_skip (nr, nbits);
+      payload_size -= nbits;
+      nbits = 8;
+    }
     res = GST_H264_PARSER_OK;
   }
 
index 60ec0f3..694066d 100644 (file)
@@ -124,21 +124,6 @@ nal_reader_skip (NalReader * nr, guint nbits)
   return TRUE;
 }
 
-inline gboolean
-nal_reader_skip_to_next_byte (NalReader * nr)
-{
-  if (nr->bits_in_cache == 0) {
-    if (G_LIKELY ((nr->size - nr->byte) > 0))
-      nr->byte++;
-    else
-      return FALSE;
-  }
-
-  nr->bits_in_cache = 0;
-
-  return TRUE;
-}
-
 inline guint
 nal_reader_get_pos (const NalReader * nr)
 {
index 44a0e60..5d231f2 100644 (file)
@@ -57,7 +57,6 @@ void nal_reader_init (NalReader * nr, const guint8 * data, guint size);
 
 gboolean nal_reader_read (NalReader * nr, guint nbits);
 gboolean nal_reader_skip (NalReader * nr, guint nbits);
-gboolean nal_reader_skip_to_next_byte (NalReader * nr);
 guint nal_reader_get_pos (const NalReader * nr);
 guint nal_reader_get_remaining (const NalReader * nr);
 guint nal_reader_get_epb_count (const NalReader * nr);