codecparsers: VC1: Implement FrameLayer parsing
authorThibault Saunier <thibault.saunier@collabora.com>
Wed, 5 Oct 2011 19:40:47 +0000 (16:40 -0300)
committerThibault Saunier <thibault.saunier@collabora.com>
Mon, 17 Oct 2011 11:17:39 +0000 (13:17 +0200)
gst-libs/gst/codecparsers/gstvc1parser.c
gst-libs/gst/codecparsers/gstvc1parser.h

index aad915d8b84faa3f568efa9d06909782149aba60..fe24d4e6fb6bad5a8620446d7e1e4fe141d04192 100644 (file)
@@ -1617,6 +1617,47 @@ failed:
   return GST_VC1_PARSER_ERROR;
 }
 
+/**
+ * gst_vc1_parse_frame_layer:
+ * @data: The data to parse
+ * @size: the size of @data
+ * @framelayer: The #GstVC1FrameLayer to fill.
+ *
+ * Parses @data, and fills @framelayer fields.
+ *
+ * Returns: a #GstVC1ParserResult
+ */
+GstVC1ParserResult
+gst_vc1_parse_frame_layer (const guint8 * data, gsize size,
+    GstVC1FrameLayer * framelayer)
+{
+  GstBitReader br = GST_BIT_READER_INIT (data, size);
+
+  if (gst_bit_reader_get_remaining (&br) < 64) {
+    GST_WARNING ("Could not parse frame layer");
+
+    return GST_VC1_PARSER_ERROR;
+  }
+
+  /* set default values */
+  framelayer->skiped_p_frame = 0;
+
+  framelayer->key = gst_bit_reader_get_bits_uint8_unchecked (&br, 1);
+  gst_bit_reader_skip_unchecked (&br, 7);
+
+  framelayer->framesize = gst_bit_reader_get_bits_uint32_unchecked (&br, 24);
+
+  if (framelayer->framesize == 0 || framelayer->framesize == 1)
+    framelayer->skiped_p_frame = 1;
+
+  /* compute  next_framelayer_offset */
+  framelayer->next_framelayer_offset = framelayer->framesize + 8;
+
+  framelayer->timestamp = gst_bit_reader_get_bits_uint32_unchecked (&br, 32);
+
+  return GST_VC1_PARSER_OK;
+}
+
 /**
  * gst_vc1_parse_frame_header:
  * @data: The data to parse
index fd792649f80f10b82677f4b65113a87813cd7465..d058f0ff4db31046af80cd98618e051c63fb65b5 100644 (file)
@@ -139,6 +139,7 @@ typedef struct _GstVC1SeqStructB   GstVC1SeqStructB;
 typedef struct _GstVC1SeqStructC   GstVC1SeqStructC;
 
 /* Pictures Structures */
+typedef struct _GstVC1FrameLayer        GstVC1FrameLayer;
 typedef struct _GstVC1FrameHdr          GstVC1FrameHdr;
 typedef struct _GstVC1PicAdvanced       GstVC1PicAdvanced;
 typedef struct _GstVC1PicSimpleMain     GstVC1PicSimpleMain;
@@ -438,6 +439,18 @@ struct _GstVC1VopDquant
 
 };
 
+struct _GstVC1FrameLayer
+{
+  guint8 key;
+  guint32 framesize;
+
+  guint32 timestamp;
+
+  /* calculated */
+  guint32 next_framelayer_offset;
+  guint8 skiped_p_frame;
+};
+
 /**
  * GstVC1FrameHdr:
  *
@@ -521,6 +534,10 @@ gst_vc1_parse_sequence_header_struct_c                 (const guint8 *data,
                                                         gsize size,
                                                         GstVC1SeqStructC *structc);
 
+GstVC1ParserResult gst_vc1_parse_frame_layer           (const guint8 *data,
+                                                        gsize size,
+                                                        GstVC1FrameLayer * framelayer);
+
 GstVC1ParserResult gst_vc1_parse_frame_header          (const guint8 *data,
                                                         gsize size,
                                                         GstVC1FrameHdr * framehdr,