From 017f056239e817cbe2ab601efe99dc9f4c9e7f52 Mon Sep 17 00:00:00 2001 From: Kimball Thurston Date: Mon, 12 Jul 2021 08:56:27 +1200 Subject: [PATCH] Simplify names, improve error messages, fix imath usage in Core (#1086) This is a consistency pass over the names to refer to all pixel data blocks as chunk, as is outlined in the master OpenEXR file layout documentation around version 2.0. Additionally cleans up up some prints, splits an overloaded error enum into three. Signed-off-by: Kimball Thurston --- src/lib/OpenEXRCore/base.c | 22 +- src/lib/OpenEXRCore/chunk.c | 244 ++++++++++++---------- src/lib/OpenEXRCore/coding.c | 4 +- src/lib/OpenEXRCore/decoding.c | 86 ++++---- src/lib/OpenEXRCore/encoding.c | 42 ++-- src/lib/OpenEXRCore/internal_b44.c | 8 +- src/lib/OpenEXRCore/internal_coding.h | 18 +- src/lib/OpenEXRCore/internal_huf.c | 28 +-- src/lib/OpenEXRCore/internal_piz.c | 20 +- src/lib/OpenEXRCore/internal_pxr24.c | 18 +- src/lib/OpenEXRCore/internal_rle.c | 10 +- src/lib/OpenEXRCore/internal_zip.c | 6 +- src/lib/OpenEXRCore/openexr_chunkio.h | 73 +++---- src/lib/OpenEXRCore/openexr_decode.h | 29 +-- src/lib/OpenEXRCore/openexr_encode.h | 45 ++-- src/lib/OpenEXRCore/openexr_errors.h | 8 +- src/lib/OpenEXRCore/openexr_part.h | 4 + src/lib/OpenEXRCore/pack.c | 4 +- src/lib/OpenEXRCore/part.c | 33 ++- src/lib/OpenEXRCore/unpack.c | 44 ++-- src/test/OpenEXRCoreTest/base_units.cpp | 8 +- src/test/OpenEXRCoreTest/compression.cpp | 60 +++--- src/test/OpenEXRCoreTest/deep.cpp | 8 +- src/test/OpenEXRCoreTest/general_attr.cpp | 10 +- src/test/OpenEXRCoreTest/performance.cpp | 12 +- src/test/OpenEXRCoreTest/read.cpp | 44 ++-- src/test/OpenEXRCoreTest/write.cpp | 20 +- 27 files changed, 476 insertions(+), 432 deletions(-) diff --git a/src/lib/OpenEXRCore/base.c b/src/lib/OpenEXRCore/base.c index 116a7cd0b8..52e723d0f3 100644 --- a/src/lib/OpenEXRCore/base.c +++ b/src/lib/OpenEXRCore/base.c @@ -41,19 +41,21 @@ static const char * the_error_code_names[] = "EXR_ERR_MISSING_REQ_ATTR", "EXR_ERR_INVALID_ATTR", "EXR_ERR_NO_ATTR_BY_NAME", - "EXR_ERR_BAD_CHUNK_DATA", "EXR_ERR_ATTR_TYPE_MISMATCH", "EXR_ERR_ATTR_SIZE_MISMATCH", "EXR_ERR_SCAN_TILE_MIXEDAPI", "EXR_ERR_TILE_SCAN_MIXEDAPI", "EXR_ERR_MODIFY_SIZE_CHANGE", "EXR_ERR_ALREADY_WROTE_ATTRS", - "EXR_ERR_PART_NOT_READY", - "EXR_ERR_CHUNK_NOT_READY", + "EXR_ERR_BAD_CHUNK_LEADER", + "EXR_ERR_CORRUPT_CHUNK", + "EXR_ERR_INCORRECT_PART", + "EXR_ERR_INCORRECT_CHUNK", "EXR_ERR_USE_SCAN_DEEP_WRITE", "EXR_ERR_USE_TILE_DEEP_WRITE", "EXR_ERR_USE_SCAN_NONDEEP_WRITE", "EXR_ERR_USE_TILE_NONDEEP_WRITE", + "EXR_ERR_INVALID_SAMPLE_DATA", "EXR_ERR_FEATURE_NOT_IMPLEMENTED", "EXR_ERR_UNKNOWN" }; @@ -79,19 +81,21 @@ static const char* the_default_errors[] = { "Missing required attribute in part header", "Invalid attribute in part header", "No attribute by that name in part header", - "Mismatch in chunk data vs computed value", "Attribute type mismatch", "Attribute type vs. size mismatch", "Attempt to use a scanline accessor function for a tiled image", "Attempt to use a tiled accessor function for a scanline image", "Attempt to modify a value when in update mode with different size", "File in write mode, but header already written, can no longer edit attributes", + "Unexpected or corrupt values in data block leader vs computed value", + "Corrupt data block data, unable to decode", "Previous part not yet finished writing", - "Not able to write chunk yet", - "Use deep scanline chunk writer with the sample count table arguments", - "Use deep tile chunk writer with the sample count table arguments", - "Use non-deep scanline chunk writer with the sample count table arguments", - "Use non-deep tile chunk writer with the sample count table arguments", + "Invalid data block to write at this point", + "Use deep scanline write with the sample count table arguments", + "Use deep tile write with the sample count table arguments", + "Use non-deep scanline write (sample count table invalid for this part type)", + "Use non-deep tile write (sample count table invalid for this part type)", + "Invalid sample data table value", "Feature not yet implemented, please use C++ library", "Unknown error code" }; diff --git a/src/lib/OpenEXRCore/chunk.c b/src/lib/OpenEXRCore/chunk.c index 301f6fa81f..3fce503a88 100644 --- a/src/lib/OpenEXRCore/chunk.c +++ b/src/lib/OpenEXRCore/chunk.c @@ -144,11 +144,8 @@ alloc_chunk_table ( /**************************************/ exr_result_t -exr_read_scanline_block_info ( - exr_const_context_t ctxt, - int part_index, - int y, - exr_chunk_block_info_t* cinfo) +exr_read_scanline_chunk_info ( + exr_const_context_t ctxt, int part_index, int y, exr_chunk_info_t* cinfo) { exr_result_t rv; int miny, cidx, rdcnt, lpc; @@ -180,7 +177,7 @@ exr_read_scanline_block_info ( dw.max.y); } - lpc = part->lines_per_chunk; + lpc = part->lines_per_chunk; cidx = (y - dw.min.y); if (lpc > 1) cidx /= lpc; @@ -248,9 +245,10 @@ exr_read_scanline_block_info ( { return pctxt->print_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Request for scanline %d found mismatch part %d vs %d in file", + EXR_ERR_BAD_CHUNK_LEADER, + "Preparing read scanline %d (chunk %d), found corrupt leader: part says %d, expected %d", y, + cidx, data[rdcnt], part_index); } @@ -260,12 +258,12 @@ exr_read_scanline_block_info ( { return pctxt->print_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Request for scanline %d found scanline %d, not %d at chunk %d", + EXR_ERR_BAD_CHUNK_LEADER, + "Preparing to read scanline %d (chunk %d), found corrupt leader: scanline says %d, expected %d", y, + cidx, data[rdcnt], - miny, - cidx); + miny); } fsize = pctxt->file_size; @@ -285,29 +283,30 @@ exr_read_scanline_block_info ( { return pctxt->print_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Request for deep scanline %d invalid sample table size %" PRId64, + EXR_ERR_BAD_CHUNK_LEADER, + "Preparing to read scanline %d (chunk %d), found corrupt leader: invalid sample table size %" PRId64, y, + cidx, ddata[0]); } if (ddata[1] < 0 || ddata[1] > (int64_t) INT_MAX) { return pctxt->print_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Request for deep scanline %d large packed size %" PRId64 - " not supported", + EXR_ERR_BAD_CHUNK_LEADER, + "Preparing to read scanline %d (chunk %d), found corrupt leader: invalid packed data size %" PRId64, y, + cidx, ddata[1]); } if (ddata[2] < 0 || ddata[2] > (int64_t) INT_MAX) { return pctxt->print_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Request for deep scanline %d large unpacked size %" PRId64 - " not supported", + EXR_ERR_BAD_CHUNK_LEADER, + "Preparing to scanline %d (chunk %d), found corrupt leader: unsupported unpacked data size %" PRId64, y, + cidx, ddata[2]); } @@ -324,11 +323,11 @@ exr_read_scanline_block_info ( { return pctxt->print_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Request for deep scanline %d sample table (%" PRId64 - ") and/or data (%" PRId64 - ") size larger than file size %" PRId64, + EXR_ERR_BAD_CHUNK_LEADER, + "Preparing to scanline %d (chunk %d), found corrupt leader: sample table and data result in access past end of the file: sample table size %" PRId64 + " + data size %" PRId64 " larger than file %" PRId64, y, + cidx, ddata[0], ddata[1], fsize); @@ -365,10 +364,13 @@ exr_read_scanline_block_info ( { return pctxt->print_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Request for scanline %d found invalid packed data block size %d", + EXR_ERR_BAD_CHUNK_LEADER, + "Preparing to read scanline %d (chunk %d), found corrupt leader: packed data size says %" PRIu64 + ", must be between 0 and %" PRIu64, y, - data[rdcnt]); + cidx, + (uint64_t) data[rdcnt], + part->unpacked_size_per_chunk); } cinfo->data_offset = dataoff; @@ -382,11 +384,12 @@ exr_read_scanline_block_info ( { return pctxt->print_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Request for scanline %d data (%" PRIu64 - ") size larger than file size %" PRId64, + EXR_ERR_BAD_CHUNK_LEADER, + "Preparing to read scanline %d (chunk %d), found corrupt leader: packed size %" PRIu64 + ", file size %" PRId64, y, - cinfo->packed_size, + cidx, + (uint64_t) data[rdcnt], fsize); } } @@ -542,14 +545,14 @@ compute_tile_chunk_off ( /**************************************/ exr_result_t -exr_read_tile_block_info ( - exr_const_context_t ctxt, - int part_index, - int tilex, - int tiley, - int levelx, - int levely, - exr_chunk_block_info_t* cinfo) +exr_read_tile_chunk_info ( + exr_const_context_t ctxt, + int part_index, + int tilex, + int tiley, + int levelx, + int levely, + exr_chunk_info_t* cinfo) { exr_result_t rv; int32_t data[6]; @@ -578,9 +581,7 @@ exr_read_tile_block_info ( !part->tile_level_tile_count_y) { return pctxt->print_error ( - pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Request for tile, but no tile data exists"); + pctxt, EXR_ERR_MISSING_REQ_ATTR, "Tile data missing or corrupt"); } tiledesc = part->tiles->tiledesc; @@ -661,7 +662,7 @@ exr_read_tile_block_info ( { return pctxt->print_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, + rv, "Request for tile (%d, %d), level (%d, %d) but unable to read %" PRId64 " bytes from offset %" PRId64 ", got %" PRId64 " bytes", tilex, @@ -681,8 +682,13 @@ exr_read_tile_block_info ( { return pctxt->print_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Request for multi-part tile found bad part index (%d), expect %d", + EXR_ERR_BAD_CHUNK_LEADER, + "Preparing to read tile (%d, %d), level (%d, %d) (chunk %d), found corrupt leader: part says %d, expected %d", + tilex, + tiley, + levelx, + levely, + cidx, data[0], part_index); } @@ -692,8 +698,13 @@ exr_read_tile_block_info ( { return pctxt->print_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Request for tile found tile x coord mismatch: found %d, expect %d", + EXR_ERR_BAD_CHUNK_LEADER, + "Preparing to read tile (%d, %d), level (%d, %d) (chunk %d), found corrupt leader: found tile x %d, expect %d", + tilex, + tiley, + levelx, + levely, + cidx, tdata[0], tilex); } @@ -701,8 +712,13 @@ exr_read_tile_block_info ( { return pctxt->print_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Request for tile found tile y coord mismatch: found %d, expect %d", + EXR_ERR_BAD_CHUNK_LEADER, + "Preparing to read tile (%d, %d), level (%d, %d) (chunk %d), found corrupt leader: found tile y %d, expect %d", + tilex, + tiley, + levelx, + levely, + cidx, tdata[1], tiley); } @@ -710,8 +726,13 @@ exr_read_tile_block_info ( { return pctxt->print_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Request for tile found tile level x mismatch: found %d, expect %d", + EXR_ERR_BAD_CHUNK_LEADER, + "Preparing to read tile (%d, %d), level (%d, %d) (chunk %d), found corrupt leader: found tile level x %d, expect %d", + tilex, + tiley, + levelx, + levely, + cidx, tdata[2], levelx); } @@ -719,8 +740,13 @@ exr_read_tile_block_info ( { return pctxt->print_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Request for tile found tile level y mismatch: found %d, expect %d", + EXR_ERR_BAD_CHUNK_LEADER, + "Preparing to read tile (%d, %d), level (%d, %d) (chunk %d), found corrupt leader: found tile level y %d, expect %d", + tilex, + tiley, + levelx, + levely, + cidx, tdata[3], levely); } @@ -743,12 +769,13 @@ exr_read_tile_block_info ( { return pctxt->print_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Request for deep tile (%d, %d), level (%d, %d) invalid sample table size %" PRId64, + EXR_ERR_BAD_CHUNK_LEADER, + "Preparing to read deep tile (%d, %d), level (%d, %d) (chunk %d), found corrupt leader: invalid sample table size %" PRId64, tilex, tiley, levelx, levely, + cidx, ddata[0]); } @@ -757,24 +784,26 @@ exr_read_tile_block_info ( { return pctxt->print_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Request for deep tile (%d, %d), level (%d, %d) invalid packed size %" PRId64, + EXR_ERR_BAD_CHUNK_LEADER, + "Preparing to read deep tile (%d, %d), level (%d, %d) (chunk %d), found corrupt leader: invalid packed data size %" PRId64, tilex, tiley, levelx, levely, + cidx, ddata[1]); } if (ddata[2] < 0 || ddata[2] > (int64_t) INT32_MAX) { return pctxt->print_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Request for deep tile (%d, %d), level (%d, %d) invalid unpacked size %" PRId64, + EXR_ERR_BAD_CHUNK_LEADER, + "Preparing to read deep tile (%d, %d), level (%d, %d) (chunk %d), found corrupt leader: invalid packed data size %" PRId64, tilex, tiley, levelx, levely, + cidx, ddata[1]); } cinfo->sample_count_data_offset = dataoff; @@ -790,14 +819,14 @@ exr_read_tile_block_info ( { return pctxt->print_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Request for deep tile (%d, %d), level (%d, %d) table (%" PRId64 - ") and/or data (%" PRId64 - ") size larger than file size %" PRId64, + EXR_ERR_BAD_CHUNK_LEADER, + "Preparing to read deep tile (%d, %d), level (%d, %d) (chunk %d), found corrupt leader: sample table and data result in access past end of the file: sample table size %" PRId64 + " + data size %" PRId64 " larger than file %" PRId64, tilex, tiley, levelx, levely, + cidx, ddata[0], ddata[1], fsize); @@ -810,14 +839,15 @@ exr_read_tile_block_info ( { return pctxt->print_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Invalid data size found for tile (%d, %d) at level (%d, %d): %d unpack size %d file size %" PRId64, + EXR_ERR_BAD_CHUNK_LEADER, + "Preparing to read deep tile (%d, %d), level (%d, %d) (chunk %d), found corrupt leader: invalid packed size (%d) vs unpacked size (%d), and file size %" PRId64, tilex, tiley, levelx, levely, - tdata[4], - unpacksize, + cidx, + (int)tdata[4], + (int)unpacksize, fsize); } cinfo->packed_size = (uint64_t) tdata[4]; @@ -831,10 +861,10 @@ exr_read_tile_block_info ( exr_result_t exr_read_chunk ( - exr_const_context_t ctxt, - int part_index, - const exr_chunk_block_info_t* cinfo, - void* packed_data) + exr_const_context_t ctxt, + int part_index, + const exr_chunk_info_t* cinfo, + void* packed_data) { exr_result_t rv; uint64_t dataoffset, toread; @@ -900,11 +930,11 @@ exr_read_chunk ( exr_result_t exr_read_deep_chunk ( - exr_const_context_t ctxt, - int part_index, - const exr_chunk_block_info_t* cinfo, - void* packed_data, - void* sample_data) + exr_const_context_t ctxt, + int part_index, + const exr_chunk_info_t* cinfo, + void* packed_data, + void* sample_data) { exr_result_t rv; uint64_t dataoffset, toread; @@ -1012,7 +1042,7 @@ write_scan_chunk ( } if (pctxt->cur_output_part != part_index) - return pctxt->standard_error (pctxt, EXR_ERR_PART_NOT_READY); + return pctxt->standard_error (pctxt, EXR_ERR_INCORRECT_PART); if (packed_size > 0 && !packed_data) return pctxt->print_error ( @@ -1086,7 +1116,7 @@ write_scan_chunk ( if (part->lineorder != EXR_LINEORDER_RANDOM_Y && pctxt->last_output_chunk != (cidx - 1)) { - return pctxt->standard_error (pctxt, EXR_ERR_CHUNK_NOT_READY); + return pctxt->standard_error (pctxt, EXR_ERR_INCORRECT_CHUNK); } if (pctxt->is_multipart) @@ -1178,12 +1208,12 @@ write_scan_chunk ( /**************************************/ exr_result_t -exr_write_scanline_block_info ( - exr_context_t ctxt, int part_index, int y, exr_chunk_block_info_t* cinfo) +exr_write_scanline_chunk_info ( + exr_context_t ctxt, int part_index, int y, exr_chunk_info_t* cinfo) { - exr_attr_box2i_t dw; - int lpc, miny, cidx; - exr_chunk_block_info_t nil = { 0 }; + exr_attr_box2i_t dw; + int lpc, miny, cidx; + exr_chunk_info_t nil = { 0 }; EXR_PROMOTE_LOCKED_CONTEXT_AND_PART_OR_ERROR (ctxt, part_index); @@ -1270,14 +1300,14 @@ exr_write_scanline_block_info ( /**************************************/ exr_result_t -exr_write_tile_block_info ( - exr_context_t ctxt, - int part_index, - int tilex, - int tiley, - int levelx, - int levely, - exr_chunk_block_info_t* cinfo) +exr_write_tile_chunk_info ( + exr_context_t ctxt, + int part_index, + int tilex, + int tiley, + int levelx, + int levely, + exr_chunk_info_t* cinfo) { exr_result_t rv; int cidx; @@ -1285,7 +1315,7 @@ exr_write_tile_block_info ( const exr_attr_tiledesc_t* tiledesc; int tilew, tileh; uint64_t unpacksize = 0; - exr_chunk_block_info_t nil = { 0 }; + exr_chunk_info_t nil = { 0 }; EXR_PROMOTE_LOCKED_CONTEXT_AND_PART_OR_ERROR (ctxt, part_index); @@ -1307,10 +1337,8 @@ exr_write_tile_block_info ( part->num_tile_levels_y <= 0 || !part->tile_level_tile_count_x || !part->tile_level_tile_count_y) { - return EXR_UNLOCK_AND_RETURN_PCTXT (pctxt->print_error ( - pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Request for tile, but no tile data exists")); + return EXR_UNLOCK_WRITE_AND_RETURN_PCTXT (pctxt->report_error ( + pctxt, EXR_ERR_MISSING_REQ_ATTR, "Tile data missing or corrupt")); } if (pctxt->mode != EXR_CONTEXT_WRITING_DATA) @@ -1481,7 +1509,7 @@ write_tile_chunk ( } if (pctxt->cur_output_part != part_index) - return pctxt->standard_error (pctxt, EXR_ERR_PART_NOT_READY); + return pctxt->standard_error (pctxt, EXR_ERR_INCORRECT_PART); if (!packed_data || packed_size == 0) return pctxt->print_error ( @@ -1516,8 +1544,8 @@ write_tile_chunk ( { return pctxt->print_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Attempting to write tiled data, missing tile description"); + EXR_ERR_MISSING_REQ_ATTR, + "Attempting to write tiled part, but tile data missing or corrupt"); } cidx = -1; @@ -1544,7 +1572,7 @@ write_tile_chunk ( { return pctxt->print_error ( pctxt, - EXR_ERR_CHUNK_NOT_READY, + EXR_ERR_INCORRECT_CHUNK, "Chunk index %d is not the next chunk to be written (last %d)", cidx, pctxt->last_output_chunk); @@ -1707,7 +1735,7 @@ internal_validate_next_chunk ( int cidx, lpc; if (pctxt->cur_output_part != encode->part_index) - return pctxt->standard_error (pctxt, EXR_ERR_PART_NOT_READY); + return pctxt->standard_error (pctxt, EXR_ERR_INCORRECT_PART); cidx = -1; @@ -1717,16 +1745,16 @@ internal_validate_next_chunk ( rv = compute_tile_chunk_off ( pctxt, part, - encode->chunk_block.start_x, - encode->chunk_block.start_y, - encode->chunk_block.level_x, - encode->chunk_block.level_y, + encode->chunk.start_x, + encode->chunk.start_y, + encode->chunk.level_x, + encode->chunk.level_y, &cidx); } else { lpc = part->lines_per_chunk; - cidx = (encode->chunk_block.start_y - part->data_window.min.y); + cidx = (encode->chunk.start_y - part->data_window.min.y); if (lpc > 1) cidx /= lpc; //if (part->lineorder == EXR_LINEORDER_DECREASING_Y) @@ -1743,7 +1771,7 @@ internal_validate_next_chunk ( pctxt, EXR_ERR_INVALID_ARGUMENT, "Chunk index for scanline %d in chunk %d outside chunk count %d", - encode->chunk_block.start_y, + encode->chunk.start_y, cidx, part->chunk_count); } @@ -1753,7 +1781,7 @@ internal_validate_next_chunk ( { rv = pctxt->print_error ( pctxt, - EXR_ERR_CHUNK_NOT_READY, + EXR_ERR_INCORRECT_CHUNK, "Attempt to write chunk %d, but last output chunk is %d", cidx, pctxt->last_output_chunk); diff --git a/src/lib/OpenEXRCore/coding.c b/src/lib/OpenEXRCore/coding.c index 90a53aed46..3ed3275b77 100644 --- a/src/lib/OpenEXRCore/coding.c +++ b/src/lib/OpenEXRCore/coding.c @@ -12,7 +12,7 @@ internal_coding_fill_channel_info ( exr_coding_channel_info_t** channels, int16_t* num_chans, exr_coding_channel_info_t* builtinextras, - const exr_chunk_block_info_t* cinfo, + const exr_chunk_info_t* cinfo, const struct _internal_exr_context* pctxt, const struct _internal_exr_part* part) { @@ -81,7 +81,7 @@ exr_result_t internal_coding_update_channel_info ( exr_coding_channel_info_t* channels, int16_t num_chans, - const exr_chunk_block_info_t* cinfo, + const exr_chunk_info_t* cinfo, const struct _internal_exr_context* pctxt, const struct _internal_exr_part* part) { diff --git a/src/lib/OpenEXRCore/decoding.c b/src/lib/OpenEXRCore/decoding.c index 0e7225a5bc..f9a4272d65 100644 --- a/src/lib/OpenEXRCore/decoding.c +++ b/src/lib/OpenEXRCore/decoding.c @@ -19,20 +19,19 @@ static exr_result_t update_pack_unpack_ptrs (exr_decode_pipeline_t* decode) { exr_result_t rv; - exr_storage_t stortype = ((exr_storage_t) decode->chunk_block.type); + exr_storage_t stortype = ((exr_storage_t) decode->chunk.type); if (stortype == EXR_STORAGE_DEEP_SCANLINE || stortype == EXR_STORAGE_DEEP_TILED) { size_t sampsize = - (((size_t) decode->chunk_block.width) * - ((size_t) decode->chunk_block.height)); + (((size_t) decode->chunk.width) * ((size_t) decode->chunk.height)); if ((decode->decode_flags & EXR_DECODE_SAMPLE_COUNTS_AS_INDIVIDUAL)) sampsize += 1; sampsize *= sizeof (int32_t); - if (decode->chunk_block.sample_count_table_size == sampsize) + if (decode->chunk.sample_count_table_size == sampsize) { internal_decode_free_buffer ( decode, @@ -58,7 +57,7 @@ update_pack_unpack_ptrs (exr_decode_pipeline_t* decode) return rv; } - if (decode->chunk_block.packed_size == decode->chunk_block.unpacked_size) + if (decode->chunk.packed_size == decode->chunk.unpacked_size) { internal_decode_free_buffer ( decode, @@ -76,7 +75,7 @@ update_pack_unpack_ptrs (exr_decode_pipeline_t* decode) EXR_TRANSCODE_BUFFER_UNPACKED, &(decode->unpacked_buffer), &(decode->unpacked_alloc_size), - decode->chunk_block.unpacked_size); + decode->chunk.unpacked_size); } return rv; @@ -92,10 +91,10 @@ read_uncompressed_direct (exr_decode_pipeline_t* decode) EXR_PROMOTE_READ_CONST_CONTEXT_AND_PART_OR_ERROR ( decode->context, decode->part_index); - dataoffset = decode->chunk_block.data_offset; + dataoffset = decode->chunk.data_offset; - height = decode->chunk_block.height; - start_y = decode->chunk_block.start_y; + height = decode->chunk.height; + start_y = decode->chunk.start_y; for (int y = 0; y < height; ++y) { for (int c = 0; c < decode->channel_count; ++c) @@ -155,7 +154,7 @@ default_read_chunk (exr_decode_pipeline_t* decode) EXR_TRANSCODE_BUFFER_PACKED_SAMPLES, &(decode->packed_sample_count_table), &(decode->packed_sample_count_alloc_size), - decode->chunk_block.sample_count_table_size); + decode->chunk.sample_count_table_size); if (rv != EXR_ERR_SUCCESS) return rv; if ((decode->decode_flags & EXR_DECODE_SAMPLE_DATA_ONLY)) @@ -163,7 +162,7 @@ default_read_chunk (exr_decode_pipeline_t* decode) rv = exr_read_deep_chunk ( decode->context, decode->part_index, - &(decode->chunk_block), + &(decode->chunk), NULL, decode->packed_sample_count_table); } @@ -174,13 +173,13 @@ default_read_chunk (exr_decode_pipeline_t* decode) EXR_TRANSCODE_BUFFER_PACKED, &(decode->packed_buffer), &(decode->packed_alloc_size), - decode->chunk_block.packed_size); + decode->chunk.packed_size); if (rv != EXR_ERR_SUCCESS) return rv; rv = exr_read_deep_chunk ( decode->context, decode->part_index, - &(decode->chunk_block), + &(decode->chunk), decode->packed_buffer, decode->packed_sample_count_table); } @@ -192,12 +191,12 @@ default_read_chunk (exr_decode_pipeline_t* decode) EXR_TRANSCODE_BUFFER_PACKED, &(decode->packed_buffer), &(decode->packed_alloc_size), - decode->chunk_block.packed_size); + decode->chunk.packed_size); if (rv != EXR_ERR_SUCCESS) return rv; rv = exr_read_chunk ( decode->context, decode->part_index, - &(decode->chunk_block), + &(decode->chunk), decode->packed_buffer); } @@ -290,8 +289,7 @@ default_decompress_chunk (exr_decode_pipeline_t* decode) part->storage_mode == EXR_STORAGE_DEEP_TILED) { size_t sampsize = - (((size_t) decode->chunk_block.width) * - ((size_t) decode->chunk_block.height)); + (((size_t) decode->chunk.width) * ((size_t) decode->chunk.height)); sampsize *= sizeof (int32_t); rv = decompress_data ( @@ -299,7 +297,7 @@ default_decompress_chunk (exr_decode_pipeline_t* decode) part->comp_type, decode, decode->packed_sample_count_table, - decode->chunk_block.sample_count_table_size, + decode->chunk.sample_count_table_size, decode->sample_count_table, sampsize); @@ -309,7 +307,7 @@ default_decompress_chunk (exr_decode_pipeline_t* decode) pctxt, rv, "Unable to decompress sample table %lu -> %lu", - decode->chunk_block.sample_count_table_size, + decode->chunk.sample_count_table_size, sampsize); } if ((decode->decode_flags & EXR_DECODE_SAMPLE_DATA_ONLY)) return rv; @@ -321,9 +319,9 @@ default_decompress_chunk (exr_decode_pipeline_t* decode) part->comp_type, decode, decode->packed_buffer, - decode->chunk_block.packed_size, + decode->chunk.packed_size, decode->unpacked_buffer, - decode->chunk_block.unpacked_size); + decode->chunk.unpacked_size); if (rv != EXR_ERR_SUCCESS) { @@ -331,8 +329,8 @@ default_decompress_chunk (exr_decode_pipeline_t* decode) pctxt, rv, "Unable to decompress image data %lu -> %lu", - decode->chunk_block.packed_size, - decode->chunk_block.unpacked_size); + decode->chunk.packed_size, + decode->chunk.unpacked_size); } return rv; } @@ -342,8 +340,8 @@ unpack_sample_table ( const struct _internal_exr_context* pctxt, exr_decode_pipeline_t* decode) { exr_result_t rv = EXR_ERR_SUCCESS; - int32_t w = decode->chunk_block.width; - int32_t h = decode->chunk_block.height; + int32_t w = decode->chunk.width; + int32_t h = decode->chunk.height; int32_t totsamp = 0; int32_t* samptable = decode->sample_count_table; size_t combSampSize = 0; @@ -360,7 +358,7 @@ unpack_sample_table ( { int32_t nsamps = (int32_t) one_to_native32 ((uint32_t) samptable[y * w + x]); - if (nsamps < 0) return EXR_ERR_BAD_CHUNK_DATA; + if (nsamps < 0) return EXR_ERR_INVALID_SAMPLE_DATA; samptable[y * w + x] = nsamps - prevsamp; prevsamp = nsamps; } @@ -377,7 +375,7 @@ unpack_sample_table ( { int32_t nsamps = (int32_t) one_to_native32 ((uint32_t) samptable[y * w + x]); - if (nsamps < 0) return EXR_ERR_BAD_CHUNK_DATA; + if (nsamps < 0) return EXR_ERR_INVALID_SAMPLE_DATA; samptable[y * w + x] = nsamps; prevsamp = nsamps; } @@ -385,11 +383,11 @@ unpack_sample_table ( } } - if (totsamp < 0 || (((uint64_t) totsamp) * combSampSize) > - decode->chunk_block.unpacked_size) + if (totsamp < 0 || + (((uint64_t) totsamp) * combSampSize) > decode->chunk.unpacked_size) { rv = pctxt->report_error ( - pctxt, EXR_ERR_BAD_CHUNK_DATA, "Corrupt sample count table"); + pctxt, EXR_ERR_INVALID_SAMPLE_DATA, "Corrupt sample count table"); } return rv; } @@ -398,10 +396,10 @@ unpack_sample_table ( exr_result_t exr_decoding_initialize ( - exr_const_context_t ctxt, - int part_index, - const exr_chunk_block_info_t* cinfo, - exr_decode_pipeline_t* decode) + exr_const_context_t ctxt, + int part_index, + const exr_chunk_info_t* cinfo, + exr_decode_pipeline_t* decode) { exr_result_t rv; exr_decode_pipeline_t nil = { 0 }; @@ -422,9 +420,9 @@ exr_decoding_initialize ( if (rv == EXR_ERR_SUCCESS) { - decode->part_index = part_index; - decode->context = ctxt; - decode->chunk_block = *cinfo; + decode->part_index = part_index; + decode->context = ctxt; + decode->chunk = *cinfo; } return rv; } @@ -595,10 +593,10 @@ exr_decoding_choose_default_routines ( exr_result_t exr_decoding_update ( - exr_const_context_t ctxt, - int part_index, - const exr_chunk_block_info_t* cinfo, - exr_decode_pipeline_t* decode) + exr_const_context_t ctxt, + int part_index, + const exr_chunk_info_t* cinfo, + exr_decode_pipeline_t* decode) { exr_result_t rv; EXR_PROMOTE_READ_CONST_CONTEXT_AND_PART_OR_ERROR (ctxt, part_index); @@ -613,7 +611,7 @@ exr_decoding_update ( rv = internal_coding_update_channel_info ( decode->channels, decode->channel_count, cinfo, pctxt, part); - decode->chunk_block = *cinfo; + decode->chunk = *cinfo; return rv; } @@ -643,8 +641,8 @@ exr_decoding_run ( if (rv != EXR_ERR_SUCCESS) return pctxt->report_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Decode pipeline unable to read data"); + rv, + "Unable to read pixel data block from context"); if (rv == EXR_ERR_SUCCESS) rv = update_pack_unpack_ptrs (decode); if (rv != EXR_ERR_SUCCESS) diff --git a/src/lib/OpenEXRCore/encoding.c b/src/lib/OpenEXRCore/encoding.c index ac0488dfd7..c14edeb4f1 100644 --- a/src/lib/OpenEXRCore/encoding.c +++ b/src/lib/OpenEXRCore/encoding.c @@ -81,13 +81,13 @@ default_write_chunk (exr_encode_pipeline_t* encode) if (!encode) return EXR_ERR_INVALID_ARGUMENT; - switch (encode->chunk_block.type) + switch (encode->chunk.type) { case EXR_STORAGE_SCANLINE: rv = exr_write_scanline_chunk ( EXR_CONST_CAST (exr_context_t, encode->context), encode->part_index, - encode->chunk_block.start_y, + encode->chunk.start_y, encode->compressed_buffer, encode->compressed_bytes); break; @@ -95,10 +95,10 @@ default_write_chunk (exr_encode_pipeline_t* encode) rv = exr_write_tile_chunk ( EXR_CONST_CAST (exr_context_t, encode->context), encode->part_index, - encode->chunk_block.start_x, - encode->chunk_block.start_y, - encode->chunk_block.level_x, - encode->chunk_block.level_y, + encode->chunk.start_x, + encode->chunk.start_y, + encode->chunk.level_x, + encode->chunk.level_y, encode->compressed_buffer, encode->compressed_bytes); break; @@ -109,7 +109,7 @@ default_write_chunk (exr_encode_pipeline_t* encode) rv = exr_write_deep_scanline_chunk ( EXR_CONST_CAST (exr_context_t, encode->context), encode->part_index, - encode->chunk_block.start_y, + encode->chunk.start_y, encode->compressed_buffer, encode->compressed_bytes, encode->packed_bytes, @@ -123,10 +123,10 @@ default_write_chunk (exr_encode_pipeline_t* encode) rv = exr_write_deep_tile_chunk ( EXR_CONST_CAST (exr_context_t, encode->context), encode->part_index, - encode->chunk_block.start_x, - encode->chunk_block.start_y, - encode->chunk_block.level_x, - encode->chunk_block.level_y, + encode->chunk.start_x, + encode->chunk.start_y, + encode->chunk.level_x, + encode->chunk.level_y, encode->compressed_buffer, encode->compressed_bytes, encode->packed_bytes, @@ -145,7 +145,7 @@ exr_result_t exr_encoding_initialize ( exr_const_context_t ctxt, int part_index, - const exr_chunk_block_info_t* cinfo, + const exr_chunk_info_t* cinfo, exr_encode_pipeline_t* encode) { exr_result_t rv; @@ -179,7 +179,7 @@ exr_encoding_initialize ( { encode->part_index = part_index; encode->context = ctxt; - encode->chunk_block = *cinfo; + encode->chunk = *cinfo; } return EXR_UNLOCK_WRITE_AND_RETURN_PCTXT (rv); } @@ -222,7 +222,7 @@ exr_result_t exr_encoding_update ( exr_const_context_t ctxt, int part_index, - const exr_chunk_block_info_t* cinfo, + const exr_chunk_info_t* cinfo, exr_encode_pipeline_t* encode) { exr_result_t rv; @@ -248,7 +248,7 @@ exr_encoding_update ( rv = internal_coding_update_channel_info ( encode->channels, encode->channel_count, cinfo, pctxt, part); - if (rv == EXR_ERR_SUCCESS) encode->chunk_block = *cinfo; + if (rv == EXR_ERR_SUCCESS) encode->chunk = *cinfo; return EXR_UNLOCK_WRITE_AND_RETURN_PCTXT (rv); } @@ -276,8 +276,8 @@ exr_encoding_run ( { if (encode->sample_count_table == NULL || encode->sample_count_alloc_size != - (((size_t) encode->chunk_block.width) * - ((size_t) encode->chunk_block.height) * sizeof (int32_t))) + (((size_t) encode->chunk.width) * + ((size_t) encode->chunk.height) * sizeof (int32_t))) { return EXR_UNLOCK_WRITE_AND_RETURN_PCTXT (pctxt->report_error ( pctxt, @@ -366,7 +366,7 @@ exr_encoding_run ( { priv_from_native32 ( encode->sample_count_table, - encode->chunk_block.width * encode->chunk_block.height); + encode->chunk.width * encode->chunk.height); } if (rv == EXR_ERR_SUCCESS) @@ -396,8 +396,8 @@ exr_encoding_run ( encode->packed_sample_count_table = encode->sample_count_table; encode->packed_sample_count_alloc_size = 0; encode->packed_sample_count_bytes = - (((size_t) encode->chunk_block.width) * - ((size_t) encode->chunk_block.height) * sizeof (int32_t)); + (((size_t) encode->chunk.width) * + ((size_t) encode->chunk.height) * sizeof (int32_t)); } } @@ -413,7 +413,7 @@ exr_encoding_run ( { priv_to_native32 ( encode->sample_count_table, - encode->chunk_block.width * encode->chunk_block.height); + encode->chunk.width * encode->chunk.height); } return rv; diff --git a/src/lib/OpenEXRCore/internal_b44.c b/src/lib/OpenEXRCore/internal_b44.c index fd5c863f76..0a07b9c633 100644 --- a/src/lib/OpenEXRCore/internal_b44.c +++ b/src/lib/OpenEXRCore/internal_b44.c @@ -319,9 +319,9 @@ compress_b44_impl (exr_encode_pipeline_t* encode, int flat_field) nOut = 0; packed = encode->packed_buffer; - for (int y = 0; y < encode->chunk_block.height; ++y) + for (int y = 0; y < encode->chunk.height; ++y) { - int cury = y + encode->chunk_block.start_y; + int cury = y + encode->chunk.start_y; scratch = encode->scratch_buffer_1; for (int c = 0; c < encode->channel_count; ++c) @@ -565,9 +565,9 @@ uncompress_b44_impl ( /* now put it back so each scanline has channel data */ bIn = 0; - for (int y = 0; y < decode->chunk_block.height; ++y) + for (int y = 0; y < decode->chunk.height; ++y) { - int cury = y + decode->chunk_block.start_y; + int cury = y + decode->chunk.start_y; scratch = decode->scratch_buffer_1; for (int c = 0; c < decode->channel_count; ++c) diff --git a/src/lib/OpenEXRCore/internal_coding.h b/src/lib/OpenEXRCore/internal_coding.h index cc40e99313..1e34c907aa 100644 --- a/src/lib/OpenEXRCore/internal_coding.h +++ b/src/lib/OpenEXRCore/internal_coding.h @@ -20,7 +20,7 @@ (IMATH_VERSION_MAJOR == 3 && IMATH_VERSION_MINOR >= 1) # define IMATH_HALF_SAFE_FOR_C /* avoid the library dependency */ -# define IMATH_HALF_NO_TABLES_AT_ALL +# define IMATH_HALF_NO_LOOKUP_TABLE # include #endif @@ -64,14 +64,14 @@ exr_result_t internal_coding_fill_channel_info ( exr_coding_channel_info_t** channels, int16_t* num_chans, exr_coding_channel_info_t* builtinextras, - const exr_chunk_block_info_t* cinfo, + const exr_chunk_info_t* cinfo, const struct _internal_exr_context* pctxt, const struct _internal_exr_part* part); exr_result_t internal_coding_update_channel_info ( exr_coding_channel_info_t* channels, int16_t num_chans, - const exr_chunk_block_info_t* cinfo, + const exr_chunk_info_t* cinfo, const struct _internal_exr_context* pctxt, const struct _internal_exr_part* part); @@ -82,30 +82,26 @@ exr_result_t internal_validate_next_chunk ( /**************************************/ -exr_result_t -internal_encode_free_buffer ( +exr_result_t internal_encode_free_buffer ( exr_encode_pipeline_t* encode, enum transcoding_pipeline_buffer_id bufid, void** buf, size_t* sz); -exr_result_t -internal_encode_alloc_buffer ( +exr_result_t internal_encode_alloc_buffer ( exr_encode_pipeline_t* encode, enum transcoding_pipeline_buffer_id bufid, void** buf, size_t* cursz, size_t newsz); -exr_result_t -internal_decode_free_buffer ( +exr_result_t internal_decode_free_buffer ( exr_decode_pipeline_t* decode, enum transcoding_pipeline_buffer_id bufid, void** buf, size_t* sz); -exr_result_t -internal_decode_alloc_buffer ( +exr_result_t internal_decode_alloc_buffer ( exr_decode_pipeline_t* decode, enum transcoding_pipeline_buffer_id bufid, void** buf, diff --git a/src/lib/OpenEXRCore/internal_huf.c b/src/lib/OpenEXRCore/internal_huf.c index e15e453858..41994ea523 100644 --- a/src/lib/OpenEXRCore/internal_huf.c +++ b/src/lib/OpenEXRCore/internal_huf.c @@ -514,7 +514,7 @@ hufUnpackEncTable ( uint64_t zerun = getBits (8, &c, &lc, &p) + SHORTEST_LONG_RUN; - if (im + zerun > iM + 1) return EXR_ERR_BAD_CHUNK_DATA; + if (im + zerun > iM + 1) return EXR_ERR_CORRUPT_CHUNK; while (zerun--) hcode[im++] = 0; @@ -525,7 +525,7 @@ hufUnpackEncTable ( { uint64_t zerun = l - SHORT_ZEROCODE_RUN + 2; - if (im + zerun > iM + 1) return EXR_ERR_BAD_CHUNK_DATA; + if (im + zerun > iM + 1) return EXR_ERR_CORRUPT_CHUNK; while (zerun--) hcode[im++] = 0; @@ -584,7 +584,7 @@ hufBuildDecTable ( // than the largest l-bit number. // - return EXR_ERR_BAD_CHUNK_DATA; + return EXR_ERR_CORRUPT_CHUNK; } if (l > HUF_DECBITS) @@ -602,7 +602,7 @@ hufBuildDecTable ( // been stored in table entry *pl. // - return EXR_ERR_BAD_CHUNK_DATA; + return EXR_ERR_CORRUPT_CHUNK; } pl->lit++; @@ -642,7 +642,7 @@ hufBuildDecTable ( // already been stored in table entry *pl. // - return EXR_ERR_BAD_CHUNK_DATA; + return EXR_ERR_CORRUPT_CHUNK; } pl->len = (int32_t) l; @@ -805,7 +805,7 @@ hufEncode ( uint8_t cs = (uint8_t) (c >> lc); \ \ if (out + cs > oe) \ - return EXR_ERR_BAD_CHUNK_DATA; \ + return EXR_ERR_CORRUPT_CHUNK; \ else if (out - 1 < ob) \ return EXR_ERR_OUT_OF_MEMORY; \ \ @@ -820,7 +820,7 @@ hufEncode ( } \ else \ { \ - return EXR_ERR_BAD_CHUNK_DATA; \ + return EXR_ERR_CORRUPT_CHUNK; \ } \ } @@ -866,7 +866,7 @@ hufDecode ( // Get short code // - if (pl.len > lc) return EXR_ERR_BAD_CHUNK_DATA; + if (pl.len > lc) return EXR_ERR_CORRUPT_CHUNK; lc -= pl.len; getCode (pl.lit, rlc, c, lc, in, out, outb, oe) @@ -875,7 +875,7 @@ hufDecode ( { uint32_t j; - if (!pl.p) return EXR_ERR_BAD_CHUNK_DATA; // wrong code + if (!pl.p) return EXR_ERR_CORRUPT_CHUNK; // wrong code // // Search long code @@ -906,7 +906,7 @@ hufDecode ( } } - if (j == pl.lit) return EXR_ERR_BAD_CHUNK_DATA; + if (j == pl.lit) return EXR_ERR_CORRUPT_CHUNK; } } } @@ -925,12 +925,12 @@ hufDecode ( if (pl.len) { - if (pl.len > lc) return EXR_ERR_BAD_CHUNK_DATA; + if (pl.len > lc) return EXR_ERR_CORRUPT_CHUNK; lc -= pl.len; getCode (pl.lit, rlc, c, lc, in, out, outb, oe) } else - return EXR_ERR_BAD_CHUNK_DATA; + return EXR_ERR_CORRUPT_CHUNK; } if ((((uintptr_t) out) - ((uintptr_t) outb)) != no) @@ -1081,7 +1081,7 @@ internal_huf_decompress ( nBits = readUInt (compressed + 12); // uint32_t future = readUInt (compressed + 16); - if (im >= HUF_ENCSIZE || iM >= HUF_ENCSIZE) return EXR_ERR_BAD_CHUNK_DATA; + if (im >= HUF_ENCSIZE || iM >= HUF_ENCSIZE) return EXR_ERR_CORRUPT_CHUNK; ptr = compressed + 20; @@ -1117,7 +1117,7 @@ internal_huf_decompress ( hufClearDecTable (hdec); hufUnpackEncTable (&ptr, nLeft, im, iM, freq); - if (nBits > 8 * nLeft) return EXR_ERR_BAD_CHUNK_DATA; + if (nBits > 8 * nLeft) return EXR_ERR_CORRUPT_CHUNK; rv = hufBuildDecTable (freq, im, iM, hdec); hufDecode (freq, hdec, ptr, nBits, iM, nRaw, raw); diff --git a/src/lib/OpenEXRCore/internal_piz.c b/src/lib/OpenEXRCore/internal_piz.c index ec6947457c..572b840ef2 100644 --- a/src/lib/OpenEXRCore/internal_piz.c +++ b/src/lib/OpenEXRCore/internal_piz.c @@ -441,9 +441,9 @@ internal_exr_apply_piz (exr_encode_pipeline_t* encode) lut = (uint16_t*) (bitmap + BITMAP_SIZE); packed = encode->packed_buffer; - for (int y = 0; y < encode->chunk_block.height; ++y) + for (int y = 0; y < encode->chunk.height; ++y) { - int cury = y + encode->chunk_block.start_y; + int cury = y + encode->chunk.start_y; scratch = encode->scratch_buffer_1; for (int c = 0; c < encode->channel_count; ++c) @@ -596,7 +596,7 @@ internal_exr_undo_piz ( memset (bitmap, 0, sizeof (uint8_t) * BITMAP_SIZE); nBytes = 0; - if (sizeof (uint16_t) * 2 > packsz) return EXR_ERR_BAD_CHUNK_DATA; + if (sizeof (uint16_t) * 2 > packsz) return EXR_ERR_CORRUPT_CHUNK; packed = src; minNonZero = unaligned_load16 (packed + nBytes); @@ -604,12 +604,12 @@ internal_exr_undo_piz ( maxNonZero = unaligned_load16 (packed + nBytes); nBytes += sizeof (uint16_t); - if (maxNonZero >= BITMAP_SIZE) return EXR_ERR_BAD_CHUNK_DATA; + if (maxNonZero >= BITMAP_SIZE) return EXR_ERR_CORRUPT_CHUNK; if (minNonZero <= maxNonZero) { uint64_t bytesToRead = maxNonZero - minNonZero + 1; - if (nBytes + bytesToRead > packsz) return EXR_ERR_BAD_CHUNK_DATA; + if (nBytes + bytesToRead > packsz) return EXR_ERR_CORRUPT_CHUNK; memcpy (bitmap + minNonZero, packed + nBytes, bytesToRead); nBytes += bytesToRead; @@ -620,12 +620,12 @@ internal_exr_undo_piz ( // // Huffman decoding // - if (nBytes + sizeof (uint32_t) > packsz) return EXR_ERR_BAD_CHUNK_DATA; + if (nBytes + sizeof (uint32_t) > packsz) return EXR_ERR_CORRUPT_CHUNK; hufbytes = unaligned_load32 (packed + nBytes); nBytes += sizeof (uint32_t); - if (nBytes + hufbytes > packsz) return EXR_ERR_BAD_CHUNK_DATA; + if (nBytes + hufbytes > packsz) return EXR_ERR_CORRUPT_CHUNK; wavbuf = decode->scratch_buffer_1; rv = internal_huf_decompress ( @@ -662,9 +662,9 @@ internal_exr_undo_piz ( // Rearrange the pixel data into the format expected by the caller. // - for (int y = 0; y < decode->chunk_block.height; ++y) + for (int y = 0; y < decode->chunk.height; ++y) { - int cury = y + decode->chunk_block.start_y; + int cury = y + decode->chunk.start_y; scratch = decode->scratch_buffer_1; for (int c = 0; c < decode->channel_count; ++c) @@ -695,6 +695,6 @@ internal_exr_undo_piz ( } } - if (nOut != outsz) return EXR_ERR_BAD_CHUNK_DATA; + if (nOut != outsz) return EXR_ERR_CORRUPT_CHUNK; return EXR_ERR_SUCCESS; } diff --git a/src/lib/OpenEXRCore/internal_pxr24.c b/src/lib/OpenEXRCore/internal_pxr24.c index efe9e54df5..96f2f66e5f 100644 --- a/src/lib/OpenEXRCore/internal_pxr24.c +++ b/src/lib/OpenEXRCore/internal_pxr24.c @@ -94,9 +94,9 @@ apply_pxr24_impl (exr_encode_pipeline_t* encode) const uint8_t* lastIn = encode->packed_buffer; uLongf compbufsz = encode->compressed_alloc_size; - for (int y = 0; y < encode->chunk_block.height; ++y) + for (int y = 0; y < encode->chunk.height; ++y) { - int cury = y + encode->chunk_block.start_y; + int cury = y + encode->chunk.start_y; for (int c = 0; c < encode->channel_count; ++c) { @@ -221,7 +221,7 @@ apply_pxr24_impl (exr_encode_pipeline_t* encode) (const Bytef*) encode->scratch_buffer_1, nOut)) { - return EXR_ERR_BAD_CHUNK_DATA; + return EXR_ERR_CORRUPT_CHUNK; } if (compbufsz > encode->packed_bytes) { @@ -277,11 +277,11 @@ undo_pxr24_impl ( (const Bytef*) compressed_data, (uLong) comp_buf_size); - if (rstat != Z_OK) return EXR_ERR_BAD_CHUNK_DATA; + if (rstat != Z_OK) return EXR_ERR_CORRUPT_CHUNK; - for (int y = 0; y < decode->chunk_block.height; ++y) + for (int y = 0; y < decode->chunk.height; ++y) { - int cury = y + decode->chunk_block.start_y; + int cury = y + decode->chunk.start_y; for (int c = 0; c < decode->channel_count; ++c) { @@ -312,7 +312,7 @@ undo_pxr24_impl ( ptr[3] = lastIn; lastIn += w; - if (nDec + nBytes > outSize) return EXR_ERR_BAD_CHUNK_DATA; + if (nDec + nBytes > outSize) return EXR_ERR_CORRUPT_CHUNK; for (int x = 0; x < w; ++x) { @@ -338,7 +338,7 @@ undo_pxr24_impl ( ptr[1] = lastIn; lastIn += w; - if (nDec + nBytes > outSize) return EXR_ERR_BAD_CHUNK_DATA; + if (nDec + nBytes > outSize) return EXR_ERR_CORRUPT_CHUNK; for (int x = 0; x < w; ++x) { @@ -365,7 +365,7 @@ undo_pxr24_impl ( lastIn += w; if (nDec + (uint64_t) (w * 3) > outSize) - return EXR_ERR_BAD_CHUNK_DATA; + return EXR_ERR_CORRUPT_CHUNK; for (int x = 0; x < w; ++x) { diff --git a/src/lib/OpenEXRCore/internal_rle.c b/src/lib/OpenEXRCore/internal_rle.c index 824f43a4d8..9d70a86abb 100644 --- a/src/lib/OpenEXRCore/internal_rle.c +++ b/src/lib/OpenEXRCore/internal_rle.c @@ -138,8 +138,8 @@ internal_rle_decompress ( { uint64_t count = (uint64_t) (-((int) *in++)); ++unpackbytes; - if (unpackbytes + count > packsz) return EXR_ERR_BAD_CHUNK_DATA; - if (outbytes + count > outsz) return EXR_ERR_BAD_CHUNK_DATA; + if (unpackbytes + count > packsz) return EXR_ERR_CORRUPT_CHUNK; + if (outbytes + count > outsz) return EXR_ERR_CORRUPT_CHUNK; memcpy (dst, in, count); in += count; @@ -150,11 +150,11 @@ internal_rle_decompress ( else { uint64_t count = (uint64_t) (*in++); - if (unpackbytes + 2 > packsz) return EXR_ERR_BAD_CHUNK_DATA; + if (unpackbytes + 2 > packsz) return EXR_ERR_CORRUPT_CHUNK; unpackbytes += 2; ++count; - if (outbytes + count > outsz) return EXR_ERR_BAD_CHUNK_DATA; + if (outbytes + count > outsz) return EXR_ERR_CORRUPT_CHUNK; memset (dst, *(const uint8_t*) in, count); dst += count; @@ -210,7 +210,7 @@ internal_exr_undo_rle ( unpackb = internal_rle_decompress (decode->scratch_buffer_1, outsz, src, packsz); - if (unpackb != outsz) return EXR_ERR_BAD_CHUNK_DATA; + if (unpackb != outsz) return EXR_ERR_CORRUPT_CHUNK; unpredict_and_reorder (out, decode->scratch_buffer_1, outsz); return EXR_ERR_SUCCESS; diff --git a/src/lib/OpenEXRCore/internal_zip.c b/src/lib/OpenEXRCore/internal_zip.c index 99f627242e..0192ac2a53 100644 --- a/src/lib/OpenEXRCore/internal_zip.c +++ b/src/lib/OpenEXRCore/internal_zip.c @@ -177,12 +177,12 @@ undo_zip_impl ( } else { - rstat = EXR_ERR_BAD_CHUNK_DATA; + rstat = EXR_ERR_CORRUPT_CHUNK; } } else { - rstat = EXR_ERR_BAD_CHUNK_DATA; + rstat = EXR_ERR_CORRUPT_CHUNK; } return (exr_result_t) rstat; @@ -253,7 +253,7 @@ apply_zip_impl (exr_encode_pipeline_t* encode) (const Bytef*) encode->scratch_buffer_1, encode->packed_bytes)) { - return EXR_ERR_BAD_CHUNK_DATA; + return EXR_ERR_CORRUPT_CHUNK; } if (compbufsz > encode->packed_bytes) { diff --git a/src/lib/OpenEXRCore/openexr_chunkio.h b/src/lib/OpenEXRCore/openexr_chunkio.h index 0f3a9f0dc6..24da708ab7 100644 --- a/src/lib/OpenEXRCore/openexr_chunkio.h +++ b/src/lib/OpenEXRCore/openexr_chunkio.h @@ -15,7 +15,11 @@ extern "C" { #endif /** - * Structure describing raw data information about a chunk + * Structure describing raw data information about a chunk. + * + * A chunk is the generic term for a pixel data block in an EXR file, + * as described in the OpenEXR File Layout documentation. This is + * common between all different forms of data that can be stored. */ typedef struct { @@ -40,24 +44,21 @@ typedef struct uint64_t sample_count_data_offset; uint64_t sample_count_table_size; -} exr_chunk_block_info_t; +} exr_chunk_info_t; EXR_EXPORT -exr_result_t exr_read_scanline_block_info ( - exr_const_context_t ctxt, - int part_index, - int y, - exr_chunk_block_info_t* cinfo); +exr_result_t exr_read_scanline_chunk_info ( + exr_const_context_t ctxt, int part_index, int y, exr_chunk_info_t* cinfo); EXR_EXPORT -exr_result_t exr_read_tile_block_info ( - exr_const_context_t ctxt, - int part_index, - int tilex, - int tiley, - int levelx, - int levely, - exr_chunk_block_info_t* cinfo); +exr_result_t exr_read_tile_chunk_info ( + exr_const_context_t ctxt, + int part_index, + int tilex, + int tiley, + int levelx, + int levely, + exr_chunk_info_t* cinfo); /** Read the packed data block for a chunk * @@ -66,10 +67,10 @@ exr_result_t exr_read_tile_block_info ( */ EXR_EXPORT exr_result_t exr_read_chunk ( - exr_const_context_t ctxt, - int part_index, - const exr_chunk_block_info_t* cinfo, - void* packed_data); + exr_const_context_t ctxt, + int part_index, + const exr_chunk_info_t* cinfo, + void* packed_data); /** * Read chunk for deep data. @@ -82,32 +83,32 @@ exr_result_t exr_read_chunk ( */ EXR_EXPORT exr_result_t exr_read_deep_chunk ( - exr_const_context_t ctxt, - int part_index, - const exr_chunk_block_info_t* cinfo, - void* packed_data, - void* sample_data); + exr_const_context_t ctxt, + int part_index, + const exr_chunk_info_t* cinfo, + void* packed_data, + void* sample_data); /**************************************/ -/** Initializes a chunk_block_info_t structure when encoding scanline +/** Initializes a @sa exr_chunk_info_t structure when encoding scanline * data (similar to read but does not do anything with a chunk * table) */ EXR_EXPORT -exr_result_t exr_write_scanline_block_info ( - exr_context_t ctxt, int part_index, int y, exr_chunk_block_info_t* cinfo); +exr_result_t exr_write_scanline_chunk_info ( + exr_context_t ctxt, int part_index, int y, exr_chunk_info_t* cinfo); -/** Initializes a chunk_block_info_t structure when encoding tiled data +/** Initializes a chunk_info_t structure when encoding tiled data * (similar to read but does not do anything with a chunk table) */ EXR_EXPORT -exr_result_t exr_write_tile_block_info ( - exr_context_t ctxt, - int part_index, - int tilex, - int tiley, - int levelx, - int levely, - exr_chunk_block_info_t* cinfo); +exr_result_t exr_write_tile_chunk_info ( + exr_context_t ctxt, + int part_index, + int tilex, + int tiley, + int levelx, + int levely, + exr_chunk_info_t* cinfo); /** y must the appropriate starting y for the specified chunk */ EXR_EXPORT diff --git a/src/lib/OpenEXRCore/openexr_decode.h b/src/lib/OpenEXRCore/openexr_decode.h index 7fd2fb863c..4adc8e4ae3 100644 --- a/src/lib/OpenEXRCore/openexr_decode.h +++ b/src/lib/OpenEXRCore/openexr_decode.h @@ -34,7 +34,7 @@ extern "C" { * (successive) entries into each destination pointer (if not null). * * So each channel pointer must then point to an array of - * chunk_block.width * chunk_block.height pointers. + * chunk.width * chunk.height pointers. * * With this, you can only extract desired pixels (although all the * pixels must be initially decompressed) to handle such operations @@ -76,9 +76,9 @@ typedef struct _exr_decode_pipeline uint16_t decode_flags; /** copy of the parameters given to the initialize / update for convenience */ - int part_index; - exr_const_context_t context; - exr_chunk_block_info_t chunk_block; + int part_index; + exr_const_context_t context; + exr_chunk_info_t chunk; /** * can be used by the user to pass custom context data through @@ -234,7 +234,10 @@ typedef struct _exr_decode_pipeline } exr_decode_pipeline_t; /** @brief simple macro to initialize an empty decode pipeline */ -#define EXR_DECODE_PIPELINE_INITIALIZER { 0 } +#define EXR_DECODE_PIPELINE_INITIALIZER \ + { \ + 0 \ + } /** initializes the decoding pipeline structure with the channel info for the specified part, and the first block to be read. * @@ -244,10 +247,10 @@ typedef struct _exr_decode_pipeline */ EXR_EXPORT exr_result_t exr_decoding_initialize ( - exr_const_context_t ctxt, - int part_index, - const exr_chunk_block_info_t* cinfo, - exr_decode_pipeline_t* decode); + exr_const_context_t ctxt, + int part_index, + const exr_chunk_info_t* cinfo, + exr_decode_pipeline_t* decode); /** Given an initialized decode pipeline, finds appropriate functions * to read and shuffle / convert data into the defined channel outputs @@ -268,10 +271,10 @@ exr_result_t exr_decoding_choose_default_routines ( */ EXR_EXPORT exr_result_t exr_decoding_update ( - exr_const_context_t ctxt, - int part_index, - const exr_chunk_block_info_t* cinfo, - exr_decode_pipeline_t* decode); + exr_const_context_t ctxt, + int part_index, + const exr_chunk_info_t* cinfo, + exr_decode_pipeline_t* decode); /** Execute the decoding pipeline */ EXR_EXPORT diff --git a/src/lib/OpenEXRCore/openexr_encode.h b/src/lib/OpenEXRCore/openexr_encode.h index 494b46a0b3..f21a8dec5e 100644 --- a/src/lib/OpenEXRCore/openexr_encode.h +++ b/src/lib/OpenEXRCore/openexr_encode.h @@ -22,7 +22,7 @@ extern "C" { * Without this (i.e. a value of 0 in that bit), indicates the sample * count table is already a cumulative list (n, n+m, n+m+o, ...), * which is the on-disk representation */ -#define EXR_ENCODE_DATA_SAMPLE_COUNTS_ARE_INDIVIDUAL ((uint16_t)(1 << 0)) +#define EXR_ENCODE_DATA_SAMPLE_COUNTS_ARE_INDIVIDUAL ((uint16_t) (1 << 0)) /** Can be bit-wise or'ed into the decode_flags in the decode pipeline. * @@ -34,7 +34,7 @@ extern "C" { * (successive) entries into each destination. * * So each channel pointer must then point to an array of - * chunk_block.width * chunk_block.height pointers. If an entry is + * chunk.width * chunk.height pointers. If an entry is * NULL, 0 samples will be placed in the output. * * If this is NOT set (0), the default packing routine assumes the @@ -42,7 +42,7 @@ extern "C" { * memory block), ignoring user_line_stride and user_pixel_stride and * advancing only by the sample counts and bytes per element */ -#define EXR_ENCODE_NON_IMAGE_DATA_AS_POINTERS ((uint16_t)(1 << 1)) +#define EXR_ENCODE_NON_IMAGE_DATA_AS_POINTERS ((uint16_t) (1 << 1)) /** * Structure meant to be used on a per-thread basis for writing exr data @@ -67,12 +67,12 @@ typedef struct _exr_encode_pipeline int16_t channel_count; /** Encode flags to control the behavior*/ - uint16_t encode_flags; + uint16_t encode_flags; /** copy of the parameters given to the initialize / update for convenience */ - int part_index; - exr_const_context_t context; - exr_chunk_block_info_t chunk_block; + int part_index; + exr_const_context_t context; + exr_chunk_info_t chunk; /** * can be used by the user to pass custom context data through @@ -266,10 +266,13 @@ typedef struct _exr_encode_pipeline } exr_encode_pipeline_t; /** @brief simple macro to initialize an empty decode pipeline */ -#define EXR_ENCODE_PIPELINE_INITIALIZER { 0 } +#define EXR_ENCODE_PIPELINE_INITIALIZER \ + { \ + 0 \ + } /** initializes the encoding pipeline structure with the channel info - * for the specified part, and the first block to be written. + * for the specified part based on the chunk to be written. * * NB: The pack_and_convert_fn will be NULL after this. If that * stage is desired, initialize the channel output information and @@ -277,10 +280,10 @@ typedef struct _exr_encode_pipeline */ EXR_EXPORT exr_result_t exr_encoding_initialize ( - exr_const_context_t ctxt, - int part_index, - const exr_chunk_block_info_t* cinfo, - exr_encode_pipeline_t* encode_pipe); + exr_const_context_t ctxt, + int part_index, + const exr_chunk_info_t* cinfo, + exr_encode_pipeline_t* encode_pipe); /** Given an initialized encode pipeline, finds an appropriate * function to shuffle and convert data into the defined channel @@ -291,7 +294,9 @@ exr_result_t exr_encoding_initialize ( */ EXR_EXPORT exr_result_t exr_encoding_choose_default_routines ( - exr_const_context_t ctxt, int part_index, exr_encode_pipeline_t* encode_pipe); + exr_const_context_t ctxt, + int part_index, + exr_encode_pipeline_t* encode_pipe); /** Given a encode pipeline previously initialized, updates it for the * new chunk to be written. @@ -302,15 +307,17 @@ exr_result_t exr_encoding_choose_default_routines ( */ EXR_EXPORT exr_result_t exr_encoding_update ( - exr_const_context_t ctxt, - int part_index, - const exr_chunk_block_info_t* cinfo, - exr_encode_pipeline_t* encode_pipe); + exr_const_context_t ctxt, + int part_index, + const exr_chunk_info_t* cinfo, + exr_encode_pipeline_t* encode_pipe); /** Execute the encoding pipeline */ EXR_EXPORT exr_result_t exr_encoding_run ( - exr_const_context_t ctxt, int part_index, exr_encode_pipeline_t* encode_pipe); + exr_const_context_t ctxt, + int part_index, + exr_encode_pipeline_t* encode_pipe); /** Free any intermediate memory in the encoding pipeline * diff --git a/src/lib/OpenEXRCore/openexr_errors.h b/src/lib/OpenEXRCore/openexr_errors.h index 9d8a507c11..bb42295978 100644 --- a/src/lib/OpenEXRCore/openexr_errors.h +++ b/src/lib/OpenEXRCore/openexr_errors.h @@ -44,19 +44,21 @@ typedef enum EXR_ERR_MISSING_REQ_ATTR, EXR_ERR_INVALID_ATTR, EXR_ERR_NO_ATTR_BY_NAME, - EXR_ERR_BAD_CHUNK_DATA, EXR_ERR_ATTR_TYPE_MISMATCH, EXR_ERR_ATTR_SIZE_MISMATCH, EXR_ERR_SCAN_TILE_MIXEDAPI, EXR_ERR_TILE_SCAN_MIXEDAPI, EXR_ERR_MODIFY_SIZE_CHANGE, EXR_ERR_ALREADY_WROTE_ATTRS, - EXR_ERR_PART_NOT_READY, - EXR_ERR_CHUNK_NOT_READY, + EXR_ERR_BAD_CHUNK_LEADER, + EXR_ERR_CORRUPT_CHUNK, + EXR_ERR_INCORRECT_PART, + EXR_ERR_INCORRECT_CHUNK, EXR_ERR_USE_SCAN_DEEP_WRITE, EXR_ERR_USE_TILE_DEEP_WRITE, EXR_ERR_USE_SCAN_NONDEEP_WRITE, EXR_ERR_USE_TILE_NONDEEP_WRITE, + EXR_ERR_INVALID_SAMPLE_DATA, EXR_ERR_FEATURE_NOT_IMPLEMENTED, EXR_ERR_UNKNOWN } exr_error_code_t; diff --git a/src/lib/OpenEXRCore/openexr_part.h b/src/lib/OpenEXRCore/openexr_part.h index 6ae08c7403..08c166b5f3 100644 --- a/src/lib/OpenEXRCore/openexr_part.h +++ b/src/lib/OpenEXRCore/openexr_part.h @@ -117,6 +117,10 @@ EXR_EXPORT exr_result_t exr_get_level_sizes ( /** Return the number of chunks contained in this part of the file * + * As in the technical documentation for OpenEXR, the chunk is the + * generic term for a pixel data block. This is the atomic unit that + * this library uses to negotiate data to and from a context. + * * This should be used as a basis for splitting up how a file is * processed. Depending on the compression, a different number of * scanlines are encoded in each chunk, and since those need to be diff --git a/src/lib/OpenEXRCore/pack.c b/src/lib/OpenEXRCore/pack.c index 85d2e85a37..2f1a1cf3da 100644 --- a/src/lib/OpenEXRCore/pack.c +++ b/src/lib/OpenEXRCore/pack.c @@ -26,9 +26,9 @@ default_pack (exr_encode_pipeline_t* encode) uint64_t packed_bytes = 0; uint64_t chan_bytes = 0; - for (int y = 0; y < encode->chunk_block.height; ++y) + for (int y = 0; y < encode->chunk.height; ++y) { - int cury = y + encode->chunk_block.start_y; + int cury = y + encode->chunk.start_y; for (int c = 0; c < encode->channel_count; ++c) { diff --git a/src/lib/OpenEXRCore/part.c b/src/lib/OpenEXRCore/part.c index fd5b72bc45..3b44e0aa51 100644 --- a/src/lib/OpenEXRCore/part.c +++ b/src/lib/OpenEXRCore/part.c @@ -198,8 +198,8 @@ exr_get_tile_levels ( { return EXR_UNLOCK_WRITE_AND_RETURN_PCTXT (pctxt->print_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Request for tile, but no tile data exists")); + EXR_ERR_MISSING_REQ_ATTR, + "Tile data missing or corrupt")); } if (levelsx) *levelsx = part->num_tile_levels_x; @@ -235,8 +235,8 @@ exr_get_tile_sizes ( { return EXR_UNLOCK_WRITE_AND_RETURN_PCTXT (pctxt->print_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Request for tile, but no tile data exists")); + EXR_ERR_MISSING_REQ_ATTR, + "Tile data missing or corrupt")); } if (levelx < 0 || levely < 0 || levelx >= part->num_tile_levels_x || @@ -248,7 +248,7 @@ exr_get_tile_sizes ( if (tilew) { int32_t levw = part->tile_level_tile_size_x[levelx]; - if (tiledesc->x_size < (uint32_t)levw) + if (tiledesc->x_size < (uint32_t) levw) *tilew = (int32_t) tiledesc->x_size; else *tilew = levw; @@ -256,7 +256,7 @@ exr_get_tile_sizes ( if (tileh) { int32_t levh = part->tile_level_tile_size_y[levely]; - if (tiledesc->y_size < (uint32_t)levh) + if (tiledesc->y_size < (uint32_t) levh) *tileh = (int32_t) tiledesc->y_size; else *tileh = levh; @@ -270,7 +270,8 @@ exr_get_tile_sizes ( /**************************************/ -exr_result_t exr_get_level_sizes ( +exr_result_t +exr_get_level_sizes ( exr_const_context_t ctxt, int part_index, int levelx, @@ -289,8 +290,8 @@ exr_result_t exr_get_level_sizes ( { return EXR_UNLOCK_WRITE_AND_RETURN_PCTXT (pctxt->print_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Request for tile, but no tile data exists")); + EXR_ERR_MISSING_REQ_ATTR, + "Tile data missing or corrupt")); } if (levelx < 0 || levely < 0 || levelx >= part->num_tile_levels_x || @@ -298,10 +299,8 @@ exr_result_t exr_get_level_sizes ( return EXR_UNLOCK_WRITE_AND_RETURN_PCTXT ( pctxt->standard_error (pctxt, EXR_ERR_ARGUMENT_OUT_OF_RANGE)); - if (levw) - *levw = part->tile_level_tile_size_x[levelx]; - if (levh) - *levh = part->tile_level_tile_size_y[levely]; + if (levw) *levw = part->tile_level_tile_size_x[levelx]; + if (levh) *levh = part->tile_level_tile_size_y[levely]; return EXR_UNLOCK_WRITE_AND_RETURN_PCTXT (EXR_ERR_SUCCESS); } @@ -332,8 +331,8 @@ exr_get_chunk_count (exr_const_context_t ctxt, int part_index, int32_t* out) } return EXR_UNLOCK_WRITE_AND_RETURN_PCTXT (pctxt->report_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, - "Missing tile chunk information")); + EXR_ERR_MISSING_REQ_ATTR, + "Tile data missing or corrupt")); } else if ( part->storage_mode == EXR_STORAGE_SCANLINE || @@ -346,14 +345,14 @@ exr_get_chunk_count (exr_const_context_t ctxt, int part_index, int32_t* out) } return EXR_UNLOCK_WRITE_AND_RETURN_PCTXT (pctxt->report_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, + EXR_ERR_MISSING_REQ_ATTR, "Missing scanline chunk compression information")); } } return EXR_UNLOCK_WRITE_AND_RETURN_PCTXT (pctxt->report_error ( pctxt, - EXR_ERR_BAD_CHUNK_DATA, + EXR_ERR_MISSING_REQ_ATTR, "Missing data window for chunk information")); } diff --git a/src/lib/OpenEXRCore/unpack.c b/src/lib/OpenEXRCore/unpack.c index 93fb776cbd..2abf4b308c 100644 --- a/src/lib/OpenEXRCore/unpack.c +++ b/src/lib/OpenEXRCore/unpack.c @@ -234,7 +234,7 @@ unpack_16bit_3chan_interleave (exr_decode_pipeline_t* decode) int linc0; w = decode->channels[0].width; - h = decode->chunk_block.height; + h = decode->chunk.height; linc0 = decode->channels[0].user_line_stride; out0 = decode->channels[0].decode_to_ptr; @@ -274,7 +274,7 @@ unpack_16bit_3chan_interleave_rev (exr_decode_pipeline_t* decode) int linc0; w = decode->channels[0].width; - h = decode->chunk_block.height; + h = decode->chunk.height; linc0 = decode->channels[0].user_line_stride; out0 = decode->channels[2].decode_to_ptr; @@ -314,7 +314,7 @@ unpack_half_to_float_3chan_interleave (exr_decode_pipeline_t* decode) int linc0; w = decode->channels[0].width; - h = decode->chunk_block.height; + h = decode->chunk.height; linc0 = decode->channels[0].user_line_stride; out0 = decode->channels[0].decode_to_ptr; @@ -354,7 +354,7 @@ unpack_half_to_float_3chan_interleave_rev (exr_decode_pipeline_t* decode) int linc0; w = decode->channels[0].width; - h = decode->chunk_block.height; + h = decode->chunk.height; linc0 = decode->channels[0].user_line_stride; out0 = decode->channels[2].decode_to_ptr; @@ -395,7 +395,7 @@ unpack_16bit_3chan_planar (exr_decode_pipeline_t* decode) int linc0, linc1, linc2; w = decode->channels[0].width; - h = decode->chunk_block.height; + h = decode->chunk.height; inc0 = decode->channels[0].user_pixel_stride; inc1 = decode->channels[1].user_pixel_stride; inc2 = decode->channels[2].user_pixel_stride; @@ -449,7 +449,7 @@ unpack_half_to_float_3chan_planar (exr_decode_pipeline_t* decode) int linc0, linc1, linc2; w = decode->channels[0].width; - h = decode->chunk_block.height; + h = decode->chunk.height; inc0 = decode->channels[0].user_pixel_stride; inc1 = decode->channels[1].user_pixel_stride; inc2 = decode->channels[2].user_pixel_stride; @@ -495,7 +495,7 @@ unpack_16bit_3chan (exr_decode_pipeline_t* decode) int linc0, linc1, linc2; w = decode->channels[0].width; - h = decode->chunk_block.height; + h = decode->chunk.height; inc0 = decode->channels[0].user_pixel_stride; inc1 = decode->channels[1].user_pixel_stride; inc2 = decode->channels[2].user_pixel_stride; @@ -552,7 +552,7 @@ unpack_16bit_4chan_interleave (exr_decode_pipeline_t* decode) } combined; w = decode->channels[0].width; - h = decode->chunk_block.height; + h = decode->chunk.height; linc0 = decode->channels[0].user_line_stride; out0 = decode->channels[0].decode_to_ptr; @@ -605,7 +605,7 @@ unpack_16bit_4chan_interleave_rev (exr_decode_pipeline_t* decode) } combined; w = decode->channels[0].width; - h = decode->chunk_block.height; + h = decode->chunk.height; linc0 = decode->channels[0].user_line_stride; out0 = decode->channels[3].decode_to_ptr; @@ -646,7 +646,7 @@ unpack_half_to_float_4chan_interleave (exr_decode_pipeline_t* decode) int linc0; w = decode->channels[0].width; - h = decode->chunk_block.height; + h = decode->chunk.height; linc0 = decode->channels[0].user_line_stride; out0 = decode->channels[0].decode_to_ptr; @@ -687,7 +687,7 @@ unpack_half_to_float_4chan_interleave_rev (exr_decode_pipeline_t* decode) int linc0; w = decode->channels[0].width; - h = decode->chunk_block.height; + h = decode->chunk.height; linc0 = decode->channels[0].user_line_stride; out0 = decode->channels[3].decode_to_ptr; @@ -728,7 +728,7 @@ unpack_16bit_4chan_planar (exr_decode_pipeline_t* decode) int linc0, linc1, linc2, linc3; w = decode->channels[0].width; - h = decode->chunk_block.height; + h = decode->chunk.height; linc0 = decode->channels[0].user_line_stride; linc1 = decode->channels[1].user_line_stride; linc2 = decode->channels[2].user_line_stride; @@ -784,7 +784,7 @@ unpack_half_to_float_4chan_planar (exr_decode_pipeline_t* decode) int linc0, linc1, linc2, linc3; w = decode->channels[0].width; - h = decode->chunk_block.height; + h = decode->chunk.height; linc0 = decode->channels[0].user_line_stride; linc1 = decode->channels[1].user_line_stride; linc2 = decode->channels[2].user_line_stride; @@ -831,7 +831,7 @@ unpack_16bit_4chan (exr_decode_pipeline_t* decode) int linc0, linc1, linc2, linc3; w = decode->channels[0].width; - h = decode->chunk_block.height; + h = decode->chunk.height; inc0 = decode->channels[0].user_pixel_stride; inc1 = decode->channels[1].user_pixel_stride; inc2 = decode->channels[2].user_pixel_stride; @@ -879,7 +879,7 @@ unpack_16bit (exr_decode_pipeline_t* decode) uint8_t* cdata; int w, h, pixincrement; - h = decode->chunk_block.height; + h = decode->chunk.height; for (int y = 0; y < h; ++y) { for (int c = 0; c < decode->channel_count; ++c) @@ -943,7 +943,7 @@ unpack_32bit (exr_decode_pipeline_t* decode) int64_t w, h, pixincrement; int chans = decode->channel_count; - h = (int64_t) decode->chunk_block.height; + h = (int64_t) decode->chunk.height; for (int64_t y = 0; y < h; ++y) { @@ -1123,9 +1123,9 @@ generic_unpack (exr_decode_pipeline_t* decode) uint8_t* cdata; int w, bpc, ubpc; - for (int y = 0; y < decode->chunk_block.height; ++y) + for (int y = 0; y < decode->chunk.height; ++y) { - int cury = y + decode->chunk_block.start_y; + int cury = y + decode->chunk.start_y; for (int c = 0; c < decode->channel_count; ++c) { @@ -1175,8 +1175,8 @@ generic_unpack_deep_pointers (exr_decode_pipeline_t* decode) void** pdata; int w, h, bpc, ubpc; - w = decode->chunk_block.width; - h = decode->chunk_block.height; + w = decode->chunk.width; + h = decode->chunk.height; for (int y = 0; y < h; ++y) { @@ -1242,8 +1242,8 @@ generic_unpack_deep (exr_decode_pipeline_t* decode) int w, h, bpc, ubpc; size_t totsamps = 0; - w = decode->chunk_block.width; - h = decode->chunk_block.height; + w = decode->chunk.width; + h = decode->chunk.height; for (int y = 0; y < h; ++y) { diff --git a/src/test/OpenEXRCoreTest/base_units.cpp b/src/test/OpenEXRCoreTest/base_units.cpp index a591e2b9ed..30047a40c9 100644 --- a/src/test/OpenEXRCoreTest/base_units.cpp +++ b/src/test/OpenEXRCoreTest/base_units.cpp @@ -93,15 +93,17 @@ testBaseErrors (const std::string& tempdir) EXRCORE_TEST( 0 == strcmp( exr_get_error_code_as_string(EXR_ERR_MISSING_REQ_ATTR), "EXR_ERR_MISSING_REQ_ATTR" ) ); EXRCORE_TEST( 0 == strcmp( exr_get_error_code_as_string(EXR_ERR_INVALID_ATTR), "EXR_ERR_INVALID_ATTR" ) ); EXRCORE_TEST( 0 == strcmp( exr_get_error_code_as_string(EXR_ERR_NO_ATTR_BY_NAME), "EXR_ERR_NO_ATTR_BY_NAME" ) ); - EXRCORE_TEST( 0 == strcmp( exr_get_error_code_as_string(EXR_ERR_BAD_CHUNK_DATA), "EXR_ERR_BAD_CHUNK_DATA" ) ); + EXRCORE_TEST( 0 == strcmp( exr_get_error_code_as_string(EXR_ERR_BAD_CHUNK_LEADER), "EXR_ERR_BAD_CHUNK_LEADER" ) ); + EXRCORE_TEST( 0 == strcmp( exr_get_error_code_as_string(EXR_ERR_CORRUPT_CHUNK), "EXR_ERR_CORRUPT_CHUNK" ) ); + EXRCORE_TEST( 0 == strcmp( exr_get_error_code_as_string(EXR_ERR_INVALID_SAMPLE_DATA), "EXR_ERR_INVALID_SAMPLE_DATA" ) ); EXRCORE_TEST( 0 == strcmp( exr_get_error_code_as_string(EXR_ERR_ATTR_TYPE_MISMATCH), "EXR_ERR_ATTR_TYPE_MISMATCH" ) ); EXRCORE_TEST( 0 == strcmp( exr_get_error_code_as_string(EXR_ERR_ATTR_SIZE_MISMATCH), "EXR_ERR_ATTR_SIZE_MISMATCH" ) ); EXRCORE_TEST( 0 == strcmp( exr_get_error_code_as_string(EXR_ERR_SCAN_TILE_MIXEDAPI), "EXR_ERR_SCAN_TILE_MIXEDAPI" ) ); EXRCORE_TEST( 0 == strcmp( exr_get_error_code_as_string(EXR_ERR_TILE_SCAN_MIXEDAPI), "EXR_ERR_TILE_SCAN_MIXEDAPI" ) ); EXRCORE_TEST( 0 == strcmp( exr_get_error_code_as_string(EXR_ERR_MODIFY_SIZE_CHANGE), "EXR_ERR_MODIFY_SIZE_CHANGE" ) ); EXRCORE_TEST( 0 == strcmp( exr_get_error_code_as_string(EXR_ERR_ALREADY_WROTE_ATTRS), "EXR_ERR_ALREADY_WROTE_ATTRS" ) ); - EXRCORE_TEST( 0 == strcmp( exr_get_error_code_as_string(EXR_ERR_PART_NOT_READY), "EXR_ERR_PART_NOT_READY" ) ); - EXRCORE_TEST( 0 == strcmp( exr_get_error_code_as_string(EXR_ERR_CHUNK_NOT_READY), "EXR_ERR_CHUNK_NOT_READY" ) ); + EXRCORE_TEST( 0 == strcmp( exr_get_error_code_as_string(EXR_ERR_INCORRECT_PART), "EXR_ERR_INCORRECT_PART" ) ); + EXRCORE_TEST( 0 == strcmp( exr_get_error_code_as_string(EXR_ERR_INCORRECT_CHUNK), "EXR_ERR_INCORRECT_CHUNK" ) ); EXRCORE_TEST( 0 == strcmp( exr_get_error_code_as_string(EXR_ERR_USE_SCAN_DEEP_WRITE), "EXR_ERR_USE_SCAN_DEEP_WRITE" ) ); EXRCORE_TEST( 0 == strcmp( exr_get_error_code_as_string(EXR_ERR_USE_TILE_DEEP_WRITE), "EXR_ERR_USE_TILE_DEEP_WRITE" ) ); EXRCORE_TEST( 0 == strcmp( exr_get_error_code_as_string(EXR_ERR_USE_SCAN_NONDEEP_WRITE), "EXR_ERR_USE_SCAN_NONDEEP_WRITE" ) ); diff --git a/src/test/OpenEXRCoreTest/compression.cpp b/src/test/OpenEXRCoreTest/compression.cpp index 6a725199f6..5d408ca7cb 100644 --- a/src/test/OpenEXRCoreTest/compression.cpp +++ b/src/test/OpenEXRCoreTest/compression.cpp @@ -608,18 +608,18 @@ fill_pointers ( static void doEncodeScan (exr_context_t f, pixels& p, int xs, int ys) { - int32_t scansperchunk = 0; - int y, starty, endy; - exr_chunk_block_info_t cinfo; - exr_encode_pipeline_t encoder; - bool first = true; + int32_t scansperchunk = 0; + int y, starty, endy; + exr_chunk_info_t cinfo; + exr_encode_pipeline_t encoder; + bool first = true; EXRCORE_TEST_RVAL (exr_get_scanlines_per_chunk (f, 0, &scansperchunk)); starty = IMG_DATA_Y * ys; endy = starty + IMG_HEIGHT * ys; for (y = starty; y < endy; y += scansperchunk) { - EXRCORE_TEST_RVAL (exr_write_scanline_block_info (f, 0, y, &cinfo)); + EXRCORE_TEST_RVAL (exr_write_scanline_chunk_info (f, 0, y, &cinfo)); if (first) { EXRCORE_TEST_RVAL ( @@ -675,14 +675,14 @@ doEncodeScan (exr_context_t f, pixels& p, int xs, int ys) static void doEncodeTile (exr_context_t f, pixels& p, int xs, int ys) { - int32_t tlevx, tlevy; - int32_t tilew, tileh; - int32_t tilex, tiley; - int y, endy; - int x, endx; - exr_chunk_block_info_t cinfo; - exr_encode_pipeline_t encoder; - bool first = true; + int32_t tlevx, tlevy; + int32_t tilew, tileh; + int32_t tilex, tiley; + int y, endy; + int x, endx; + exr_chunk_info_t cinfo; + exr_encode_pipeline_t encoder; + bool first = true; EXRCORE_TEST (xs == 1 && ys == 1); EXRCORE_TEST_RVAL (exr_get_tile_levels (f, 0, &tlevx, &tlevy)); @@ -703,7 +703,7 @@ doEncodeTile (exr_context_t f, pixels& p, int xs, int ys) for (; x < endx; x += tilew, ++tilex) { EXRCORE_TEST_RVAL ( - exr_write_tile_block_info (f, 0, tilex, tiley, 0, 0, &cinfo)); + exr_write_tile_chunk_info (f, 0, tilex, tiley, 0, 0, &cinfo)); if (first) { EXRCORE_TEST_RVAL ( @@ -752,11 +752,11 @@ doEncodeTile (exr_context_t f, pixels& p, int xs, int ys) static void doDecodeScan (exr_context_t f, pixels& p, int xs, int ys) { - exr_chunk_block_info_t cinfo; - exr_decode_pipeline_t decoder; - int32_t scansperchunk; - exr_attr_box2i_t dw; - bool first = true; + exr_chunk_info_t cinfo; + exr_decode_pipeline_t decoder; + int32_t scansperchunk; + exr_attr_box2i_t dw; + bool first = true; EXRCORE_TEST_RVAL (exr_get_data_window (f, 0, &dw)); EXRCORE_TEST (dw.min.x == IMG_DATA_X * xs); @@ -773,7 +773,7 @@ doDecodeScan (exr_context_t f, pixels& p, int xs, int ys) //const uint8_t* tmp; for (int y = dw.min.y; y <= dw.max.y; y += scansperchunk) { - EXRCORE_TEST_RVAL (exr_read_scanline_block_info (f, 0, y, &cinfo)); + EXRCORE_TEST_RVAL (exr_read_scanline_chunk_info (f, 0, y, &cinfo)); if (first) { EXRCORE_TEST_RVAL ( @@ -828,14 +828,14 @@ doDecodeScan (exr_context_t f, pixels& p, int xs, int ys) static void doDecodeTile (exr_context_t f, pixels& p, int xs, int ys) { - int32_t tlevx, tlevy; - int32_t tilew, tileh; - int32_t tilex, tiley; - int y, endy; - int x, endx; - exr_chunk_block_info_t cinfo; - exr_decode_pipeline_t decoder; - bool first = true; + int32_t tlevx, tlevy; + int32_t tilew, tileh; + int32_t tilex, tiley; + int y, endy; + int x, endx; + exr_chunk_info_t cinfo; + exr_decode_pipeline_t decoder; + bool first = true; EXRCORE_TEST (xs == 1 && ys == 1); EXRCORE_TEST_RVAL (exr_get_tile_levels (f, 0, &tlevx, &tlevy)); @@ -856,7 +856,7 @@ doDecodeTile (exr_context_t f, pixels& p, int xs, int ys) for (; x < endx; x += tilew, ++tilex) { EXRCORE_TEST_RVAL ( - exr_read_tile_block_info (f, 0, tilex, tiley, 0, 0, &cinfo)); + exr_read_tile_chunk_info (f, 0, tilex, tiley, 0, 0, &cinfo)); if (first) { EXRCORE_TEST_RVAL ( diff --git a/src/test/OpenEXRCoreTest/deep.cpp b/src/test/OpenEXRCoreTest/deep.cpp index 4850fba664..0068304da3 100644 --- a/src/test/OpenEXRCoreTest/deep.cpp +++ b/src/test/OpenEXRCoreTest/deep.cpp @@ -418,7 +418,7 @@ testReadDeep (const std::string& tempdir) Compression comps[] = { NO_COMPRESSION, RLE_COMPRESSION, ZIPS_COMPRESSION }; std::vector packed; std::vector sampdata; - exr_chunk_block_info_t cinfo; + exr_chunk_info_t cinfo; for (int c = 0; chancounts[c] > 0; ++c) { @@ -437,7 +437,7 @@ testReadDeep (const std::string& tempdir) EXRCORE_TEST_RVAL (exr_start_read (&f, fn.c_str (), &cinit)); - EXRCORE_TEST_RVAL (exr_read_scanline_block_info (f, 0, minY + height / 2, &cinfo)); + EXRCORE_TEST_RVAL (exr_read_scanline_chunk_info (f, 0, minY + height / 2, &cinfo)); packed.resize(cinfo.packed_size); sampdata.resize(cinfo.sample_count_table_size); EXRCORE_TEST_RVAL (exr_read_deep_chunk (f, 0, &cinfo, &packed[0], &sampdata[0])); @@ -456,7 +456,7 @@ testReadDeep (const std::string& tempdir) EXRCORE_TEST(packed.size() == (sampcount[N-1]) * bps); } - EXRCORE_TEST_RVAL (exr_read_scanline_block_info (f, 0, minY + height / 4, &cinfo)); + EXRCORE_TEST_RVAL (exr_read_scanline_chunk_info (f, 0, minY + height / 4, &cinfo)); packed.resize(cinfo.packed_size); sampdata.resize(cinfo.sample_count_table_size); // we support reading the two bits separately @@ -468,7 +468,7 @@ testReadDeep (const std::string& tempdir) generateRandomTileFile (fn, chancounts[c], comps[cp]); EXRCORE_TEST_RVAL (exr_start_read (&f, fn.c_str (), &cinit)); - EXRCORE_TEST_RVAL (exr_read_tile_block_info (f, 0, 0, 1, 0, 0, &cinfo)); + EXRCORE_TEST_RVAL (exr_read_tile_chunk_info (f, 0, 0, 1, 0, 0, &cinfo)); packed.resize(cinfo.packed_size); sampdata.resize(cinfo.sample_count_table_size); EXRCORE_TEST_RVAL (exr_read_deep_chunk (f, 0, &cinfo, &packed[0], &sampdata[0])); diff --git a/src/test/OpenEXRCoreTest/general_attr.cpp b/src/test/OpenEXRCoreTest/general_attr.cpp index 7ed9b2977d..57607a0f54 100644 --- a/src/test/OpenEXRCoreTest/general_attr.cpp +++ b/src/test/OpenEXRCoreTest/general_attr.cpp @@ -854,7 +854,7 @@ test_unpack (exr_context_t, const void*, int32_t, int32_t* ns, void** ptr) if (ns) *ns = 4; static uint8_t data4[] = { 0xDE, 0xAD, 0xBE, 0xEF }; if (ptr) *ptr = data4; - if (s_unpack_fail > 0) return EXR_ERR_BAD_CHUNK_DATA; + if (s_unpack_fail > 0) return EXR_ERR_CORRUPT_CHUNK; return EXR_ERR_SUCCESS; } @@ -864,7 +864,7 @@ test_pack (exr_context_t, const void*, int32_t, int32_t* nsize, void* ptr) { *nsize = 1; if (ptr) *((char*) ptr) = 'E'; - if (s_pack_fail == 1) return EXR_ERR_BAD_CHUNK_DATA; + if (s_pack_fail == 1) return EXR_ERR_CORRUPT_CHUNK; if (s_pack_fail > 0) --s_pack_fail; return EXR_ERR_SUCCESS; } @@ -981,7 +981,7 @@ testAttrHandler (const std::string& tempdir) s_unpack_fail = 1; EXRCORE_TEST_RVAL_FAIL ( - EXR_ERR_BAD_CHUNK_DATA, + EXR_ERR_CORRUPT_CHUNK, exr_attr_opaquedata_unpack (f, bar->opaque, &nsz, &packed)); s_unpack_fail = 0; EXRCORE_TEST_RVAL ( @@ -1001,11 +1001,11 @@ testAttrHandler (const std::string& tempdir) exr_attr_opaquedata_set_unpacked (f, foo->opaque, data4, 4)); s_pack_fail = 1; EXRCORE_TEST_RVAL_FAIL ( - EXR_ERR_BAD_CHUNK_DATA, + EXR_ERR_CORRUPT_CHUNK, exr_attr_opaquedata_pack (f, foo->opaque, &nsz, &packed)); s_pack_fail = 2; EXRCORE_TEST_RVAL_FAIL ( - EXR_ERR_BAD_CHUNK_DATA, + EXR_ERR_CORRUPT_CHUNK, exr_attr_opaquedata_pack (f, foo->opaque, &nsz, &packed)); s_pack_fail = 0; EXRCORE_TEST_RVAL_FAIL_MALLOC ( diff --git a/src/test/OpenEXRCoreTest/performance.cpp b/src/test/OpenEXRCoreTest/performance.cpp index 9c91080baf..391f10106b 100644 --- a/src/test/OpenEXRCoreTest/performance.cpp +++ b/src/test/OpenEXRCoreTest/performance.cpp @@ -44,9 +44,9 @@ class CoreReadTask : public Task {} void execute () override { - exr_chunk_block_info_t cinfo = { 0 }; - exr_decode_pipeline_t chunk; - exr_result_t rv = exr_read_scanline_block_info (_f, 0, _y, &cinfo); + exr_chunk_info_t cinfo = { 0 }; + exr_decode_pipeline_t chunk; + exr_result_t rv = exr_read_scanline_chunk_info (_f, 0, _y, &cinfo); if (rv == EXR_ERR_SUCCESS) rv = exr_decoding_initialize (_f, 0, &cinfo, &chunk); if (rv == EXR_ERR_SUCCESS) @@ -143,11 +143,11 @@ read_pixels_raw (exr_context_t f) ret += linesread * w; } #else - exr_chunk_block_info_t cinfo = { 0 }; - exr_decode_pipeline_t chunk = { 0 }; + exr_chunk_info_t cinfo = { 0 }; + exr_decode_pipeline_t chunk = { 0 }; for (int y = dw.min.y; y <= dw.max.y;) { - exr_result_t rv = exr_read_scanline_block_info (f, 0, y, &cinfo); + exr_result_t rv = exr_read_scanline_chunk_info (f, 0, y, &cinfo); if (rv != EXR_ERR_SUCCESS) throw std::runtime_error ("unable to init scanline block info"); diff --git a/src/test/OpenEXRCoreTest/read.cpp b/src/test/OpenEXRCoreTest/read.cpp index bd621a2364..7fcb8ca8ba 100644 --- a/src/test/OpenEXRCoreTest/read.cpp +++ b/src/test/OpenEXRCoreTest/read.cpp @@ -251,31 +251,31 @@ testReadScans (const std::string& tempdir) EXR_ERR_INVALID_ARGUMENT, exr_get_data_window (f, 0, NULL)); EXRCORE_TEST_RVAL (exr_get_data_window (f, 0, &dw)); - exr_chunk_block_info_t cinfo; + exr_chunk_info_t cinfo; EXRCORE_TEST_RVAL_FAIL ( EXR_ERR_MISSING_CONTEXT_ARG, - exr_read_scanline_block_info (NULL, 0, 42, &cinfo)); + exr_read_scanline_chunk_info (NULL, 0, 42, &cinfo)); EXRCORE_TEST_RVAL_FAIL ( EXR_ERR_ARGUMENT_OUT_OF_RANGE, - exr_read_scanline_block_info (f, -1, 42, &cinfo)); + exr_read_scanline_chunk_info (f, -1, 42, &cinfo)); EXRCORE_TEST_RVAL_FAIL ( EXR_ERR_ARGUMENT_OUT_OF_RANGE, - exr_read_scanline_block_info (f, 1, 42, &cinfo)); + exr_read_scanline_chunk_info (f, 1, 42, &cinfo)); EXRCORE_TEST_RVAL_FAIL ( EXR_ERR_INVALID_ARGUMENT, - exr_read_scanline_block_info (f, 0, 42, NULL)); + exr_read_scanline_chunk_info (f, 0, 42, NULL)); EXRCORE_TEST_RVAL_FAIL ( EXR_ERR_TILE_SCAN_MIXEDAPI, - exr_read_tile_block_info (f, 0, 4, 2, 0, 0, &cinfo)); + exr_read_tile_chunk_info (f, 0, 4, 2, 0, 0, &cinfo)); EXRCORE_TEST_RVAL_FAIL ( EXR_ERR_INVALID_ARGUMENT, - exr_read_scanline_block_info (f, 0, dw.min.y - 1, &cinfo)); + exr_read_scanline_chunk_info (f, 0, dw.min.y - 1, &cinfo)); EXRCORE_TEST_RVAL_FAIL ( EXR_ERR_INVALID_ARGUMENT, - exr_read_scanline_block_info (f, 0, dw.max.y + 1, &cinfo)); - EXRCORE_TEST_RVAL (exr_read_scanline_block_info (f, 0, dw.min.y, &cinfo)); + exr_read_scanline_chunk_info (f, 0, dw.max.y + 1, &cinfo)); + EXRCORE_TEST_RVAL (exr_read_scanline_chunk_info (f, 0, dw.min.y, &cinfo)); uint64_t pchunksz = 0; EXRCORE_TEST_RVAL (exr_get_chunk_unpacked_size (f, 0, &pchunksz)); @@ -434,38 +434,38 @@ testReadTiles (const std::string& tempdir) EXRCORE_TEST_RVAL (exr_get_tile_sizes (f, 0, 0, 0, NULL, &levelsy)); EXRCORE_TEST (levelsy == 24); - exr_chunk_block_info_t cinfo; + exr_chunk_info_t cinfo; EXRCORE_TEST_RVAL_FAIL ( EXR_ERR_SCAN_TILE_MIXEDAPI, - exr_read_scanline_block_info (f, 0, 42, &cinfo)); + exr_read_scanline_chunk_info (f, 0, 42, &cinfo)); EXRCORE_TEST_RVAL_FAIL ( EXR_ERR_MISSING_CONTEXT_ARG, - exr_read_tile_block_info (NULL, 0, 4, 2, 0, 0, &cinfo)); + exr_read_tile_chunk_info (NULL, 0, 4, 2, 0, 0, &cinfo)); EXRCORE_TEST_RVAL_FAIL ( EXR_ERR_ARGUMENT_OUT_OF_RANGE, - exr_read_tile_block_info (f, -1, 4, 2, 0, 0, &cinfo)); + exr_read_tile_chunk_info (f, -1, 4, 2, 0, 0, &cinfo)); EXRCORE_TEST_RVAL_FAIL ( EXR_ERR_ARGUMENT_OUT_OF_RANGE, - exr_read_tile_block_info (f, 1, 4, 2, 0, 0, &cinfo)); + exr_read_tile_chunk_info (f, 1, 4, 2, 0, 0, &cinfo)); EXRCORE_TEST_RVAL_FAIL ( EXR_ERR_INVALID_ARGUMENT, - exr_read_tile_block_info (f, 0, 4, 2, 0, 0, NULL)); + exr_read_tile_chunk_info (f, 0, 4, 2, 0, 0, NULL)); EXRCORE_TEST_RVAL_FAIL ( EXR_ERR_INVALID_ARGUMENT, - exr_read_tile_block_info (f, 0, 4, 2, 0, -1, &cinfo)); + exr_read_tile_chunk_info (f, 0, 4, 2, 0, -1, &cinfo)); EXRCORE_TEST_RVAL_FAIL ( EXR_ERR_INVALID_ARGUMENT, - exr_read_tile_block_info (f, 0, 4, 2, -1, 0, &cinfo)); + exr_read_tile_chunk_info (f, 0, 4, 2, -1, 0, &cinfo)); EXRCORE_TEST_RVAL_FAIL ( EXR_ERR_INVALID_ARGUMENT, - exr_read_tile_block_info (f, 0, 4, -2, 0, 0, &cinfo)); + exr_read_tile_chunk_info (f, 0, 4, -2, 0, 0, &cinfo)); EXRCORE_TEST_RVAL_FAIL ( EXR_ERR_INVALID_ARGUMENT, - exr_read_tile_block_info (f, 0, -4, 2, 0, 0, &cinfo)); + exr_read_tile_chunk_info (f, 0, -4, 2, 0, 0, &cinfo)); // actually read a tile... - EXRCORE_TEST_RVAL (exr_read_tile_block_info (f, 0, 4, 2, 0, 0, &cinfo)); + EXRCORE_TEST_RVAL (exr_read_tile_chunk_info (f, 0, 4, 2, 0, 0, &cinfo)); uint64_t pchunksz = 0; EXRCORE_TEST_RVAL (exr_get_chunk_unpacked_size (f, 0, &pchunksz)); EXRCORE_TEST (cinfo.type == EXR_STORAGE_TILED); @@ -544,8 +544,8 @@ testReadUnpack (const std::string& tempdir) fn += "v1.7.test.tiled.exr"; EXRCORE_TEST_RVAL (exr_start_read (&f, fn.c_str (), &cinit)); - exr_chunk_block_info_t cinfo; - EXRCORE_TEST_RVAL (exr_read_tile_block_info (f, 0, 4, 2, 0, 0, &cinfo)); + exr_chunk_info_t cinfo; + EXRCORE_TEST_RVAL (exr_read_tile_chunk_info (f, 0, 4, 2, 0, 0, &cinfo)); { exr_decode_pipeline_t decoder; diff --git a/src/test/OpenEXRCoreTest/write.cpp b/src/test/OpenEXRCoreTest/write.cpp index c6951abadf..ae73f32085 100644 --- a/src/test/OpenEXRCoreTest/write.cpp +++ b/src/test/OpenEXRCoreTest/write.cpp @@ -81,10 +81,10 @@ testStartWriteScan (const std::string& tempdir) EXRCORE_TEST (partidx == 1); partidx = 0; - exr_chunk_block_info_t cinfo; + exr_chunk_info_t cinfo; EXRCORE_TEST_RVAL_FAIL ( EXR_ERR_NOT_OPEN_READ, - exr_read_scanline_block_info (outf, partidx, 42, &cinfo)); + exr_read_scanline_chunk_info (outf, partidx, 42, &cinfo)); const char* partname; EXRCORE_TEST_RVAL_FAIL ( @@ -185,10 +185,10 @@ testStartWriteTile (const std::string& tempdir) EXRCORE_TEST (partidx == 1); partidx = 0; - exr_chunk_block_info_t cinfo; + exr_chunk_info_t cinfo; EXRCORE_TEST_RVAL_FAIL ( EXR_ERR_NOT_OPEN_READ, - exr_read_scanline_block_info (outf, partidx, 42, &cinfo)); + exr_read_scanline_chunk_info (outf, partidx, 42, &cinfo)); const char* partname; EXRCORE_TEST_RVAL_FAIL ( @@ -282,10 +282,10 @@ testWriteBaseHeader (const std::string& tempdir) EXRCORE_TEST (partidx == 1); partidx = 0; - exr_chunk_block_info_t cinfo; + exr_chunk_info_t cinfo; EXRCORE_TEST_RVAL_FAIL ( EXR_ERR_NOT_OPEN_READ, - exr_read_scanline_block_info (outf, partidx, 42, &cinfo)); + exr_read_scanline_chunk_info (outf, partidx, 42, &cinfo)); const char* partname; EXRCORE_TEST_RVAL_FAIL ( @@ -1081,8 +1081,8 @@ testWriteAttrs (const std::string& tempdir) } EXRCORE_TEST_RVAL (exr_write_header (outf)); - exr_chunk_block_info_t cinfo; - EXRCORE_TEST_RVAL (exr_write_scanline_block_info (outf, 0, 0, &cinfo)); + exr_chunk_info_t cinfo; + EXRCORE_TEST_RVAL (exr_write_scanline_chunk_info (outf, 0, 0, &cinfo)); exr_encode_pipeline_t encoder; EXRCORE_TEST_RVAL (exr_encoding_initialize (outf, 0, &cinfo, &encoder)); const uint8_t rgb[] = { 0, 0, 0, 0, 0, 0 }; @@ -1170,9 +1170,9 @@ testWriteTiles (const std::string& tempdir) tx = 0; for (int32_t x = dw.min.x; x <= dw.max.x; x += levelsx) { - exr_chunk_block_info_t cinfo; + exr_chunk_info_t cinfo; EXRCORE_TEST_RVAL ( - exr_read_tile_block_info (f, 0, tx, ty, 0, 0, &cinfo)); + exr_read_tile_chunk_info (f, 0, tx, ty, 0, 0, &cinfo)); if (cmemsize < cinfo.packed_size) { if (cmem) free (cmem);