take padding into account

This commit is contained in:
Wim Taymans 2012-03-14 19:55:32 +01:00
parent 98c681fe5b
commit 751fcf035b
12 changed files with 49 additions and 35 deletions

View file

@ -346,7 +346,7 @@ gst_aasink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
size = GST_VIDEO_INFO_SIZE (&info); size = GST_VIDEO_INFO_SIZE (&info);
/* we need at least 2 buffer because we hold on to the last one */ /* 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, NULL); gst_query_set_allocation_params (query, size, 2, 0, 0, 0, 0, NULL);
/* we support various metadata */ /* we support various metadata */
gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE); gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE);

View file

@ -253,7 +253,7 @@ gst_dvdec_negotiate_pool (GstDVDec * dec, GstCaps * caps, GstVideoInfo * info)
{ {
GstQuery *query; GstQuery *query;
GstBufferPool *pool = NULL; GstBufferPool *pool = NULL;
guint size, min, max, prefix, alignment; guint size, min, max, prefix, padding, alignment;
GstStructure *config; GstStructure *config;
/* find a pool for the negotiated caps now */ /* find a pool for the negotiated caps now */
@ -263,13 +263,14 @@ gst_dvdec_negotiate_pool (GstDVDec * dec, GstCaps * caps, GstVideoInfo * info)
GST_DEBUG_OBJECT (dec, "got downstream ALLOCATION hints"); GST_DEBUG_OBJECT (dec, "got downstream ALLOCATION hints");
/* 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);
size = MAX (size, info->size); size = MAX (size, info->size);
} else { } else {
GST_DEBUG_OBJECT (dec, "didn't get downstream ALLOCATION hints"); GST_DEBUG_OBJECT (dec, "didn't get downstream ALLOCATION hints");
size = info->size; size = info->size;
min = max = 0; min = max = 0;
prefix = 0; prefix = 0;
padding = 0;
alignment = 0; alignment = 0;
} }
@ -283,7 +284,8 @@ gst_dvdec_negotiate_pool (GstDVDec * dec, GstCaps * caps, GstVideoInfo * info)
dec->pool = pool; dec->pool = pool;
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, alignment); gst_buffer_pool_config_set (config, caps, size, min, max, prefix, padding,
alignment);
/* just set the option, if the pool can support it we will transparently use /* just set the option, if the pool can support it we will transparently use
* it through the video info API. We could also see if the pool support this * it through the video info API. We could also see if the pool support this
* option and only activate it then. */ * option and only activate it then. */

View file

@ -225,7 +225,7 @@ gst_gdk_pixbuf_setup_pool (GstGdkPixbuf * filter, GstVideoInfo * info)
GstCaps *target; GstCaps *target;
GstQuery *query; GstQuery *query;
GstBufferPool *pool = NULL; GstBufferPool *pool = NULL;
guint size, min, max, prefix, alignment; guint size, min, max, prefix, padding, alignment;
target = gst_pad_get_current_caps (filter->srcpad); target = gst_pad_get_current_caps (filter->srcpad);
@ -236,11 +236,12 @@ gst_gdk_pixbuf_setup_pool (GstGdkPixbuf * filter, GstVideoInfo * info)
if (gst_pad_peer_query (filter->srcpad, query)) { if (gst_pad_peer_query (filter->srcpad, query)) {
/* 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);
} else { } else {
size = info->size; size = info->size;
min = max = 0; min = max = 0;
prefix = 0; prefix = 0;
padding = 0;
alignment = 0; alignment = 0;
} }
@ -252,7 +253,7 @@ gst_gdk_pixbuf_setup_pool (GstGdkPixbuf * filter, GstVideoInfo * info)
config = gst_buffer_pool_get_config (pool); config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_set (config, target, size, min, max, prefix, gst_buffer_pool_config_set (config, target, size, min, max, prefix,
alignment); padding, alignment);
gst_buffer_pool_set_config (pool, config); gst_buffer_pool_set_config (pool, config);
} }

View file

@ -1164,7 +1164,7 @@ gst_jpeg_dec_buffer_pool (GstJpegDec * dec, GstCaps * caps)
{ {
GstQuery *query; GstQuery *query;
GstBufferPool *pool = NULL; GstBufferPool *pool = NULL;
guint size, min, max, prefix, alignment; guint size, min, max, prefix, padding, alignment;
GstStructure *config; GstStructure *config;
GST_DEBUG_OBJECT (dec, "setting up bufferpool"); GST_DEBUG_OBJECT (dec, "setting up bufferpool");
@ -1175,13 +1175,14 @@ gst_jpeg_dec_buffer_pool (GstJpegDec * dec, GstCaps * caps)
if (gst_pad_peer_query (dec->srcpad, query)) { if (gst_pad_peer_query (dec->srcpad, query)) {
/* 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);
size = MAX (size, dec->info.size); size = MAX (size, dec->info.size);
} else { } else {
GST_DEBUG_OBJECT (dec, "peer query failed, using defaults"); GST_DEBUG_OBJECT (dec, "peer query failed, using defaults");
size = dec->info.size; size = dec->info.size;
min = max = 0; min = max = 0;
prefix = 0; prefix = 0;
padding = 0;
alignment = 15; alignment = 15;
} }
gst_query_unref (query); gst_query_unref (query);
@ -1193,7 +1194,7 @@ gst_jpeg_dec_buffer_pool (GstJpegDec * dec, 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 | 15); padding, alignment | 15);
/* and store */ /* and store */
gst_buffer_pool_set_config (pool, config); gst_buffer_pool_set_config (pool, config);

View file

@ -338,7 +338,7 @@ gst_pngdec_negotiate_pool (GstPngDec * dec, GstCaps * caps, GstVideoInfo * info)
{ {
GstQuery *query; GstQuery *query;
GstBufferPool *pool = NULL; GstBufferPool *pool = NULL;
guint size, min, max, prefix, alignment; guint size, min, max, prefix, padding, alignment;
GstStructure *config; GstStructure *config;
/* find a pool for the negotiated caps now */ /* find a pool for the negotiated caps now */
@ -348,13 +348,14 @@ gst_pngdec_negotiate_pool (GstPngDec * dec, GstCaps * caps, GstVideoInfo * info)
GST_DEBUG_OBJECT (dec, "got downstream ALLOCATION hints"); GST_DEBUG_OBJECT (dec, "got downstream ALLOCATION hints");
/* 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);
size = MAX (size, info->size); size = MAX (size, info->size);
} else { } else {
GST_DEBUG_OBJECT (dec, "didn't get downstream ALLOCATION hints"); GST_DEBUG_OBJECT (dec, "didn't get downstream ALLOCATION hints");
size = info->size; size = info->size;
min = max = 0; min = max = 0;
prefix = 0; prefix = 0;
padding = 0;
alignment = 0; alignment = 0;
} }
@ -368,7 +369,8 @@ gst_pngdec_negotiate_pool (GstPngDec * dec, GstCaps * caps, GstVideoInfo * info)
dec->pool = pool; dec->pool = pool;
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, alignment); gst_buffer_pool_config_set (config, caps, size, min, max, prefix, padding,
alignment);
/* just set the option, if the pool can support it we will transparently use /* just set the option, if the pool can support it we will transparently use
* it through the video info API. We could also see if the pool support this * it through the video info API. We could also see if the pool support this
* option and only activate it then. */ * option and only activate it then. */

View file

@ -255,7 +255,7 @@ gst_goom_src_negotiate (GstGoom * goom)
GstCaps *templ; GstCaps *templ;
GstQuery *query; GstQuery *query;
GstBufferPool *pool = NULL; GstBufferPool *pool = NULL;
guint size, min, max, prefix, alignment; guint size, min, max, prefix, padding, alignment;
templ = gst_pad_get_pad_template_caps (goom->srcpad); templ = gst_pad_get_pad_template_caps (goom->srcpad);
@ -291,11 +291,12 @@ gst_goom_src_negotiate (GstGoom * goom)
if (gst_pad_peer_query (goom->srcpad, query)) { if (gst_pad_peer_query (goom->srcpad, query)) {
/* 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);
} else { } else {
size = goom->outsize; size = goom->outsize;
min = max = 0; min = max = 0;
prefix = 0; prefix = 0;
padding = 0;
alignment = 0; alignment = 0;
} }
@ -307,7 +308,7 @@ gst_goom_src_negotiate (GstGoom * goom)
config = gst_buffer_pool_get_config (pool); config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_set (config, target, size, min, max, prefix, gst_buffer_pool_config_set (config, target, size, min, max, prefix,
alignment); padding, alignment);
gst_buffer_pool_set_config (pool, config); gst_buffer_pool_set_config (pool, config);
} }

View file

@ -252,7 +252,7 @@ gst_goom_src_negotiate (GstGoom * goom)
GstCaps *templ; GstCaps *templ;
GstQuery *query; GstQuery *query;
GstBufferPool *pool = NULL; GstBufferPool *pool = NULL;
guint size, min, max, prefix, alignment; guint size, min, max, prefix, padding, alignment;
templ = gst_pad_get_pad_template_caps (goom->srcpad); templ = gst_pad_get_pad_template_caps (goom->srcpad);
@ -288,11 +288,12 @@ gst_goom_src_negotiate (GstGoom * goom)
if (gst_pad_peer_query (goom->srcpad, query)) { if (gst_pad_peer_query (goom->srcpad, query)) {
/* 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);
} else { } else {
size = goom->outsize; size = goom->outsize;
min = max = 0; min = max = 0;
prefix = 0; prefix = 0;
padding = 0;
alignment = 0; alignment = 0;
} }
@ -304,7 +305,7 @@ gst_goom_src_negotiate (GstGoom * goom)
config = gst_buffer_pool_get_config (pool); config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_set (config, target, size, min, max, prefix, gst_buffer_pool_config_set (config, target, size, min, max, prefix,
alignment); padding, alignment);
gst_buffer_pool_set_config (pool, config); gst_buffer_pool_set_config (pool, config);
} }

View file

@ -118,7 +118,7 @@ gst_rtp_vraw_depay_negotiate_pool (GstRtpVRawDepay * depay, GstCaps * caps,
{ {
GstQuery *query; GstQuery *query;
GstBufferPool *pool = NULL; GstBufferPool *pool = NULL;
guint size, min, max, prefix, alignment; guint size, min, max, prefix, padding, alignment;
GstStructure *config; GstStructure *config;
/* find a pool for the negotiated caps now */ /* find a pool for the negotiated caps now */
@ -128,12 +128,13 @@ gst_rtp_vraw_depay_negotiate_pool (GstRtpVRawDepay * depay, GstCaps * caps,
GST_DEBUG_OBJECT (depay, "got downstream ALLOCATION hints"); GST_DEBUG_OBJECT (depay, "got downstream ALLOCATION hints");
/* 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);
} else { } else {
GST_DEBUG_OBJECT (depay, "didn't get downstream ALLOCATION hints"); GST_DEBUG_OBJECT (depay, "didn't get downstream ALLOCATION hints");
size = info->size; size = info->size;
min = max = 0; min = max = 0;
prefix = 0; prefix = 0;
padding = 0;
alignment = 0; alignment = 0;
} }
@ -147,7 +148,8 @@ gst_rtp_vraw_depay_negotiate_pool (GstRtpVRawDepay * depay, GstCaps * caps,
depay->pool = pool; depay->pool = pool;
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, alignment); gst_buffer_pool_config_set (config, caps, size, min, max, prefix, padding,
alignment);
/* just set the metadata, if the pool can support it we will transparently use /* just set the metadata, if the pool can support it we will transparently use
* it through the video info API. We could also see if the pool support this * it through the video info API. We could also see if the pool support this
* metadata and only activate it then. */ * metadata and only activate it then. */

View file

@ -244,7 +244,7 @@ gst_v4l2_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * config)
GstV4l2Object *obj = pool->obj; GstV4l2Object *obj = pool->obj;
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;
GST_DEBUG_OBJECT (pool, "set config"); GST_DEBUG_OBJECT (pool, "set config");
@ -267,7 +267,7 @@ gst_v4l2_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * config)
/* 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);
@ -276,10 +276,11 @@ gst_v4l2_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * config)
pool->max_buffers = MAX (min_buffers, max_buffers); pool->max_buffers = MAX (min_buffers, max_buffers);
pool->min_buffers = MIN (pool->max_buffers, min_buffers); pool->min_buffers = MIN (pool->max_buffers, min_buffers);
pool->prefix = prefix; pool->prefix = prefix;
pool->padding = padding;
pool->align = align; pool->align = align;
gst_buffer_pool_config_set (config, caps, size, min_buffers, gst_buffer_pool_config_set (config, caps, size, min_buffers,
max_buffers, prefix, align); max_buffers, prefix, padding, align);
return GST_BUFFER_POOL_CLASS (parent_class)->set_config (bpool, config); return GST_BUFFER_POOL_CLASS (parent_class)->set_config (bpool, config);
@ -888,7 +889,7 @@ gst_v4l2_buffer_pool_new (GstV4l2Object * obj, GstCaps * caps)
pool->obj = obj; pool->obj = obj;
s = gst_buffer_pool_get_config (GST_BUFFER_POOL_CAST (pool)); s = gst_buffer_pool_get_config (GST_BUFFER_POOL_CAST (pool));
gst_buffer_pool_config_set (s, caps, obj->sizeimage, 2, 0, 0, 0); gst_buffer_pool_config_set (s, caps, obj->sizeimage, 2, 0, 0, 0, 0);
gst_buffer_pool_set_config (GST_BUFFER_POOL_CAST (pool), s); gst_buffer_pool_set_config (GST_BUFFER_POOL_CAST (pool), s);
return GST_BUFFER_POOL (pool); return GST_BUFFER_POOL (pool);

View file

@ -56,6 +56,7 @@ struct _GstV4l2BufferPool
guint min_buffers; guint min_buffers;
guint max_buffers; guint max_buffers;
guint prefix; guint prefix;
guint padding;
guint align; guint align;
gboolean add_videometa; gboolean add_videometa;

View file

@ -640,7 +640,8 @@ gst_v4l2sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
/* we had a pool, check caps */ /* we had a pool, check caps */
config = gst_buffer_pool_get_config (pool); 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 (v4l2sink, GST_DEBUG_OBJECT (v4l2sink,
"we had a pool with caps %" GST_PTR_FORMAT, pcaps); "we had a pool with caps %" GST_PTR_FORMAT, pcaps);
@ -650,7 +651,7 @@ gst_v4l2sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
} }
} }
/* we need at least 2 buffers to operate */ /* we need at least 2 buffers to operate */
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 */ /* we also support various metadata */
gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE); gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE);

View file

@ -511,17 +511,17 @@ gst_v4l2src_decide_allocation (GstBaseSrc * bsrc, GstQuery * query)
GstV4l2Src *src; GstV4l2Src *src;
GstV4l2Object *obj; GstV4l2Object *obj;
GstBufferPool *pool; GstBufferPool *pool;
guint size, min, max, prefix, alignment; guint size, min, max, prefix, padding, alignment;
src = GST_V4L2SRC (bsrc); src = GST_V4L2SRC (bsrc);
obj = src->v4l2object; obj = src->v4l2object;
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);
GST_DEBUG_OBJECT (src, "allocation: size:%u min:%u max:%u prefix:%u " GST_DEBUG_OBJECT (src, "allocation: size:%u min:%u max:%u prefix:%u "
"align:%u pool:%" GST_PTR_FORMAT, size, min, max, prefix, alignment, "padding: %u align:%u pool:%" GST_PTR_FORMAT, size, min, max,
pool); prefix, padding, alignment, pool);
if (min != 0) { if (min != 0) {
/* if there is a min-buffers suggestion, use it. We add 1 because we need 1 /* if there is a min-buffers suggestion, use it. We add 1 because we need 1
@ -569,8 +569,9 @@ gst_v4l2src_decide_allocation (GstBaseSrc * bsrc, GstQuery * query)
const GstCaps *caps; const GstCaps *caps;
config = gst_buffer_pool_get_config (pool); config = gst_buffer_pool_get_config (pool);
gst_buffer_pool_config_get (config, &caps, NULL, NULL, NULL, NULL, NULL); gst_buffer_pool_config_get (config, &caps, NULL, NULL, NULL, NULL, NULL,
gst_buffer_pool_config_set (config, caps, size, min, max, prefix, NULL);
gst_buffer_pool_config_set (config, caps, size, min, max, prefix, padding,
alignment); alignment);
/* if downstream supports video metadata, add this to the pool config */ /* if downstream supports video metadata, add this to the pool config */
@ -581,7 +582,7 @@ gst_v4l2src_decide_allocation (GstBaseSrc * bsrc, GstQuery * query)
gst_buffer_pool_set_config (pool, config); gst_buffer_pool_set_config (pool, config);
} }
gst_query_set_allocation_params (query, size, min, max, prefix, gst_query_set_allocation_params (query, size, min, max, prefix, padding,
alignment, pool); alignment, pool);
return TRUE; return TRUE;