From: Nicolas Dufresne Date: Sun, 14 Jul 2019 20:33:35 +0000 (-0400) Subject: eglimage: Fix exported DMABuf size X-Git-Tag: 1.19.3~511^2~871 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ac0d19b72fd41def919893e4c6ce631559640c56;p=platform%2Fupstream%2Fgstreamer.git eglimage: Fix exported DMABuf size All we know is the height and the stride, so make sure not to expose the DMABuf larger then the size we know about. --- diff --git a/ext/gl/gstgldownloadelement.c b/ext/gl/gstgldownloadelement.c index b7cf474..8ece34d 100644 --- a/ext/gl/gstgldownloadelement.c +++ b/ext/gl/gstgldownloadelement.c @@ -286,13 +286,14 @@ _create_cached_dmabuf_info (GstGLContext * context, gpointer data) if (gst_egl_image_export_dmabuf (image, &fd, &stride, &offset)) { GstGLDownloadElement *download = transfer->download; struct DmabufInfo *info; - gsize maxsize; + gsize size; - gst_memory_get_sizes (GST_MEMORY_CAST (transfer->glmem), NULL, &maxsize); + size = + gst_gl_memory_get_texture_height (transfer->glmem) * stride + offset; info = g_new0 (struct DmabufInfo, 1); info->dmabuf = - gst_dmabuf_allocator_alloc (download->dmabuf_allocator, fd, maxsize); + gst_dmabuf_allocator_alloc (download->dmabuf_allocator, fd, size); info->stride = stride; info->offset = offset; diff --git a/gst-libs/gst/gl/egl/gsteglimage.c b/gst-libs/gst/gl/egl/gsteglimage.c index 911b712..6ae5e0e 100644 --- a/gst-libs/gst/gl/egl/gsteglimage.c +++ b/gst-libs/gst/gl/egl/gsteglimage.c @@ -1029,10 +1029,6 @@ gst_egl_image_export_dmabuf (GstEGLImage * image, int *fd, gint * stride, if (num_planes > 1) return FALSE; - GST_DEBUG_OBJECT (image->context, "Export DMABuf with fourcc %" - GST_FOURCC_FORMAT " and modififers %" G_GUINT64_FORMAT, - GST_FOURCC_ARGS (fourcc), modifier); - /* FIXME We don't support modifiers */ if (modifier != DRM_FORMAT_MOD_LINEAR) return FALSE; @@ -1041,6 +1037,11 @@ gst_egl_image_export_dmabuf (GstEGLImage * image, int *fd, gint * stride, &egl_stride, &egl_offset)) return FALSE; + GST_DEBUG_OBJECT (image->context, "Export DMABuf with fourcc %" + GST_FOURCC_FORMAT ", modififers %" G_GUINT64_FORMAT + ", stride %i and offset %i", GST_FOURCC_ARGS (fourcc), modifier, + egl_stride, egl_offset); + *fd = egl_fd; *stride = egl_stride; *offset = egl_offset;