[Mesa-dev] [PATCH kmscube 1/2] gst-decoder.c: set EGL_DMA_BUF attributes upon variable declaration

Emil Velikov emil.l.velikov at gmail.com
Tue May 2 13:32:01 UTC 2017


From: Emil Velikov <emil.velikov at collabora.com>

Makes the code shorter and more explicit.

Cc: Carlos Rafael Giani <dv at pseudoterminal.org>
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
Worth moving the plane[i] bits as well?

The loop guard for the close() looks a big funky.

Carlos, care to throw a comment why it's using nmem and not something
else - say is_dmabuf_mem?
---
 gst-decoder.c | 31 +++++++++++--------------------
 1 file changed, 11 insertions(+), 20 deletions(-)

diff --git a/gst-decoder.c b/gst-decoder.c
index deffad5..dd2a6fa 100644
--- a/gst-decoder.c
+++ b/gst-decoder.c
@@ -368,22 +368,6 @@ buffer_to_image(struct decoder *dec, GstBuffer *buf)
 	GstMemory *mem;
 	int dmabuf_fd = -1;
 
-	static const EGLint egl_dmabuf_plane_fd_attr[MAX_NUM_PLANES] = {
-		EGL_DMA_BUF_PLANE0_FD_EXT,
-		EGL_DMA_BUF_PLANE1_FD_EXT,
-		EGL_DMA_BUF_PLANE2_FD_EXT,
-	};
-	static const EGLint egl_dmabuf_plane_offset_attr[MAX_NUM_PLANES] = {
-		EGL_DMA_BUF_PLANE0_OFFSET_EXT,
-		EGL_DMA_BUF_PLANE1_OFFSET_EXT,
-		EGL_DMA_BUF_PLANE2_OFFSET_EXT,
-	};
-	static const EGLint egl_dmabuf_plane_pitch_attr[MAX_NUM_PLANES] = {
-		EGL_DMA_BUF_PLANE0_PITCH_EXT,
-		EGL_DMA_BUF_PLANE1_PITCH_EXT,
-		EGL_DMA_BUF_PLANE2_PITCH_EXT,
-	};
-
 	/* Query gst_is_dmabuf_memory() here, since the gstmemory
 	 * block might get merged below by gst_buffer_map(), meaning
 	 * that the mem pointer would become invalid */
@@ -464,18 +448,25 @@ buffer_to_image(struct decoder *dec, GstBuffer *buf)
 	{
 		/* Initialize the first 6 attributes with values that are
 		 * plane invariant (width, height, format) */
-		EGLint attr[6 + 6*(MAX_NUM_PLANES) + 1] = {
+		EGLint attr[] = {
 			EGL_WIDTH, width,
 			EGL_HEIGHT, height,
 			EGL_LINUX_DRM_FOURCC_EXT, dec->format
+			EGL_DMA_BUF_PLANE0_FD_EXT, -1,
+			EGL_DMA_BUF_PLANE0_OFFSET_EXT, -1,
+			EGL_DMA_BUF_PLANE0_PITCH_EXT, -1,
+			EGL_DMA_BUF_PLANE1_FD_EXT, -1,
+			EGL_DMA_BUF_PLANE1_OFFSET_EXT, -1,
+			EGL_DMA_BUF_PLANE1_PITCH_EXT, -1,
+			EGL_DMA_BUF_PLANE2_FD_EXT, -1,
+			EGL_DMA_BUF_PLANE2_OFFSET_EXT, -1,
+			EGL_DMA_BUF_PLANE2_PITCH_EXT, -1,
+			EGL_NONE,
 		};
 
 		for (i = 0; i < nplanes; i++) {
-			attr[6 + 6*i + 0] = egl_dmabuf_plane_fd_attr[i];
 			attr[6 + 6*i + 1] = planes[i].fd;
-			attr[6 + 6*i + 2] = egl_dmabuf_plane_offset_attr[i];
 			attr[6 + 6*i + 3] = planes[i].offset;
-			attr[6 + 6*i + 4] = egl_dmabuf_plane_pitch_attr[i];
 			attr[6 + 6*i + 5] = planes[i].stride;
 		}
 
-- 
2.12.2



More information about the mesa-dev mailing list