Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adjust checks for core to better match c++ checks #1632

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions src/lib/OpenEXRUtil/ImfCheckFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ realloc_deepdata(exr_decode_pipeline_t* decode)
bytes += totsamps * outc.user_bytes_per_element;
}

if (bytes >= gMaxBytesPerDeepScanline * h)
if (bytes >= gMaxBytesPerDeepScanline)
{
for (int c = 0; c < decode->channel_count; c++)
{
Expand Down Expand Up @@ -1332,6 +1332,8 @@ readCoreScanlinePart (
}

doread = true;
if (reduceMemory && bytes >= gMaxBytesPerScanline)
doread = false;

if (cinfo.type == EXR_STORAGE_DEEP_SCANLINE)
{
Expand All @@ -1340,8 +1342,6 @@ readCoreScanlinePart (
}
else
{
if (reduceMemory && bytes >= gMaxBytesPerScanline) doread = false;

if (doread) imgdata.resize (bytes);
}
rv = exr_decoding_choose_default_routines (f, part, &decoder);
Expand Down Expand Up @@ -1507,16 +1507,16 @@ readCoreTiledPart (
}

doread = true;
if (reduceMemory && bytes >= gMaxTileBytes)
doread = false;

if (cinfo.type == EXR_STORAGE_DEEP_TILED)
{
decoder.decoding_user_data = &tiledata;
decoder.realloc_nonimage_data_fn = &realloc_deepdata;
}
else
{
if (reduceMemory && bytes >= gMaxTileBytes)
doread = false;

if (doread) tiledata.resize (bytes);
}
rv = exr_decoding_choose_default_routines (
Expand Down Expand Up @@ -1647,6 +1647,20 @@ runCoreChecks (const char* filename, bool reduceMemory, bool reduceTime)

cinit.error_handler_fn = &core_error_handler_cb;

if (reduceMemory || reduceTime)
{
/* could use set_default functions for this, but those just
* initialize the context, doing it in the initializer is mt
* safe...
* exr_set_default_maximum_image_size (2048, 2048);
* exr_set_default_maximum_tile_size (512, 512);
*/
cinit.max_image_width = 2048;
cinit.max_image_height = 2048;
cinit.max_tile_width = 512;
cinit.max_tile_height = 512;
}

rv = exr_start_read (&f, filename, &cinit);
if (rv != EXR_ERR_SUCCESS) return true;

Expand Down
Loading