From cd3bd818c9bfd28bd5eef99181d6343a6a6f2c91 Mon Sep 17 00:00:00 2001
From: Song Bing <b06498@freescale.com>
Date: Wed, 20 May 2015 15:15:08 +0800
Subject: [PATCH] mpegvideoparse: Need detect picture coding type when drain
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Need detect picture coding type when drain

Upstream Status: Waiting for review.

https://bugzilla.gnome.org/show_bug.cgi?id=749617
Signed-off-by: Lyon Wang <lyon.wang@freescale.com>
---
 gst/videoparsers/gstmpegvideoparse.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/gst/videoparsers/gstmpegvideoparse.c b/gst/videoparsers/gstmpegvideoparse.c
index bf71a3e7cf1d..7ba624eb8c74 100644
--- a/gst/videoparsers/gstmpegvideoparse.c
+++ b/gst/videoparsers/gstmpegvideoparse.c
@@ -717,6 +717,22 @@ need_more:
   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");
