From 51bc7631ab773908448fb4f4428e9f9a023cebad Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Wed, 6 Dec 2017 00:14:45 +1100 Subject: [PATCH] [host] fixed incorrect checking of difference map --- host/Capture/NvFBC.cpp | 16 ++++++++++------ host/Capture/NvFBC.h | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/host/Capture/NvFBC.cpp b/host/Capture/NvFBC.cpp index bd532bb2..00139960 100644 --- a/host/Capture/NvFBC.cpp +++ b/host/Capture/NvFBC.cpp @@ -140,6 +140,7 @@ bool NvFBC::Initialize(CaptureOptions * options) setupParams.eMode = NVFBC_TOSYS_ARGB; setupParams.bWithHWCursor = TRUE; setupParams.bDiffMap = TRUE; + setupParams.eDiffMapBlockSize = (NvU32)NVFBC_TOSYS_DIFFMAP_BLOCKSIZE_128X128; setupParams.ppBuffer = (void **)&m_frameBuffer; setupParams.ppDiffMap = (void **)&m_diffMap; @@ -226,13 +227,16 @@ bool NvFBC::GrabFrame(struct FrameInfo & frame) if (status == NVFBC_SUCCESS) { + const int diffW = (m_grabInfo.dwWidth + 0x7F) >> 7; + const int diffH = (m_grabInfo.dwHeight + 0x7F) >> 7; bool hasDiff = false; - for (int r = (m_grabInfo.dwWidth * m_grabInfo.dwHeight) / (128 * 128); r >= 0; --r) - if (*((uint8_t*)m_diffMap + r)) - { - hasDiff = true; - break; - } + for(int y = 0; y < diffH && !hasDiff; ++y) + for (int x = 0; x < diffW; ++x) + if (m_diffMap[y * diffW + x]) + { + hasDiff = true; + break; + } if (!hasDiff) { diff --git a/host/Capture/NvFBC.h b/host/Capture/NvFBC.h index 96815742..30991534 100644 --- a/host/Capture/NvFBC.h +++ b/host/Capture/NvFBC.h @@ -57,8 +57,8 @@ namespace Capture DWORD m_maxCaptureWidth, m_maxCaptureHeight; NvFBCToSys * m_nvFBC; - void * m_frameBuffer; - void * m_diffMap; + uint8_t * m_frameBuffer; + uint8_t * m_diffMap; NvFBCFrameGrabInfo m_grabInfo; NVFBC_TOSYS_GRAB_FRAME_PARAMS m_grabFrameParams; };