[host] nvfbc: optimize change detection loop

Before, we only break out of the current row when a change is detected,
and all subsequent rows are still scanned. Now we break out of the entire
loop. This should make change detection ever so slightly faster.
This commit is contained in:
Quantum 2021-07-10 19:07:43 -04:00 committed by Geoffrey McRae
parent fd8f8b2b28
commit 501b270890

View File

@ -165,7 +165,7 @@ static bool nvfbc_init(void)
privDataLen = (bufferLen - 1) / 2; privDataLen = (bufferLen - 1) / 2;
privData = (uint8_t *)malloc(privDataLen); privData = (uint8_t *)malloc(privDataLen);
char hex[3] = {0}; char hex[3] = {0};
for(int i = 0; i < privDataLen; ++i) for (int i = 0; i < privDataLen; ++i)
{ {
memcpy(hex, &buffer[i*2], 2); memcpy(hex, &buffer[i*2], 2);
privData[i] = (uint8_t)strtoul(hex, NULL, 16); privData[i] = (uint8_t)strtoul(hex, NULL, 16);
@ -300,14 +300,15 @@ static CaptureResult nvfbc_capture(void)
bool changed = false; bool changed = false;
const unsigned int h = (this->height + 127) / 128; const unsigned int h = (this->height + 127) / 128;
const unsigned int w = (this->width + 127) / 128; const unsigned int w = (this->width + 127) / 128;
for(unsigned int y = 0; y < h; ++y) for (unsigned int y = 0; y < h; ++y)
for(unsigned int x = 0; x < w; ++x) for (unsigned int x = 0; x < w; ++x)
if (this->diffMap[(y*w)+x]) if (this->diffMap[(y*w)+x])
{ {
changed = true; changed = true;
break; goto done;
} }
done:
if (!changed) if (!changed)
return CAPTURE_RESULT_TIMEOUT; return CAPTURE_RESULT_TIMEOUT;