summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSreerenj Balachandran <sreerenj.balachandran@intel.com>2015-11-13 19:39:56 +0200
committerSreerenj Balachandran <sreerenj.balachandran@intel.com>2015-11-13 19:46:01 +0200
commit8ee23ffd967b65f244ed5c72dadf8b3e1b374b6c (patch)
treedfa282f034b17062dcf0370686fcb066c0b8d908
parenta48eebefd63b37b842f45d2e8a040a0e2c57a36f (diff)
downloadgst-vaapi-8ee23ffd967b65f244ed5c72dadf8b3e1b374b6c.tar.gz
decoder: vp9: Add crop rectangle support.
Set crop rectange if: There is display_width and display_height which is different from actual width/height or The changed resolution is less than the actual configured dimension of surfaces
-rw-r--r--gst-libs/gst/vaapi/gstvaapidecoder_vp9.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapidecoder_vp9.c b/gst-libs/gst/vaapi/gstvaapidecoder_vp9.c
index 508805e4..ea5673a0 100644
--- a/gst-libs/gst/vaapi/gstvaapidecoder_vp9.c
+++ b/gst-libs/gst/vaapi/gstvaapidecoder_vp9.c
@@ -395,8 +395,10 @@ decode_picture (GstVaapiDecoderVp9 * decoder, const guchar * buf,
guint buf_size)
{
GstVaapiDecoderVp9Private *const priv = &decoder->priv;
+ GstVp9FrameHdr *frame_hdr = &priv->frame_hdr;
GstVaapiPicture *picture;
GstVaapiDecoderStatus status;
+ guint crop_width = 0, crop_height = 0;
status = ensure_context (decoder);
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
@@ -413,6 +415,23 @@ decode_picture (GstVaapiDecoderVp9 * decoder, const guchar * buf,
gst_vaapi_picture_replace (&priv->current_picture, picture);
gst_vaapi_picture_unref (picture);
+ if (frame_hdr->display_size_enabled) {
+ crop_width = frame_hdr->display_width;
+ crop_height = frame_hdr->display_height;
+ } else if (priv->width > frame_hdr->width
+ || priv->height > frame_hdr->height) {
+ crop_width = frame_hdr->width;
+ crop_height = frame_hdr->height;
+ }
+ if (crop_width || crop_height) {
+ GstVaapiRectangle crop_rect;
+ crop_rect.x = 0;
+ crop_rect.y = 0;
+ crop_rect.width = crop_width;
+ crop_rect.height = crop_height;
+ gst_vaapi_picture_set_crop_rect (picture, &crop_rect);
+ }
+
init_picture (decoder, picture);
if (!fill_picture (decoder, picture))
return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;