mpeg2: catch incorrect picture_structure from bitstreams.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Fri, 24 Feb 2012 11:56:48 +0000 (12:56 +0100)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Fri, 16 Mar 2012 12:56:26 +0000 (13:56 +0100)
Assume "frame" picture structure if the syntax element was zero or if
progressive_frame is set.

gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c

index 11bbe93..b523fb9 100644 (file)
@@ -582,6 +582,14 @@ decode_picture_ext(GstVaapiDecoderMpeg2 *decoder, guchar *buf, guint buf_size)
     }
     priv->has_pic_ext = TRUE;
 
+    if (pic_ext->picture_structure == 0 ||
+        (pic_ext->progressive_frame &&
+         pic_ext->picture_structure != GST_MPEG_VIDEO_PICTURE_STRUCTURE_FRAME)) {
+        GST_WARNING("invalid picture_structure %d, replacing with \"frame\"",
+                    pic_ext->picture_structure);
+        pic_ext->picture_structure = GST_MPEG_VIDEO_PICTURE_STRUCTURE_FRAME;
+    }
+
     switch (pic_ext->picture_structure) {
     case GST_MPEG_VIDEO_PICTURE_STRUCTURE_TOP_FIELD:
         GST_VAAPI_PICTURE_FLAG_SET(picture, GST_VAAPI_PICTURE_FLAG_TOP_FIELD);