From 751fcf035ba27f28579cb02b630fc38afbf97620 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 14 Mar 2012 19:55:32 +0100 Subject: [PATCH] take padding into account --- ext/aalib/gstaasink.c | 2 +- ext/dv/gstdvdec.c | 8 +++++--- ext/gdk_pixbuf/gstgdkpixbuf.c | 7 ++++--- ext/jpeg/gstjpegdec.c | 7 ++++--- ext/libpng/gstpngdec.c | 8 +++++--- gst/goom/gstgoom.c | 7 ++++--- gst/goom2k1/gstgoom.c | 7 ++++--- gst/rtp/gstrtpvrawdepay.c | 8 +++++--- sys/v4l2/gstv4l2bufferpool.c | 9 +++++---- sys/v4l2/gstv4l2bufferpool.h | 1 + sys/v4l2/gstv4l2sink.c | 5 +++-- sys/v4l2/gstv4l2src.c | 15 ++++++++------- 12 files changed, 49 insertions(+), 35 deletions(-) diff --git a/ext/aalib/gstaasink.c b/ext/aalib/gstaasink.c index 5ba829a750..18946316a0 100644 --- a/ext/aalib/gstaasink.c +++ b/ext/aalib/gstaasink.c @@ -346,7 +346,7 @@ gst_aasink_propose_allocation (GstBaseSink * bsink, GstQuery * query) size = GST_VIDEO_INFO_SIZE (&info); /* 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 */ gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE); diff --git a/ext/dv/gstdvdec.c b/ext/dv/gstdvdec.c index 84912e5238..3cadcd9924 100644 --- a/ext/dv/gstdvdec.c +++ b/ext/dv/gstdvdec.c @@ -253,7 +253,7 @@ gst_dvdec_negotiate_pool (GstDVDec * dec, GstCaps * caps, GstVideoInfo * info) { GstQuery *query; GstBufferPool *pool = NULL; - guint size, min, max, prefix, alignment; + guint size, min, max, prefix, padding, alignment; GstStructure *config; /* 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"); /* we got configuration from our peer, parse them */ gst_query_parse_allocation_params (query, &size, &min, &max, &prefix, - &alignment, &pool); + &padding, &alignment, &pool); size = MAX (size, info->size); } else { GST_DEBUG_OBJECT (dec, "didn't get downstream ALLOCATION hints"); size = info->size; min = max = 0; prefix = 0; + padding = 0; alignment = 0; } @@ -283,7 +284,8 @@ gst_dvdec_negotiate_pool (GstDVDec * dec, GstCaps * caps, GstVideoInfo * info) dec->pool = 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 * it through the video info API. We could also see if the pool support this * option and only activate it then. */ diff --git a/ext/gdk_pixbuf/gstgdkpixbuf.c b/ext/gdk_pixbuf/gstgdkpixbuf.c index 638acdd5ad..0076a3cab3 100644 --- a/ext/gdk_pixbuf/gstgdkpixbuf.c +++ b/ext/gdk_pixbuf/gstgdkpixbuf.c @@ -225,7 +225,7 @@ gst_gdk_pixbuf_setup_pool (GstGdkPixbuf * filter, GstVideoInfo * info) GstCaps *target; GstQuery *query; GstBufferPool *pool = NULL; - guint size, min, max, prefix, alignment; + guint size, min, max, prefix, padding, alignment; 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)) { /* 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 = info->size; min = max = 0; prefix = 0; + padding = 0; alignment = 0; } @@ -252,7 +253,7 @@ gst_gdk_pixbuf_setup_pool (GstGdkPixbuf * filter, GstVideoInfo * info) 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); } diff --git a/ext/jpeg/gstjpegdec.c b/ext/jpeg/gstjpegdec.c index 203a2e83d3..8178814383 100644 --- a/ext/jpeg/gstjpegdec.c +++ b/ext/jpeg/gstjpegdec.c @@ -1164,7 +1164,7 @@ gst_jpeg_dec_buffer_pool (GstJpegDec * dec, GstCaps * caps) { GstQuery *query; GstBufferPool *pool = NULL; - guint size, min, max, prefix, alignment; + guint size, min, max, prefix, padding, alignment; GstStructure *config; 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)) { /* we got configuration from our peer, parse them */ gst_query_parse_allocation_params (query, &size, &min, &max, &prefix, - &alignment, &pool); + &padding, &alignment, &pool); size = MAX (size, dec->info.size); } else { GST_DEBUG_OBJECT (dec, "peer query failed, using defaults"); size = dec->info.size; min = max = 0; prefix = 0; + padding = 0; alignment = 15; } gst_query_unref (query); @@ -1193,7 +1194,7 @@ gst_jpeg_dec_buffer_pool (GstJpegDec * dec, GstCaps * caps) config = gst_buffer_pool_get_config (pool); gst_buffer_pool_config_set (config, caps, size, min, max, prefix, - alignment | 15); + padding, alignment | 15); /* and store */ gst_buffer_pool_set_config (pool, config); diff --git a/ext/libpng/gstpngdec.c b/ext/libpng/gstpngdec.c index 9ad3679c0d..623237efd9 100644 --- a/ext/libpng/gstpngdec.c +++ b/ext/libpng/gstpngdec.c @@ -338,7 +338,7 @@ gst_pngdec_negotiate_pool (GstPngDec * dec, GstCaps * caps, GstVideoInfo * info) { GstQuery *query; GstBufferPool *pool = NULL; - guint size, min, max, prefix, alignment; + guint size, min, max, prefix, padding, alignment; GstStructure *config; /* 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"); /* we got configuration from our peer, parse them */ gst_query_parse_allocation_params (query, &size, &min, &max, &prefix, - &alignment, &pool); + &padding, &alignment, &pool); size = MAX (size, info->size); } else { GST_DEBUG_OBJECT (dec, "didn't get downstream ALLOCATION hints"); size = info->size; min = max = 0; prefix = 0; + padding = 0; alignment = 0; } @@ -368,7 +369,8 @@ gst_pngdec_negotiate_pool (GstPngDec * dec, GstCaps * caps, GstVideoInfo * info) dec->pool = 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 * it through the video info API. We could also see if the pool support this * option and only activate it then. */ diff --git a/gst/goom/gstgoom.c b/gst/goom/gstgoom.c index 7351503864..64c7135602 100644 --- a/gst/goom/gstgoom.c +++ b/gst/goom/gstgoom.c @@ -255,7 +255,7 @@ gst_goom_src_negotiate (GstGoom * goom) GstCaps *templ; GstQuery *query; 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); @@ -291,11 +291,12 @@ gst_goom_src_negotiate (GstGoom * goom) if (gst_pad_peer_query (goom->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 = goom->outsize; min = max = 0; prefix = 0; + padding = 0; alignment = 0; } @@ -307,7 +308,7 @@ gst_goom_src_negotiate (GstGoom * goom) 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); } diff --git a/gst/goom2k1/gstgoom.c b/gst/goom2k1/gstgoom.c index ee01a2aa10..228df9f289 100644 --- a/gst/goom2k1/gstgoom.c +++ b/gst/goom2k1/gstgoom.c @@ -252,7 +252,7 @@ gst_goom_src_negotiate (GstGoom * goom) GstCaps *templ; GstQuery *query; 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); @@ -288,11 +288,12 @@ gst_goom_src_negotiate (GstGoom * goom) if (gst_pad_peer_query (goom->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 = goom->outsize; min = max = 0; prefix = 0; + padding = 0; alignment = 0; } @@ -304,7 +305,7 @@ gst_goom_src_negotiate (GstGoom * goom) 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); } diff --git a/gst/rtp/gstrtpvrawdepay.c b/gst/rtp/gstrtpvrawdepay.c index eb5a8ceeac..941107bb20 100644 --- a/gst/rtp/gstrtpvrawdepay.c +++ b/gst/rtp/gstrtpvrawdepay.c @@ -118,7 +118,7 @@ gst_rtp_vraw_depay_negotiate_pool (GstRtpVRawDepay * depay, GstCaps * caps, { GstQuery *query; GstBufferPool *pool = NULL; - guint size, min, max, prefix, alignment; + guint size, min, max, prefix, padding, alignment; GstStructure *config; /* 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"); /* we got configuration from our peer, parse them */ gst_query_parse_allocation_params (query, &size, &min, &max, &prefix, - &alignment, &pool); + &padding, &alignment, &pool); } else { GST_DEBUG_OBJECT (depay, "didn't get downstream ALLOCATION hints"); size = info->size; min = max = 0; prefix = 0; + padding = 0; alignment = 0; } @@ -147,7 +148,8 @@ gst_rtp_vraw_depay_negotiate_pool (GstRtpVRawDepay * depay, GstCaps * caps, depay->pool = 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 * it through the video info API. We could also see if the pool support this * metadata and only activate it then. */ diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c index 7a68926657..b58648cde6 100644 --- a/sys/v4l2/gstv4l2bufferpool.c +++ b/sys/v4l2/gstv4l2bufferpool.c @@ -244,7 +244,7 @@ gst_v4l2_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * config) GstV4l2Object *obj = pool->obj; const GstCaps *caps; guint size, min_buffers, max_buffers; - guint prefix, align; + guint prefix, padding, align; 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 */ 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); @@ -276,10 +276,11 @@ gst_v4l2_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * config) pool->max_buffers = MAX (min_buffers, max_buffers); pool->min_buffers = MIN (pool->max_buffers, min_buffers); pool->prefix = prefix; + pool->padding = padding; pool->align = align; 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); @@ -888,7 +889,7 @@ gst_v4l2_buffer_pool_new (GstV4l2Object * obj, GstCaps * caps) pool->obj = obj; 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); return GST_BUFFER_POOL (pool); diff --git a/sys/v4l2/gstv4l2bufferpool.h b/sys/v4l2/gstv4l2bufferpool.h index 5503628174..09745fdb58 100644 --- a/sys/v4l2/gstv4l2bufferpool.h +++ b/sys/v4l2/gstv4l2bufferpool.h @@ -56,6 +56,7 @@ struct _GstV4l2BufferPool guint min_buffers; guint max_buffers; guint prefix; + guint padding; guint align; gboolean add_videometa; diff --git a/sys/v4l2/gstv4l2sink.c b/sys/v4l2/gstv4l2sink.c index bcb0bb4a5f..b428dacad0 100644 --- a/sys/v4l2/gstv4l2sink.c +++ b/sys/v4l2/gstv4l2sink.c @@ -640,7 +640,8 @@ gst_v4l2sink_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 (v4l2sink, "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 */ - 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); diff --git a/sys/v4l2/gstv4l2src.c b/sys/v4l2/gstv4l2src.c index 7f04f92cf1..26a61c384c 100644 --- a/sys/v4l2/gstv4l2src.c +++ b/sys/v4l2/gstv4l2src.c @@ -511,17 +511,17 @@ gst_v4l2src_decide_allocation (GstBaseSrc * bsrc, GstQuery * query) GstV4l2Src *src; GstV4l2Object *obj; GstBufferPool *pool; - guint size, min, max, prefix, alignment; + guint size, min, max, prefix, padding, alignment; src = GST_V4L2SRC (bsrc); obj = src->v4l2object; 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 " - "align:%u pool:%" GST_PTR_FORMAT, size, min, max, prefix, alignment, - pool); + "padding: %u align:%u pool:%" GST_PTR_FORMAT, size, min, max, + prefix, padding, alignment, pool); if (min != 0) { /* 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; config = gst_buffer_pool_get_config (pool); - gst_buffer_pool_config_get (config, &caps, NULL, NULL, NULL, NULL, NULL); - gst_buffer_pool_config_set (config, caps, size, min, max, prefix, + gst_buffer_pool_config_get (config, &caps, NULL, NULL, NULL, NULL, NULL, + NULL); + gst_buffer_pool_config_set (config, caps, size, min, max, prefix, padding, alignment); /* 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_query_set_allocation_params (query, size, min, max, prefix, + gst_query_set_allocation_params (query, size, min, max, prefix, padding, alignment, pool); return TRUE;