Skip to content

Commit

Permalink
exrcheck: assume lots of memory required whenever MultiPart ctor thro…
Browse files Browse the repository at this point in the history
…ws (#915)

Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
  • Loading branch information
peterhillman committed Feb 6, 2021
1 parent 1b59bd3 commit 5b4337f
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/lib/OpenEXRUtil/ImfCheckFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,30 +901,39 @@ runChecks(T& source,bool reduceMemory,bool reduceTime)
//

string firstPartType;
bool firstPartWide = false;


//
// 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.
//
// If the MultiPartInputFile constructor throws an exception, the first part
// will assumed to be a wide image
//
bool firstPartWide = true;

bool threw = false;
{
try
{
MultiPartInputFile multi(source);
firstPartType = multi.header(0).type();
Box2i b = multi.header(0).dataWindow();

//
// scanline images with very wide parts take excessive memory to read
// detect that here so that tests can be skipped when reduceMemory is set
//
if (b.max.x - b.min.x > gMaxScanlineWidth )
// confirm first part is small enough to read without using excessive memory
if (b.max.x - b.min.x <= gMaxScanlineWidth )
{
firstPartWide = true;
firstPartWide = false;
}


//
// significant memory is also required to read a tiled file
// using the scanline interface with tall tiles - the scanlineAPI
// needs to allocate memory to store an entire row of tiles
//

firstPartType = multi.header(0).type();
if (isTiled(firstPartType))
{
if ( multi.header(0).tileDescription().ySize * (b.max.x-b.min.x+1) > gMaxTilePixelsPerScanline )
Expand Down

0 comments on commit 5b4337f

Please sign in to comment.