summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2015-09-15 11:34:12 +0100
committerTim-Philipp Müller <tim@centricular.com>2015-09-15 16:11:23 +0100
commitfe8de1857a704af9ed6160dfdf8f93131e78ba19 (patch)
treeafac4d8b643a42b9a847c34c269eef0149f53d5f
parentb6ad1b0c22de9d815a10ccf7471ca592bf25fc8c (diff)
downloadgstreamer-plugins-bad-fe8de1857a704af9ed6160dfdf8f93131e78ba19.tar.gz
gl: bufferpool take into account video stride alignment requirements
when allocating memory. Fixes crashes with avdec_h265 in the AVX2 code path which requires 32-byte stride alignment, but the GstAllocationParams only specified a 16-byte alignment. https://bugzilla.gnome.org/show_bug.cgi?id=754120
-rw-r--r--gst-libs/gst/gl/gstglbufferpool.c20
-rw-r--r--gst-libs/gst/gl/gstglmemory.c15
2 files changed, 35 insertions, 0 deletions
diff --git a/gst-libs/gst/gl/gstglbufferpool.c b/gst-libs/gst/gl/gstglbufferpool.c
index 78c6a7747..69ac2d891 100644
--- a/gst-libs/gst/gl/gstglbufferpool.c
+++ b/gst-libs/gst/gl/gstglbufferpool.c
@@ -93,6 +93,7 @@ gst_gl_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
GstVideoInfo info;
GstCaps *caps = NULL;
guint min_buffers, max_buffers;
+ guint max_align, n;
GstAllocator *allocator = NULL;
GstAllocationParams alloc_params;
gboolean reset = TRUE;
@@ -152,12 +153,21 @@ gst_gl_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
priv->want_eglimage = FALSE;
#endif
+ max_align = alloc_params.align;
+
if (gst_buffer_pool_config_has_option (config,
GST_BUFFER_POOL_OPTION_VIDEO_ALIGNMENT)) {
priv->add_videometa = TRUE;
gst_buffer_pool_config_get_video_alignment (config, &priv->valign);
+
+ for (n = 0; n < GST_VIDEO_MAX_PLANES; ++n)
+ max_align |= priv->valign.stride_align[n];
+
+ for (n = 0; n < GST_VIDEO_MAX_PLANES; ++n)
+ priv->valign.stride_align[n] = max_align;
+
gst_video_info_align (&priv->info, &priv->valign);
gst_buffer_pool_config_set_video_alignment (config, &priv->valign);
@@ -165,6 +175,16 @@ gst_gl_buffer_pool_set_config (GstBufferPool * pool, GstStructure * config)
gst_video_alignment_reset (&priv->valign);
}
+ if (alloc_params.align < max_align) {
+ GST_WARNING_OBJECT (pool, "allocation params alignment %u is smaller "
+ "than the max specified video stride alignment %u, fixing",
+ (guint) alloc_params.align, max_align);
+
+ alloc_params.align = max_align;
+ gst_buffer_pool_config_set_allocator (config, allocator, &alloc_params);
+ priv->params = alloc_params;
+ }
+
if (reset) {
if (glpool->upload)
gst_object_unref (glpool->upload);
diff --git a/gst-libs/gst/gl/gstglmemory.c b/gst-libs/gst/gl/gstglmemory.c
index 5d3f73a05..b1bef1eb0 100644
--- a/gst-libs/gst/gl/gstglmemory.c
+++ b/gst-libs/gst/gl/gstglmemory.c
@@ -631,6 +631,21 @@ _gl_mem_init (GstGLMemory * mem, GstAllocator * allocator, GstMemory * parent,
else
gst_video_alignment_reset (&mem->valign);
+ /* double-check alignment requirements (caller should've taken care of this) */
+ if (params) {
+ guint max_align, n;
+
+ max_align = gst_memory_alignment;
+ max_align |= params->align;
+ for (n = 0; n < GST_VIDEO_MAX_PLANES; ++n)
+ max_align |= mem->valign.stride_align[n];
+
+ if (params->align < max_align && max_align > gst_memory_alignment) {
+ GST_WARNING ("allocation params alignment %" G_GSIZE_FORMAT " is smaller "
+ "than the max required video alignment %u", params->align, max_align);
+ }
+ }
+
size = gst_gl_get_plane_data_size (info, valign, plane);
/* we always operate on 2D textures unless we're dealing with wrapped textures */