From c6ee20fab319a92a71a9fecf10703f1d211e3fba Mon Sep 17 00:00:00 2001 From: "U. Artie Eoff" Date: Fri, 30 Aug 2019 14:14:30 -0700 Subject: [PATCH] vaapipostproc: fix output buffer WxH for crop meta forwarding Adding crop meta x,y to w,h only compensates for left,top cropping. But we also need to compensate for right,bottom cropping. The video meta contains the appropriate w,h (uncropped) values, so use it instead. Test: gst-launch-1.0 -vf videotestsrc num-buffers=500 \ ! videocrop top=50 bottom=30 left=40 right=20 \ ! vaapipostproc ! vaapisink & \ gst-launch-1.0 -vf videotestsrc num-buffers=500 \ ! videocrop top=50 bottom=30 left=40 right=20 \ ! vaapipostproc ! identity drop-allocation=1 \ ! vaapisink --- gst/vaapi/gstvaapipostproc.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/gst/vaapi/gstvaapipostproc.c b/gst/vaapi/gstvaapipostproc.c index b115de01e7..724cf978d4 100644 --- a/gst/vaapi/gstvaapipostproc.c +++ b/gst/vaapi/gstvaapipostproc.c @@ -1443,7 +1443,7 @@ gst_vaapipostproc_prepare_output_buffer (GstBaseTransform * trans, GstBuffer * inbuf, GstBuffer ** outbuf_ptr) { GstVaapiPostproc *const postproc = GST_VAAPIPOSTPROC (trans); - const GstVideoCropMeta *crop_meta; + const GstVideoMeta *video_meta; GstVideoInfo info; if (gst_base_transform_is_passthrough (trans)) { @@ -1453,11 +1453,17 @@ gst_vaapipostproc_prepare_output_buffer (GstBaseTransform * trans, /* If we are not using vpp crop (i.e. forwarding crop meta to downstream) * then, ensure our output buffer pool is sized for uncropped output */ - crop_meta = gst_buffer_get_video_crop_meta (inbuf); - if (crop_meta && !use_vpp_crop (postproc)) { + if (gst_buffer_get_video_crop_meta (inbuf) && !use_vpp_crop (postproc)) { + /* The video meta is required since the caps width/height are smaller, + * which would not result in a usable GstVideoInfo for mapping the + * buffer. */ + video_meta = gst_buffer_get_video_meta (inbuf); + if (!video_meta) + return GST_FLOW_ERROR; + info = postproc->srcpad_info; - info.width += crop_meta->x; - info.height += crop_meta->y; + info.width = video_meta->width; + info.height = video_meta->height; ensure_buffer_pool (postproc, &info); }