add support for UYVY format (FaceTime camera)
This commit is contained in:
parent
af9a77b0b4
commit
62879c4484
|
@ -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);
|
cam->feedFrame((u32*)frame.bits(0), frame.width(), frame.height(), frame.pixelFormat() == QVideoFrameFormat::Format_YUYV);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case QVideoFrameFormat::Format_UYVY:
|
||||||
|
cam->feedFrame_UYVY((u32*)frame.bits(0), frame.width(), frame.height());
|
||||||
|
break;
|
||||||
|
|
||||||
case QVideoFrameFormat::Format_NV12:
|
case QVideoFrameFormat::Format_NV12:
|
||||||
cam->feedFrame_NV12((u8*)frame.bits(0), (u8*)frame.bits(1), frame.width(), frame.height());
|
cam->feedFrame_NV12((u8*)frame.bits(0), (u8*)frame.bits(1), frame.width(), frame.height());
|
||||||
break;
|
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);
|
cam->feedFrame((u32*)frame.bits(0), frame.width(), frame.height(), frame.pixelFormat() == QVideoFrame::Format_YUYV);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case QVideoFrame::Format_UYVY:
|
||||||
|
cam->feedFrame_UYVY((u32*)frame.bits(0), frame.width(), frame.height());
|
||||||
|
break;
|
||||||
|
|
||||||
case QVideoFrame::Format_NV12:
|
case QVideoFrame::Format_NV12:
|
||||||
cam->feedFrame_NV12((u8*)frame.bits(0), (u8*)frame.bits(1), frame.width(), frame.height());
|
cam->feedFrame_NV12((u8*)frame.bits(0), (u8*)frame.bits(1), frame.width(), frame.height());
|
||||||
break;
|
break;
|
||||||
|
@ -96,6 +104,7 @@ QList<QVideoFrame::PixelFormat> CameraFrameDumper::supportedPixelFormats(QAbstra
|
||||||
|
|
||||||
ret.append(QVideoFrame::Format_RGB32);
|
ret.append(QVideoFrame::Format_RGB32);
|
||||||
ret.append(QVideoFrame::Format_YUYV);
|
ret.append(QVideoFrame::Format_YUYV);
|
||||||
|
ret.append(QVideoFrame::Format_UYVY);
|
||||||
ret.append(QVideoFrame::Format_NV12);
|
ret.append(QVideoFrame::Format_NV12);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -209,6 +218,7 @@ void CameraManager::init()
|
||||||
for (const QCameraFormat& item : supported)
|
for (const QCameraFormat& item : supported)
|
||||||
{
|
{
|
||||||
if (item.pixelFormat() != QVideoFrameFormat::Format_YUYV &&
|
if (item.pixelFormat() != QVideoFrameFormat::Format_YUYV &&
|
||||||
|
item.pixelFormat() != QVideoFrameFormat::Format_UYVY &&
|
||||||
item.pixelFormat() != QVideoFrameFormat::Format_NV12 &&
|
item.pixelFormat() != QVideoFrameFormat::Format_NV12 &&
|
||||||
item.pixelFormat() != QVideoFrameFormat::Format_XRGB8888)
|
item.pixelFormat() != QVideoFrameFormat::Format_XRGB8888)
|
||||||
continue;
|
continue;
|
||||||
|
@ -252,6 +262,7 @@ void CameraManager::init()
|
||||||
for (const QCameraViewfinderSettings& item : supported)
|
for (const QCameraViewfinderSettings& item : supported)
|
||||||
{
|
{
|
||||||
if (item.pixelFormat() != QVideoFrame::Format_YUYV &&
|
if (item.pixelFormat() != QVideoFrame::Format_YUYV &&
|
||||||
|
item.pixelFormat() != QVideoFrame::Format_UYVY &&
|
||||||
item.pixelFormat() != QVideoFrame::Format_NV12 &&
|
item.pixelFormat() != QVideoFrame::Format_NV12 &&
|
||||||
item.pixelFormat() != QVideoFrame::Format_RGB32)
|
item.pixelFormat() != QVideoFrame::Format_RGB32)
|
||||||
continue;
|
continue;
|
||||||
|
@ -417,6 +428,27 @@ void CameraManager::feedFrame(u32* frame, int width, int height, bool yuv)
|
||||||
frameMutex.unlock();
|
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)
|
void CameraManager::feedFrame_NV12(u8* planeY, u8* planeUV, int width, int height)
|
||||||
{
|
{
|
||||||
for (int y = 0; y < frameHeight; y++)
|
for (int y = 0; y < frameHeight; y++)
|
||||||
|
|
|
@ -92,6 +92,7 @@ public:
|
||||||
void captureFrame(u32* frame, int width, int height, bool yuv);
|
void captureFrame(u32* frame, int width, int height, bool yuv);
|
||||||
|
|
||||||
void feedFrame(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);
|
void feedFrame_NV12(u8* planeY, u8* planeUV, int width, int height);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
Loading…
Reference in New Issue