mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
basetransform: improve propose_allocation
Always call the propose_allocation method and provide a default implementation that passes the query on in passthrough mode so that subclasses can also call this. Also pass if the transform is in passthrough mode so that the implementation can adjust its algorithm.
This commit is contained in:
parent
90a82c7e81
commit
f3ca3f89f7
2 changed files with 33 additions and 12 deletions
|
@ -330,6 +330,8 @@ static gboolean gst_base_transform_acceptcaps_default (GstBaseTransform * trans,
|
|||
GstPadDirection direction, GstCaps * caps);
|
||||
static gboolean gst_base_transform_setcaps (GstBaseTransform * trans,
|
||||
GstPad * pad, GstCaps * caps);
|
||||
static gboolean gst_base_transform_default_propose_allocation (GstBaseTransform
|
||||
* trans, gboolean passthrough, GstQuery * query);
|
||||
static gboolean gst_base_transform_query (GstPad * pad, GstObject * parent,
|
||||
GstQuery * query);
|
||||
static gboolean gst_base_transform_default_query (GstBaseTransform * trans,
|
||||
|
@ -392,6 +394,8 @@ gst_base_transform_class_init (GstBaseTransformClass * klass)
|
|||
klass->accept_caps =
|
||||
GST_DEBUG_FUNCPTR (gst_base_transform_acceptcaps_default);
|
||||
klass->query = GST_DEBUG_FUNCPTR (gst_base_transform_default_query);
|
||||
klass->propose_allocation =
|
||||
GST_DEBUG_FUNCPTR (gst_base_transform_default_propose_allocation);
|
||||
klass->transform_size =
|
||||
GST_DEBUG_FUNCPTR (gst_base_transform_default_transform_size);
|
||||
|
||||
|
@ -807,7 +811,7 @@ gst_base_transform_do_bufferpool (GstBaseTransform * trans, GstCaps * outcaps)
|
|||
* 2) we need to do a transform, we need to get a bufferpool from downstream
|
||||
* and configure it. When upstream does the ALLOCATION query, the
|
||||
* propose_allocation vmethod will be called and we will configure the
|
||||
* upstream allocator with our porposed values then.
|
||||
* upstream allocator with our proposed values then.
|
||||
*/
|
||||
|
||||
/* clear old pool */
|
||||
|
@ -1303,6 +1307,21 @@ failed_configure:
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_base_transform_default_propose_allocation (GstBaseTransform * trans,
|
||||
gboolean passthrough, GstQuery * query)
|
||||
{
|
||||
gboolean ret;
|
||||
|
||||
if (passthrough) {
|
||||
GST_DEBUG_OBJECT (trans, "doing passthrough query");
|
||||
ret = gst_pad_peer_query (trans->srcpad, query);
|
||||
} else {
|
||||
ret = FALSE;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_base_transform_default_query (GstBaseTransform * trans,
|
||||
GstPadDirection direction, GstQuery * query)
|
||||
|
@ -1334,16 +1353,15 @@ gst_base_transform_default_query (GstBaseTransform * trans,
|
|||
passthrough = trans->passthrough;
|
||||
GST_BASE_TRANSFORM_UNLOCK (trans);
|
||||
|
||||
GST_DEBUG_OBJECT (trans, "propose allocation values");
|
||||
GST_DEBUG_OBJECT (trans, "propose %spassthrough allocation values",
|
||||
(passthrough ? "" : "non-"));
|
||||
|
||||
/* pass the query to the propose_allocation vmethod if any */
|
||||
if (G_LIKELY (klass->propose_allocation)) {
|
||||
ret = klass->propose_allocation (trans, query);
|
||||
} else if (passthrough) {
|
||||
GST_DEBUG_OBJECT (trans, "doing passthrough query");
|
||||
ret = gst_pad_peer_query (otherpad, query);
|
||||
} else {
|
||||
if (G_LIKELY (klass->propose_allocation))
|
||||
ret = klass->propose_allocation (trans, passthrough, query);
|
||||
else
|
||||
ret = FALSE;
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (trans, "ALLOCATION ret %d, %" GST_PTR_FORMAT, ret,
|
||||
query);
|
||||
break;
|
||||
|
|
|
@ -162,7 +162,9 @@ struct _GstBaseTransform {
|
|||
* query
|
||||
* @propose_allocation: Propose buffer allocation parameters for upstream elements.
|
||||
* This function must be implemented if the element reads or
|
||||
* writes the buffer content. The default implementation is NULL.
|
||||
* writes the buffer content. In passthrough mode, the
|
||||
* default implementation will forward the ALLOCATION query
|
||||
* downstream.
|
||||
* @decide_allocation: Setup the allocation parameters for allocating output
|
||||
* buffers. The passed in query contains the result of the
|
||||
* downstream allocation query. This function is only called
|
||||
|
@ -237,9 +239,10 @@ struct _GstBaseTransformClass {
|
|||
GstQuery *query);
|
||||
|
||||
/* propose allocation query parameters for input buffers */
|
||||
gboolean (*propose_allocation) (GstBaseTransform *trans, GstQuery *query);
|
||||
gboolean (*propose_allocation) (GstBaseTransform *trans, gboolean passthrough,
|
||||
GstQuery *query);
|
||||
/* decide allocation query for output buffers */
|
||||
gboolean (*decide_allocation) (GstBaseTransform *trans, GstQuery *query);
|
||||
gboolean (*decide_allocation) (GstBaseTransform *trans, GstQuery *query);
|
||||
|
||||
/* transform size */
|
||||
gboolean (*transform_size) (GstBaseTransform *trans,
|
||||
|
|
Loading…
Reference in a new issue