aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArisotura <thetotalworm@gmail.com>2022-10-02 19:43:57 +0200
committerArisotura <thetotalworm@gmail.com>2022-10-02 19:43:57 +0200
commit62879c44840f66a9854ab3938412b97828154d7f (patch)
tree3dea414f266e74eee9e83bf42d4d6949adf70b84 /src
parentaf9a77b0b4880f7362ac85e468a98315133bd39e (diff)
add support for UYVY format (FaceTime camera)
Diffstat (limited to 'src')
-rw-r--r--src/frontend/qt_sdl/CameraManager.cpp32
-rw-r--r--src/frontend/qt_sdl/CameraManager.h1
2 files changed, 33 insertions, 0 deletions
diff --git a/src/frontend/qt_sdl/CameraManager.cpp b/src/frontend/qt_sdl/CameraManager.cpp
index d2cb1e5..19cf8d4 100644
--- a/src/frontend/qt_sdl/CameraManager.cpp
+++ b/src/frontend/qt_sdl/CameraManager.cpp
@@ -47,6 +47,10 @@ void CameraFrameDumper::present(const QVideoFrame& _frame)
cam->feedFrame((u32*)frame.bits(0), frame.width(), frame.height(), frame.pixelFormat() == QVideoFrameFormat::Format_YUYV);
break;
+ case QVideoFrameFormat::Format_UYVY:
+ cam->feedFrame_UYVY((u32*)frame.bits(0), frame.width(), frame.height());
+ break;
+
case QVideoFrameFormat::Format_NV12:
cam->feedFrame_NV12((u8*)frame.bits(0), (u8*)frame.bits(1), frame.width(), frame.height());
break;
@@ -80,6 +84,10 @@ bool CameraFrameDumper::present(const QVideoFrame& _frame)
cam->feedFrame((u32*)frame.bits(0), frame.width(), frame.height(), frame.pixelFormat() == QVideoFrame::Format_YUYV);
break;
+ case QVideoFrame::Format_UYVY:
+ cam->feedFrame_UYVY((u32*)frame.bits(0), frame.width(), frame.height());
+ break;
+
case QVideoFrame::Format_NV12:
cam->feedFrame_NV12((u8*)frame.bits(0), (u8*)frame.bits(1), frame.width(), frame.height());
break;
@@ -96,6 +104,7 @@ QList<QVideoFrame::PixelFormat> CameraFrameDumper::supportedPixelFormats(QAbstra
ret.append(QVideoFrame::Format_RGB32);
ret.append(QVideoFrame::Format_YUYV);
+ ret.append(QVideoFrame::Format_UYVY);
ret.append(QVideoFrame::Format_NV12);
return ret;
@@ -209,6 +218,7 @@ void CameraManager::init()
for (const QCameraFormat& item : supported)
{
if (item.pixelFormat() != QVideoFrameFormat::Format_YUYV &&
+ item.pixelFormat() != QVideoFrameFormat::Format_UYVY &&
item.pixelFormat() != QVideoFrameFormat::Format_NV12 &&
item.pixelFormat() != QVideoFrameFormat::Format_XRGB8888)
continue;
@@ -252,6 +262,7 @@ void CameraManager::init()
for (const QCameraViewfinderSettings& item : supported)
{
if (item.pixelFormat() != QVideoFrame::Format_YUYV &&
+ item.pixelFormat() != QVideoFrame::Format_UYVY &&
item.pixelFormat() != QVideoFrame::Format_NV12 &&
item.pixelFormat() != QVideoFrame::Format_RGB32)
continue;
@@ -417,6 +428,27 @@ void CameraManager::feedFrame(u32* frame, int width, int height, bool yuv)
frameMutex.unlock();
}
+void CameraManager::feedFrame_UYVY(u32* frame, int width, int height)
+{
+ for (int y = 0; y < frameHeight; y++)
+ {
+ int sy = (y * height) / frameHeight;
+
+ for (int x = 0; x < frameWidth; x+=2)
+ {
+ int sx = (x * width) / frameWidth;
+
+ u32 val = frame[((sy*width) + sx) >> 1];
+
+ val = ((val & 0xFF00FF00) >> 8) | ((val & 0x00FF00FF) << 8);
+
+ tempFrameBuffer[((y*frameWidth) + x) >> 1] = val;
+ }
+ }
+
+ feedFrame(tempFrameBuffer, frameWidth, frameHeight, true);
+}
+
void CameraManager::feedFrame_NV12(u8* planeY, u8* planeUV, int width, int height)
{
for (int y = 0; y < frameHeight; y++)
diff --git a/src/frontend/qt_sdl/CameraManager.h b/src/frontend/qt_sdl/CameraManager.h
index 36e8565..6743d19 100644
--- a/src/frontend/qt_sdl/CameraManager.h
+++ b/src/frontend/qt_sdl/CameraManager.h
@@ -92,6 +92,7 @@ public:
void captureFrame(u32* frame, int width, int height, bool yuv);
void feedFrame(u32* frame, int width, int height, bool yuv);
+ void feedFrame_UYVY(u32* frame, int width, int height);
void feedFrame_NV12(u8* planeY, u8* planeUV, int width, int height);
signals: