update for allocation query changes

This commit is contained in:
Wim Taymans 2012-03-15 20:38:50 +01:00
parent 7cd283ebc6
commit 5aba4d40c1

View file

@ -291,49 +291,52 @@ gst_mpeg2dec_negotiate_pool (GstMpeg2dec * dec, GstCaps * caps,
GstVideoInfo * info) GstVideoInfo * info)
{ {
GstQuery *query; GstQuery *query;
GstBufferPool *pool = NULL; GstBufferPool *pool;
guint size, min, max, prefix, padding, alignment; guint size, min, max;
GstStructure *config; GstStructure *config;
/* find a pool for the negotiated caps now */ /* find a pool for the negotiated caps now */
query = gst_query_new_allocation (caps, TRUE); query = gst_query_new_allocation (caps, TRUE);
if (gst_pad_peer_query (dec->srcpad, query)) { if (!gst_pad_peer_query (dec->srcpad, query)) {
GST_DEBUG_OBJECT (dec, "got downstream ALLOCATION hints"); /* use the query default then */
/* we got configuration from our peer, parse them */
gst_query_parse_allocation_params (query, &size, &min, &max, &prefix,
&padding, &alignment, &pool);
size = MAX (size, info->size);
alignment |= 15;
} else {
GST_DEBUG_OBJECT (dec, "didn't get downstream ALLOCATION hints"); GST_DEBUG_OBJECT (dec, "didn't get downstream ALLOCATION hints");
}
if (gst_query_get_n_allocation_pools (query) > 0) {
/* we got configuration from our peer, parse them */
gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
size = MAX (size, info->size);
} else {
pool = NULL;
size = info->size; size = info->size;
min = max = 0; min = max = 0;
prefix = 0;
padding = 0;
alignment = 15;
} }
GST_DEBUG_OBJECT (dec, GST_DEBUG_OBJECT (dec,
"size:%d, min:%d, max:%d, prefix:%d, padding:%d, alignment:%d, pool:%p", "size:%d, min:%d, max:%d,pool:%p", size, min, max, pool);
size, min, max, prefix, padding, alignment, pool);
if (pool == NULL) { if (pool == NULL) {
/* we did not get a pool, make one ourselves then */ /* we did not get a pool, make one ourselves then */
pool = gst_buffer_pool_new (); pool = gst_video_buffer_pool_new ();
} }
if (dec->pool) if (dec->pool) {
gst_buffer_pool_set_active (dec->pool, FALSE);
gst_object_unref (dec->pool); gst_object_unref (dec->pool);
}
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, padding, gst_buffer_pool_config_set (config, caps, size, min, max, 0, 0, 0);
alignment);
/* just set the option, if the pool can support it we will transparently use if (gst_query_has_allocation_meta (query, GST_VIDEO_META_API_TYPE)) {
* it through the video info API. We could also see if the pool support this /* just set the option, if the pool can support it we will transparently use
* option and only activate it then. */ * it through the video info API. We could also see if the pool support this
gst_buffer_pool_config_add_option (config, GST_BUFFER_POOL_OPTION_VIDEO_META); * option and only activate it then. */
gst_buffer_pool_config_add_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_META);
}
/* check if downstream supports cropping */ /* check if downstream supports cropping */
dec->use_cropping = dec->use_cropping =