From: Hans Verkuil Date: Thu, 17 Jul 2014 22:15:43 +0000 (+0200) Subject: qv4l2: add support for new alpha-aware pixelformats. X-Git-Tag: v4l-utils-1.3.90~91 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c7a5ba9486942d591b365f9d91d6efbf494c0fd1;p=platform%2Fupstream%2Fv4l-utils.git qv4l2: add support for new alpha-aware pixelformats. Signed-off-by: Hans Verkuil --- diff --git a/utils/qv4l2/capture-win-gl.cpp b/utils/qv4l2/capture-win-gl.cpp index 135de12..b785658 100644 --- a/utils/qv4l2/capture-win-gl.cpp +++ b/utils/qv4l2/capture-win-gl.cpp @@ -278,12 +278,18 @@ bool CaptureWinGLEngine::hasNativeFormat(__u32 format) { static const __u32 supported_fmts[] = { V4L2_PIX_FMT_RGB32, + V4L2_PIX_FMT_XRGB32, + V4L2_PIX_FMT_ARGB32, V4L2_PIX_FMT_BGR32, + V4L2_PIX_FMT_XBGR32, + V4L2_PIX_FMT_ABGR32, V4L2_PIX_FMT_RGB24, V4L2_PIX_FMT_BGR24, V4L2_PIX_FMT_RGB565, V4L2_PIX_FMT_RGB565X, V4L2_PIX_FMT_RGB555, + V4L2_PIX_FMT_XRGB555, + V4L2_PIX_FMT_ARGB555, V4L2_PIX_FMT_RGB555X, V4L2_PIX_FMT_YUYV, V4L2_PIX_FMT_YVYU, @@ -336,6 +342,8 @@ void CaptureWinGLEngine::changeShader() break; case V4L2_PIX_FMT_RGB555: + case V4L2_PIX_FMT_XRGB555: + case V4L2_PIX_FMT_ARGB555: case V4L2_PIX_FMT_RGB555X: case V4L2_PIX_FMT_RGB565: case V4L2_PIX_FMT_RGB565X: @@ -343,6 +351,10 @@ void CaptureWinGLEngine::changeShader() case V4L2_PIX_FMT_BGR24: case V4L2_PIX_FMT_RGB32: case V4L2_PIX_FMT_BGR32: + case V4L2_PIX_FMT_XRGB32: + case V4L2_PIX_FMT_XBGR32: + case V4L2_PIX_FMT_ARGB32: + case V4L2_PIX_FMT_ABGR32: default: shader_RGB(); break; @@ -419,6 +431,8 @@ void CaptureWinGLEngine::paintGL() break; case V4L2_PIX_FMT_RGB555: + case V4L2_PIX_FMT_XRGB555: + case V4L2_PIX_FMT_ARGB555: case V4L2_PIX_FMT_RGB555X: case V4L2_PIX_FMT_RGB565: case V4L2_PIX_FMT_RGB565X: @@ -426,6 +440,10 @@ void CaptureWinGLEngine::paintGL() case V4L2_PIX_FMT_BGR24: case V4L2_PIX_FMT_RGB32: case V4L2_PIX_FMT_BGR32: + case V4L2_PIX_FMT_XRGB32: + case V4L2_PIX_FMT_XBGR32: + case V4L2_PIX_FMT_ARGB32: + case V4L2_PIX_FMT_ABGR32: default: render_RGB(); break; @@ -927,10 +945,13 @@ void CaptureWinGLEngine::shader_RGB() GL_SRGB8_ALPHA8 : GL_RGBA8; switch (m_frameFormat) { + case V4L2_PIX_FMT_ARGB555: + hasAlpha = true; + /* fall-through */ case V4L2_PIX_FMT_RGB555: + case V4L2_PIX_FMT_XRGB555: glTexImage2D(GL_TEXTURE_2D, 0, internalFmt, m_frameWidth, m_frameHeight, 0, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, NULL); - hasAlpha = true; break; case V4L2_PIX_FMT_RGB555X: @@ -944,15 +965,21 @@ void CaptureWinGLEngine::shader_RGB() glTexImage2D(GL_TEXTURE_2D, 0, internalFmt, m_frameWidth, m_frameHeight, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL); break; + case V4L2_PIX_FMT_ARGB32: + hasAlpha = true; + /* fall-through */ case V4L2_PIX_FMT_RGB32: + case V4L2_PIX_FMT_XRGB32: glTexImage2D(GL_TEXTURE_2D, 0, internalFmt, m_frameWidth, m_frameHeight, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, NULL); - hasAlpha = true; break; + case V4L2_PIX_FMT_ABGR32: + hasAlpha = true; + /* fall-through */ case V4L2_PIX_FMT_BGR32: + case V4L2_PIX_FMT_XBGR32: glTexImage2D(GL_TEXTURE_2D, 0, internalFmt, m_frameWidth, m_frameHeight, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, NULL); - hasAlpha = true; break; case V4L2_PIX_FMT_RGB24: case V4L2_PIX_FMT_BGR24: @@ -1018,6 +1045,8 @@ void CaptureWinGLEngine::render_RGB() switch (m_frameFormat) { case V4L2_PIX_FMT_RGB555: + case V4L2_PIX_FMT_XRGB555: + case V4L2_PIX_FMT_ARGB555: glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_frameWidth, m_frameHeight, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, m_frameData); break; @@ -1048,10 +1077,14 @@ void CaptureWinGLEngine::render_RGB() break; case V4L2_PIX_FMT_RGB32: + case V4L2_PIX_FMT_XRGB32: + case V4L2_PIX_FMT_ARGB32: glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_frameWidth, m_frameHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, m_frameData); break; case V4L2_PIX_FMT_BGR32: + case V4L2_PIX_FMT_XBGR32: + case V4L2_PIX_FMT_ABGR32: glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_frameWidth, m_frameHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, m_frameData); break; diff --git a/utils/qv4l2/capture-win-qt.cpp b/utils/qv4l2/capture-win-qt.cpp index d2f80c9..7aafabc 100644 --- a/utils/qv4l2/capture-win-qt.cpp +++ b/utils/qv4l2/capture-win-qt.cpp @@ -130,15 +130,21 @@ bool CaptureWinQt::findNativeFormat(__u32 format, QImage::Format &dstFmt) } supported_fmts[] = { #if Q_BYTE_ORDER == Q_BIG_ENDIAN { V4L2_PIX_FMT_RGB32, QImage::Format_RGB32 }, + { V4L2_PIX_FMT_XRGB32, QImage::Format_RGB32 }, + { V4L2_PIX_FMT_ARGB32, QImage::Format_ARGB32 }, { V4L2_PIX_FMT_RGB24, QImage::Format_RGB888 }, { V4L2_PIX_FMT_RGB565X, QImage::Format_RGB16 }, { V4L2_PIX_FMT_RGB555X, QImage::Format_RGB555 }, #else { V4L2_PIX_FMT_BGR32, QImage::Format_RGB32 }, + { V4L2_PIX_FMT_XBGR32, QImage::Format_RGB32 }, + { V4L2_PIX_FMT_ABGR32, QImage::Format_ARGB32 }, { V4L2_PIX_FMT_RGB24, QImage::Format_RGB888 }, { V4L2_PIX_FMT_RGB565, QImage::Format_RGB16 }, { V4L2_PIX_FMT_RGB555, QImage::Format_RGB555 }, + { V4L2_PIX_FMT_XRGB555, QImage::Format_RGB555 }, { V4L2_PIX_FMT_RGB444, QImage::Format_RGB444 }, + { V4L2_PIX_FMT_XRGB444, QImage::Format_RGB444 }, #endif { 0, QImage::Format_Invalid } }; diff --git a/utils/qv4l2/qv4l2.cpp b/utils/qv4l2/qv4l2.cpp index 3490714..b1c3001 100644 --- a/utils/qv4l2/qv4l2.cpp +++ b/utils/qv4l2/qv4l2.cpp @@ -1187,8 +1187,18 @@ void ApplicationWindow::capStart(bool start) } // Ensure that the initial image is large enough for native 32 bit per pixel formats - if (pixfmt == V4L2_PIX_FMT_RGB32 || pixfmt == V4L2_PIX_FMT_BGR32) + switch (pixfmt) { + case V4L2_PIX_FMT_RGB32: + case V4L2_PIX_FMT_BGR32: + case V4L2_PIX_FMT_XRGB32: + case V4L2_PIX_FMT_XBGR32: + dstFmt = QImage::Format_RGB32; + break; + case V4L2_PIX_FMT_ARGB32: + case V4L2_PIX_FMT_ABGR32: dstFmt = QImage::Format_ARGB32; + break; + } m_capImage = new QImage(width, height, dstFmt); m_capImage->fill(0);