theoradec: handle empty adapter
authorWim Taymans <wim.taymans@collabora.co.uk>
Sun, 31 Mar 2013 16:28:09 +0000 (18:28 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Sun, 31 Mar 2013 16:31:36 +0000 (18:31 +0200)
Should not be empty but might be when we actually pass and decode the 0 packets
later.

ext/theora/gsttheoradec.c

index 3bff259..ed5d3f4 100644 (file)
@@ -273,11 +273,13 @@ theora_dec_parse (GstVideoDecoder * decoder,
 
   av = gst_adapter_available (adapter);
 
-  data = gst_adapter_map (adapter, 1);
-  /* check for keyframe; must not be header packet */
-  if (!(data[0] & 0x80) && (data[0] & 0x40) == 0)
-    GST_VIDEO_CODEC_FRAME_SET_SYNC_POINT (frame);
-  gst_adapter_unmap (adapter);
+  if (av > 0) {
+    data = gst_adapter_map (adapter, 1);
+    /* check for keyframe; must not be header packet */
+    if (!(data[0] & 0x80) && (data[0] & 0x40) == 0)
+      GST_VIDEO_CODEC_FRAME_SET_SYNC_POINT (frame);
+    gst_adapter_unmap (adapter);
+  }
 
   /* and pass along all */
   gst_video_decoder_add_to_frame (decoder, av);