mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-23 15:48:23 +00:00
glimagesink: add support for BGR10A2_LE / RGB10A2_LE
This makes a pipeline below work: gst-launch-1.0 videotestsrc ! video/x-raw,format={BGR10A2_LE, \ RGB10A2_LE} ! glimagesink
This commit is contained in:
parent
d15a516037
commit
3f63295280
6 changed files with 84 additions and 3 deletions
|
@ -70,6 +70,14 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef DRM_FORMAT_BGRA1010102
|
||||
#define DRM_FORMAT_BGRA1010102 fourcc_code('B', 'A', '3', '0')
|
||||
#endif
|
||||
|
||||
#ifndef DRM_FORMAT_RGBA1010102
|
||||
#define DRM_FORMAT_RGBA1010102 fourcc_code('R', 'A', '3', '0')
|
||||
#endif
|
||||
|
||||
#ifndef EGL_LINUX_DMA_BUF_EXT
|
||||
#define EGL_LINUX_DMA_BUF_EXT 0x3270
|
||||
#endif
|
||||
|
@ -501,6 +509,14 @@ _drm_rgba_fourcc_from_info (GstVideoInfo * info, int plane,
|
|||
*out_format = GST_GL_RED;
|
||||
return DRM_FORMAT_R8;
|
||||
|
||||
case GST_VIDEO_FORMAT_BGR10A2_LE:
|
||||
*out_format = GST_GL_RGB10_A2;
|
||||
return DRM_FORMAT_BGRA1010102;
|
||||
|
||||
case GST_VIDEO_FORMAT_RGB10A2_LE:
|
||||
*out_format = GST_GL_RGB10_A2;
|
||||
return DRM_FORMAT_RGBA1010102;
|
||||
|
||||
default:
|
||||
GST_ERROR ("Unsupported format for DMABuf.");
|
||||
return -1;
|
||||
|
|
|
@ -950,6 +950,12 @@ _init_supported_formats (GstGLContext * context, gboolean output,
|
|||
|
||||
if (!context || gst_gl_format_is_supported (context, GST_GL_RGB565))
|
||||
_append_value_string_list (supported_formats, "RGB16", "BGR16", NULL);
|
||||
|
||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||
if (!context || gst_gl_format_is_supported (context, GST_GL_RGB10_A2))
|
||||
_append_value_string_list (supported_formats, "BGR10A2_LE", "RGB10A2_LE",
|
||||
NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* copies the given caps */
|
||||
|
@ -974,7 +980,8 @@ gst_gl_color_convert_caps_transform_format_info (GstGLContext * context,
|
|||
*/
|
||||
|
||||
_init_value_string_list (&rgb_formats, "RGBA", "ARGB", "BGRA", "ABGR", "RGBx",
|
||||
"xRGB", "BGRx", "xBGR", "RGB", "BGR", "ARGB64", NULL);
|
||||
"xRGB", "BGRx", "xBGR", "RGB", "BGR", "ARGB64", "BGR10A2_LE",
|
||||
"RGB10A2_LE", NULL);
|
||||
_init_supported_formats (context, output, &supported_formats);
|
||||
gst_value_intersect (&supported_rgb_formats, &rgb_formats,
|
||||
&supported_formats);
|
||||
|
@ -1438,12 +1445,28 @@ _RGB_pixel_order (const gchar * expected, const gchar * wanted)
|
|||
gchar *temp = expect;
|
||||
expect = g_strndup (temp, 3);
|
||||
g_free (temp);
|
||||
} else if (strcmp (expect, "bgr10a2_le") == 0) {
|
||||
gchar *temp = expect;
|
||||
expect = g_strndup ("bgra", 4);
|
||||
g_free (temp);
|
||||
} else if (strcmp (expect, "rgb10a2_le") == 0) {
|
||||
gchar *temp = expect;
|
||||
expect = g_strndup ("rgba", 4);
|
||||
g_free (temp);
|
||||
}
|
||||
|
||||
if (strcmp (want, "rgb16") == 0 || strcmp (want, "bgr16") == 0) {
|
||||
gchar *temp = want;
|
||||
orig_want = want = g_strndup (temp, 3);
|
||||
g_free (temp);
|
||||
} else if (strcmp (want, "bgr10a2_le") == 0) {
|
||||
gchar *temp = want;
|
||||
orig_want = want = g_strndup ("bgra", 4);
|
||||
g_free (temp);
|
||||
} else if (strcmp (want, "rgb10a2_le") == 0) {
|
||||
gchar *temp = want;
|
||||
orig_want = want = g_strndup ("rgba", 4);
|
||||
g_free (temp);
|
||||
}
|
||||
|
||||
/* pad want with 'a's */
|
||||
|
@ -1519,6 +1542,8 @@ _get_n_textures (GstVideoFormat v_format)
|
|||
case GST_VIDEO_FORMAT_RGB16:
|
||||
case GST_VIDEO_FORMAT_BGR16:
|
||||
case GST_VIDEO_FORMAT_ARGB64:
|
||||
case GST_VIDEO_FORMAT_BGR10A2_LE:
|
||||
case GST_VIDEO_FORMAT_RGB10A2_LE:
|
||||
return 1;
|
||||
case GST_VIDEO_FORMAT_NV12:
|
||||
case GST_VIDEO_FORMAT_NV21:
|
||||
|
|
|
@ -87,10 +87,17 @@ struct _GstGLColorConvertClass
|
|||
*
|
||||
* The currently supported formats that can be converted
|
||||
*/
|
||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||
#define COLOR_CONVERT_EXT_FORMATS ", BGR10A2_LE, RGB10A2_LE"
|
||||
#else
|
||||
#define COLOR_CONVERT_EXT_FORMATS ""
|
||||
#endif
|
||||
|
||||
#define GST_GL_COLOR_CONVERT_FORMATS "{ RGBA, RGB, RGBx, BGR, BGRx, BGRA, xRGB, " \
|
||||
"xBGR, ARGB, ABGR, Y444, I420, YV12, Y42B, " \
|
||||
"Y41B, NV12, NV21, YUY2, UYVY, AYUV, VUYA, " \
|
||||
"GRAY8, GRAY16_LE, GRAY16_BE, RGB16, BGR16, ARGB64 }"
|
||||
"GRAY8, GRAY16_LE, GRAY16_BE, RGB16, BGR16, ARGB64 " \
|
||||
COLOR_CONVERT_EXT_FORMATS "}"
|
||||
|
||||
/**
|
||||
* GST_GL_COLOR_CONVERT_VIDEO_CAPS:
|
||||
|
|
|
@ -49,6 +49,9 @@
|
|||
#ifndef GL_TEXTURE_EXTERNAL_OES
|
||||
#define GL_TEXTURE_EXTERNAL_OES 0x8D65
|
||||
#endif
|
||||
#ifndef GL_UNSIGNED_INT_2_10_10_10_REV
|
||||
#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
|
||||
#endif
|
||||
|
||||
static inline guint
|
||||
_gl_format_n_components (guint format)
|
||||
|
@ -58,6 +61,7 @@ _gl_format_n_components (guint format)
|
|||
case GST_GL_RGBA:
|
||||
case GST_GL_RGBA8:
|
||||
case GST_GL_RGBA16:
|
||||
case GST_GL_RGB10_A2:
|
||||
return 4;
|
||||
case GST_VIDEO_GL_TEXTURE_TYPE_RGB:
|
||||
case GST_VIDEO_GL_TEXTURE_TYPE_RGB16:
|
||||
|
@ -93,6 +97,8 @@ _gl_type_n_components (guint type)
|
|||
return 1;
|
||||
case GL_UNSIGNED_SHORT_5_6_5:
|
||||
return 3;
|
||||
case GL_UNSIGNED_INT_2_10_10_10_REV:
|
||||
return 4;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return 0;
|
||||
|
@ -108,6 +114,8 @@ _gl_type_n_bytes (guint type)
|
|||
case GL_UNSIGNED_SHORT:
|
||||
case GL_UNSIGNED_SHORT_5_6_5:
|
||||
return 2;
|
||||
case GL_UNSIGNED_INT_2_10_10_10_REV:
|
||||
return 4;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return 0;
|
||||
|
@ -190,6 +198,9 @@ gst_gl_format_from_video_info (GstGLContext * context, GstVideoInfo * vinfo,
|
|||
case GST_VIDEO_FORMAT_YV12:
|
||||
n_plane_components = 1;
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_BGR10A2_LE:
|
||||
case GST_VIDEO_FORMAT_RGB10A2_LE:
|
||||
return GST_GL_RGB10_A2;
|
||||
default:
|
||||
n_plane_components = 4;
|
||||
g_assert_not_reached ();
|
||||
|
@ -237,6 +248,8 @@ gst_gl_sized_gl_format_from_gl_format_type (GstGLContext * context,
|
|||
&& !USING_GLES3 (context) ? GST_GL_RGBA : GST_GL_RGBA8;
|
||||
case GL_UNSIGNED_SHORT:
|
||||
return GST_GL_RGBA16;
|
||||
case GL_UNSIGNED_INT_2_10_10_10_REV:
|
||||
return GST_GL_RGB10_A2;
|
||||
}
|
||||
break;
|
||||
case GST_GL_RGB:
|
||||
|
@ -278,6 +291,7 @@ gst_gl_sized_gl_format_from_gl_format_type (GstGLContext * context,
|
|||
case GST_GL_ALPHA:
|
||||
case GST_GL_DEPTH_COMPONENT16:
|
||||
case GST_GL_DEPTH24_STENCIL8:
|
||||
case GST_GL_RGB10_A2:
|
||||
return format;
|
||||
default:
|
||||
g_critical ("Unknown GL format 0x%x type 0x%x provided", format, type);
|
||||
|
@ -345,6 +359,10 @@ gst_gl_format_type_from_sized_gl_format (GstGLFormat format,
|
|||
*unsized_format = format;
|
||||
*gl_type = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case GST_GL_RGB10_A2:
|
||||
*unsized_format = GST_GL_RGBA;
|
||||
*gl_type = GL_UNSIGNED_INT_2_10_10_10_REV;
|
||||
break;
|
||||
default:
|
||||
g_critical ("Unknown GL format 0x%x provided", format);
|
||||
*unsized_format = format;
|
||||
|
@ -412,6 +430,11 @@ gst_gl_format_is_supported (GstGLContext * context, GstGLFormat format)
|
|||
"GL_OES_packed_depth_stencil")
|
||||
|| gst_gl_context_check_feature (context,
|
||||
"GL_EXT_packed_depth_stencil");
|
||||
case GST_GL_RGB10_A2:
|
||||
return USING_OPENGL (context) || USING_OPENGL3 (context)
|
||||
|| USING_GLES3 (context)
|
||||
|| gst_gl_context_check_feature (context,
|
||||
"GL_OES_required_internalformat");
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return FALSE;
|
||||
|
|
|
@ -96,6 +96,8 @@ G_BEGIN_DECLS
|
|||
* @GST_GL_DEPTH_COMPONENT16: A single 16-bit component for depth information.
|
||||
* @GST_GL_DEPTH24_STENCIL8: A 24-bit component for depth information and
|
||||
* a 8-bit component for stencil informat.
|
||||
* @GST_GL_RGBA10_A2: Four components of bit depth 10, 10, 10 and 2 stored in the
|
||||
* R, G, B and A texture components respectively.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
|
@ -124,6 +126,8 @@ typedef enum
|
|||
GST_GL_DEPTH_COMPONENT16 = 0x81A5,
|
||||
|
||||
GST_GL_DEPTH24_STENCIL8 = 0x88F0,
|
||||
|
||||
GST_GL_RGB10_A2 = 0x8059,
|
||||
} GstGLFormat;
|
||||
|
||||
GST_GL_API
|
||||
|
|
|
@ -50,10 +50,16 @@ GType gst_gl_memory_allocator_get_type(void);
|
|||
*
|
||||
* List of video formats that are supported by #GstGLMemory
|
||||
*/
|
||||
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
||||
#define MEMORY_VIDEO_EXT_FORMATS ", BGR10A2_LE, RGB10A2_LE"
|
||||
#else
|
||||
#define MEMORY_VIDEO_EXT_FORMATS ""
|
||||
#endif
|
||||
|
||||
#define GST_GL_MEMORY_VIDEO_FORMATS_STR \
|
||||
"{ RGBA, BGRA, RGBx, BGRx, ARGB, ABGR, xRGB, xBGR, RGB, BGR, RGB16, BGR16, " \
|
||||
"AYUV, VUYA, I420, YV12, NV12, NV21, YUY2, UYVY, Y41B, Y42B, Y444, " \
|
||||
"GRAY8, GRAY16_LE, GRAY16_BE, ARGB64 }"
|
||||
"GRAY8, GRAY16_LE, GRAY16_BE, ARGB64" MEMORY_VIDEO_EXT_FORMATS "}"
|
||||
|
||||
/**
|
||||
* GstGLMemory:
|
||||
|
|
Loading…
Reference in a new issue