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
This commit is contained in:
U. Artie Eoff 2019-08-30 14:14:30 -07:00 committed by Víctor Manuel Jáquez Leal
parent 9fd020a117
commit c6ee20fab3

View file

@ -1443,7 +1443,7 @@ gst_vaapipostproc_prepare_output_buffer (GstBaseTransform * trans,
GstBuffer * inbuf, GstBuffer ** outbuf_ptr) GstBuffer * inbuf, GstBuffer ** outbuf_ptr)
{ {
GstVaapiPostproc *const postproc = GST_VAAPIPOSTPROC (trans); GstVaapiPostproc *const postproc = GST_VAAPIPOSTPROC (trans);
const GstVideoCropMeta *crop_meta; const GstVideoMeta *video_meta;
GstVideoInfo info; GstVideoInfo info;
if (gst_base_transform_is_passthrough (trans)) { 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) /* 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 */ * then, ensure our output buffer pool is sized for uncropped output */
crop_meta = gst_buffer_get_video_crop_meta (inbuf); if (gst_buffer_get_video_crop_meta (inbuf) && !use_vpp_crop (postproc)) {
if (crop_meta && !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 = postproc->srcpad_info;
info.width += crop_meta->x; info.width = video_meta->width;
info.height += crop_meta->y; info.height = video_meta->height;
ensure_buffer_pool (postproc, &info); ensure_buffer_pool (postproc, &info);
} }