mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
basetransform: only get caps for size transform
Delay getting the caps until we need to call the transform_size function.
This commit is contained in:
parent
e4ee356449
commit
3bb167a1bf
1 changed files with 37 additions and 34 deletions
|
@ -1371,8 +1371,6 @@ gst_base_transform_prepare_output_buffer (GstBaseTransform * trans,
|
||||||
GstBaseTransformPrivate *priv;
|
GstBaseTransformPrivate *priv;
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
gboolean copymeta;
|
gboolean copymeta;
|
||||||
gsize insize, outsize;
|
|
||||||
GstCaps *incaps = NULL, *outcaps = NULL;
|
|
||||||
|
|
||||||
bclass = GST_BASE_TRANSFORM_GET_CLASS (trans);
|
bclass = GST_BASE_TRANSFORM_GET_CLASS (trans);
|
||||||
|
|
||||||
|
@ -1380,34 +1378,6 @@ gst_base_transform_prepare_output_buffer (GstBaseTransform * trans,
|
||||||
|
|
||||||
*out_buf = NULL;
|
*out_buf = NULL;
|
||||||
|
|
||||||
insize = gst_buffer_get_size (in_buf);
|
|
||||||
|
|
||||||
/* figure out how to allocate a buffer based on the current configuration */
|
|
||||||
if (trans->passthrough) {
|
|
||||||
GST_DEBUG_OBJECT (trans, "doing passthrough alloc");
|
|
||||||
/* passthrough, the output size is the same as the input size. */
|
|
||||||
outsize = insize;
|
|
||||||
} else {
|
|
||||||
gboolean want_in_place = (bclass->transform_ip != NULL)
|
|
||||||
&& trans->always_in_place;
|
|
||||||
|
|
||||||
if (want_in_place) {
|
|
||||||
GST_DEBUG_OBJECT (trans, "doing inplace alloc");
|
|
||||||
/* we alloc a buffer of the same size as the input */
|
|
||||||
outsize = insize;
|
|
||||||
} else {
|
|
||||||
incaps = gst_pad_get_current_caps (trans->sinkpad);
|
|
||||||
outcaps = gst_pad_get_current_caps (trans->srcpad);
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (trans, "getting output size for copy transform");
|
|
||||||
/* copy transform, figure out the output size */
|
|
||||||
if (!gst_base_transform_transform_size (trans,
|
|
||||||
GST_PAD_SINK, incaps, insize, outcaps, &outsize)) {
|
|
||||||
goto unknown_size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bclass->prepare_output_buffer) {
|
if (bclass->prepare_output_buffer) {
|
||||||
GST_DEBUG_OBJECT (trans, "calling prepare buffer");
|
GST_DEBUG_OBJECT (trans, "calling prepare buffer");
|
||||||
ret = bclass->prepare_output_buffer (trans, in_buf, out_buf);
|
ret = bclass->prepare_output_buffer (trans, in_buf, out_buf);
|
||||||
|
@ -1432,6 +1402,43 @@ gst_base_transform_prepare_output_buffer (GstBaseTransform * trans,
|
||||||
GST_DEBUG_OBJECT (trans, "using pool alloc");
|
GST_DEBUG_OBJECT (trans, "using pool alloc");
|
||||||
ret = gst_buffer_pool_acquire_buffer (priv->pool, out_buf, NULL);
|
ret = gst_buffer_pool_acquire_buffer (priv->pool, out_buf, NULL);
|
||||||
} else {
|
} else {
|
||||||
|
gsize insize, outsize;
|
||||||
|
gboolean res;
|
||||||
|
|
||||||
|
/* no pool, we need to figure out the size of the output buffer first */
|
||||||
|
insize = gst_buffer_get_size (in_buf);
|
||||||
|
|
||||||
|
if (trans->passthrough) {
|
||||||
|
GST_DEBUG_OBJECT (trans, "doing passthrough alloc");
|
||||||
|
/* passthrough, the output size is the same as the input size. */
|
||||||
|
outsize = insize;
|
||||||
|
} else {
|
||||||
|
gboolean want_in_place = (bclass->transform_ip != NULL)
|
||||||
|
&& trans->always_in_place;
|
||||||
|
|
||||||
|
if (want_in_place) {
|
||||||
|
GST_DEBUG_OBJECT (trans, "doing inplace alloc");
|
||||||
|
/* we alloc a buffer of the same size as the input */
|
||||||
|
outsize = insize;
|
||||||
|
} else {
|
||||||
|
GstCaps *incaps, *outcaps;
|
||||||
|
|
||||||
|
/* else use the transform function to get the size */
|
||||||
|
incaps = gst_pad_get_current_caps (trans->sinkpad);
|
||||||
|
outcaps = gst_pad_get_current_caps (trans->srcpad);
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (trans, "getting output size for alloc");
|
||||||
|
/* copy transform, figure out the output size */
|
||||||
|
res = gst_base_transform_transform_size (trans,
|
||||||
|
GST_PAD_SINK, incaps, insize, outcaps, &outsize);
|
||||||
|
|
||||||
|
gst_caps_unref (incaps);
|
||||||
|
gst_caps_unref (outcaps);
|
||||||
|
|
||||||
|
if (!res)
|
||||||
|
goto unknown_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
GST_DEBUG_OBJECT (trans, "doing alloc of size %u", outsize);
|
GST_DEBUG_OBJECT (trans, "doing alloc of size %u", outsize);
|
||||||
*out_buf =
|
*out_buf =
|
||||||
gst_buffer_new_allocate (priv->allocator, outsize, priv->alignment);
|
gst_buffer_new_allocate (priv->allocator, outsize, priv->alignment);
|
||||||
|
@ -1500,10 +1507,6 @@ gst_base_transform_prepare_output_buffer (GstBaseTransform * trans,
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (incaps)
|
|
||||||
gst_caps_unref (incaps);
|
|
||||||
if (outcaps)
|
|
||||||
gst_caps_unref (outcaps);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue