mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 09:40:37 +00:00
[224/906] fix a regression about MESA YCbCr colorspace conversion
This commit is contained in:
parent
51cdfc6682
commit
9b18be0019
1 changed files with 241 additions and 124 deletions
|
@ -990,12 +990,12 @@ gst_gl_display_thread_init_upload (GstGLDisplay *display)
|
|||
{
|
||||
GST_CAT_INFO (GST_CAT_DEFAULT, "Context %d, ARB_fragment_shader supported: yes", display->glutWinId);
|
||||
|
||||
display->upload_colorspace_conversion = GST_GL_DISPLAY_CONVERSION_GLSL;
|
||||
|
||||
gst_gl_display_thread_init_upload_fbo (display);
|
||||
if (!display->isAlive)
|
||||
break;
|
||||
|
||||
display->upload_colorspace_conversion = GST_GL_DISPLAY_CONVERSION_GLSL;
|
||||
|
||||
switch (display->upload_video_format)
|
||||
{
|
||||
case GST_VIDEO_FORMAT_YUY2:
|
||||
|
@ -1066,7 +1066,6 @@ gst_gl_display_thread_init_upload (GstGLDisplay *display)
|
|||
{
|
||||
//GLSL and Color Matrix are not available on your drivers, switch to YCBCR MESA
|
||||
GST_CAT_INFO (GST_CAT_DEFAULT, "Context %d, ARB_fragment_shader supported: no", display->glutWinId);
|
||||
GST_CAT_INFO (GST_CAT_DEFAULT, "Context %d, GLEW_ARB_imaging supported: no", display->glutWinId);
|
||||
GST_CAT_INFO (GST_CAT_DEFAULT, "Context %d, GLEW_MESA_ycbcr_texture supported: yes", display->glutWinId);
|
||||
|
||||
display->upload_colorspace_conversion = GST_GL_DISPLAY_CONVERSION_MESA;
|
||||
|
@ -1075,6 +1074,12 @@ gst_gl_display_thread_init_upload (GstGLDisplay *display)
|
|||
{
|
||||
case GST_VIDEO_FORMAT_YUY2:
|
||||
case GST_VIDEO_FORMAT_UYVY:
|
||||
//color space conversion is not needed
|
||||
//but if the size is different we need to redraw it
|
||||
//using fbo
|
||||
if (display->upload_width != display->upload_data_width ||
|
||||
display->upload_height != display->upload_data_height)
|
||||
gst_gl_display_thread_init_upload_fbo (display);
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_I420:
|
||||
case GST_VIDEO_FORMAT_YV12:
|
||||
|
@ -1165,6 +1170,11 @@ gst_gl_display_thread_do_upload (GstGLDisplay *display)
|
|||
break;
|
||||
case GST_GL_DISPLAY_CONVERSION_MESA:
|
||||
//color space conversion is not needed
|
||||
//but if the size is different we need to redraw it
|
||||
//using fbo
|
||||
if (display->upload_width != display->upload_data_width ||
|
||||
display->upload_height != display->upload_data_height)
|
||||
gst_gl_display_thread_do_upload_draw (display);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
|
@ -1843,8 +1853,54 @@ gst_gl_display_glgen_texture (GstGLDisplay* display, GLuint* pTexture, GLint wid
|
|||
//sub texture pool does not exist yet or empty
|
||||
glGenTextures (1, pTexture);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, *pTexture);
|
||||
|
||||
switch (display->upload_video_format)
|
||||
{
|
||||
case GST_VIDEO_FORMAT_RGB:
|
||||
case GST_VIDEO_FORMAT_BGR:
|
||||
case GST_VIDEO_FORMAT_RGBx:
|
||||
case GST_VIDEO_FORMAT_BGRx:
|
||||
case GST_VIDEO_FORMAT_xRGB:
|
||||
case GST_VIDEO_FORMAT_xBGR:
|
||||
case GST_VIDEO_FORMAT_RGBA:
|
||||
case GST_VIDEO_FORMAT_BGRA:
|
||||
case GST_VIDEO_FORMAT_ARGB:
|
||||
case GST_VIDEO_FORMAT_ABGR:
|
||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
|
||||
width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_YUY2:
|
||||
case GST_VIDEO_FORMAT_UYVY:
|
||||
switch (display->upload_colorspace_conversion)
|
||||
{
|
||||
case GST_GL_DISPLAY_CONVERSION_GLSL:
|
||||
case GST_GL_DISPLAY_CONVERSION_MATRIX:
|
||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
|
||||
width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
break;
|
||||
case GST_GL_DISPLAY_CONVERSION_MESA:
|
||||
if (display->upload_width != display->upload_data_width ||
|
||||
display->upload_height != display->upload_data_height)
|
||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
|
||||
width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
else
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_YCBCR_MESA,width, height,
|
||||
0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, NULL);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_I420:
|
||||
case GST_VIDEO_FORMAT_YV12:
|
||||
case GST_VIDEO_FORMAT_AYUV:
|
||||
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA8,
|
||||
width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
|
@ -2410,6 +2466,10 @@ void gst_gl_display_thread_do_upload_make (GstGLDisplay *display)
|
|||
width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, NULL);
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_YUY2:
|
||||
switch (display->upload_colorspace_conversion)
|
||||
{
|
||||
case GST_GL_DISPLAY_CONVERSION_GLSL:
|
||||
case GST_GL_DISPLAY_CONVERSION_MATRIX:
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE_ALPHA,
|
||||
width, height,
|
||||
0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
|
||||
|
@ -2419,8 +2479,20 @@ void gst_gl_display_thread_do_upload_make (GstGLDisplay *display)
|
|||
width, height,
|
||||
0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
|
||||
break;
|
||||
case GST_GL_DISPLAY_CONVERSION_MESA:
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_YCBCR_MESA, width, height,
|
||||
0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, NULL);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_UYVY:
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE_ALPHA,
|
||||
switch (display->upload_colorspace_conversion)
|
||||
{
|
||||
case GST_GL_DISPLAY_CONVERSION_GLSL:
|
||||
case GST_GL_DISPLAY_CONVERSION_MATRIX:
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE_ALPHA,
|
||||
width, height,
|
||||
0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, NULL);
|
||||
glGenTextures (1, &display->upload_intex_u);
|
||||
|
@ -2429,23 +2501,30 @@ glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE_ALPHA,
|
|||
width, height,
|
||||
0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
|
||||
break;
|
||||
|
||||
case GST_GL_DISPLAY_CONVERSION_MESA:
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_YCBCR_MESA, width, height,
|
||||
0, GL_YCBCR_MESA, GL_UNSIGNED_SHORT_8_8_MESA, NULL);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_I420:
|
||||
case GST_VIDEO_FORMAT_YV12:
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
|
||||
width, height,
|
||||
0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
|
||||
|
||||
glGenTextures (1, &display->upload_intex_u);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_u);
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
|
||||
glGenTextures (1, &display->upload_intex_u);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_u);
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
|
||||
GST_ROUND_UP_2 (width) / 2,
|
||||
GST_ROUND_UP_2 (height) / 2,
|
||||
0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
|
||||
|
||||
glGenTextures (1, &display->upload_intex_v);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_v);
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
|
||||
glGenTextures (1, &display->upload_intex_v);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex_v);
|
||||
glTexImage2D (GL_TEXTURE_RECTANGLE_ARB, 0, GL_LUMINANCE,
|
||||
GST_ROUND_UP_2 (width) / 2,
|
||||
GST_ROUND_UP_2 (height) / 2,
|
||||
0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
|
||||
|
@ -2489,9 +2568,23 @@ gst_gl_display_thread_do_upload_fill (GstGLDisplay *display)
|
|||
case GST_VIDEO_FORMAT_I420:
|
||||
case GST_VIDEO_FORMAT_YV12:
|
||||
case GST_VIDEO_FORMAT_AYUV:
|
||||
//color space conversion is needed
|
||||
switch (display->upload_colorspace_conversion)
|
||||
{
|
||||
case GST_GL_DISPLAY_CONVERSION_GLSL:
|
||||
case GST_GL_DISPLAY_CONVERSION_MATRIX:
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex);
|
||||
break;
|
||||
case GST_GL_DISPLAY_CONVERSION_MESA:
|
||||
if (display->upload_width != display->upload_data_width ||
|
||||
display->upload_height != display->upload_data_height)
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex);
|
||||
else
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_outtex);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
@ -2681,6 +2774,11 @@ gst_gl_display_thread_do_upload_draw (GstGLDisplay *display)
|
|||
|
||||
case GST_VIDEO_FORMAT_YUY2:
|
||||
case GST_VIDEO_FORMAT_UYVY:
|
||||
{
|
||||
switch (display->upload_colorspace_conversion)
|
||||
{
|
||||
case GST_GL_DISPLAY_CONVERSION_GLSL:
|
||||
case GST_GL_DISPLAY_CONVERSION_MATRIX:
|
||||
{
|
||||
GstGLShader* shader_upload_YUY2_UYVY = NULL;
|
||||
|
||||
|
@ -2718,6 +2816,25 @@ gst_gl_display_thread_do_upload_draw (GstGLDisplay *display)
|
|||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
}
|
||||
break;
|
||||
case GST_GL_DISPLAY_CONVERSION_MESA:
|
||||
{
|
||||
glMatrixMode (GL_PROJECTION);
|
||||
glLoadIdentity ();
|
||||
|
||||
glEnable(GL_TEXTURE_RECTANGLE_ARB);
|
||||
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, display->upload_intex);
|
||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri (GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GST_VIDEO_FORMAT_I420:
|
||||
case GST_VIDEO_FORMAT_YV12:
|
||||
|
|
Loading…
Reference in a new issue