summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2017-04-21 19:07:18 +0200
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>2017-04-25 15:06:39 +0200
commit158b44fc1ed7d8fb48bd1db9a36b8ddb30f38c5b (patch)
treed8f748e0525d968a576d03766f1b74aed7e1aaff
parent10fc9a97b5556407571ae6834f3553317a88cf7e (diff)
vaapivideobufferpool: create or reconfig allocator
Sometimes a video decoder could set different buffer pool configurations, because their frame size changes. In this case we did not reconfigure the allocator. This patch enables this use case, creating a new allocator inside the VAAPI buffer pool if the caps changed, if it is not dmabuf-based. If so, it is just reconfigured, since it doesn't have a surface pool. https://bugzilla.gnome.org/show_bug.cgi?id=781577
-rw-r--r--gst/vaapi/gstvaapivideobufferpool.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/gst/vaapi/gstvaapivideobufferpool.c b/gst/vaapi/gstvaapivideobufferpool.c
index 6aec9653..1834bd75 100644
--- a/gst/vaapi/gstvaapivideobufferpool.c
+++ b/gst/vaapi/gstvaapivideobufferpool.c
@@ -161,6 +161,27 @@ gst_vaapi_video_buffer_pool_set_config (GstBufferPool * pool,
gst_object_replace ((GstObject **) & priv->allocator, NULL);
priv->video_info = new_vip;
+ {
+ guint surface_alloc_flags;
+ gboolean vinfo_changed = FALSE;
+
+ if (allocator) {
+ const GstVideoInfo *alloc_vinfo =
+ gst_allocator_get_vaapi_video_info (allocator, &surface_alloc_flags);
+ vinfo_changed = gst_video_info_changed (alloc_vinfo, &new_vip);
+ }
+
+ if (vinfo_changed && allocator && priv->use_dmabuf_memory) {
+ gst_allocator_set_vaapi_video_info (allocator, &new_vip,
+ surface_alloc_flags);
+ } else if (!priv->use_dmabuf_memory && (vinfo_changed || !allocator)) {
+ /* let's destroy the other allocator and create a new one */
+ allocator = gst_vaapi_video_allocator_new (priv->display, &new_vip,
+ surface_alloc_flags, 0);
+ gst_buffer_pool_config_set_allocator (config, allocator, NULL);
+ }
+ }
+
if (!gst_buffer_pool_config_has_option (config,
GST_BUFFER_POOL_OPTION_VAAPI_VIDEO_META))
goto error_no_vaapi_video_meta_option;