From f9ae0c0de4bc569dd3b4cdf5c18d776e9be50ff8 Mon Sep 17 00:00:00 2001 From: Sreerenj Balachandran Date: Mon, 18 Feb 2013 15:05:37 +0200 Subject: [PATCH] vc1: add support for video cropping. 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 --- gst-libs/gst/vaapi/gstvaapidecoder_vc1.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_vc1.c b/gst-libs/gst/vaapi/gstvaapidecoder_vc1.c index 752ee6858f..a2ee00234d 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder_vc1.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder_vc1.c @@ -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;