aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2019-02-19 12:02:57 (GMT)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2019-02-19 12:02:57 (GMT)
commit193d650fdc4201bb20d8d32b4ab0c7ae7dca7359 (patch)
tree82367c16e0078dd5ab92a3b1a4aed6ef642631e1
parent6fa4ce61662e884627bad6af53be6c3e8fc587fe (diff)
v4l2 utils: support V4L2_PIX_FMT_AYUV32 et al
Add support for all four variants of V4L2_PIX_FMT_AYUV32 in the v4l2-ctl, v4l2-compliance, qvidcap and qv4l2 utilities. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rw-r--r--utils/qv4l2/capture-win-gl.cpp35
-rw-r--r--utils/qv4l2/qv4l2.cpp6
-rw-r--r--utils/qvidcap/capture.cpp8
-rw-r--r--utils/qvidcap/paint.cpp37
-rw-r--r--utils/qvidcap/v4l2-convert.glsl13
-rw-r--r--utils/v4l2-compliance/v4l2-test-colors.cpp8
-rw-r--r--utils/v4l2-ctl/v4l2-ctl.cpp4
7 files changed, 96 insertions, 15 deletions
diff --git a/utils/qv4l2/capture-win-gl.cpp b/utils/qv4l2/capture-win-gl.cpp
index 0adb08b..fc8e7f4 100644
--- a/utils/qv4l2/capture-win-gl.cpp
+++ b/utils/qv4l2/capture-win-gl.cpp
@@ -185,6 +185,10 @@ void CaptureWinGLEngine::setColorspace(unsigned colorspace, unsigned xfer_func,
case V4L2_PIX_FMT_YUV555:
case V4L2_PIX_FMT_YUV565:
case V4L2_PIX_FMT_YUV32:
+ case V4L2_PIX_FMT_AYUV32:
+ case V4L2_PIX_FMT_XYUV32:
+ case V4L2_PIX_FMT_VUYA32:
+ case V4L2_PIX_FMT_VUYX32:
case V4L2_PIX_FMT_HSV24:
case V4L2_PIX_FMT_HSV32:
is_rgb = false;
@@ -400,6 +404,10 @@ bool CaptureWinGLEngine::hasNativeFormat(__u32 format)
V4L2_PIX_FMT_YUV555,
V4L2_PIX_FMT_YUV565,
V4L2_PIX_FMT_YUV32,
+ V4L2_PIX_FMT_AYUV32,
+ V4L2_PIX_FMT_XYUV32,
+ V4L2_PIX_FMT_VUYA32,
+ V4L2_PIX_FMT_VUYX32,
V4L2_PIX_FMT_GREY,
V4L2_PIX_FMT_Z16,
V4L2_PIX_FMT_INZI,
@@ -464,6 +472,10 @@ void CaptureWinGLEngine::changeShader()
case V4L2_PIX_FMT_YUV555:
case V4L2_PIX_FMT_YUV565:
case V4L2_PIX_FMT_YUV32:
+ case V4L2_PIX_FMT_AYUV32:
+ case V4L2_PIX_FMT_XYUV32:
+ case V4L2_PIX_FMT_VUYA32:
+ case V4L2_PIX_FMT_VUYX32:
shader_YUV_packed(m_frameFormat);
break;
@@ -628,6 +640,10 @@ void CaptureWinGLEngine::paintGL()
case V4L2_PIX_FMT_YUV555:
case V4L2_PIX_FMT_YUV565:
case V4L2_PIX_FMT_YUV32:
+ case V4L2_PIX_FMT_AYUV32:
+ case V4L2_PIX_FMT_XYUV32:
+ case V4L2_PIX_FMT_VUYA32:
+ case V4L2_PIX_FMT_VUYX32:
render_YUV_packed(m_frameFormat);
break;
@@ -2062,10 +2078,20 @@ void CaptureWinGLEngine::shader_YUV_packed(__u32 format)
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_frameWidth, m_frameHeight, 0,
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL);
break;
+ case V4L2_PIX_FMT_AYUV32:
+ hasAlpha = true;
+ // fall-through
case V4L2_PIX_FMT_YUV32:
+ case V4L2_PIX_FMT_XYUV32:
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_frameWidth, m_frameHeight, 0,
+ GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, NULL);
+ break;
+ case V4L2_PIX_FMT_VUYA32:
hasAlpha = true;
+ // fall-through
+ case V4L2_PIX_FMT_VUYX32:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_frameWidth, m_frameHeight, 0,
- GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, NULL);
+ GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, NULL);
break;
}
@@ -2133,9 +2159,16 @@ void CaptureWinGLEngine::render_YUV_packed(__u32 format)
break;
case V4L2_PIX_FMT_YUV32:
+ case V4L2_PIX_FMT_AYUV32:
+ case V4L2_PIX_FMT_XYUV32:
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_VUYA32:
+ case V4L2_PIX_FMT_VUYX32:
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_frameWidth, m_frameHeight,
+ GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, m_frameData);
+ break;
}
checkError("Packed YUV paint");
}
diff --git a/utils/qv4l2/qv4l2.cpp b/utils/qv4l2/qv4l2.cpp
index df9711b..832f479 100644
--- a/utils/qv4l2/qv4l2.cpp
+++ b/utils/qv4l2/qv4l2.cpp
@@ -1516,11 +1516,15 @@ void ApplicationWindow::capStart(bool start)
case V4L2_PIX_FMT_BGR32:
case V4L2_PIX_FMT_XRGB32:
case V4L2_PIX_FMT_XBGR32:
+ case V4L2_PIX_FMT_YUV32:
+ case V4L2_PIX_FMT_XYUV32:
+ case V4L2_PIX_FMT_VUYX32:
dstFmt = QImage::Format_RGB32;
break;
case V4L2_PIX_FMT_ARGB32:
case V4L2_PIX_FMT_ABGR32:
- case V4L2_PIX_FMT_YUV32:
+ case V4L2_PIX_FMT_AYUV32:
+ case V4L2_PIX_FMT_VUYA32:
dstFmt = QImage::Format_ARGB32;
break;
case V4L2_PIX_FMT_INZI:
diff --git a/utils/qvidcap/capture.cpp b/utils/qvidcap/capture.cpp
index e04db6b..b69de29 100644
--- a/utils/qvidcap/capture.cpp
+++ b/utils/qvidcap/capture.cpp
@@ -53,6 +53,10 @@ const __u32 formats[] = {
V4L2_PIX_FMT_YUV555,
V4L2_PIX_FMT_YUV565,
V4L2_PIX_FMT_YUV32,
+ V4L2_PIX_FMT_AYUV32,
+ V4L2_PIX_FMT_XYUV32,
+ V4L2_PIX_FMT_VUYA32,
+ V4L2_PIX_FMT_VUYX32,
V4L2_PIX_FMT_RGB32,
V4L2_PIX_FMT_XRGB32,
V4L2_PIX_FMT_ARGB32,
@@ -826,6 +830,10 @@ bool CaptureWin::updateV4LFormat(const cv4l_fmt &fmt)
case V4L2_PIX_FMT_YUV555:
case V4L2_PIX_FMT_YUV565:
case V4L2_PIX_FMT_YUV32:
+ case V4L2_PIX_FMT_AYUV32:
+ case V4L2_PIX_FMT_XYUV32:
+ case V4L2_PIX_FMT_VUYA32:
+ case V4L2_PIX_FMT_VUYX32:
m_is_rgb = false;
m_accepts_srgb = false;
break;
diff --git a/utils/qvidcap/paint.cpp b/utils/qvidcap/paint.cpp
index 61c2a73..547ad07 100644
--- a/utils/qvidcap/paint.cpp
+++ b/utils/qvidcap/paint.cpp
@@ -155,6 +155,10 @@ void CaptureWin::paintGL()
case V4L2_PIX_FMT_YUV555:
case V4L2_PIX_FMT_YUV565:
case V4L2_PIX_FMT_YUV32:
+ case V4L2_PIX_FMT_AYUV32:
+ case V4L2_PIX_FMT_XYUV32:
+ case V4L2_PIX_FMT_VUYA32:
+ case V4L2_PIX_FMT_VUYX32:
render_YUV_packed(m_v4l_fmt.g_pixelformat());
break;
@@ -331,6 +335,10 @@ static const struct define defines[] = {
DEF(V4L2_PIX_FMT_YUV555),
DEF(V4L2_PIX_FMT_YUV565),
DEF(V4L2_PIX_FMT_YUV32),
+ DEF(V4L2_PIX_FMT_AYUV32),
+ DEF(V4L2_PIX_FMT_XYUV32),
+ DEF(V4L2_PIX_FMT_VUYA32),
+ DEF(V4L2_PIX_FMT_VUYX32),
DEF(V4L2_PIX_FMT_RGB32),
DEF(V4L2_PIX_FMT_XRGB32),
DEF(V4L2_PIX_FMT_ARGB32),
@@ -551,6 +559,10 @@ void CaptureWin::changeShader()
case V4L2_PIX_FMT_YUV555:
case V4L2_PIX_FMT_YUV565:
case V4L2_PIX_FMT_YUV32:
+ case V4L2_PIX_FMT_AYUV32:
+ case V4L2_PIX_FMT_XYUV32:
+ case V4L2_PIX_FMT_VUYA32:
+ case V4L2_PIX_FMT_VUYX32:
shader_YUV_packed();
break;
@@ -773,14 +785,11 @@ void CaptureWin::shader_RGB()
case V4L2_PIX_FMT_RGB32:
case V4L2_PIX_FMT_XRGB32:
case V4L2_PIX_FMT_HSV32:
- glTexImage2D(GL_TEXTURE_2D, 0, internalFmt, m_v4l_fmt.g_width(), m_v4l_fmt.g_height(), 0,
- GL_RGBA, GL_UNSIGNED_BYTE, NULL);
- break;
case V4L2_PIX_FMT_ABGR32:
case V4L2_PIX_FMT_BGR32:
case V4L2_PIX_FMT_XBGR32:
glTexImage2D(GL_TEXTURE_2D, 0, internalFmt, m_v4l_fmt.g_width(), m_v4l_fmt.g_height(), 0,
- GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ GL_RGBA, GL_UNSIGNED_BYTE, NULL);
break;
case V4L2_PIX_FMT_GREY:
glTexImage2D(GL_TEXTURE_2D, 0, GL_R8UI, m_v4l_fmt.g_width(), m_v4l_fmt.g_height(), 0,
@@ -864,8 +873,12 @@ void CaptureWin::shader_YUV_packed()
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, NULL);
break;
case V4L2_PIX_FMT_YUV32:
+ case V4L2_PIX_FMT_AYUV32:
+ case V4L2_PIX_FMT_XYUV32:
+ case V4L2_PIX_FMT_VUYA32:
+ case V4L2_PIX_FMT_VUYX32:
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_v4l_fmt.g_width(), m_v4l_fmt.g_height(), 0,
- GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ GL_RGBA, GL_UNSIGNED_BYTE, NULL);
break;
}
@@ -1121,6 +1134,9 @@ void CaptureWin::render_RGB(__u32 format)
case V4L2_PIX_FMT_XRGB32:
case V4L2_PIX_FMT_ARGB32:
case V4L2_PIX_FMT_HSV32:
+ case V4L2_PIX_FMT_BGR32:
+ case V4L2_PIX_FMT_XBGR32:
+ case V4L2_PIX_FMT_ABGR32:
glPixelStorei(GL_UNPACK_ROW_LENGTH, m_v4l_fmt.g_bytesperline() / 4);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_v4l_fmt.g_width(), m_v4l_fmt.g_height(),
GL_RGBA, GL_UNSIGNED_BYTE, m_curData[0]);
@@ -1131,13 +1147,6 @@ void CaptureWin::render_RGB(__u32 format)
GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, m_curData[0]);
break;
- case V4L2_PIX_FMT_BGR32:
- case V4L2_PIX_FMT_XBGR32:
- case V4L2_PIX_FMT_ABGR32:
- glPixelStorei(GL_UNPACK_ROW_LENGTH, m_v4l_fmt.g_bytesperline() / 4);
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_v4l_fmt.g_width(), m_v4l_fmt.g_height(),
- GL_RGBA, GL_UNSIGNED_BYTE, m_curData[0]);
- break;
case V4L2_PIX_FMT_RGB24:
case V4L2_PIX_FMT_BGR24:
case V4L2_PIX_FMT_HSV24:
@@ -1205,6 +1214,10 @@ void CaptureWin::render_YUV_packed(__u32 format)
break;
case V4L2_PIX_FMT_YUV32:
+ case V4L2_PIX_FMT_AYUV32:
+ case V4L2_PIX_FMT_XYUV32:
+ case V4L2_PIX_FMT_VUYA32:
+ case V4L2_PIX_FMT_VUYX32:
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_v4l_fmt.g_width(), m_v4l_fmt.g_height(),
GL_RGBA, GL_UNSIGNED_BYTE, m_curData[0]);
break;
diff --git a/utils/qvidcap/v4l2-convert.glsl b/utils/qvidcap/v4l2-convert.glsl
index 8187956..8f80a90 100644
--- a/utils/qvidcap/v4l2-convert.glsl
+++ b/utils/qvidcap/v4l2-convert.glsl
@@ -254,12 +254,23 @@ void main()
vec4 color = texture(tex, xy);
alpha = color.a;
yuv = color.rgb;
-#elif PIXFMT == V4L2_PIX_FMT_YUV444 || PIXFMT == V4L2_PIX_FMT_YUV32
+#elif PIXFMT == V4L2_PIX_FMT_YUV444 || PIXFMT == V4L2_PIX_FMT_YUV32 || \
+ PIXFMT == V4L2_PIX_FMT_XYUV32 || PIXFMT == V4L2_PIX_FMT_AYUV32
vec4 color = texture(tex, xy);
+#if PIXFMT == V4L2_PIX_FMT_AYUV32
alpha = color.r;
+#endif
yuv.r = color.g;
yuv.g = color.b;
yuv.b = color.a;
+#elif PIXFMT == V4L2_PIX_FMT_VUYA32 || PIXFMT == V4L2_PIX_FMT_VUYX32
+ vec4 color = texture(tex, xy);
+#if PIXFMT == V4L2_PIX_FMT_VUYA32
+ alpha = color.a;
+#endif
+ yuv.r = color.b;
+ yuv.g = color.g;
+ yuv.b = color.r;
#elif PIXFMT == V4L2_PIX_FMT_YUV565
yuv = texture(tex, xy).rgb;
#elif PIXFMT == V4L2_PIX_FMT_YUV422P || PIXFMT == V4L2_PIX_FMT_YUV420 || PIXFMT == V4L2_PIX_FMT_YVU420 || \
diff --git a/utils/v4l2-compliance/v4l2-test-colors.cpp b/utils/v4l2-compliance/v4l2-test-colors.cpp
index ca7a4ea..7c62dc7 100644
--- a/utils/v4l2-compliance/v4l2-test-colors.cpp
+++ b/utils/v4l2-compliance/v4l2-test-colors.cpp
@@ -145,6 +145,8 @@ static void getColor(const cv4l_fmt &fmt, __u8 * const planes[3],
case V4L2_PIX_FMT_XRGB32:
case V4L2_PIX_FMT_ARGB32:
case V4L2_PIX_FMT_YUV32:
+ case V4L2_PIX_FMT_AYUV32:
+ case V4L2_PIX_FMT_XYUV32:
v32 = p8[4 * x + 3] + (p8[4 * x + 2] << 8) +
(p8[4 * x + 1] << 16) + (p8[4 * x] << 24);
break;
@@ -156,6 +158,8 @@ static void getColor(const cv4l_fmt &fmt, __u8 * const planes[3],
case V4L2_PIX_FMT_BGR32:
case V4L2_PIX_FMT_XBGR32:
case V4L2_PIX_FMT_ABGR32:
+ case V4L2_PIX_FMT_VUYA32:
+ case V4L2_PIX_FMT_VUYX32:
v32 = p8[4 * x] + (p8[4 * x + 1] << 8) +
(p8[4 * x + 2] << 16) + (p8[4 * x + 3] << 24);
break;
@@ -319,6 +323,10 @@ static void getColor(const cv4l_fmt &fmt, __u8 * const planes[3],
case V4L2_PIX_FMT_YUV555:
case V4L2_PIX_FMT_YUV565:
case V4L2_PIX_FMT_YUV32:
+ case V4L2_PIX_FMT_AYUV32:
+ case V4L2_PIX_FMT_XYUV32:
+ case V4L2_PIX_FMT_VUYA32:
+ case V4L2_PIX_FMT_VUYX32:
case V4L2_PIX_FMT_YUYV:
case V4L2_PIX_FMT_UYVY:
case V4L2_PIX_FMT_YVYU:
diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp
index 2c24ade..cbe31c8 100644
--- a/utils/v4l2-ctl/v4l2-ctl.cpp
+++ b/utils/v4l2-ctl/v4l2-ctl.cpp
@@ -347,6 +347,10 @@ static bool is_rgb_or_hsv(__u32 pixelformat)
case V4L2_PIX_FMT_YUV555:
case V4L2_PIX_FMT_YUV565:
case V4L2_PIX_FMT_YUV32:
+ case V4L2_PIX_FMT_AYUV32:
+ case V4L2_PIX_FMT_XYUV32:
+ case V4L2_PIX_FMT_VUYA32:
+ case V4L2_PIX_FMT_VUYX32:
case V4L2_PIX_FMT_YUV410:
case V4L2_PIX_FMT_YUV420:
case V4L2_PIX_FMT_HI240:

Privacy Policy