d3d11compositor: Fix caps update handling

New caps is applied only when previous buffer is consumed if any.
So, the lastest given caps might not be corresponding to the current buffer
to be handled.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2284>
This commit is contained in:
Seungha Yang 2021-05-26 16:37:06 +09:00
parent 9514340d2d
commit da33921f8d

View file

@ -407,7 +407,6 @@ struct _GstD3D11CompositorPad
gboolean alpha_updated;
gboolean blend_desc_updated;
ID3D11BlendState *blend;
gboolean caps_updated;
/* properties */
gint xpos;
@ -431,6 +430,8 @@ struct _GstD3D11Compositor
GstD3D11Quad *checker_background;
D3D11_VIEWPORT viewport;
gboolean reconfigured;
/* properties */
gint adapter;
GstD3D11CompositorBackground background;
@ -1198,14 +1199,13 @@ gst_d3d11_compositor_pad_setup_converter (GstVideoAggregatorPad * pad,
guint zorder = 0;
#endif
if (!cpad->convert || cpad->alpha_updated || cpad->caps_updated) {
if (!cpad->convert || cpad->alpha_updated || self->reconfigured) {
if (cpad->convert)
gst_d3d11_converter_free (cpad->convert);
cpad->convert =
gst_d3d11_converter_new_with_alpha (self->device,
&pad->info, &vagg->info, cpad->alpha);
cpad->alpha_updated = FALSE;
cpad->caps_updated = FALSE;
if (!cpad->convert) {
GST_ERROR_OBJECT (pad, "Couldn't create converter");
return FALSE;
@ -1310,8 +1310,6 @@ static gboolean gst_d3d11_compositor_propose_allocation (GstAggregator *
GstQuery * query);
static gboolean gst_d3d11_compositor_decide_allocation (GstAggregator *
aggregator, GstQuery * query);
static gboolean gst_d3d11_compositor_sink_event (GstAggregator * agg,
GstAggregatorPad * pad, GstEvent * event);
static GstFlowReturn
gst_d3d11_compositor_aggregate_frames (GstVideoAggregator * vagg,
GstBuffer * outbuf);
@ -1369,8 +1367,6 @@ gst_d3d11_compositor_class_init (GstD3D11CompositorClass * klass)
GST_DEBUG_FUNCPTR (gst_d3d11_compositor_propose_allocation);
aggregator_class->decide_allocation =
GST_DEBUG_FUNCPTR (gst_d3d11_compositor_decide_allocation);
aggregator_class->sink_event =
GST_DEBUG_FUNCPTR (gst_d3d11_compositor_sink_event);
vagg_class->aggregate_frames =
GST_DEBUG_FUNCPTR (gst_d3d11_compositor_aggregate_frames);
@ -1903,27 +1899,11 @@ gst_d3d11_compositor_decide_allocation (GstAggregator * aggregator,
gst_query_add_allocation_pool (query, pool, size, min, max);
gst_object_unref (pool);
self->reconfigured = TRUE;
return TRUE;
}
static gboolean
gst_d3d11_compositor_sink_event (GstAggregator * agg, GstAggregatorPad * pad,
GstEvent * event)
{
GstD3D11CompositorPad *cpad = GST_D3D11_COMPOSITOR_PAD (pad);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_CAPS:
GST_DEBUG_OBJECT (pad, "Got new caps event %" GST_PTR_FORMAT, event);
cpad->caps_updated = TRUE;
break;
default:
break;
}
return GST_AGGREGATOR_CLASS (parent_class)->sink_event (agg, pad, event);
}
typedef struct
{
struct
@ -2251,6 +2231,8 @@ gst_d3d11_compositor_aggregate_frames (GstVideoAggregator * vagg,
break;
}
}
self->reconfigured = FALSE;
GST_OBJECT_UNLOCK (self);
gst_d3d11_device_unlock (self->device);