take padding into account

This commit is contained in:
Wim Taymans 2012-03-14 19:52:03 +01:00
parent 090a8b2273
commit 39d78762b9
9 changed files with 46 additions and 30 deletions

View file

@ -422,7 +422,7 @@ gst_vis_src_negotiate (GstVisual * visual)
GstCaps *caps;
GstQuery *query;
GstBufferPool *pool = NULL;
guint size, min, max, prefix, alignment;
guint size, min, max, prefix, padding, alignment;
caps = gst_pad_query_caps (visual->srcpad, NULL);
@ -464,11 +464,12 @@ gst_vis_src_negotiate (GstVisual * visual)
if (gst_pad_peer_query (visual->srcpad, query)) {
/* we got configuration from our peer, parse them */
gst_query_parse_allocation_params (query, &size, &min, &max, &prefix,
&alignment, &pool);
&padding, &alignment, &pool);
} else {
size = visual->outsize;
min = max = 0;
prefix = 0;
padding = 0;
alignment = 0;
}
@ -480,7 +481,7 @@ gst_vis_src_negotiate (GstVisual * visual)
config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_set (config, target, size, min, max, prefix,
alignment);
padding, alignment);
gst_buffer_pool_set_config (pool, config);
}

View file

@ -773,7 +773,7 @@ theora_negotiate (GstTheoraDec * dec)
GstVideoFormat format;
GstQuery *query;
GstBufferPool *pool;
guint size, min, max, prefix, alignment;
guint size, min, max, prefix, padding, alignment;
GstStructure *config;
GstCaps *caps;
GstVideoInfo info, cinfo;
@ -879,7 +879,7 @@ theora_negotiate (GstTheoraDec * dec)
GST_DEBUG_OBJECT (dec, "got downstream ALLOCATION hints");
/* we got configuration from our peer, parse them */
gst_query_parse_allocation_params (query, &size, &min, &max, &prefix,
&alignment, &pool);
&padding, &alignment, &pool);
/* check if downstream supports cropping */
dec->has_cropping =
@ -889,6 +889,7 @@ theora_negotiate (GstTheoraDec * dec)
size = 0;
min = max = 0;
prefix = 0;
padding = 0;
alignment = 0;
pool = NULL;
dec->has_cropping = FALSE;
@ -917,7 +918,8 @@ theora_negotiate (GstTheoraDec * dec)
size = MAX (size, GST_VIDEO_INFO_SIZE (&dec->vinfo));
config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_set (config, caps, size, min, max, prefix, alignment);
gst_buffer_pool_config_set (config, caps, size, min, max, prefix, padding,
alignment);
gst_caps_unref (caps);
/* just set the option, if the pool can support it we will transparently use

View file

@ -86,13 +86,13 @@ gst_video_filter_propose_allocation (GstBaseTransform * trans,
pool = gst_video_buffer_pool_new ();
structure = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_set (structure, caps, size, 0, 0, 0, 15);
gst_buffer_pool_config_set (structure, caps, size, 0, 0, 0, 0, 15);
if (!gst_buffer_pool_set_config (pool, structure))
goto config_failed;
} else
pool = NULL;
gst_query_set_allocation_params (query, size, 0, 0, 0, 15, pool);
gst_query_set_allocation_params (query, size, 0, 0, 0, 0, 15, pool);
gst_object_unref (pool);
gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE);
@ -114,10 +114,10 @@ static gboolean
gst_video_filter_decide_allocation (GstBaseTransform * trans, GstQuery * query)
{
GstBufferPool *pool = NULL;
guint size, min, max, prefix, alignment;
guint size, min, max, prefix, padding, alignment;
gst_query_parse_allocation_params (query, &size, &min, &max, &prefix,
&alignment, &pool);
&padding, &alignment, &pool);
if (pool) {
GstStructure *config;

View file

@ -145,6 +145,7 @@ struct _GstVideoBufferPoolPrivate
gboolean add_videometa;
gboolean need_alignment;
guint prefix;
guint padding;
guint align;
};
@ -173,10 +174,10 @@ video_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
GstVideoInfo info;
const GstCaps *caps;
gint width, height;
guint prefix, align;
guint prefix, padding, align;
if (!gst_buffer_pool_config_get (config, &caps, NULL, NULL, NULL, &prefix,
&align))
&padding, &align))
goto wrong_config;
if (caps == NULL)
@ -195,6 +196,7 @@ video_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
gst_caps_unref (priv->caps);
priv->caps = gst_caps_copy (caps);
priv->prefix = prefix;
priv->padding = padding;
priv->align = align;
/* enable metadata based on config of the pool */
@ -242,18 +244,19 @@ video_buffer_pool_alloc (GstBufferPool * pool, GstBuffer ** buffer,
GstVideoBufferPoolPrivate *priv = vpool->priv;
GstVideoInfo *info;
GstMemory *mem;
gint maxsize;
info = &priv->info;
GST_DEBUG_OBJECT (pool, "alloc %" G_GSIZE_FORMAT, info->size);
mem =
gst_allocator_alloc (priv->allocator, info->size + priv->prefix,
priv->align);
maxsize = info->size + priv->prefix + priv->padding;
mem = gst_allocator_alloc (priv->allocator, maxsize, priv->align);
if (mem == NULL)
goto no_memory;
*buffer = gst_buffer_new ();
if (priv->prefix != 0 || priv->padding != 0)
gst_memory_resize (mem, priv->prefix, info->size);
gst_buffer_take_memory (*buffer, -1, mem);

View file

@ -611,12 +611,12 @@ gst_video_test_src_decide_allocation (GstBaseSrc * bsrc, GstQuery * query)
{
GstVideoTestSrc *videotestsrc;
GstBufferPool *pool;
guint size, min, max, prefix, alignment;
guint size, min, max, prefix, padding, alignment;
videotestsrc = GST_VIDEO_TEST_SRC (bsrc);
gst_query_parse_allocation_params (query, &size, &min, &max, &prefix,
&alignment, &pool);
&padding, &alignment, &pool);
/* adjust size */
size = MAX (size, videotestsrc->info.size);
@ -629,7 +629,7 @@ gst_video_test_src_decide_allocation (GstBaseSrc * bsrc, GstQuery * query)
gst_buffer_pool_set_config (pool, config);
}
gst_query_set_allocation_params (query, size, min, max, prefix,
alignment, pool);
padding, alignment, pool);
if (pool)
gst_object_unref (pool);

