Code review for OpenMP code path

This commit is contained in:
Chuck Walbourn
2019-12-13 22:26:18 -08:00
parent 3bf3c288f3
commit 5d5ebd7b7c
2 changed files with 17 additions and 7 deletions

View File

@@ -250,12 +250,12 @@ namespace
assert((y >= 0) && (y < int(image.height)));
size_t rowPitch = image.rowPitch;
const uint8_t *pSrc = image.pixels + (y*rowPitch) + (x*sbpp);
const uint8_t *pSrc = image.pixels + (size_t(y)*rowPitch) + (size_t(x)*sbpp);
uint8_t *pDest = result.pixels + (nb*blocksize);
uint8_t *pDest = result.pixels + (size_t(nb)*blocksize);
size_t ph = std::min<size_t>(4, image.height - y);
size_t pw = std::min<size_t>(4, image.width - x);
size_t ph = std::min<size_t>(4, image.height - size_t(y));
size_t pw = std::min<size_t>(4, image.width - size_t(x));
assert(pw > 0 && ph > 0);
ptrdiff_t bytesLeft = pEnd - pSrc;
@@ -268,19 +268,19 @@ namespace
if (ph > 1)
{
bytesToRead = std::min<size_t>(rowPitch, size_t(bytesLeft - rowPitch));
bytesToRead = std::min<size_t>(rowPitch, size_t(bytesLeft) - rowPitch);
if (!_LoadScanline(&temp[4], pw, pSrc + rowPitch, bytesToRead, format))
fail = true;
if (ph > 2)
{
bytesToRead = std::min<size_t>(rowPitch, size_t(bytesLeft - rowPitch * 2));
bytesToRead = std::min<size_t>(rowPitch, size_t(bytesLeft) - rowPitch * 2);
if (!_LoadScanline(&temp[8], pw, pSrc + rowPitch * 2, bytesToRead, format))
fail = true;
if (ph > 3)
{
bytesToRead = std::min<size_t>(rowPitch, size_t(bytesLeft - rowPitch * 3));
bytesToRead = std::min<size_t>(rowPitch, size_t(bytesLeft) - rowPitch * 3);
if (!_LoadScanline(&temp[12], pw, pSrc + rowPitch * 3, bytesToRead, format))
fail = true;
}