mpegvideoparse: Need detect picture coding type when drain

Need detect picture coding type when drain

Upstream Status: Waiting for review.

https://bugzilla.gnome.org/show_bug.cgi?id=749617
diff --git a/gst/videoparsers/gstmpegvideoparse.c b/gst/videoparsers/gstmpegvideoparse.c
index 6896339..769e0fd 100644
--- a/gst/videoparsers/gstmpegvideoparse.c
+++ b/gst/videoparsers/gstmpegvideoparse.c
@@ -715,6 +715,22 @@
   if (GST_BASE_PARSE_DRAINING (parse)) {
     GST_LOG_OBJECT (mpvparse, "draining, accepting all data");
     off = size;
+    /* decide picture codding type */
+    if (mpvparse->pic_offset >= 0 && mpvparse->pic_offset < off) {
+      GstMpegVideoPacket header;
+
+      header.data = map.data;
+      header.type = GST_MPEG_VIDEO_PACKET_PICTURE;
+      header.offset = mpvparse->pic_offset;
+      header.size = map.size - mpvparse->pic_offset;
+      if (gst_mpeg_video_packet_parse_picture_header (&header, &mpvparse->pichdr))
+        GST_LOG_OBJECT (mpvparse, "picture_coding_type %d (%s), ending"
+            "frame of size %d", mpvparse->pichdr.pic_type,
+            picture_type_name (mpvparse->pichdr.pic_type), off - 4);
+      else
+        GST_LOG_OBJECT (mpvparse, "Couldn't parse picture at offset %d",
+            mpvparse->pic_offset);
+    }
     ret = TRUE;
   } else {
     GST_LOG_OBJECT (mpvparse, "need more data");