View file

@ -483,7 +483,8 @@ ximage_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
GstVideoInfo info;
const GstCaps *caps;
if (!gst_buffer_pool_config_get (config, &caps, NULL, NULL, NULL, NULL, NULL))
if (!gst_buffer_pool_config_get (config, &caps, NULL, NULL, NULL, NULL, NULL,
NULL))
goto wrong_config;
if (caps == NULL)

View file

@ -1148,12 +1148,16 @@ gst_ximagesink_setcaps (GstBaseSink * bsink, GstCaps * caps)
newpool = gst_ximage_buffer_pool_new (ximagesink);
structure = gst_buffer_pool_get_config (newpool);
gst_buffer_pool_config_set (structure, caps, size, 2, 0, 0, 15);
gst_buffer_pool_config_set (structure, caps, size, 2, 0, 0, 0, 15);
if (!gst_buffer_pool_set_config (newpool, structure))
goto config_failed;
oldpool = ximagesink->pool;
/* we don't activate the pool yet, this will be done by downstream after it
* has configured the pool. If downstream does not want our pool we will
* activate it when we render into it */
ximagesink->pool = newpool;
g_mutex_unlock (ximagesink->flow_lock);
/* unref the old sink */
if (oldpool) {
@ -1161,7 +1165,6 @@ gst_ximagesink_setcaps (GstBaseSink * bsink, GstCaps * caps)
* deactivated when the last ref is gone */
gst_object_unref (oldpool);
}
g_mutex_unlock (ximagesink->flow_lock);
return TRUE;
@ -1439,7 +1442,8 @@ gst_ximagesink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
/* we had a pool, check caps */
config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_get (config, &pcaps, &size, NULL, NULL, NULL, NULL);
gst_buffer_pool_config_get (config, &pcaps, &size, NULL, NULL, NULL, NULL,
NULL);
GST_DEBUG_OBJECT (ximagesink,
"we had a pool with caps %" GST_PTR_FORMAT, pcaps);
@ -1463,12 +1467,12 @@ gst_ximagesink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
size = info.size;
config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_set (config, caps, size, 0, 0, 0, 0);
gst_buffer_pool_config_set (config, caps, size, 0, 0, 0, 0, 0);
if (!gst_buffer_pool_set_config (pool, config))
goto config_failed;
}
/* we need at least 2 buffer because we hold on to the last one */
gst_query_set_allocation_params (query, size, 2, 0, 0, 0, pool);
gst_query_set_allocation_params (query, size, 2, 0, 0, 0, 0, pool);
/* we also support various metadata */
gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE);

View file

@ -519,7 +519,8 @@ xvimage_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
GstVideoInfo info;
const GstCaps *caps;
if (!gst_buffer_pool_config_get (config, &caps, NULL, NULL, NULL, NULL, NULL))
if (!gst_buffer_pool_config_get (config, &caps, NULL, NULL, NULL, NULL, NULL,
NULL))
goto wrong_config;
if (caps == NULL)

View file

@ -1656,11 +1656,14 @@ gst_xvimagesink_setcaps (GstBaseSink * bsink, GstCaps * caps)
newpool = gst_xvimage_buffer_pool_new (xvimagesink);
structure = gst_buffer_pool_get_config (newpool);
gst_buffer_pool_config_set (structure, caps, size, 2, 0, 0, 15);
gst_buffer_pool_config_set (structure, caps, size, 2, 0, 0, 0, 15);
if (!gst_buffer_pool_set_config (newpool, structure))
goto config_failed;
oldpool = xvimagesink->pool;
/* we don't activate the pool yet, this will be done by downstream after it
* has configured the pool. If downstream does not want our pool we will
* activate it when we render into it */
xvimagesink->pool = newpool;
g_mutex_unlock (xvimagesink->flow_lock);
@ -1954,7 +1957,8 @@ gst_xvimagesink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
/* we had a pool, check caps */
GST_DEBUG_OBJECT (xvimagesink, "check existing pool caps");
config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_get (config, &pcaps, &size, NULL, NULL, NULL, NULL);
gst_buffer_pool_config_get (config, &pcaps, &size, NULL, NULL, NULL, NULL,
NULL);
if (!gst_caps_is_equal (caps, pcaps)) {
GST_DEBUG_OBJECT (xvimagesink, "pool has different caps");
@ -1977,12 +1981,12 @@ gst_xvimagesink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
size = info.size;
config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_set (config, caps, size, 0, 0, 0, 0);
gst_buffer_pool_config_set (config, caps, size, 0, 0, 0, 0, 0);
if (!gst_buffer_pool_set_config (pool, config))
goto config_failed;
}
/* we need at least 2 buffer because we hold on to the last one */
gst_query_set_allocation_params (query, size, 2, 0, 0, 0, pool);
gst_query_set_allocation_params (query, size, 2, 0, 0, 0, 0, pool);
/* we also support various metadata */
gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE);