mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
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.
This commit is contained in:
parent
23d1440a60
commit
99ac4e6600
1 changed files with 11 additions and 5 deletions
|
@ -353,7 +353,8 @@ gst_egl_image_from_texture (GstGLContext * context, GstGLMemory * gl_mem,
|
||||||
* target.
|
* target.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
_drm_rgba_fourcc_from_info (GstVideoInfo * info, int plane)
|
_drm_rgba_fourcc_from_info (GstVideoInfo * info, int plane,
|
||||||
|
GstGLFormat * out_format)
|
||||||
{
|
{
|
||||||
GstVideoFormat format = GST_VIDEO_INFO_FORMAT (info);
|
GstVideoFormat format = GST_VIDEO_INFO_FORMAT (info);
|
||||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||||
|
@ -372,10 +373,12 @@ _drm_rgba_fourcc_from_info (GstVideoInfo * info, int plane)
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case GST_VIDEO_FORMAT_RGB16:
|
case GST_VIDEO_FORMAT_RGB16:
|
||||||
case GST_VIDEO_FORMAT_BGR16:
|
case GST_VIDEO_FORMAT_BGR16:
|
||||||
|
*out_format = GST_GL_RGB565;
|
||||||
return DRM_FORMAT_RGB565;
|
return DRM_FORMAT_RGB565;
|
||||||
|
|
||||||
case GST_VIDEO_FORMAT_RGB:
|
case GST_VIDEO_FORMAT_RGB:
|
||||||
case GST_VIDEO_FORMAT_BGR:
|
case GST_VIDEO_FORMAT_BGR:
|
||||||
|
*out_format = GST_GL_RGB;
|
||||||
return rgb_fourcc;
|
return rgb_fourcc;
|
||||||
|
|
||||||
case GST_VIDEO_FORMAT_RGBA:
|
case GST_VIDEO_FORMAT_RGBA:
|
||||||
|
@ -387,19 +390,23 @@ _drm_rgba_fourcc_from_info (GstVideoInfo * info, int plane)
|
||||||
case GST_VIDEO_FORMAT_ABGR:
|
case GST_VIDEO_FORMAT_ABGR:
|
||||||
case GST_VIDEO_FORMAT_xBGR:
|
case GST_VIDEO_FORMAT_xBGR:
|
||||||
case GST_VIDEO_FORMAT_AYUV:
|
case GST_VIDEO_FORMAT_AYUV:
|
||||||
|
*out_format = GST_GL_RGBA;
|
||||||
return rgba_fourcc;
|
return rgba_fourcc;
|
||||||
|
|
||||||
case GST_VIDEO_FORMAT_GRAY8:
|
case GST_VIDEO_FORMAT_GRAY8:
|
||||||
|
*out_format = GST_GL_RED;
|
||||||
return DRM_FORMAT_R8;
|
return DRM_FORMAT_R8;
|
||||||
|
|
||||||
case GST_VIDEO_FORMAT_YUY2:
|
case GST_VIDEO_FORMAT_YUY2:
|
||||||
case GST_VIDEO_FORMAT_UYVY:
|
case GST_VIDEO_FORMAT_UYVY:
|
||||||
case GST_VIDEO_FORMAT_GRAY16_LE:
|
case GST_VIDEO_FORMAT_GRAY16_LE:
|
||||||
case GST_VIDEO_FORMAT_GRAY16_BE:
|
case GST_VIDEO_FORMAT_GRAY16_BE:
|
||||||
|
*out_format = GST_GL_RG;
|
||||||
return rg_fourcc;
|
return rg_fourcc;
|
||||||
|
|
||||||
case GST_VIDEO_FORMAT_NV12:
|
case GST_VIDEO_FORMAT_NV12:
|
||||||
case GST_VIDEO_FORMAT_NV21:
|
case GST_VIDEO_FORMAT_NV21:
|
||||||
|
*out_format = plane == 0 ? GST_GL_RED : GST_GL_RG;
|
||||||
return plane == 0 ? DRM_FORMAT_R8 : rg_fourcc;
|
return plane == 0 ? DRM_FORMAT_R8 : rg_fourcc;
|
||||||
|
|
||||||
case GST_VIDEO_FORMAT_I420:
|
case GST_VIDEO_FORMAT_I420:
|
||||||
|
@ -407,6 +414,7 @@ _drm_rgba_fourcc_from_info (GstVideoInfo * info, int plane)
|
||||||
case GST_VIDEO_FORMAT_Y41B:
|
case GST_VIDEO_FORMAT_Y41B:
|
||||||
case GST_VIDEO_FORMAT_Y42B:
|
case GST_VIDEO_FORMAT_Y42B:
|
||||||
case GST_VIDEO_FORMAT_Y444:
|
case GST_VIDEO_FORMAT_Y444:
|
||||||
|
*out_format = GST_GL_RED;
|
||||||
return DRM_FORMAT_R8;
|
return DRM_FORMAT_R8;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -437,16 +445,14 @@ GstEGLImage *
|
||||||
gst_egl_image_from_dmabuf (GstGLContext * context,
|
gst_egl_image_from_dmabuf (GstGLContext * context,
|
||||||
gint dmabuf, GstVideoInfo * in_info, gint plane, gsize offset)
|
gint dmabuf, GstVideoInfo * in_info, gint plane, gsize offset)
|
||||||
{
|
{
|
||||||
GstGLFormat format;
|
GstGLFormat format = 0;
|
||||||
guintptr attribs[13];
|
guintptr attribs[13];
|
||||||
EGLImageKHR img;
|
EGLImageKHR img;
|
||||||
gint atti = 0;
|
gint atti = 0;
|
||||||
gint fourcc;
|
gint fourcc;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
fourcc = _drm_rgba_fourcc_from_info (in_info, plane);
|
fourcc = _drm_rgba_fourcc_from_info (in_info, plane, &format);
|
||||||
format = gst_gl_format_from_video_info (context, in_info, plane);
|
|
||||||
|
|
||||||
GST_DEBUG ("fourcc %.4s (%d) plane %d (%dx%d)",
|
GST_DEBUG ("fourcc %.4s (%d) plane %d (%dx%d)",
|
||||||
(char *) &fourcc, fourcc, plane,
|
(char *) &fourcc, fourcc, plane,
|
||||||
GST_VIDEO_INFO_COMP_WIDTH (in_info, plane),
|
GST_VIDEO_INFO_COMP_WIDTH (in_info, plane),
|
||||||
|
|
Loading…
Reference in a new issue