From a7f6af9817771b8211433c8cf24fe7150c5b7bf5 Mon Sep 17 00:00:00 2001 From: Andrew den Exter Date: Tue, 16 Feb 2010 14:26:14 +1000 Subject: Don't paint RGB24 frames as BGR24. A non-swizzling shader was being used for RGB24. This looked correct on linux because the gstreamer backend was misidentifying BGR24 as RGB24. And since BGR is supported include it in the list of supported formats. --- src/multimedia/base/qpaintervideosurface.cpp | 26 ++++++++++++++++++++++ .../gstreamer/qvideosurfacegstsink.cpp | 5 ++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/multimedia/base/qpaintervideosurface.cpp b/src/multimedia/base/qpaintervideosurface.cpp index f7ffb02..58d7412 100644 --- a/src/multimedia/base/qpaintervideosurface.cpp +++ b/src/multimedia/base/qpaintervideosurface.cpp @@ -579,8 +579,10 @@ QVideoSurfaceArbFpPainter::QVideoSurfaceArbFpPainter(QGLContext *context) m_imagePixelFormats << QVideoFrame::Format_RGB32 + << QVideoFrame::Format_BGR32 << QVideoFrame::Format_ARGB32 << QVideoFrame::Format_RGB24 + << QVideoFrame::Format_BGR24 << QVideoFrame::Format_RGB565 << QVideoFrame::Format_YV12 << QVideoFrame::Format_YUV420P; @@ -605,6 +607,10 @@ QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::start(const QVideoSurfac initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); program = qt_arbfp_xrgbShaderProgram; break; + case QVideoFrame::Format_BGR32: + initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); + program = qt_arbfp_rgbShaderProgram; + break; case QVideoFrame::Format_ARGB32: initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); program = qt_arbfp_argbShaderProgram; @@ -613,6 +619,10 @@ QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::start(const QVideoSurfac initRgbTextureInfo(GL_RGB8, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); program = qt_arbfp_argbShaderProgram; break; + case QVideoFrame::Format_BGR24: + initRgbTextureInfo(GL_RGB8, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); + program = qt_arbfp_rgbShaderProgram; + break; case QVideoFrame::Format_RGB565: initRgbTextureInfo(GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, format.frameSize()); program = qt_arbfp_rgbShaderProgram; @@ -706,6 +716,9 @@ QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::paint( if (m_frame.isValid()) { painter->beginNativePainting(); + glEnable(GL_STENCIL_TEST); + glEnable(GL_SCISSOR_TEST); + const float txLeft = source.left() / m_frameSize.width(); const float txRight = source.right() / m_frameSize.width(); const float txTop = m_scanLineDirection == QVideoSurfaceFormat::TopToBottom @@ -779,6 +792,9 @@ QAbstractVideoSurface::Error QVideoSurfaceArbFpPainter::paint( glDisableClientState(GL_VERTEX_ARRAY); glDisable(GL_FRAGMENT_PROGRAM_ARB); + glDisable(GL_STENCIL_TEST); + glDisable(GL_SCISSOR_TEST); + painter->endNativePainting(); } return QAbstractVideoSurface::NoError; @@ -872,9 +888,11 @@ QVideoSurfaceGlslPainter::QVideoSurfaceGlslPainter(QGLContext *context) { m_imagePixelFormats << QVideoFrame::Format_RGB32 + << QVideoFrame::Format_BGR32 << QVideoFrame::Format_ARGB32 #ifndef QT_OPENGL_ES << QVideoFrame::Format_RGB24 + << QVideoFrame::Format_BGR24 #endif << QVideoFrame::Format_RGB565 << QVideoFrame::Format_YV12 @@ -900,6 +918,10 @@ QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::start(const QVideoSurface initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); fragmentProgram = qt_glsl_xrgbShaderProgram; break; + case QVideoFrame::Format_BGR32: + initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); + fragmentProgram = qt_glsl_rgbShaderProgram; + break; case QVideoFrame::Format_ARGB32: initRgbTextureInfo(GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, format.frameSize()); fragmentProgram = qt_glsl_argbShaderProgram; @@ -907,6 +929,10 @@ QAbstractVideoSurface::Error QVideoSurfaceGlslPainter::start(const QVideoSurface #ifndef QT_OPENGL_ES case QVideoFrame::Format_RGB24: initRgbTextureInfo(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize()); + fragmentProgram = qt_glsl_argbShaderProgram; + break; + case QVideoFrame::Format_BGR24: + initRgbTextureInfo(GL_RGB8, GL_RGB, GL_UNSIGNED_BYTE, format.frameSize()); fragmentProgram = qt_glsl_rgbShaderProgram; break; #endif diff --git a/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.cpp b/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.cpp index 8c61846..3108e1a 100644 --- a/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.cpp +++ b/src/plugins/mediaservices/gstreamer/qvideosurfacegstsink.cpp @@ -268,9 +268,12 @@ static const RgbFormat qt_rgbColorLookup[] = { { QVideoFrame::Format_RGB32 , 32, 24, 4321, 0x0000FF00, 0x00FF0000, 0xFF000000, 0x00000000 }, { QVideoFrame::Format_RGB32 , 32, 24, 1234, 0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000 }, + { QVideoFrame::Format_BGR32 , 32, 24, 4321, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x00000000 }, + { QVideoFrame::Format_BGR32 , 32, 24, 1234, 0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000 }, { QVideoFrame::Format_ARGB32, 32, 24, 4321, 0x0000FF00, 0x00FF0000, 0xFF000000, 0x000000FF }, { QVideoFrame::Format_ARGB32, 32, 24, 1234, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000 }, - { QVideoFrame::Format_RGB24 , 24, 24, 4321, 0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000 }, + { QVideoFrame::Format_RGB24 , 24, 24, 4321, 0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000 }, + { QVideoFrame::Format_BGR24 , 24, 24, 4321, 0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000 }, { QVideoFrame::Format_RGB565, 16, 16, 1234, 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 } }; -- cgit v0.12