guint min_buffers;
guint max_buffers;
guint prefix;
+ guint padding;
guint align;
};
pool->priv->started = FALSE;
pool->priv->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_DEBUG_OBJECT (pool, "created");
*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_buffer_take_memory (*buffer, -1, mem);
GstBufferPoolPrivate *priv = pool->priv;
const GstCaps *caps;
guint size, min_buffers, max_buffers;
- guint prefix, align;
+ guint prefix, padding, align;
/* parse the config and keep around */
if (!gst_buffer_pool_config_get (config, &caps, &size, &min_buffers,
- &max_buffers, &prefix, &align))
+ &max_buffers, &prefix, &padding, &align))
goto wrong_config;
GST_DEBUG_OBJECT (pool, "config %" GST_PTR_FORMAT, config);
priv->min_buffers = min_buffers;
priv->max_buffers = max_buffers;
priv->prefix = prefix;
+ priv->padding = padding;
priv->align = align;
return TRUE;
* gst_buffer_pool_config_set:
* @config: a #GstBufferPool configuration
* @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.
* @max_buffers: the maximum amount of buffers to allocate or 0 for unlimited.
* @prefix: prefix each buffer with this many bytes
+ * @padding: pad each buffer with this many bytes
* @align: alignment of the buffer data.
*
* Configure @config with the given parameters.
*/
void
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);
GST_QUARK (MIN_BUFFERS), G_TYPE_UINT, min_buffers,
GST_QUARK (MAX_BUFFERS), G_TYPE_UINT, max_buffers,
GST_QUARK (PREFIX), G_TYPE_UINT, prefix,
+ GST_QUARK (PADDING), G_TYPE_UINT, padding,
GST_QUARK (ALIGN), G_TYPE_UINT, align, NULL);
}
* gst_buffer_pool_config_get:
* @config: (transfer none): a #GstBufferPool configuration
* @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.
* @max_buffers: (out): the maximum amount of buffers to allocate or 0 for unlimited.
* @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.
*
* Get the configuration values from @config.
gboolean
gst_buffer_pool_config_get (GstStructure * config, const GstCaps ** caps,
guint * size, guint * min_buffers, guint * max_buffers, guint * prefix,
- guint * align)
+ guint * padding, guint * align)
{
g_return_val_if_fail (config != NULL, FALSE);
GST_QUARK (MIN_BUFFERS), G_TYPE_UINT, min_buffers,
GST_QUARK (MAX_BUFFERS), G_TYPE_UINT, max_buffers,
GST_QUARK (PREFIX), G_TYPE_UINT, prefix,
+ GST_QUARK (PADDING), G_TYPE_UINT, padding,
GST_QUARK (ALIGN), G_TYPE_UINT, align, NULL);
}
* be released when there are no buffers available.
* @alloc_buffer: allocate a buffer. the default implementation allocates
* 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
* be removed from the buffer in @reset_buffer.
* @reset_buffer: reset the buffer to its state when it was freshly allocated.
/* helpers for configuring the config structure */
void gst_buffer_pool_config_set (GstStructure *config, const GstCaps *caps,
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,
guint *size, guint *min_buffers, guint *max_buffers,
- guint *prefix, guint *align);
+ guint *prefix, guint *padding, guint *align);
/* options */
guint gst_buffer_pool_config_n_options (GstStructure *config);
"message", "GstMessageQOS", "running-time", "stream-time", "jitter",
"quality", "processed", "dropped", "buffering-ranges", "GstMessageProgress",
"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",
"GstEventReconfigure", "segment", "GstQueryScheduling", "pull-mode",
"allocator", "GstEventFlushStop", "options", "GstQueryAcceptCaps",
GST_QUARK_MIN_BUFFERS = 109,
GST_QUARK_MAX_BUFFERS = 110,
GST_QUARK_PREFIX = 111,
- GST_QUARK_POSTFIX = 112,
+ GST_QUARK_PADDING = 112,
GST_QUARK_ALIGN = 113,
GST_QUARK_TIME = 114,
GST_QUARK_QUERY_ALLOCATION = 115,
GST_QUARK (MIN_BUFFERS), G_TYPE_UINT, 0,
GST_QUARK (MAX_BUFFERS), 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 (POOL), GST_TYPE_BUFFER_POOL, NULL, NULL);
* @min_buffers: the min buffers
* @max_buffers: the max buffers
* @prefix: the prefix
+ * @padding: the padding
* @alignment: the alignment
* @pool: the #GstBufferPool
*
*/
void
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)
{
GstStructure *structure;
GST_QUARK (MIN_BUFFERS), G_TYPE_UINT, min_buffers,
GST_QUARK (MAX_BUFFERS), G_TYPE_UINT, max_buffers,
GST_QUARK (PREFIX), G_TYPE_UINT, prefix,
+ GST_QUARK (PADDING), G_TYPE_UINT, padding,
GST_QUARK (ALIGN), G_TYPE_UINT, alignment,
GST_QUARK (POOL), GST_TYPE_BUFFER_POOL, pool, NULL);
}
* @min_buffers: (out) (allow-none): the min buffers
* @max_buffers: (out) (allow-none): the max buffers
* @prefix: (out) (allow-none): the prefix
+ * @padding: (out) (allow-none): the padding
* @alignment: (out) (allow-none): the alignment
* @pool: (out) (allow-none) (transfer full): the #GstBufferPool
*
void
gst_query_parse_allocation_params (GstQuery * query, guint * size,
guint * min_buffers, guint * max_buffers, guint * prefix,
- guint * alignment, GstBufferPool ** pool)
+ guint * padding, guint * alignment, GstBufferPool ** pool)
{
GstStructure *structure;
GST_QUARK (MIN_BUFFERS), G_TYPE_UINT, min_buffers,
GST_QUARK (MAX_BUFFERS), G_TYPE_UINT, max_buffers,
GST_QUARK (PREFIX), G_TYPE_UINT, prefix,
+ GST_QUARK (PADDING), G_TYPE_UINT, padding,
GST_QUARK (ALIGN), G_TYPE_UINT, alignment,
GST_QUARK (POOL), GST_TYPE_BUFFER_POOL, pool, NULL);
}
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,
- guint max_buffers, guint prefix, guint alignment,
- GstBufferPool *pool);
+ guint max_buffers, guint prefix, guint padding,
+ guint alignment, GstBufferPool *pool);
void gst_query_parse_allocation_params (GstQuery *query, guint *size, guint *min_buffers,
- guint *max_buffers, guint *prefix, guint *alignment,
- GstBufferPool **pool);
+ guint *max_buffers, guint *prefix, guint *padding,
+ guint *alignment, GstBufferPool **pool);
void gst_query_add_allocation_meta (GstQuery *query, GType api);
guint gst_query_get_n_allocation_metas (GstQuery *query);
GstBufferPool *pool;
GstAllocator *allocator;
guint prefix;
+ guint padding;
guint alignment;
};
GstMemory *mem;
guint maxsize;
- maxsize = size + priv->prefix;
+ maxsize = size + priv->prefix + priv->padding;
mem = gst_allocator_alloc (priv->allocator, maxsize, priv->alignment);
if (G_UNLIKELY (mem == NULL))
goto alloc_failed;
- if (priv->prefix != 0)
+ if (priv->prefix != 0 || priv->padding != 0)
gst_memory_resize (mem, priv->prefix, size);
*buffer = gst_buffer_new ();
static gboolean
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;
GstBufferPool *oldpool;
priv->allocator = allocator;
priv->prefix = prefix;
+ priv->padding = padding;
priv->alignment = alignment;
GST_OBJECT_UNLOCK (basesrc);
GstQuery *query;
GstBufferPool *pool = NULL;
GstAllocator *allocator = NULL;
- guint size, min, max, prefix, alignment;
+ guint size, min, max, prefix, padding, alignment;
bclass = GST_BASE_SRC_GET_CLASS (basesrc);
GST_DEBUG_OBJECT (basesrc, "ALLOCATION (%d) params: %" GST_PTR_FORMAT, result,
query);
gst_query_parse_allocation_params (query, &size, &min, &max, &prefix,
- &alignment, &pool);
+ &padding, &alignment, &pool);
if (size == 0) {
/* no size, we have variable size buffers */
config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_set (config, caps, size, min, max, prefix,
- alignment);
+ padding, alignment);
gst_buffer_pool_set_config (pool, config);
}
gst_query_unref (query);
result =
- gst_base_src_set_allocation (basesrc, pool, allocator, prefix, alignment);
+ gst_base_src_set_allocation (basesrc, pool, allocator, prefix, padding,
+ alignment);
return result;
if (bclass->stop)
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;
gboolean pool_active;
GstAllocator *allocator;
guint prefix;
+ guint padding;
guint alignment;
GstQuery *query;
};
static gboolean
gst_base_transform_set_allocation (GstBaseTransform * trans,
GstBufferPool * pool, GstAllocator * allocator, guint prefix,
- guint alignment, GstQuery * query)
+ guint padding, guint alignment, GstQuery * query)
{
GstAllocator *oldalloc;
GstBufferPool *oldpool;
oldquery = priv->query;
priv->query = query;
priv->prefix = prefix;
+ priv->padding = padding;
priv->alignment = alignment;
GST_OBJECT_UNLOCK (trans);
GstQuery *query;
gboolean result = TRUE;
GstBufferPool *pool = NULL;
- guint size, min, max, prefix, alignment;
+ guint size, min, max, prefix, padding, alignment;
GstBaseTransformClass *klass;
GstAllocator *allocator = NULL;
* let the upstream element decide if it wants to use a bufferpool and
* then we will proxy the downstream pool */
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;
}
/* we got configuration from our peer, parse them */
gst_query_parse_allocation_params (query, &size, &min, &max, &prefix,
- &alignment, &pool);
+ &padding, &alignment, &pool);
if (size == 0) {
/* no size, we have variable size buffers */
GST_DEBUG_OBJECT (trans, "no pool, making one");
config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_set (config, outcaps, size, min, max, prefix,
- alignment);
+ padding, alignment);
gst_buffer_pool_set_config (pool, config);
}
/* and store */
result =
gst_base_transform_set_allocation (trans, pool, allocator, prefix,
- alignment, query);
+ padding, alignment, query);
return result;
GstFlowReturn ret = GST_FLOW_OK;
GstBaseTransformClass *bclass;
GstCaps *incaps, *outcaps;
- gsize insize, outsize;
+ gsize insize, outsize, maxsize;
+ GstMemory *mem;
gboolean res;
priv = trans->priv;
goto unknown_size;
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 the metadata */
if (trans->priv->pad_mode != GST_PAD_MODE_NONE && bclass->stop)
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;