vc1: add support for video cropping.
authorSreerenj Balachandran <sreerenj.balachandran@intel.com>
Mon, 18 Feb 2013 13:05:37 +0000 (15:05 +0200)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Mon, 8 Jul 2013 16:54:15 +0000 (18:54 +0200)
If the Advanced profile has display_extension fields, then set the display
width/height dimension as cropping rectangle to the GstVaapiPicture.

Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
gst-libs/gst/vaapi/gstvaapidecoder_vc1.c

index 752ee6858f6738d6847dc39969174abf9c6c9205..a2ee00234d439049b0a4c8bccf6107d71bfc5e33 100644 (file)
@@ -1320,6 +1320,26 @@ gst_vaapi_decoder_vc1_start_frame(GstVaapiDecoder *base_decoder,
     gst_vaapi_picture_replace(&priv->current_picture, picture);
     gst_vaapi_picture_unref(picture);
 
+    /* Update cropping rectangle */
+    do {
+        GstVC1AdvancedSeqHdr *adv_hdr;
+        GstVaapiRectangle crop_rect;
+
+        if (priv->profile != GST_VAAPI_PROFILE_VC1_ADVANCED)
+            break;
+
+        adv_hdr = &priv->seq_hdr.advanced;
+        if (!adv_hdr->display_ext)
+            break;
+
+        crop_rect.x = 0;
+        crop_rect.y = 0;
+        crop_rect.width = adv_hdr->disp_horiz_size;
+        crop_rect.height = adv_hdr->disp_vert_size;
+        if (crop_rect.width <= priv->width && crop_rect.height <= priv->height)
+            gst_vaapi_picture_set_crop_rect(picture, &crop_rect);
+    } while (0);
+
     if (!gst_vc1_bitplanes_ensure_size(priv->bitplanes, &priv->seq_hdr)) {
         GST_ERROR("failed to allocate bitplanes");
         return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;