query: also include padding in ALLOCATION query

Negotiating padding is needed on second thought so include it in the
ALLOCATION query.
Make the bufferpool take padding into account when allocating.
Make basesrc take padding into account.
Use padding and prefix when allocating in basetransform.
This commit is contained in:
Wim Taymans 2012-03-14 19:37:22 +01:00
parent 72ac5f5165
commit 3d76e6011c
8 changed files with 62 additions and 36 deletions

View file

@ -70,6 +70,7 @@ struct _GstBufferPoolPrivate
guint min_buffers; guint min_buffers;
guint max_buffers; guint max_buffers;
guint prefix; guint prefix;
guint padding;
guint align; guint align;
}; };
@ -133,7 +134,7 @@ gst_buffer_pool_init (GstBufferPool * pool)
pool->priv->started = FALSE; pool->priv->started = FALSE;
pool->priv->config = pool->priv->config =
gst_structure_new_id_empty (GST_QUARK (BUFFER_POOL_CONFIG)); gst_structure_new_id_empty (GST_QUARK (BUFFER_POOL_CONFIG));
gst_buffer_pool_config_set (pool->priv->config, NULL, 0, 0, 0, 0, 0); gst_buffer_pool_config_set (pool->priv->config, NULL, 0, 0, 0, 0, 0, 0);
gst_poll_write_control (pool->priv->poll); gst_poll_write_control (pool->priv->poll);
GST_DEBUG_OBJECT (pool, "created"); GST_DEBUG_OBJECT (pool, "created");
@ -184,7 +185,9 @@ default_alloc_buffer (GstBufferPool * pool, GstBuffer ** buffer,
*buffer = gst_buffer_new (); *buffer = gst_buffer_new ();
mem = gst_allocator_alloc (NULL, priv->size + priv->prefix, priv->align); mem =
gst_allocator_alloc (NULL, priv->size + priv->prefix + priv->padding,
priv->align);
gst_memory_resize (mem, priv->prefix, priv->size); gst_memory_resize (mem, priv->prefix, priv->size);
gst_buffer_take_memory (*buffer, -1, mem); gst_buffer_take_memory (*buffer, -1, mem);
@ -431,11 +434,11 @@ default_set_config (GstBufferPool * pool, GstStructure * config)
GstBufferPoolPrivate *priv = pool->priv; GstBufferPoolPrivate *priv = pool->priv;
const GstCaps *caps; const GstCaps *caps;
guint size, min_buffers, max_buffers; guint size, min_buffers, max_buffers;
guint prefix, align; guint prefix, padding, align;
/* parse the config and keep around */ /* parse the config and keep around */
if (!gst_buffer_pool_config_get (config, &caps, &size, &min_buffers, if (!gst_buffer_pool_config_get (config, &caps, &size, &min_buffers,
&max_buffers, &prefix, &align)) &max_buffers, &prefix, &padding, &align))
goto wrong_config; goto wrong_config;
GST_DEBUG_OBJECT (pool, "config %" GST_PTR_FORMAT, config); GST_DEBUG_OBJECT (pool, "config %" GST_PTR_FORMAT, config);
@ -444,6 +447,7 @@ default_set_config (GstBufferPool * pool, GstStructure * config)
priv->min_buffers = min_buffers; priv->min_buffers = min_buffers;
priv->max_buffers = max_buffers; priv->max_buffers = max_buffers;
priv->prefix = prefix; priv->prefix = prefix;
priv->padding = padding;
priv->align = align; priv->align = align;
return TRUE; return TRUE;
@ -621,17 +625,19 @@ gst_buffer_pool_has_option (GstBufferPool * pool, const gchar * option)
* gst_buffer_pool_config_set: * gst_buffer_pool_config_set:
* @config: a #GstBufferPool configuration * @config: a #GstBufferPool configuration
* @caps: caps for the buffers * @caps: caps for the buffers
* @size: the size of each buffer, not including prefix * @size: the size of each buffer, not including prefix and padding
* @min_buffers: the minimum amount of buffers to allocate. * @min_buffers: the minimum amount of buffers to allocate.
* @max_buffers: the maximum amount of buffers to allocate or 0 for unlimited. * @max_buffers: the maximum amount of buffers to allocate or 0 for unlimited.
* @prefix: prefix each buffer with this many bytes * @prefix: prefix each buffer with this many bytes
* @padding: pad each buffer with this many bytes
* @align: alignment of the buffer data. * @align: alignment of the buffer data.
* *
* Configure @config with the given parameters. * Configure @config with the given parameters.
*/ */
void void
gst_buffer_pool_config_set (GstStructure * config, const GstCaps * caps, gst_buffer_pool_config_set (GstStructure * config, const GstCaps * caps,
guint size, guint min_buffers, guint max_buffers, guint prefix, guint align) guint size, guint min_buffers, guint max_buffers, guint prefix,
guint padding, guint align)
{ {
g_return_if_fail (config != NULL); g_return_if_fail (config != NULL);
@ -641,6 +647,7 @@ gst_buffer_pool_config_set (GstStructure * config, const GstCaps * caps,
GST_QUARK (MIN_BUFFERS), G_TYPE_UINT, min_buffers, GST_QUARK (MIN_BUFFERS), G_TYPE_UINT, min_buffers,
GST_QUARK (MAX_BUFFERS), G_TYPE_UINT, max_buffers, GST_QUARK (MAX_BUFFERS), G_TYPE_UINT, max_buffers,
GST_QUARK (PREFIX), G_TYPE_UINT, prefix, GST_QUARK (PREFIX), G_TYPE_UINT, prefix,
GST_QUARK (PADDING), G_TYPE_UINT, padding,
GST_QUARK (ALIGN), G_TYPE_UINT, align, NULL); GST_QUARK (ALIGN), G_TYPE_UINT, align, NULL);
} }
@ -772,10 +779,11 @@ gst_buffer_pool_config_has_option (GstStructure * config, const gchar * option)
* gst_buffer_pool_config_get: * gst_buffer_pool_config_get:
* @config: (transfer none): a #GstBufferPool configuration * @config: (transfer none): a #GstBufferPool configuration
* @caps: (out): the caps of buffers * @caps: (out): the caps of buffers
* @size: (out): the size of each buffer, not including prefix * @size: (out): the size of each buffer, not including prefix and padding
* @min_buffers: (out): the minimum amount of buffers to allocate. * @min_buffers: (out): the minimum amount of buffers to allocate.
* @max_buffers: (out): the maximum amount of buffers to allocate or 0 for unlimited. * @max_buffers: (out): the maximum amount of buffers to allocate or 0 for unlimited.
* @prefix: (out): prefix each buffer with this many bytes * @prefix: (out): prefix each buffer with this many bytes
* @padding: (out): pad each buffer with this many bytes
* @align: (out): alignment of the buffer data. * @align: (out): alignment of the buffer data.
* *
* Get the configuration values from @config. * Get the configuration values from @config.
@ -783,7 +791,7 @@ gst_buffer_pool_config_has_option (GstStructure * config, const gchar * option)
gboolean gboolean
gst_buffer_pool_config_get (GstStructure * config, const GstCaps ** caps, gst_buffer_pool_config_get (GstStructure * config, const GstCaps ** caps,
guint * size, guint * min_buffers, guint * max_buffers, guint * prefix, guint * size, guint * min_buffers, guint * max_buffers, guint * prefix,
guint * align) guint * padding, guint * align)
{ {
g_return_val_if_fail (config != NULL, FALSE); g_return_val_if_fail (config != NULL, FALSE);
@ -793,6 +801,7 @@ gst_buffer_pool_config_get (GstStructure * config, const GstCaps ** caps,
GST_QUARK (MIN_BUFFERS), G_TYPE_UINT, min_buffers, GST_QUARK (MIN_BUFFERS), G_TYPE_UINT, min_buffers,
GST_QUARK (MAX_BUFFERS), G_TYPE_UINT, max_buffers, GST_QUARK (MAX_BUFFERS), G_TYPE_UINT, max_buffers,
GST_QUARK (PREFIX), G_TYPE_UINT, prefix, GST_QUARK (PREFIX), G_TYPE_UINT, prefix,
GST_QUARK (PADDING), G_TYPE_UINT, padding,
GST_QUARK (ALIGN), G_TYPE_UINT, align, NULL); GST_QUARK (ALIGN), G_TYPE_UINT, align, NULL);
} }

