mpeg2: fix first field detection.
authorZhao Halley <halley.zhao@intel.com>
Mon, 9 Jan 2012 16:37:34 +0000 (17:37 +0100)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Mon, 16 Jan 2012 10:40:51 +0000 (11:40 +0100)
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c

index d2963b9..e70c635 100644 (file)
@@ -440,6 +440,8 @@ decode_gop(GstVaapiDecoderMpeg2 *decoder, guchar *buf, guint buf_size)
     priv->gop_pts = pts;
     if (!priv->pts_diff)
         priv->pts_diff = priv->seq_pts - priv->gop_pts;
+
+    priv->is_first_field = TRUE;
     return GST_VAAPI_DECODER_STATUS_SUCCESS;
 }
 
@@ -500,10 +502,6 @@ decode_picture(GstVaapiDecoderMpeg2 *decoder, guchar *buf, guint buf_size)
     }
 
     priv->mb_y = 0;
-    if (pic_hdr->pic_type == GST_MPEG_VIDEO_PICTURE_TYPE_I)
-        priv->is_first_field = TRUE;
-    else
-        priv->is_first_field ^= 1;
 
     /* Update presentation time */
     pts = priv->gop_pts;
@@ -618,8 +616,13 @@ decode_slice(
 
     GST_DEBUG("slice %d @ %p, %u bytes)", slice_no, buf, buf_size);
 
-    if (picture->slices->len == 0 && !fill_picture(decoder, picture))
-        return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;
+    if (picture->slices->len == 0) {
+        if (!fill_picture(decoder, picture))
+            return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;
+
+        if (!priv->pic_ext.progressive_frame)
+            priv->is_first_field ^= 1;
+    }
 
     priv->mb_y = slice_no;