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);