ivfparse: Fix the wrong width & height parsing of vp9 bitstream
authorSreerenj Balachandran <sreerenj.balachandran@intel.com>
Mon, 9 Nov 2015 15:45:29 +0000 (17:45 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Wed, 11 Nov 2015 14:30:25 +0000 (15:30 +0100)
The current implementation for detecting the resolution changes
on key frames is based on vp8 bitstream alignment. Avoid this
width and height parsing for vp9 bitstream, which requires proper
frame header parsing inorder to detect the resolution change (Fixme).

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

gst/ivfparse/gstivfparse.c

index 4e3ea8b..bea1e19 100644 (file)
@@ -331,15 +331,20 @@ gst_ivf_parse_handle_frame_data (GstIvfParse * ivf, GstBaseParseFrame * frame,
 
     /* Detect resolution changes on key frames */
     if (gst_buffer_map (frame->out_buffer, &map, GST_MAP_READ)) {
-      guint32 frame_tag, width, height;
-
-      frame_tag = GST_READ_UINT24_LE (map.data);
-      if (!(frame_tag & 0x01) && map.size >= 10) {      /* key frame */
-        GST_DEBUG_OBJECT (ivf, "key frame detected");
-
-        width = GST_READ_UINT16_LE (map.data + 6) & 0x3fff;
-        height = GST_READ_UINT16_LE (map.data + 8) & 0x3fff;
-        gst_ivf_parse_set_size (ivf, width, height);
+      guint32 width, height;
+
+      if (ivf->fourcc == GST_MAKE_FOURCC ('V', 'P', '8', '0')) {
+        guint32 frame_tag;
+        frame_tag = GST_READ_UINT24_LE (map.data);
+        if (!(frame_tag & 0x01) && map.size >= 10) {    /* key frame */
+          GST_DEBUG_OBJECT (ivf, "key frame detected");
+
+          width = GST_READ_UINT16_LE (map.data + 6) & 0x3fff;
+          height = GST_READ_UINT16_LE (map.data + 8) & 0x3fff;
+          gst_ivf_parse_set_size (ivf, width, height);
+        }
+      } else {
+        /* Fixme: Add vp9 frame header parsing? */
       }
       gst_buffer_unmap (frame->out_buffer, &map);
     }