View file

@ -128,7 +128,7 @@ struct _GstBufferPool {
* be released when there are no buffers available. * be released when there are no buffers available.
* @alloc_buffer: allocate a buffer. the default implementation allocates * @alloc_buffer: allocate a buffer. the default implementation allocates
* buffers from the default memory allocator and with the configured * buffers from the default memory allocator and with the configured
* size, prefix and alignment. All metadata that is present on the * size, prefix, padding and alignment. All metadata that is present on the
* allocated buffer will be marked as #GST_META_FLAG_POOLED and will not * allocated buffer will be marked as #GST_META_FLAG_POOLED and will not
* be removed from the buffer in @reset_buffer. * be removed from the buffer in @reset_buffer.
* @reset_buffer: reset the buffer to its state when it was freshly allocated. * @reset_buffer: reset the buffer to its state when it was freshly allocated.
@ -182,10 +182,10 @@ gboolean gst_buffer_pool_has_option (GstBufferPool *pool, const gch
/* helpers for configuring the config structure */ /* helpers for configuring the config structure */
void gst_buffer_pool_config_set (GstStructure *config, const GstCaps *caps, void gst_buffer_pool_config_set (GstStructure *config, const GstCaps *caps,
guint size, guint min_buffers, guint max_buffers, guint size, guint min_buffers, guint max_buffers,
guint prefix, guint align); guint prefix, guint padding, guint align);
gboolean gst_buffer_pool_config_get (GstStructure *config, const GstCaps **caps, gboolean gst_buffer_pool_config_get (GstStructure *config, const GstCaps **caps,
guint *size, guint *min_buffers, guint *max_buffers, guint *size, guint *min_buffers, guint *max_buffers,
guint *prefix, guint *align); guint *prefix, guint *padding, guint *align);
/* options */ /* options */
guint gst_buffer_pool_config_n_options (GstStructure *config); guint gst_buffer_pool_config_n_options (GstStructure *config);

View file

@ -51,7 +51,7 @@ static const gchar *_quark_strings[] = {
"message", "GstMessageQOS", "running-time", "stream-time", "jitter", "message", "GstMessageQOS", "running-time", "stream-time", "jitter",
"quality", "processed", "dropped", "buffering-ranges", "GstMessageProgress", "quality", "processed", "dropped", "buffering-ranges", "GstMessageProgress",
"code", "text", "percent", "timeout", "GstBufferPoolConfig", "caps", "size", "code", "text", "percent", "timeout", "GstBufferPoolConfig", "caps", "size",
"min-buffers", "max-buffers", "prefix", "postfix", "align", "time", "min-buffers", "max-buffers", "prefix", "padding", "align", "time",
"GstQueryAllocation", "need-pool", "meta", "pool", "GstEventCaps", "GstQueryAllocation", "need-pool", "meta", "pool", "GstEventCaps",
"GstEventReconfigure", "segment", "GstQueryScheduling", "pull-mode", "GstEventReconfigure", "segment", "GstQueryScheduling", "pull-mode",
"allocator", "GstEventFlushStop", "options", "GstQueryAcceptCaps", "allocator", "GstEventFlushStop", "options", "GstQueryAcceptCaps",

View file

@ -138,7 +138,7 @@ typedef enum _GstQuarkId
GST_QUARK_MIN_BUFFERS = 109, GST_QUARK_MIN_BUFFERS = 109,
GST_QUARK_MAX_BUFFERS = 110, GST_QUARK_MAX_BUFFERS = 110,
GST_QUARK_PREFIX = 111, GST_QUARK_PREFIX = 111,
GST_QUARK_POSTFIX = 112, GST_QUARK_PADDING = 112,
GST_QUARK_ALIGN = 113, GST_QUARK_ALIGN = 113,
GST_QUARK_TIME = 114, GST_QUARK_TIME = 114,
GST_QUARK_QUERY_ALLOCATION = 115, GST_QUARK_QUERY_ALLOCATION = 115,

View file

@ -1484,6 +1484,7 @@ gst_query_new_allocation (GstCaps * caps, gboolean need_pool)
GST_QUARK (MIN_BUFFERS), G_TYPE_UINT, 0, GST_QUARK (MIN_BUFFERS), G_TYPE_UINT, 0,
GST_QUARK (MAX_BUFFERS), G_TYPE_UINT, 0, GST_QUARK (MAX_BUFFERS), G_TYPE_UINT, 0,
GST_QUARK (PREFIX), G_TYPE_UINT, 0, GST_QUARK (PREFIX), G_TYPE_UINT, 0,
GST_QUARK (PADDING), G_TYPE_UINT, 0,
GST_QUARK (ALIGN), G_TYPE_UINT, 0, GST_QUARK (ALIGN), G_TYPE_UINT, 0,
GST_QUARK (POOL), GST_TYPE_BUFFER_POOL, NULL, NULL); GST_QUARK (POOL), GST_TYPE_BUFFER_POOL, NULL, NULL);
@ -1523,6 +1524,7 @@ gst_query_parse_allocation (GstQuery * query, GstCaps ** caps,
* @min_buffers: the min buffers * @min_buffers: the min buffers
* @max_buffers: the max buffers * @max_buffers: the max buffers
* @prefix: the prefix * @prefix: the prefix
* @padding: the padding
* @alignment: the alignment * @alignment: the alignment
* @pool: the #GstBufferPool * @pool: the #GstBufferPool
* *
@ -1530,7 +1532,7 @@ gst_query_parse_allocation (GstQuery * query, GstCaps ** caps,
*/ */
void void
gst_query_set_allocation_params (GstQuery * query, guint size, gst_query_set_allocation_params (GstQuery * query, guint size,
guint min_buffers, guint max_buffers, guint prefix, guint min_buffers, guint max_buffers, guint prefix, guint padding,
guint alignment, GstBufferPool * pool) guint alignment, GstBufferPool * pool)
{ {
GstStructure *structure; GstStructure *structure;
@ -1546,6 +1548,7 @@ gst_query_set_allocation_params (GstQuery * query, guint size,
GST_QUARK (MIN_BUFFERS), G_TYPE_UINT, min_buffers, GST_QUARK (MIN_BUFFERS), G_TYPE_UINT, min_buffers,
GST_QUARK (MAX_BUFFERS), G_TYPE_UINT, max_buffers, GST_QUARK (MAX_BUFFERS), G_TYPE_UINT, max_buffers,
GST_QUARK (PREFIX), G_TYPE_UINT, prefix, GST_QUARK (PREFIX), G_TYPE_UINT, prefix,
GST_QUARK (PADDING), G_TYPE_UINT, padding,
GST_QUARK (ALIGN), G_TYPE_UINT, alignment, GST_QUARK (ALIGN), G_TYPE_UINT, alignment,
GST_QUARK (POOL), GST_TYPE_BUFFER_POOL, pool, NULL); GST_QUARK (POOL), GST_TYPE_BUFFER_POOL, pool, NULL);
} }
@ -1557,6 +1560,7 @@ gst_query_set_allocation_params (GstQuery * query, guint size,
* @min_buffers: (out) (allow-none): the min buffers * @min_buffers: (out) (allow-none): the min buffers
* @max_buffers: (out) (allow-none): the max buffers * @max_buffers: (out) (allow-none): the max buffers
* @prefix: (out) (allow-none): the prefix * @prefix: (out) (allow-none): the prefix
* @padding: (out) (allow-none): the padding
* @alignment: (out) (allow-none): the alignment * @alignment: (out) (allow-none): the alignment
* @pool: (out) (allow-none) (transfer full): the #GstBufferPool * @pool: (out) (allow-none) (transfer full): the #GstBufferPool
* *
@ -1565,7 +1569,7 @@ gst_query_set_allocation_params (GstQuery * query, guint size,
void void
gst_query_parse_allocation_params (GstQuery * query, guint * size, gst_query_parse_allocation_params (GstQuery * query, guint * size,
guint * min_buffers, guint * max_buffers, guint * prefix, guint * min_buffers, guint * max_buffers, guint * prefix,
guint * alignment, GstBufferPool ** pool) guint * padding, guint * alignment, GstBufferPool ** pool)
{ {
GstStructure *structure; GstStructure *structure;
@ -1577,6 +1581,7 @@ gst_query_parse_allocation_params (GstQuery * query, guint * size,
GST_QUARK (MIN_BUFFERS), G_TYPE_UINT, min_buffers, GST_QUARK (MIN_BUFFERS), G_TYPE_UINT, min_buffers,
GST_QUARK (MAX_BUFFERS), G_TYPE_UINT, max_buffers, GST_QUARK (MAX_BUFFERS), G_TYPE_UINT, max_buffers,
GST_QUARK (PREFIX), G_TYPE_UINT, prefix, GST_QUARK (PREFIX), G_TYPE_UINT, prefix,
GST_QUARK (PADDING), G_TYPE_UINT, padding,
GST_QUARK (ALIGN), G_TYPE_UINT, alignment, GST_QUARK (ALIGN), G_TYPE_UINT, alignment,
GST_QUARK (POOL), GST_TYPE_BUFFER_POOL, pool, NULL); GST_QUARK (POOL), GST_TYPE_BUFFER_POOL, pool, NULL);
} }

View file

@ -402,11 +402,11 @@ GstQuery * gst_query_new_allocation (GstCaps *caps, gboolean need_
void gst_query_parse_allocation (GstQuery *query, GstCaps **caps, gboolean *need_pool); void gst_query_parse_allocation (GstQuery *query, GstCaps **caps, gboolean *need_pool);
void gst_query_set_allocation_params (GstQuery *query, guint size, guint min_buffers, void gst_query_set_allocation_params (GstQuery *query, guint size, guint min_buffers,
guint max_buffers, guint prefix, guint alignment, guint max_buffers, guint prefix, guint padding,
GstBufferPool *pool); guint alignment, GstBufferPool *pool);
void gst_query_parse_allocation_params (GstQuery *query, guint *size, guint *min_buffers, void gst_query_parse_allocation_params (GstQuery *query, guint *size, guint *min_buffers,
guint *max_buffers, guint *prefix, guint *alignment, guint *max_buffers, guint *prefix, guint *padding,
GstBufferPool **pool); guint *alignment, GstBufferPool **pool);
void gst_query_add_allocation_meta (GstQuery *query, GType api); void gst_query_add_allocation_meta (GstQuery *query, GType api);
guint gst_query_get_n_allocation_metas (GstQuery *query); guint gst_query_get_n_allocation_metas (GstQuery *query);

View file

@ -247,6 +247,7 @@ struct _GstBaseSrcPrivate
GstBufferPool *pool; GstBufferPool *pool;
GstAllocator *allocator; GstAllocator *allocator;
guint prefix; guint prefix;
guint padding;
guint alignment; guint alignment;
}; };
@ -1357,13 +1358,13 @@ gst_base_src_default_alloc (GstBaseSrc * src, guint64 offset,
GstMemory *mem; GstMemory *mem;
guint maxsize; guint maxsize;
maxsize = size + priv->prefix; maxsize = size + priv->prefix + priv->padding;
mem = gst_allocator_alloc (priv->allocator, maxsize, priv->alignment); mem = gst_allocator_alloc (priv->allocator, maxsize, priv->alignment);
if (G_UNLIKELY (mem == NULL)) if (G_UNLIKELY (mem == NULL))
goto alloc_failed; goto alloc_failed;
if (priv->prefix != 0) if (priv->prefix != 0 || priv->padding != 0)
gst_memory_resize (mem, priv->prefix, size); gst_memory_resize (mem, priv->prefix, size);
*buffer = gst_buffer_new (); *buffer = gst_buffer_new ();
@ -2722,7 +2723,7 @@ null_buffer:
static gboolean static gboolean
gst_base_src_set_allocation (GstBaseSrc * basesrc, GstBufferPool * pool, gst_base_src_set_allocation (GstBaseSrc * basesrc, GstBufferPool * pool,
GstAllocator * allocator, guint prefix, guint alignment) GstAllocator * allocator, guint prefix, guint padding, guint alignment)
{ {
GstAllocator *oldalloc; GstAllocator *oldalloc;
GstBufferPool *oldpool; GstBufferPool *oldpool;
@ -2742,6 +2743,7 @@ gst_base_src_set_allocation (GstBaseSrc * basesrc, GstBufferPool * pool,
priv->allocator = allocator; priv->allocator = allocator;
priv->prefix = prefix; priv->prefix = prefix;
priv->padding = padding;
priv->alignment = alignment; priv->alignment = alignment;
GST_OBJECT_UNLOCK (basesrc); GST_OBJECT_UNLOCK (basesrc);
@ -2793,7 +2795,7 @@ gst_base_src_prepare_allocation (GstBaseSrc * basesrc, GstCaps * caps)
GstQuery *query; GstQuery *query;
GstBufferPool *pool = NULL; GstBufferPool *pool = NULL;
GstAllocator *allocator = NULL; GstAllocator *allocator = NULL;
guint size, min, max, prefix, alignment; guint size, min, max, prefix, padding, alignment;
bclass = GST_BASE_SRC_GET_CLASS (basesrc); bclass = GST_BASE_SRC_GET_CLASS (basesrc);
@ -2812,7 +2814,7 @@ gst_base_src_prepare_allocation (GstBaseSrc * basesrc, GstCaps * caps)
GST_DEBUG_OBJECT (basesrc, "ALLOCATION (%d) params: %" GST_PTR_FORMAT, result, GST_DEBUG_OBJECT (basesrc, "ALLOCATION (%d) params: %" GST_PTR_FORMAT, result,
query); query);
gst_query_parse_allocation_params (query, &size, &min, &max, &prefix, gst_query_parse_allocation_params (query, &size, &min, &max, &prefix,
&alignment, &pool); &padding, &alignment, &pool);
if (size == 0) { if (size == 0) {
/* no size, we have variable size buffers */ /* no size, we have variable size buffers */
@ -2831,14 +2833,15 @@ gst_base_src_prepare_allocation (GstBaseSrc * basesrc, GstCaps * caps)
config = gst_buffer_pool_get_config (pool); config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_set (config, caps, size, min, max, prefix, gst_buffer_pool_config_set (config, caps, size, min, max, prefix,
alignment); padding, alignment);
gst_buffer_pool_set_config (pool, config); gst_buffer_pool_set_config (pool, config);
} }
gst_query_unref (query); gst_query_unref (query);
result = result =
gst_base_src_set_allocation (basesrc, pool, allocator, prefix, alignment); gst_base_src_set_allocation (basesrc, pool, allocator, prefix, padding,
alignment);
return result; return result;
@ -3195,7 +3198,7 @@ gst_base_src_stop (GstBaseSrc * basesrc)
if (bclass->stop) if (bclass->stop)
result = bclass->stop (basesrc); result = bclass->stop (basesrc);
gst_base_src_set_allocation (basesrc, NULL, NULL, 0, 0); gst_base_src_set_allocation (basesrc, NULL, NULL, 0, 0, 0);
return result; return result;

View file

@ -256,6 +256,7 @@ struct _GstBaseTransformPrivate
gboolean pool_active; gboolean pool_active;
GstAllocator *allocator; GstAllocator *allocator;
guint prefix; guint prefix;
guint padding;
guint alignment; guint alignment;
GstQuery *query; GstQuery *query;
}; };
@ -744,7 +745,7 @@ done:
static gboolean static gboolean
gst_base_transform_set_allocation (GstBaseTransform * trans, gst_base_transform_set_allocation (GstBaseTransform * trans,
GstBufferPool * pool, GstAllocator * allocator, guint prefix, GstBufferPool * pool, GstAllocator * allocator, guint prefix,
guint alignment, GstQuery * query) guint padding, guint alignment, GstQuery * query)
{ {
GstAllocator *oldalloc; GstAllocator *oldalloc;
GstBufferPool *oldpool; GstBufferPool *oldpool;
@ -760,6 +761,7 @@ gst_base_transform_set_allocation (GstBaseTransform * trans,
oldquery = priv->query; oldquery = priv->query;
priv->query = query; priv->query = query;
priv->prefix = prefix; priv->prefix = prefix;
priv->padding = padding;
priv->alignment = alignment; priv->alignment = alignment;
GST_OBJECT_UNLOCK (trans); GST_OBJECT_UNLOCK (trans);
@ -827,7 +829,7 @@ gst_base_transform_do_bufferpool (GstBaseTransform * trans, GstCaps * outcaps)
GstQuery *query; GstQuery *query;
gboolean result = TRUE; gboolean result = TRUE;
GstBufferPool *pool = NULL; GstBufferPool *pool = NULL;
guint size, min, max, prefix, alignment; guint size, min, max, prefix, padding, alignment;
GstBaseTransformClass *klass; GstBaseTransformClass *klass;
GstAllocator *allocator = NULL; GstAllocator *allocator = NULL;
@ -846,7 +848,7 @@ gst_base_transform_do_bufferpool (GstBaseTransform * trans, GstCaps * outcaps)
* let the upstream element decide if it wants to use a bufferpool and * let the upstream element decide if it wants to use a bufferpool and
* then we will proxy the downstream pool */ * then we will proxy the downstream pool */
GST_DEBUG_OBJECT (trans, "we're passthough, delay bufferpool"); GST_DEBUG_OBJECT (trans, "we're passthough, delay bufferpool");
gst_base_transform_set_allocation (trans, NULL, NULL, 0, 0, NULL); gst_base_transform_set_allocation (trans, NULL, NULL, 0, 0, 0, NULL);
return TRUE; return TRUE;
} }
@ -868,7 +870,7 @@ gst_base_transform_do_bufferpool (GstBaseTransform * trans, GstCaps * outcaps)
/* we got configuration from our peer, parse them */ /* we got configuration from our peer, parse them */
gst_query_parse_allocation_params (query, &size, &min, &max, &prefix, gst_query_parse_allocation_params (query, &size, &min, &max, &prefix,
&alignment, &pool); &padding, &alignment, &pool);
if (size == 0) { if (size == 0) {
/* no size, we have variable size buffers */ /* no size, we have variable size buffers */
@ -886,14 +888,14 @@ gst_base_transform_do_bufferpool (GstBaseTransform * trans, GstCaps * outcaps)
GST_DEBUG_OBJECT (trans, "no pool, making one"); GST_DEBUG_OBJECT (trans, "no pool, making one");
config = gst_buffer_pool_get_config (pool); config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_set (config, outcaps, size, min, max, prefix, gst_buffer_pool_config_set (config, outcaps, size, min, max, prefix,
alignment); padding, alignment);
gst_buffer_pool_set_config (pool, config); gst_buffer_pool_set_config (pool, config);
} }
/* and store */ /* and store */
result = result =
gst_base_transform_set_allocation (trans, pool, allocator, prefix, gst_base_transform_set_allocation (trans, pool, allocator, prefix,
alignment, query); padding, alignment, query);
return result; return result;
@ -1460,7 +1462,8 @@ default_prepare_output_buffer (GstBaseTransform * trans,
GstFlowReturn ret = GST_FLOW_OK; GstFlowReturn ret = GST_FLOW_OK;
GstBaseTransformClass *bclass; GstBaseTransformClass *bclass;
GstCaps *incaps, *outcaps; GstCaps *incaps, *outcaps;
gsize insize, outsize; gsize insize, outsize, maxsize;
GstMemory *mem;
gboolean res; gboolean res;
priv = trans->priv; priv = trans->priv;
@ -1519,7 +1522,13 @@ default_prepare_output_buffer (GstBaseTransform * trans,
goto unknown_size; goto unknown_size;
GST_DEBUG_OBJECT (trans, "doing alloc of size %" G_GSIZE_FORMAT, outsize); GST_DEBUG_OBJECT (trans, "doing alloc of size %" G_GSIZE_FORMAT, outsize);
*outbuf = gst_buffer_new_allocate (priv->allocator, outsize, priv->alignment); maxsize = outsize + priv->prefix + priv->padding;
mem = gst_allocator_alloc (priv->allocator, maxsize, priv->alignment);
if (priv->prefix != 0 || priv->padding != 0)
gst_memory_resize (mem, priv->prefix, outsize);
*outbuf = gst_buffer_new ();
gst_buffer_take_memory (*outbuf, -1, mem);
copy_meta: copy_meta:
/* copy the metadata */ /* copy the metadata */
@ -2236,7 +2245,7 @@ gst_base_transform_activate (GstBaseTransform * trans, gboolean active)
if (trans->priv->pad_mode != GST_PAD_MODE_NONE && bclass->stop) if (trans->priv->pad_mode != GST_PAD_MODE_NONE && bclass->stop)
result &= bclass->stop (trans); result &= bclass->stop (trans);
gst_base_transform_set_allocation (trans, NULL, NULL, 0, 0, NULL); gst_base_transform_set_allocation (trans, NULL, NULL, 0, 0, 0, NULL);
} }
return result; return result;