Skip to content

Commit

Permalink
exrcheck: check for tilesize in reduceMemory mode (#920)
Browse files Browse the repository at this point in the history
* exrcheck: check for tilesize in reduceMemory mode

Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>

* exrcheck: don't treat non-tiled files as having large tiles

Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
  • Loading branch information
peterhillman committed Feb 15, 2021
1 parent 6fcc341 commit 50edd2a
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/lib/OpenEXRUtil/ImfCheckFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,14 +904,16 @@ runChecks(T& source,bool reduceMemory,bool reduceTime)


//
// scanline images with very wide parts take excessive memory to read
// assume the first part is wide until the header of the first part is checked
// so the single part scanline input APIs can be skipped.
// scanline images with very wide parts and tiled images with large tiles
// take excessive memory to read.
// Assume the first part requires excessive memory until the header of the first part is checked
// so the single part input APIs can be skipped.
//
// If the MultiPartInputFile constructor throws an exception, the first part
// will assumed to be a wide image
//
bool firstPartWide = true;
bool largeTiles = true;

bool threw = false;
{
Expand All @@ -936,10 +938,24 @@ runChecks(T& source,bool reduceMemory,bool reduceTime)
firstPartType = multi.header(0).type();
if (isTiled(firstPartType))
{
if ( multi.header(0).tileDescription().ySize * (b.max.x-b.min.x+1) > gMaxTilePixelsPerScanline )
const TileDescription& tileDescription = multi.header(0).tileDescription();
if ( tileDescription.ySize * (b.max.x-b.min.x+1) > gMaxTilePixelsPerScanline )
{
firstPartWide = true;
}

if( tileDescription.ySize * tileDescription.xSize <= gMaxTileSize)
{
largeTiles = false;
}

}
else
{
// file is not tiled, so can't contain large tiles
// setting largeTiles false here causes the Tile and DeepTile API
// tests to run on non-tiled files, which should cause exceptions to be thrown
largeTiles = false;
}


Expand Down Expand Up @@ -991,6 +1007,7 @@ runChecks(T& source,bool reduceMemory,bool reduceTime)
}
}

if( !reduceMemory || !largeTiles )
{
bool gotThrow = false;
resetInput(source);
Expand Down Expand Up @@ -1028,6 +1045,7 @@ runChecks(T& source,bool reduceMemory,bool reduceTime)
}
}

if( !reduceMemory || !largeTiles )
{
bool gotThrow = false;
resetInput(source);
Expand Down

0 comments on commit 50edd2a

Please sign in to comment.