Skip to content

Commit

Permalink
Use 64-bit values for the pointer math
Browse files Browse the repository at this point in the history
Other reader classes already use 64-bit numbers for pointer math, fix
this case to use the same

Signed-off-by: Kimball Thurston <kdt3rd@gmail.com>
  • Loading branch information
kdt3rd committed Sep 27, 2024
1 parent 3ebc6ed commit 35e0993
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/lib/OpenEXR/ImfInputFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,16 +579,16 @@ InputFile::Data::copyCachedBuffer (FrameBuffer::ConstIterator to,
const char* fromPtr = fromSlice.base;

if (toSlice.yTileCoords)
toPtr += (y - yStart) * toSlice.yStride;
toPtr += ( int64_t (y) - int64_t (yStart) ) * toSlice.yStride;
else
toPtr += y * toSlice.yStride;
toPtr += int64_t (y) * toSlice.yStride;
if (!toSlice.xTileCoords)
toPtr += xStart * toSlice.xStride;
toPtr += int64_t (xStart) * toSlice.xStride;

fromPtr += (y - yStart) * fromSlice.yStride;
fromPtr += ( int64_t (y) - int64_t (yStart) ) * fromSlice.yStride;
if (fromSlice.xStride == 2)
{
fromPtr += xStart * 2;
fromPtr += int64_t (xStart) * 2;
for (int x = 0; x < width; ++x)
{
*reinterpret_cast<uint16_t*> (toPtr) =
Expand All @@ -599,7 +599,7 @@ InputFile::Data::copyCachedBuffer (FrameBuffer::ConstIterator to,
}
else
{
fromPtr += xStart * 4;
fromPtr += int64_t (xStart) * 4;
for (int x = 0; x < width; ++x)
{
*reinterpret_cast<uint32_t*> (toPtr) =
Expand Down Expand Up @@ -627,11 +627,11 @@ InputFile::Data::fillBuffer (FrameBuffer::ConstIterator to,
char* toPtr = toSlice.base;

if (toSlice.yTileCoords)
toPtr += (y - yStart) * toSlice.yStride;
toPtr += ( int64_t (y) - int64_t (yStart) ) * toSlice.yStride;
else
toPtr += y * toSlice.yStride;
toPtr += int64_t (y) * toSlice.yStride;
if (!toSlice.xTileCoords)
toPtr += xStart * toSlice.xStride;
toPtr += int64_t (xStart) * toSlice.xStride;

//
// Copy all pixels for the scanline in this row of tiles
Expand Down

0 comments on commit 35e0993

Please sign in to comment.