diff --git a/src/codec/video/VideoDecoderVDA.cpp b/src/codec/video/VideoDecoderVDA.cpp index 3912755d..f624a5ac 100755 --- a/src/codec/video/VideoDecoderVDA.cpp +++ b/src/codec/video/VideoDecoderVDA.cpp @@ -269,15 +269,15 @@ VideoFrame VideoDecoderVDA::frame() if (pixfmt == NV12) { dtype = GL_UNSIGNED_BYTE; if (plane == 0) { - iformat = format = GL_RED; + iformat = format = OpenGLHelper::useDeprecatedFormats() ? GL_LUMINANCE : GL_RED; } else { - iformat = format = GL_RG; + iformat = format = OpenGLHelper::useDeprecatedFormats() ? GL_LUMINANCE_ALPHA : GL_RG; } } else if (pixfmt == UYVY || pixfmt == YUYV) { w /= 2; //rgba texture } else if (pixfmt == YUV420P) { dtype = GL_UNSIGNED_BYTE; - iformat = format = GL_RED; + iformat = format = OpenGLHelper::useDeprecatedFormats() ? GL_LUMINANCE : GL_RED; } DYGL(glBindTexture(target, *((GLuint*)handle))); CGLError err = CGLTexImageIOSurface2D(CGLGetCurrentContext(), target, iformat, w, h, format, dtype, surface, plane); diff --git a/src/codec/video/VideoDecoderVideoToolbox.cpp b/src/codec/video/VideoDecoderVideoToolbox.cpp index 780f7f3c..97c667fb 100755 --- a/src/codec/video/VideoDecoderVideoToolbox.cpp +++ b/src/codec/video/VideoDecoderVideoToolbox.cpp @@ -255,15 +255,15 @@ VideoFrame VideoDecoderVideoToolbox::frame() if (pixfmt == NV12) { dtype = GL_UNSIGNED_BYTE; if (plane == 0) { - iformat = format = GL_RED; + iformat = format = OpenGLHelper::useDeprecatedFormats() ? GL_LUMINANCE : GL_RED; } else { - iformat = format = GL_RG; + iformat = format = OpenGLHelper::useDeprecatedFormats() ? GL_LUMINANCE_ALPHA : GL_RG; } } else if (pixfmt == UYVY || pixfmt == YUYV) { w /= 2; //rgba texture } else if (pixfmt == YUV420P) { dtype = GL_UNSIGNED_BYTE; - iformat = format = GL_RED; + iformat = format = OpenGLHelper::useDeprecatedFormats() ? GL_LUMINANCE : GL_RED; } DYGL(glBindTexture(target, *((GLuint*)handle))); CGLError err = CGLTexImageIOSurface2D(CGLGetCurrentContext(), target, iformat, w, h, format, dtype, surface, plane); diff --git a/src/utils/OpenGLHelper.cpp b/src/utils/OpenGLHelper.cpp index 4e77ac6b..c968625b 100644 --- a/src/utils/OpenGLHelper.cpp +++ b/src/utils/OpenGLHelper.cpp @@ -39,6 +39,12 @@ int depth16BitTexture() return depth; } +bool useDeprecatedFormats() +{ + static int v = qgetenv("QTAV_GL_DEPRECATED").toInt() == 1; + return v; +} + int GLSLVersion() { static int v = -1; @@ -295,15 +301,19 @@ static const gl_param_t* get_gl_param() else gp = (gl_param_t*)gl_param_desktop_fallback; has_16_tex = has_16; - qDebug("using gl_param_desktop%s", gp == gl_param_desktop? "" : "_fallback"); - return gp; + if (!useDeprecatedFormats()) { + qDebug("using gl_param_desktop%s", gp == gl_param_desktop? "" : "_fallback"); + return gp; + } } else if (test_gl_param(gl_param_es3[4], &has_16)) { - qDebug("using gl_param_es3"); gp = (gl_param_t*)gl_param_es3; has_16_tex = has_16; - return gp; + if (!useDeprecatedFormats()) { + qDebug("using gl_param_es3"); + return gp; + } } - qDebug("using gl_param_compat"); + qDebug("fallback to gl_param_compat"); gp = (gl_param_t*)gl_param_compat; has_16_tex = false; return gp; diff --git a/src/utils/OpenGLHelper.h b/src/utils/OpenGLHelper.h index df4979ed..02967441 100644 --- a/src/utils/OpenGLHelper.h +++ b/src/utils/OpenGLHelper.h @@ -159,6 +159,8 @@ bool hasRG(); bool has16BitTexture(); // set by user (environment var "QTAV_TEXTURE16_DEPTH=8") int depth16BitTexture(); +// set by user (environment var "QTAV_GL_DEPRECATED=1") +bool useDeprecatedFormats(); /*! * \brief hasExtension * Current OpenGL context must be valid.