From f7dcb1712d24a8c35cbf8501234596555b8cbb7f Mon Sep 17 00:00:00 2001 From: "Tux3 / Mlkj / !Lev.uXFMLA" Date: Tue, 1 Jul 2014 20:56:27 +0200 Subject: [PATCH] Improve video reception quality --- widget/camera.cpp | 6 +++++- widget/netcamview.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/widget/camera.cpp b/widget/camera.cpp index 7018e70d3..fa75803b9 100644 --- a/widget/camera.cpp +++ b/widget/camera.cpp @@ -132,7 +132,11 @@ bool Camera::isFormatSupported(const QVideoSurfaceFormat& format) const QImage Camera::getLastImage() { - lastFrame.map(QAbstractVideoBuffer::ReadOnly); + if (!lastFrame.map(QAbstractVideoBuffer::ReadOnly)) + { + qWarning() << "Camera::getLastImage: Error maping last frame"; + return QImage(); + } int w = lastFrame.width(), h = lastFrame.height(); int bpl = lastFrame.bytesPerLine(), cxbpl = bpl/2; QImage img(w, h, QImage::Format_RGB32); diff --git a/widget/netcamview.cpp b/widget/netcamview.cpp index fb0537bf1..a57787713 100644 --- a/widget/netcamview.cpp +++ b/widget/netcamview.cpp @@ -20,16 +20,16 @@ void NetCamView::updateDisplay(vpx_image frame) QImage img(w, h, QImage::Format_RGB32); uint8_t* yData = frame.planes[VPX_PLANE_Y]; - uint8_t* uData = frame.planes[VPX_PLANE_V]; - uint8_t* vData = frame.planes[VPX_PLANE_U]; + uint8_t* uData = frame.planes[VPX_PLANE_U]; + uint8_t* vData = frame.planes[VPX_PLANE_V]; for (int i = 0; i< h; i++) { uint32_t* scanline = (uint32_t*)img.scanLine(i); for (int j=0; j < w; j++) { float Y = yData[i*bpl + j]; - float U = uData[i*cxbpl/2 + j/2]; - float V = vData[i*cxbpl/2 + j/2]; + float U = uData[i/2*cxbpl + j/2]; + float V = vData[i/2*cxbpl + j/2]; uint8_t R = qMax(qMin((int)(Y + 1.402 * (V - 128)),255),0); uint8_t G = qMax(qMin((int)(Y - 0.344 * (U - 128) - 0.714 * (V - 128)),255),0);