aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-multimedia/gstreamer/gstreamer1.0-libav/videodec-Don-t-use-non-growable-pool.patch
blob: d9b796b6bc0ca5f40a07f0dac2a95057946f1afe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
From 62a4d065ed7bd117d869fd8bcb61274c2870ddf5 Mon Sep 17 00:00:00 2001
From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Date: Thu, 27 Mar 2014 18:53:53 -0400
Subject: [PATCH] videodec: Don't use non-growable pool

As we don't know how many output buffers we need to operate, we need to
avoid pool that can't grow. Otherwise the pipeline may stall, waiting
for buffers. For now, we require it to be able to grow to at least
32 buffers, which I think is a fair amount of buffers for decoders.

https://bugzilla.gnome.org/show_bug.cgi?id=726299

Commit 2a337d926cc30cd7eaae13a4b46eea68ba89e368 in master branch

Upstream Status:  Backported

Signed-off-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
---
 ext/libav/gstavviddec.c |   22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/ext/libav/gstavviddec.c b/ext/libav/gstavviddec.c
index 6c9c0c9..d80fd52 100644
--- a/ext/libav/gstavviddec.c
+++ b/ext/libav/gstavviddec.c
@@ -46,6 +46,7 @@ GST_DEBUG_CATEGORY_EXTERN (GST_CAT_PERFORMANCE);
 #define DEFAULT_DIRECT_RENDERING	TRUE
 #define DEFAULT_DEBUG_MV		FALSE
 #define DEFAULT_MAX_THREADS		0
+#define REQUIRED_POOL_MAX_BUFFERS       32
 
 enum
 {
@@ -1620,7 +1621,7 @@ gst_ffmpegviddec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
   GstBufferPool *pool;
   guint size, min, max;
   GstStructure *config;
-  gboolean have_videometa, have_alignment;
+  gboolean have_videometa, have_alignment, update_pool;
   GstAllocator *allocator = NULL;
   GstAllocationParams params = { 0, 15, 0, 0, };
 
@@ -1639,6 +1640,22 @@ gst_ffmpegviddec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
 
   gst_query_parse_nth_allocation_pool (query, 0, &pool, &size, &min, &max);
 
+  /* Don't use pool that can't grow, as we don't know how many buffer we'll
+   * need, otherwise we may stall */
+  if (max != 0 && max < REQUIRED_POOL_MAX_BUFFERS) {
+    gst_object_unref (pool);
+    pool = gst_video_buffer_pool_new ();
+    max = 0;
+    update_pool = TRUE;
+
+    /* if there is an allocator, also drop it, as it might be the reason we
+     * have this limit. Default will be used */
+    if (allocator) {
+      gst_object_unref (allocator);
+      allocator = NULL;
+    }
+  }
+
   config = gst_buffer_pool_get_config (pool);
   gst_buffer_pool_config_set_params (config, state->caps, size, min, max);
   /* we are happy with the default allocator but we would like to have 16 bytes
@@ -1726,6 +1743,9 @@ gst_ffmpegviddec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
   /* and store */
   gst_buffer_pool_set_config (pool, config);
 
+  if (update_pool)
+    gst_query_set_nth_allocation_pool (query, 0, pool, size, min, max);
+
   gst_object_unref (pool);
   if (allocator)
     gst_object_unref (allocator);