mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
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
This commit is contained in:
parent
a48eebefd6
commit
8ee23ffd96
1 changed files with 19 additions and 0 deletions
|
@ -395,8 +395,10 @@ decode_picture (GstVaapiDecoderVp9 * decoder, const guchar * buf,
|
||||||
guint buf_size)
|
guint buf_size)
|
||||||
{
|
{
|
||||||
GstVaapiDecoderVp9Private *const priv = &decoder->priv;
|
GstVaapiDecoderVp9Private *const priv = &decoder->priv;
|
||||||
|
GstVp9FrameHdr *frame_hdr = &priv->frame_hdr;
|
||||||
GstVaapiPicture *picture;
|
GstVaapiPicture *picture;
|
||||||
GstVaapiDecoderStatus status;
|
GstVaapiDecoderStatus status;
|
||||||
|
guint crop_width = 0, crop_height = 0;
|
||||||
|
|
||||||
status = ensure_context (decoder);
|
status = ensure_context (decoder);
|
||||||
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
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_replace (&priv->current_picture, picture);
|
||||||
gst_vaapi_picture_unref (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);
|
init_picture (decoder, picture);
|
||||||
if (!fill_picture (decoder, picture))
|
if (!fill_picture (decoder, picture))
|
||||||
return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;
|
return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;
|
||||||
|
|
Loading…
Reference in a new issue