Skip to content

Commit

Permalink
gl: add support for RGBP and BGRP formats
Browse files Browse the repository at this point in the history
gst-launch-1.0 videotestsrc ! video/x-raw,format=RGBP ! glimagesink
gst-launch-1.0 videotestsrc ! video/x-raw,format=BGRP ! glimagesink

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1141>
  • Loading branch information
xhaihao committed May 11, 2021
1 parent ca046ca commit 7412921
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
13 changes: 11 additions & 2 deletions gst-libs/gst/gl/gstglcolorconvert.c
Expand Up @@ -964,8 +964,9 @@ _init_supported_formats (GstGLContext * context, gboolean output,

/* Always supported input formats or output with multiple draw buffers */
if (!output || (!context || context->gl_vtable->DrawBuffers))
_append_value_string_list (supported_formats, "GBRA", "GBR", "Y444",
"I420", "YV12", "Y42B", "Y41B", "NV12", "NV21", "NV16", "NV61", NULL);
_append_value_string_list (supported_formats, "GBRA", "GBR", "RGBP", "BGRP",
"Y444", "I420", "YV12", "Y42B", "Y41B", "NV12", "NV21", "NV16", "NV61",
NULL);

/* Requires reading from a RG/LA framebuffer... */
if (!context || (USING_GLES3 (context) || USING_OPENGL (context)))
Expand Down Expand Up @@ -1468,6 +1469,8 @@ _is_planar_rgb (GstVideoFormat v_format)
{
switch (v_format) {
case GST_VIDEO_FORMAT_GBR:
case GST_VIDEO_FORMAT_RGBP:
case GST_VIDEO_FORMAT_BGRP:
case GST_VIDEO_FORMAT_GBR_10BE:
case GST_VIDEO_FORMAT_GBR_10LE:
case GST_VIDEO_FORMAT_GBRA:
Expand Down Expand Up @@ -1530,6 +1533,10 @@ _RGB_pixel_order (const gchar * expected, const gchar * wanted)
gchar *temp = expect;
expect = g_strndup ("rgba", 4);
g_free (temp);
} else if (strcmp (expect, "rgbp") == 0 || strcmp (expect, "bgrp") == 0) {
gchar *temp = expect;
expect = g_strndup (temp, 3);
g_free (temp);
}

if (strcmp (want, "rgb16") == 0 || strcmp (want, "bgr16") == 0) {
Expand Down Expand Up @@ -1645,6 +1652,8 @@ _get_n_textures (GstVideoFormat v_format)
case GST_VIDEO_FORMAT_Y41B:
case GST_VIDEO_FORMAT_YV12:
case GST_VIDEO_FORMAT_GBR:
case GST_VIDEO_FORMAT_RGBP:
case GST_VIDEO_FORMAT_BGRP:
return 3;
case GST_VIDEO_FORMAT_GBRA:
return 4;
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/gstglcolorconvert.h
Expand Up @@ -100,7 +100,7 @@ struct _GstGLColorConvertClass
* The currently supported formats that can be converted
*/
#define GST_GL_COLOR_CONVERT_FORMATS "{ RGBA, RGB, RGBx, BGR, BGRx, BGRA, xRGB, " \
"xBGR, ARGB, ABGR, GBRA, GBR, Y444, I420, YV12, Y42B, " \
"xBGR, ARGB, ABGR, GBRA, GBR, RGBP, BGRP, Y444, I420, YV12, Y42B, " \
"Y41B, NV12, NV21, NV16, NV61, YUY2, UYVY, Y210, AYUV, " \
"VUYA, Y410, GRAY8, GRAY16_LE, GRAY16_BE, " \
"RGB16, BGR16, ARGB64 " \
Expand Down
2 changes: 2 additions & 0 deletions gst-libs/gst/gl/gstglformat.c
Expand Up @@ -221,6 +221,8 @@ gst_gl_format_from_video_info (GstGLContext * context,
case GST_VIDEO_FORMAT_Y412_BE:
return GST_GL_RGBA16;
case GST_VIDEO_FORMAT_GBR:
case GST_VIDEO_FORMAT_RGBP:
case GST_VIDEO_FORMAT_BGRP:
case GST_VIDEO_FORMAT_GBRA:
return GST_GL_R8;
default:
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/gstglmemory.h
Expand Up @@ -62,7 +62,7 @@ GType gst_gl_memory_allocator_get_type(void);
* List of video formats that are supported by #GstGLMemory
*/
#define GST_GL_MEMORY_VIDEO_FORMATS_STR \
"{ RGBA, BGRA, RGBx, BGRx, ARGB, ABGR, xRGB, xBGR, GBRA, GBR, RGB, BGR, RGB16, BGR16, " \
"{ RGBA, BGRA, RGBx, BGRx, ARGB, ABGR, xRGB, xBGR, GBRA, GBR, RGBP, BGRP, RGB, BGR, RGB16, BGR16, " \
"AYUV, VUYA, Y410, I420, YV12, NV12, NV21, NV16, NV61, YUY2, UYVY, Y210, Y41B, " \
"Y42B, Y444, GRAY8, GRAY16_LE, GRAY16_BE, ARGB64" \
GST_GL_MEMORY_VIDEO_EXT_FORMATS "}"
Expand Down

0 comments on commit 7412921

Please sign in to comment.