1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Improve video reception quality

This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-07-01 20:56:27 +02:00
parent 53a8221aff
commit f7dcb1712d
2 changed files with 9 additions and 5 deletions

View File

@ -132,7 +132,11 @@ bool Camera::isFormatSupported(const QVideoSurfaceFormat& format) const
QImage Camera::getLastImage() 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 w = lastFrame.width(), h = lastFrame.height();
int bpl = lastFrame.bytesPerLine(), cxbpl = bpl/2; int bpl = lastFrame.bytesPerLine(), cxbpl = bpl/2;
QImage img(w, h, QImage::Format_RGB32); QImage img(w, h, QImage::Format_RGB32);

View File

@ -20,16 +20,16 @@ void NetCamView::updateDisplay(vpx_image frame)
QImage img(w, h, QImage::Format_RGB32); QImage img(w, h, QImage::Format_RGB32);
uint8_t* yData = frame.planes[VPX_PLANE_Y]; uint8_t* yData = frame.planes[VPX_PLANE_Y];
uint8_t* uData = frame.planes[VPX_PLANE_V]; uint8_t* uData = frame.planes[VPX_PLANE_U];
uint8_t* vData = frame.planes[VPX_PLANE_U]; uint8_t* vData = frame.planes[VPX_PLANE_V];
for (int i = 0; i< h; i++) for (int i = 0; i< h; i++)
{ {
uint32_t* scanline = (uint32_t*)img.scanLine(i); uint32_t* scanline = (uint32_t*)img.scanLine(i);
for (int j=0; j < w; j++) for (int j=0; j < w; j++)
{ {
float Y = yData[i*bpl + j]; float Y = yData[i*bpl + j];
float U = uData[i*cxbpl/2 + j/2]; float U = uData[i/2*cxbpl + j/2];
float V = vData[i*cxbpl/2 + 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 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); uint8_t G = qMax(qMin((int)(Y - 0.344 * (U - 128) - 0.714 * (V - 128)),255),0);