summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2018-11-09 10:30:06 +0100
committerNicolas Dufresne <nicolas@ndufresne.ca>2018-11-11 21:30:56 +0000
commit2041434f7667c28b16de93e9f041607f1209f5ef (patch)
treeb2f2c5e47a82a9a2b56c1002580c18dda8f6ec36
parent91b6b98fdf70b910d2f09ed49136e68597ad6d8e (diff)
downloadgstreamer-plugins-base-2041434f7667c28b16de93e9f041607f1209f5ef.tar.gz
gl/egl: Determine correct format on dmabuf import
When importing an egl image from dmabuf gst_gl_format_from_video_info was used to work what the result GL format will be. Unfortunately that will only work if the conventional format and the choosen DRM fourcc for the format match up. On etnaviv platforms there is no support for GL_EXT_texture_rg, so the GL format chosen for YUY2 ends up being GST_GL_LUMINANCE_ALPHA. However DRM does not do luminance + alpha as it's a legacy GL thing, so the dmabuf import ends up using DRM_FORMAT_GR88. To fix this, tie the DRM_FORMAT and the GL format together so they always match up.
-rw-r--r--gst-libs/gst/gl/egl/gsteglimage.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/gst-libs/gst/gl/egl/gsteglimage.c b/gst-libs/gst/gl/egl/gsteglimage.c
index 601e1fddc..0eee71e03 100644
--- a/gst-libs/gst/gl/egl/gsteglimage.c
+++ b/gst-libs/gst/gl/egl/gsteglimage.c
@@ -353,7 +353,7 @@ gst_egl_image_from_texture (GstGLContext * context, GstGLMemory * gl_mem,
* target.
*/
static int
-_drm_fourcc_from_info (GstVideoInfo * info, int plane)
+_drm_fourcc_from_info (GstVideoInfo * info, int plane, GstGLFormat *out_format)
{
GstVideoFormat format = GST_VIDEO_INFO_FORMAT (info);
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
@@ -372,10 +372,12 @@ _drm_fourcc_from_info (GstVideoInfo * info, int plane)
switch (format) {
case GST_VIDEO_FORMAT_RGB16:
case GST_VIDEO_FORMAT_BGR16:
+ *out_format = GST_GL_RGB565;
return DRM_FORMAT_RGB565;
case GST_VIDEO_FORMAT_RGB:
case GST_VIDEO_FORMAT_BGR:
+ *out_format = GST_GL_RGB;
return rgb_fourcc;
case GST_VIDEO_FORMAT_RGBA:
@@ -387,19 +389,23 @@ _drm_fourcc_from_info (GstVideoInfo * info, int plane)
case GST_VIDEO_FORMAT_ABGR:
case GST_VIDEO_FORMAT_xBGR:
case GST_VIDEO_FORMAT_AYUV:
+ *out_format = GST_GL_RGBA;
return rgba_fourcc;
case GST_VIDEO_FORMAT_GRAY8:
+ *out_format = GST_GL_RED;
return DRM_FORMAT_R8;
case GST_VIDEO_FORMAT_YUY2:
case GST_VIDEO_FORMAT_UYVY:
case GST_VIDEO_FORMAT_GRAY16_LE:
case GST_VIDEO_FORMAT_GRAY16_BE:
+ *out_format = GST_GL_RG;
return rg_fourcc;
case GST_VIDEO_FORMAT_NV12:
case GST_VIDEO_FORMAT_NV21:
+ *out_format = plane == 0 ? GST_GL_RED : GST_GL_RG;
return plane == 0 ? DRM_FORMAT_R8 : rg_fourcc;
case GST_VIDEO_FORMAT_I420:
@@ -407,6 +413,7 @@ _drm_fourcc_from_info (GstVideoInfo * info, int plane)
case GST_VIDEO_FORMAT_Y41B:
case GST_VIDEO_FORMAT_Y42B:
case GST_VIDEO_FORMAT_Y444:
+ *out_format = GST_GL_RED;
return DRM_FORMAT_R8;
default:
@@ -436,9 +443,7 @@ gst_egl_image_from_dmabuf (GstGLContext * context,
gint fourcc;
gint i;
- fourcc = _drm_fourcc_from_info (in_info, plane);
- format = gst_gl_format_from_video_info (context, in_info, plane);
-
+ fourcc = _drm_fourcc_from_info (in_info, plane, &format);
GST_DEBUG ("fourcc %.4s (%d) plane %d (%dx%d)",
(char *) &fourcc, fourcc, plane,
GST_VIDEO_INFO_COMP_WIDTH (in_info, plane),