From a373e75949f481a20710862be1a9b3676a1e425a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 13 Mar 2013 11:29:45 +0100 Subject: [PATCH] egl: Add support for different orientations of the EGLImage The content of the EGLImages can be at least in GStreamer orientation, meaning top line first in memory, or OpenGL orientation, meaning bottom line first in memory. --- gst-libs/gst/egl/egl.c | 25 +++++++++++++++++++++++++ gst-libs/gst/egl/egl.h | 12 ++++++++++++ 2 files changed, 37 insertions(+) diff --git a/gst-libs/gst/egl/egl.c b/gst-libs/gst/egl/egl.c index 7df4c035e9..cbbd8e3303 100644 --- a/gst-libs/gst/egl/egl.c +++ b/gst-libs/gst/egl/egl.c @@ -34,6 +34,7 @@ typedef struct GstEGLDisplay *display; EGLImageKHR image; GstEGLImageType type; + GstEGLImageOrientation orientation; gpointer user_data; GDestroyNotify user_data_destroy; @@ -90,6 +91,29 @@ gst_egl_image_memory_get_type (GstMemory * mem) return GST_EGL_IMAGE_MEMORY (mem)->type; } +GstEGLImageOrientation +gst_egl_image_memory_get_orientation (GstMemory *mem) +{ + g_return_val_if_fail (gst_is_egl_image_memory (mem), + GST_EGL_IMAGE_MEMORY_TYPE_INVALID); + + if (mem->parent) + mem = mem->parent; + + return GST_EGL_IMAGE_MEMORY (mem)->orientation; +} + +void +gst_egl_image_memory_set_orientation (GstMemory *mem, GstEGLImageOrientation orientation) +{ + g_return_if_fail (gst_is_egl_image_memory (mem)); + + if (mem->parent) + mem = mem->parent; + + GST_EGL_IMAGE_MEMORY (mem)->orientation = orientation; +} + static GstMemory * gst_egl_image_allocator_alloc_vfunc (GstAllocator * allocator, gsize size, GstAllocationParams * params) @@ -257,6 +281,7 @@ gst_egl_image_allocator_wrap (GstAllocator * allocator, mem->display = gst_egl_display_ref (display); mem->image = image; mem->type = type; + mem->orientation = GST_EGL_IMAGE_ORIENTATION_X_NORMAL_Y_NORMAL; mem->user_data = user_data; mem->user_data_destroy = user_data_destroy; diff --git a/gst-libs/gst/egl/egl.h b/gst-libs/gst/egl/egl.h index df3412995e..9e6f2ae605 100644 --- a/gst-libs/gst/egl/egl.h +++ b/gst-libs/gst/egl/egl.h @@ -42,6 +42,16 @@ typedef enum { GST_EGL_IMAGE_MEMORY_TYPE_OTHER = 0xffff } GstEGLImageType; +typedef enum { + /* GStreamer orientation, top line first in memory, left row first */ + GST_EGL_IMAGE_ORIENTATION_X_NORMAL_Y_NORMAL, + /* OpenGL orientation, bottom line first in memory, left row first */ + GST_EGL_IMAGE_ORIENTATION_X_NORMAL_Y_FLIP, + /* Just for the sake of completeness, nothing uses this probably */ + GST_EGL_IMAGE_ORIENTATION_X_FLIP_Y_NORMAL, + GST_EGL_IMAGE_ORIENTATION_X_FLIP_Y_FLIP +} GstEGLImageOrientation; + typedef struct _GstEGLDisplay GstEGLDisplay; /* EGLImage GstMemory handling */ @@ -50,6 +60,8 @@ gboolean gst_is_egl_image_memory (GstMemory * mem); EGLImageKHR gst_egl_image_memory_get_image (GstMemory * mem); GstEGLDisplay * gst_egl_image_memory_get_display (GstMemory * mem); GstEGLImageType gst_egl_image_memory_get_type (GstMemory * mem); +GstEGLImageOrientation gst_egl_image_memory_get_orientation (GstMemory *mem); +void gst_egl_image_memory_set_orientation (GstMemory *mem, GstEGLImageOrientation orientation); /* Generic EGLImage allocator that doesn't support mapping, copying or anything */ GstAllocator * gst_egl_image_allocator_obtain (void);