diff mbox

[2/2] qv4l2: gl: Add support for V4L2_PIX_FMT_Y16_BE

Message ID 1432026185-12284-2-git-send-email-ricardo.ribalda@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ricardo Ribalda Delgado May 19, 2015, 9:03 a.m. UTC
Add support for a 16 bit wide greyscale format in big endian.

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
---
This patch needs to be applied after the headers have been updated
to support Y16_BE. It is scheduled for 4.2.

It has been tested with vivid and an nvidia-glx driver (propietary)
 utils/qv4l2/capture-win-gl.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox

Patch

diff --git a/utils/qv4l2/capture-win-gl.cpp b/utils/qv4l2/capture-win-gl.cpp
index ee51089b5775..25dec3e79070 100644
--- a/utils/qv4l2/capture-win-gl.cpp
+++ b/utils/qv4l2/capture-win-gl.cpp
@@ -413,6 +413,7 @@  bool CaptureWinGLEngine::hasNativeFormat(__u32 format)
 		V4L2_PIX_FMT_YUV32,
 		V4L2_PIX_FMT_GREY,
 		V4L2_PIX_FMT_Y16,
+		V4L2_PIX_FMT_Y16_BE,
 		0
 	};
 
@@ -509,6 +510,7 @@  void CaptureWinGLEngine::changeShader()
 	case V4L2_PIX_FMT_ABGR32:
 	case V4L2_PIX_FMT_GREY:
 	case V4L2_PIX_FMT_Y16:
+	case V4L2_PIX_FMT_Y16_BE:
 	default:
 		shader_RGB(m_frameFormat);
 		break;
@@ -617,6 +619,7 @@  void CaptureWinGLEngine::paintGL()
 
 	case V4L2_PIX_FMT_GREY:
 	case V4L2_PIX_FMT_Y16:
+	case V4L2_PIX_FMT_Y16_BE:
 	case V4L2_PIX_FMT_RGB332:
 	case V4L2_PIX_FMT_BGR666:
 	case V4L2_PIX_FMT_RGB555:
@@ -1549,6 +1552,7 @@  void CaptureWinGLEngine::shader_RGB(__u32 format)
 			     GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
 		break;
 	case V4L2_PIX_FMT_Y16:
+	case V4L2_PIX_FMT_Y16_BE:
 		internalFmt = manualTransform ? GL_LUMINANCE : GL_SLUMINANCE;
 		glTexImage2D(GL_TEXTURE_2D, 0, internalFmt, m_frameWidth, m_frameHeight, 0,
 			     GL_LUMINANCE, GL_UNSIGNED_SHORT, NULL);
@@ -1654,6 +1658,12 @@  void CaptureWinGLEngine::render_RGB(__u32 format)
 		glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_frameWidth, m_frameHeight,
 				GL_LUMINANCE, GL_UNSIGNED_SHORT, m_frameData);
 		break;
+	case V4L2_PIX_FMT_Y16_BE:
+		glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_TRUE);
+		glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_frameWidth, m_frameHeight,
+				GL_LUMINANCE, GL_UNSIGNED_SHORT, m_frameData);
+		glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
+		break;
 
 	case V4L2_PIX_FMT_RGB555X:
 	case V4L2_PIX_FMT_XRGB555X: