d3d11compositor: Add support for crop meta

GstD3D11Converter supports cropping already. Cropping is just
a matter of setting source rectangle area to converter,
from d3d11 point of view

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2782>
This commit is contained in:
Seungha Yang 2022-07-22 04:51:14 +09:00
parent aa0b7f3284
commit ac6577e2a9

View file

@ -1674,6 +1674,7 @@ gst_d3d11_compositor_propose_allocation (GstAggregator * agg,
}
gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE, nullptr);
gst_query_add_allocation_meta (query, GST_VIDEO_CROP_META_API_TYPE, nullptr);
return TRUE;
}
@ -2077,6 +2078,8 @@ gst_d3d11_compositor_aggregate_frames (GstVideoAggregator * vagg,
GstD3D11CompositorPad *cpad = GST_D3D11_COMPOSITOR_PAD (pad);
GstVideoFrame *prepared_frame =
gst_video_aggregator_pad_get_prepared_frame (pad);
gint x, y, w, h;
GstVideoCropMeta *crop_meta;
if (!prepared_frame)
continue;
@ -2087,6 +2090,21 @@ gst_d3d11_compositor_aggregate_frames (GstVideoAggregator * vagg,
break;
}
crop_meta = gst_buffer_get_video_crop_meta (prepared_frame->buffer);
if (crop_meta) {
x = crop_meta->x;
y = crop_meta->y;
w = crop_meta->width;
h = crop_meta->height;
} else {
x = y = 0;
w = pad->info.width;
h = pad->info.height;
}
g_object_set (cpad->convert, "src-x", x, "src-y", y, "src-width", w,
"src-height", h, nullptr);
if (!gst_d3d11_converter_convert_buffer_unlocked (cpad->convert,
prepared_frame->buffer, target_buf)) {
GST_ERROR_OBJECT (self, "Couldn't convert frame");