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

check and control reduceMemory and reduceTime in stream mode #1635

Merged
merged 1 commit into from
Feb 11, 2024
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
17 changes: 17 additions & 0 deletions src/lib/OpenEXRUtil/ImfCheckFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,11 @@ realloc_deepdata(exr_decode_pipeline_t* decode)
}

if (ud->size () < bytes)
{
ud->resize (bytes);
if (ud->capacity() < bytes)
return EXR_ERR_OUT_OF_MEMORY;
}

uint8_t* dptr = &((*ud)[0]);
for (int c = 0; c < decode->channel_count; c++)
Expand Down Expand Up @@ -1730,6 +1734,19 @@ runCoreChecks (
cinit.read_fn = &memstream_read;
cinit.size_fn = &memstream_size;
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, "<memstream>", &cinit);
if (rv != EXR_ERR_SUCCESS) return true;
Expand Down
Loading