gl: add support for P012_LE / P012_BE format

Because the color value is stored in MSB, so we can reuse the
P016_LE / P016_BE code for P012_LE / P012_BE
This commit is contained in:
Haihao Xiang 2020-03-24 12:39:50 +08:00
parent 7cd2f5a29f
commit 1db94e5205
5 changed files with 16 additions and 6 deletions

View file

@ -534,11 +534,13 @@ _drm_rgba_fourcc_from_info (GstVideoInfo * info, int plane,
return DRM_FORMAT_RGBA1010102; return DRM_FORMAT_RGBA1010102;
case GST_VIDEO_FORMAT_P010_10LE: case GST_VIDEO_FORMAT_P010_10LE:
case GST_VIDEO_FORMAT_P012_LE:
case GST_VIDEO_FORMAT_P016_LE: case GST_VIDEO_FORMAT_P016_LE:
*out_format = plane == 0 ? GST_GL_R16 : GST_GL_RG16; *out_format = plane == 0 ? GST_GL_R16 : GST_GL_RG16;
return plane == 0 ? DRM_FORMAT_R16 : DRM_FORMAT_GR1616; return plane == 0 ? DRM_FORMAT_R16 : DRM_FORMAT_GR1616;
case GST_VIDEO_FORMAT_P010_10BE: case GST_VIDEO_FORMAT_P010_10BE:
case GST_VIDEO_FORMAT_P012_BE:
case GST_VIDEO_FORMAT_P016_BE: case GST_VIDEO_FORMAT_P016_BE:
*out_format = plane == 0 ? GST_GL_R16 : GST_GL_RG16; *out_format = plane == 0 ? GST_GL_R16 : GST_GL_RG16;
return plane == 0 ? DRM_FORMAT_R16 : DRM_FORMAT_RG1616; return plane == 0 ? DRM_FORMAT_R16 : DRM_FORMAT_RG1616;

View file

@ -937,9 +937,11 @@ _init_supported_formats (GstGLContext * context, gboolean output,
if (!context || (gst_gl_format_is_supported (context, GST_GL_R16) && if (!context || (gst_gl_format_is_supported (context, GST_GL_R16) &&
gst_gl_format_is_supported (context, GST_GL_RG16))) { gst_gl_format_is_supported (context, GST_GL_RG16))) {
#if G_BYTE_ORDER == G_LITTLE_ENDIAN #if G_BYTE_ORDER == G_LITTLE_ENDIAN
_append_value_string_list (supported_formats, "P010_10LE", "P016_LE", NULL); _append_value_string_list (supported_formats, "P010_10LE", "P012_LE",
"P016_LE", NULL);
#else #else
_append_value_string_list (supported_formats, "P010_10BE", "P016_BE", NULL); _append_value_string_list (supported_formats, "P010_10BE", "P012_BE",
"P016_BE", NULL);
#endif #endif
} }
@ -1542,6 +1544,8 @@ _get_n_textures (GstVideoFormat v_format)
case GST_VIDEO_FORMAT_NV61: case GST_VIDEO_FORMAT_NV61:
case GST_VIDEO_FORMAT_P010_10LE: case GST_VIDEO_FORMAT_P010_10LE:
case GST_VIDEO_FORMAT_P010_10BE: case GST_VIDEO_FORMAT_P010_10BE:
case GST_VIDEO_FORMAT_P012_LE:
case GST_VIDEO_FORMAT_P012_BE:
case GST_VIDEO_FORMAT_P016_LE: case GST_VIDEO_FORMAT_P016_LE:
case GST_VIDEO_FORMAT_P016_BE: case GST_VIDEO_FORMAT_P016_BE:
return 2; return 2;
@ -1722,6 +1726,8 @@ _YUV_to_RGB (GstGLColorConvert * convert)
} }
case GST_VIDEO_FORMAT_P010_10LE: case GST_VIDEO_FORMAT_P010_10LE:
case GST_VIDEO_FORMAT_P010_10BE: case GST_VIDEO_FORMAT_P010_10BE:
case GST_VIDEO_FORMAT_P012_LE:
case GST_VIDEO_FORMAT_P012_BE:
case GST_VIDEO_FORMAT_P016_LE: case GST_VIDEO_FORMAT_P016_LE:
case GST_VIDEO_FORMAT_P016_BE: case GST_VIDEO_FORMAT_P016_BE:
{ {

View file

@ -88,9 +88,9 @@ struct _GstGLColorConvertClass
* The currently supported formats that can be converted * The currently supported formats that can be converted
*/ */
#if G_BYTE_ORDER == G_LITTLE_ENDIAN #if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define COLOR_CONVERT_EXT_FORMATS ", BGR10A2_LE, RGB10A2_LE, P010_10LE, P016_LE" #define COLOR_CONVERT_EXT_FORMATS ", BGR10A2_LE, RGB10A2_LE, P010_10LE, P012_LE, P016_LE"
#else #else
#define COLOR_CONVERT_EXT_FORMATS ", P010_10BE, P016_BE" #define COLOR_CONVERT_EXT_FORMATS ", P010_10BE, P012_BE, P016_BE"
#endif #endif
#define GST_GL_COLOR_CONVERT_FORMATS "{ RGBA, RGB, RGBx, BGR, BGRx, BGRA, xRGB, " \ #define GST_GL_COLOR_CONVERT_FORMATS "{ RGBA, RGB, RGBx, BGR, BGRx, BGRA, xRGB, " \

View file

@ -208,6 +208,8 @@ gst_gl_format_from_video_info (GstGLContext * context, GstVideoInfo * vinfo,
return GST_GL_RGB10_A2; return GST_GL_RGB10_A2;
case GST_VIDEO_FORMAT_P010_10LE: case GST_VIDEO_FORMAT_P010_10LE:
case GST_VIDEO_FORMAT_P010_10BE: case GST_VIDEO_FORMAT_P010_10BE:
case GST_VIDEO_FORMAT_P012_LE:
case GST_VIDEO_FORMAT_P012_BE:
case GST_VIDEO_FORMAT_P016_LE: case GST_VIDEO_FORMAT_P016_LE:
case GST_VIDEO_FORMAT_P016_BE: case GST_VIDEO_FORMAT_P016_BE:
return plane == 0 ? GST_GL_R16 : GST_GL_RG16; return plane == 0 ? GST_GL_R16 : GST_GL_RG16;

View file

@ -51,9 +51,9 @@ GType gst_gl_memory_allocator_get_type(void);
* List of video formats that are supported by #GstGLMemory * List of video formats that are supported by #GstGLMemory
*/ */
#if G_BYTE_ORDER == G_LITTLE_ENDIAN #if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define MEMORY_VIDEO_EXT_FORMATS ", BGR10A2_LE, RGB10A2_LE, P010_10LE, P016_LE" #define MEMORY_VIDEO_EXT_FORMATS ", BGR10A2_LE, RGB10A2_LE, P010_10LE, P012_LE, P016_LE"
#else #else
#define MEMORY_VIDEO_EXT_FORMATS ", P010_10BE, P016_BE" #define MEMORY_VIDEO_EXT_FORMATS ", P010_10BE, P012_BE, P016_BE"
#endif #endif
#define GST_GL_MEMORY_VIDEO_FORMATS_STR \ #define GST_GL_MEMORY_VIDEO_FORMATS_STR \