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:
parent
53a8221aff
commit
f7dcb1712d
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user