mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-25 23:07:18 +00:00
[host] Use ARGB instead of RGB for performance
This is counter intuative as it consumes more RAM, but performance is improved on the client as video hardware doesn't work in RGB but BGRA.
This commit is contained in:
parent
ad9b78a7cc
commit
3a64f9b96c
@ -20,7 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
|||||||
using namespace Capture;
|
using namespace Capture;
|
||||||
|
|
||||||
#include "common\debug.h"
|
#include "common\debug.h"
|
||||||
#include "Util.h"
|
#include "common\memcpySSE.h"
|
||||||
|
|
||||||
DXGI::DXGI() :
|
DXGI::DXGI() :
|
||||||
m_options(NULL),
|
m_options(NULL),
|
||||||
@ -219,7 +219,7 @@ FrameType DXGI::GetFrameType()
|
|||||||
if (!m_initialized)
|
if (!m_initialized)
|
||||||
return FRAME_TYPE_INVALID;
|
return FRAME_TYPE_INVALID;
|
||||||
|
|
||||||
return FRAME_TYPE_RGB;
|
return FRAME_TYPE_ARGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
FrameComp DXGI::GetFrameCompression()
|
FrameComp DXGI::GetFrameCompression()
|
||||||
@ -235,7 +235,7 @@ size_t DXGI::GetMaxFrameSize()
|
|||||||
if (!m_initialized)
|
if (!m_initialized)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return (m_width * m_height * 3) + 4;
|
return (m_width * m_height * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DXGI::GrabFrame(FrameInfo & frame)
|
bool DXGI::GrabFrame(FrameInfo & frame)
|
||||||
@ -347,7 +347,7 @@ bool DXGI::GrabFrame(FrameInfo & frame)
|
|||||||
|
|
||||||
m_width = desc.Width;
|
m_width = desc.Width;
|
||||||
m_height = desc.Height;
|
m_height = desc.Height;
|
||||||
const int pitch = m_width * 3;
|
const int pitch = m_width * 4;
|
||||||
|
|
||||||
frame.width = desc.Width;
|
frame.width = desc.Width;
|
||||||
frame.height = desc.Height;
|
frame.height = desc.Height;
|
||||||
@ -418,7 +418,7 @@ bool DXGI::GrabFrame(FrameInfo & frame)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Util::BGRAtoRGB(rect.pBits, m_height * m_width, (uint8_t *)frame.buffer);
|
memcpySSE(frame.buffer, rect.pBits, frame.outSize);
|
||||||
status = surface->Unmap();
|
status = surface->Unmap();
|
||||||
|
|
||||||
if (FAILED(status))
|
if (FAILED(status))
|
||||||
|
@ -135,7 +135,7 @@ bool NvFBC::Initialize(CaptureOptions * options)
|
|||||||
NVFBC_TOSYS_SETUP_PARAMS setupParams;
|
NVFBC_TOSYS_SETUP_PARAMS setupParams;
|
||||||
ZeroMemory(&setupParams, sizeof(NVFBC_TOSYS_SETUP_PARAMS));
|
ZeroMemory(&setupParams, sizeof(NVFBC_TOSYS_SETUP_PARAMS));
|
||||||
setupParams.dwVersion = NVFBC_TOSYS_SETUP_PARAMS_VER;
|
setupParams.dwVersion = NVFBC_TOSYS_SETUP_PARAMS_VER;
|
||||||
setupParams.eMode = NVFBC_TOSYS_RGB;
|
setupParams.eMode = NVFBC_TOSYS_ARGB;
|
||||||
setupParams.bWithHWCursor = TRUE;
|
setupParams.bWithHWCursor = TRUE;
|
||||||
setupParams.bDiffMap = FALSE;
|
setupParams.bDiffMap = FALSE;
|
||||||
setupParams.ppBuffer = (void **)&m_frameBuffer;
|
setupParams.ppBuffer = (void **)&m_frameBuffer;
|
||||||
@ -198,7 +198,7 @@ FrameType NvFBC::GetFrameType()
|
|||||||
if (!m_initialized)
|
if (!m_initialized)
|
||||||
return FRAME_TYPE_INVALID;
|
return FRAME_TYPE_INVALID;
|
||||||
|
|
||||||
return FRAME_TYPE_RGB;
|
return FRAME_TYPE_ARGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
FrameComp NvFBC::GetFrameCompression()
|
FrameComp NvFBC::GetFrameCompression()
|
||||||
@ -214,7 +214,7 @@ size_t NvFBC::GetMaxFrameSize()
|
|||||||
if (!m_initialized)
|
if (!m_initialized)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return m_maxCaptureWidth * m_maxCaptureHeight * 3;
|
return m_maxCaptureWidth * m_maxCaptureHeight * 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NvFBC::GrabFrame(struct FrameInfo & frame)
|
bool NvFBC::GrabFrame(struct FrameInfo & frame)
|
||||||
@ -246,21 +246,21 @@ bool NvFBC::GrabFrame(struct FrameInfo & frame)
|
|||||||
{
|
{
|
||||||
const unsigned int realHeight = min(m_grabInfo.dwHeight, (unsigned int)(desktop.bottom - desktop.top));
|
const unsigned int realHeight = min(m_grabInfo.dwHeight, (unsigned int)(desktop.bottom - desktop.top));
|
||||||
const unsigned int realWidth = min(m_grabInfo.dwWidth , (unsigned int)(desktop.right - desktop.left));
|
const unsigned int realWidth = min(m_grabInfo.dwWidth , (unsigned int)(desktop.right - desktop.left));
|
||||||
dataWidth = realWidth * 3;
|
dataWidth = realWidth * 4;
|
||||||
dataOffset =
|
dataOffset =
|
||||||
(((m_grabInfo.dwHeight - realHeight) >> 1) * m_grabInfo.dwBufferWidth +
|
(((m_grabInfo.dwHeight - realHeight) >> 1) * m_grabInfo.dwBufferWidth +
|
||||||
((m_grabInfo.dwWidth - realWidth ) >> 1)) * 3;
|
((m_grabInfo.dwWidth - realWidth ) >> 1)) * 4;
|
||||||
|
|
||||||
frame.width = realWidth;
|
frame.width = realWidth;
|
||||||
frame.height = realHeight;
|
frame.height = realHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
frame.stride = frame.width;
|
frame.stride = frame.width;
|
||||||
frame.outSize = frame.width * frame.height * 3;
|
frame.outSize = frame.width * frame.height * 4;
|
||||||
|
|
||||||
uint8_t *src = (uint8_t *)m_frameBuffer + dataOffset;
|
uint8_t *src = (uint8_t *)m_frameBuffer + dataOffset;
|
||||||
uint8_t *dst = (uint8_t *)frame.buffer;
|
uint8_t *dst = (uint8_t *)frame.buffer;
|
||||||
for(unsigned int y = 0; y < frame.height; ++y, dst += dataWidth, src += m_grabInfo.dwBufferWidth * 3)
|
for(unsigned int y = 0; y < frame.height; ++y, dst += dataWidth, src += m_grabInfo.dwBufferWidth * 4)
|
||||||
memcpySSE(dst, src, dataWidth);
|
memcpySSE(dst, src, dataWidth);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user