From 2c458f33048face8681de7ae335118b9c2fc8038 Mon Sep 17 00:00:00 2001 From: Kimball Thurston Date: Sun, 27 Jun 2021 14:10:22 +1200 Subject: [PATCH] Use same struct scheme as box from imath for consistency Initially we did this differently so it was obvious it didn't have the other functionality, but by having the same nested scheme of a box having 2 vecs, enables us to add templated sfinae constructors to auto convert the C type into c++ instead of just having to reinterpret cast Signed-off-by: Kimball Thurston --- src/lib/OpenEXRCore/chunk.c | 98 ++++++++++++------------ src/lib/OpenEXRCore/debug.c | 20 ++--- src/lib/OpenEXRCore/internal_structs.c | 8 +- src/lib/OpenEXRCore/openexr_attr.h | 32 ++++---- src/lib/OpenEXRCore/parse_header.c | 27 +++---- src/lib/OpenEXRCore/part_attr.c | 2 +- src/lib/OpenEXRCore/validation.c | 46 +++++------ src/test/OpenEXRCoreTest/compression.cpp | 20 ++--- src/test/OpenEXRCoreTest/performance.cpp | 12 +-- src/test/OpenEXRCoreTest/read.cpp | 6 +- src/test/OpenEXRCoreTest/write.cpp | 20 ++--- 11 files changed, 142 insertions(+), 149 deletions(-) diff --git a/src/lib/OpenEXRCore/chunk.c b/src/lib/OpenEXRCore/chunk.c index f8617003a9..2c97f3d542 100644 --- a/src/lib/OpenEXRCore/chunk.c +++ b/src/lib/OpenEXRCore/chunk.c @@ -168,29 +168,29 @@ exr_read_scanline_block_info ( } dw = part->data_window; - if (y < dw.y_min || y > dw.y_max) + if (y < dw.min.y || y > dw.max.y) { return pctxt->print_error ( pctxt, EXR_ERR_INVALID_ARGUMENT, "Invalid request for scanline %d outside range of data window (%d - %d)", y, - dw.y_min, - dw.y_max); + dw.min.y, + dw.max.y); } lpc = part->lines_per_chunk; - cidx = (y - dw.y_min); + cidx = (y - dw.min.y); if (lpc > 1) cidx /= lpc; if (part->lineorder == EXR_LINEORDER_DECREASING_Y) { cidx = part->chunk_count - (cidx + 1); - miny = dw.y_max - (cidx + 1) * lpc; + miny = dw.max.y - (cidx + 1) * lpc; } else { - miny = cidx * lpc + dw.y_min; + miny = cidx * lpc + dw.min.y; } if (cidx < 0 || cidx >= part->chunk_count) @@ -207,18 +207,18 @@ exr_read_scanline_block_info ( cinfo->idx = cidx; cinfo->type = (uint8_t) part->storage_mode; cinfo->compression = (uint8_t) part->comp_type; - cinfo->start_x = dw.x_min; + cinfo->start_x = dw.min.x; cinfo->start_y = miny; - cinfo->width = dw.x_max - dw.x_min + 1; + cinfo->width = dw.max.x - dw.min.x + 1; cinfo->height = lpc; - if (miny < dw.y_min) + if (miny < dw.min.y) { - cinfo->start_y = dw.y_min; - cinfo->height -= (dw.y_min - miny); + cinfo->start_y = dw.min.y; + cinfo->height -= (dw.min.y - miny); } - else if ((miny + lpc) > dw.y_max) + else if ((miny + lpc) > dw.max.y) { - cinfo->height = (dw.y_max - miny + 1); + cinfo->height = (dw.max.y - miny + 1); } cinfo->level_x = 0; cinfo->level_y = 0; @@ -512,20 +512,20 @@ exr_read_tile_block_info ( if (tiledesc->y_size < (uint32_t) tileh) tileh = (int) tiledesc->y_size; if (((int64_t) (tilex) * (int64_t) (tilew) + (int64_t) (tilew) + - (int64_t) (part->data_window.x_min) - 1) > - (int64_t) (part->data_window.x_max)) + (int64_t) (part->data_window.min.x) - 1) > + (int64_t) (part->data_window.max.x)) { - int64_t sz = (int64_t) (part->data_window.x_max) - - (int64_t) (part->data_window.x_min) + 1; + int64_t sz = (int64_t) (part->data_window.max.x) - + (int64_t) (part->data_window.min.x) + 1; tilew = (int) (sz - ((int64_t) (tilex) * (int64_t) (tilew))); } if (((int64_t) (tiley) * (int64_t) (tileh) + (int64_t) (tileh) + - (int64_t) (part->data_window.y_min) - 1) > - (int64_t) (part->data_window.y_max)) + (int64_t) (part->data_window.min.y) - 1) > + (int64_t) (part->data_window.max.y)) { - int64_t sz = (int64_t) (part->data_window.y_max) - - (int64_t) (part->data_window.y_min) + 1; + int64_t sz = (int64_t) (part->data_window.max.y) - + (int64_t) (part->data_window.min.y) + 1; tileh = (int) (sz - ((int64_t) (tiley) * (int64_t) (tileh))); } @@ -960,29 +960,29 @@ write_scan_chunk ( (uint64_t) sample_data_size, sample_data); - if (y < part->data_window.y_min || y > part->data_window.y_max) + if (y < part->data_window.min.y || y > part->data_window.max.y) { return pctxt->print_error ( pctxt, EXR_ERR_INVALID_ARGUMENT, "Invalid attempt to write scanlines starting at %d outside range of data window (%d - %d)", y, - part->data_window.y_min, - part->data_window.y_max); + part->data_window.min.y, + part->data_window.max.y); } lpc = part->lines_per_chunk; - cidx = (y - part->data_window.y_min); + cidx = (y - part->data_window.min.y); if (lpc > 1) cidx /= lpc; if (part->lineorder == EXR_LINEORDER_DECREASING_Y) { cidx = part->chunk_count - (cidx + 1); - miny = part->data_window.y_max - (cidx + 1) * lpc; + miny = part->data_window.max.y - (cidx + 1) * lpc; } else { - miny = cidx * lpc + part->data_window.y_min; + miny = cidx * lpc + part->data_window.min.y; } if (y != miny) @@ -1132,29 +1132,29 @@ exr_write_scanline_block_info ( } dw = part->data_window; - if (y < dw.y_min || y > dw.y_max) + if (y < dw.min.y || y > dw.max.y) { return EXR_UNLOCK_AND_RETURN_PCTXT (pctxt->print_error ( pctxt, EXR_ERR_INVALID_ARGUMENT, "Invalid request for scanline %d outside range of data window (%d - %d)", y, - dw.y_min, - dw.y_max)); + dw.min.y, + dw.max.y)); } lpc = part->lines_per_chunk; - cidx = (y - dw.y_min); + cidx = (y - dw.min.y); if (lpc > 1) cidx /= lpc; if (part->lineorder == EXR_LINEORDER_DECREASING_Y) { cidx = part->chunk_count - (cidx + 1); - miny = dw.y_max - (cidx + 1) * lpc; + miny = dw.max.y - (cidx + 1) * lpc; } else { - miny = cidx * lpc + dw.y_min; + miny = cidx * lpc + dw.min.y; } if (cidx < 0 || cidx >= part->chunk_count) @@ -1172,18 +1172,18 @@ exr_write_scanline_block_info ( cinfo->idx = cidx; cinfo->type = (uint8_t) part->storage_mode; cinfo->compression = (uint8_t) part->comp_type; - cinfo->start_x = dw.x_min; + cinfo->start_x = dw.min.x; cinfo->start_y = miny; - cinfo->width = dw.x_max - dw.x_min + 1; + cinfo->width = dw.max.x - dw.min.x + 1; cinfo->height = lpc; - if (miny < dw.y_min) + if (miny < dw.min.y) { - cinfo->start_y = dw.y_min; - cinfo->height -= (dw.y_min - miny); + cinfo->start_y = dw.min.y; + cinfo->height -= (dw.min.y - miny); } - else if ((miny + lpc) > dw.y_max) + else if ((miny + lpc) > dw.max.y) { - cinfo->height = (dw.y_max - miny + 1); + cinfo->height = (dw.max.y - miny + 1); } cinfo->level_x = 0; cinfo->level_y = 0; @@ -1259,20 +1259,20 @@ exr_write_tile_block_info ( if (tiledesc->y_size < (uint32_t) tileh) tileh = (int) tiledesc->y_size; if (((int64_t) (tilex) * (int64_t) (tilew) + (int64_t) (tilew) + - (int64_t) (part->data_window.x_min) - 1) > - (int64_t) (part->data_window.x_max)) + (int64_t) (part->data_window.min.x) - 1) > + (int64_t) (part->data_window.max.x)) { - int64_t sz = (int64_t) (part->data_window.x_max) - - (int64_t) (part->data_window.x_min) + 1; + int64_t sz = (int64_t) (part->data_window.max.x) - + (int64_t) (part->data_window.min.x) + 1; tilew = (int) (sz - ((int64_t) (tilex) * (int64_t) (tilew))); } if (((int64_t) (tiley) * (int64_t) (tileh) + (int64_t) (tileh) + - (int64_t) (part->data_window.y_min) - 1) > - (int64_t) (part->data_window.y_max)) + (int64_t) (part->data_window.min.y) - 1) > + (int64_t) (part->data_window.max.y)) { - int64_t sz = (int64_t) (part->data_window.y_max) - - (int64_t) (part->data_window.y_min) + 1; + int64_t sz = (int64_t) (part->data_window.max.y) - + (int64_t) (part->data_window.min.y) + 1; tileh = (int) (sz - ((int64_t) (tiley) * (int64_t) (tileh))); } @@ -1656,7 +1656,7 @@ internal_validate_next_chunk ( else { lpc = part->lines_per_chunk; - cidx = (encode->chunk_block.start_y - part->data_window.y_min); + cidx = (encode->chunk_block.start_y - part->data_window.min.y); if (lpc > 1) cidx /= lpc; if (part->lineorder == EXR_LINEORDER_DECREASING_Y) diff --git a/src/lib/OpenEXRCore/debug.c b/src/lib/OpenEXRCore/debug.c index 44f6438c99..459a33d91c 100644 --- a/src/lib/OpenEXRCore/debug.c +++ b/src/lib/OpenEXRCore/debug.c @@ -24,20 +24,20 @@ print_attr (const exr_attribute_t* a, int verbose) case EXR_ATTR_BOX2I: printf ( "[ %d, %d - %d %d ] %d x %d", - a->box2i->x_min, - a->box2i->y_min, - a->box2i->x_max, - a->box2i->y_max, - a->box2i->x_max - a->box2i->x_min + 1, - a->box2i->y_max - a->box2i->y_min + 1); + a->box2i->min.x, + a->box2i->min.y, + a->box2i->max.x, + a->box2i->max.y, + a->box2i->max.x - a->box2i->min.x + 1, + a->box2i->max.y - a->box2i->min.y + 1); break; case EXR_ATTR_BOX2F: printf ( "[ %g, %g - %g %g ]", - (double) a->box2f->x_min, - (double) a->box2f->y_min, - (double) a->box2f->x_max, - (double) a->box2f->y_max); + (double) a->box2f->min.x, + (double) a->box2f->min.y, + (double) a->box2f->max.x, + (double) a->box2f->max.y); break; case EXR_ATTR_CHLIST: printf ("%d channels\n", a->chlist->num_channels); diff --git a/src/lib/OpenEXRCore/internal_structs.c b/src/lib/OpenEXRCore/internal_structs.c index 6c2160c238..580bc739af 100644 --- a/src/lib/OpenEXRCore/internal_structs.c +++ b/src/lib/OpenEXRCore/internal_structs.c @@ -243,10 +243,10 @@ internal_exr_add_part ( /* assign appropriately invalid values */ part->storage_mode = EXR_STORAGE_LAST_TYPE; - part->data_window.x_max = -1; - part->data_window.y_max = -1; - part->display_window.x_max = -1; - part->display_window.y_max = -1; + part->data_window.max.x = -1; + part->data_window.max.y = -1; + part->display_window.max.x = -1; + part->display_window.max.y = -1; part->chunk_count = -1; /* put it into the part table */ diff --git a/src/lib/OpenEXRCore/openexr_attr.h b/src/lib/OpenEXRCore/openexr_attr.h index ca14c4c1b1..a12a251709 100644 --- a/src/lib/OpenEXRCore/openexr_attr.h +++ b/src/lib/OpenEXRCore/openexr_attr.h @@ -106,24 +106,6 @@ typedef enum * structs to be tightly packed */ #pragma pack(push, 1) -/** @brief struct to hold an integer box / region definition */ -typedef struct -{ - int32_t x_min; - int32_t y_min; - int32_t x_max; - int32_t y_max; -} exr_attr_box2i_t; - -/** @brief struct to hold a floating-point box / region definition */ -typedef struct -{ - float x_min; - float y_min; - float x_max; - float y_max; -} exr_attr_box2f_t; - /** @brief struct to hold color chromaticities to interpret the tristimulus color values in the image data */ typedef struct { @@ -265,6 +247,20 @@ typedef struct }; } exr_attr_v3d_t; +/** @brief struct to hold an integer box / region definition */ +typedef struct +{ + exr_attr_v2i_t min; + exr_attr_v2i_t max; +} exr_attr_box2i_t; + +/** @brief struct to hold a floating-point box / region definition */ +typedef struct +{ + exr_attr_v2f_t min; + exr_attr_v2f_t max; +} exr_attr_box2f_t; + /** @brief Struct holding base tiledesc attribute type defined in spec * * NB: this is in a tightly packed area so it can be read directly, be diff --git a/src/lib/OpenEXRCore/parse_header.c b/src/lib/OpenEXRCore/parse_header.c index 3692d159fa..e4996d1fb3 100644 --- a/src/lib/OpenEXRCore/parse_header.c +++ b/src/lib/OpenEXRCore/parse_header.c @@ -1971,8 +1971,8 @@ internal_exr_compute_tile_information ( int32_t* levszX = NULL; int32_t* levszY = NULL; - w = dw.x_max - dw.x_min + 1; - h = dw.y_max - dw.y_min + 1; + w = ((int64_t) dw.max.x) - ((int64_t) dw.min.x) + 1; + h = ((int64_t) dw.max.y) - ((int64_t) dw.min.y) + 1; switch (EXR_GET_TILE_LEVEL_MODE ((*tiledesc))) { @@ -2020,15 +2020,15 @@ internal_exr_compute_tile_information ( for (int l = 0; l < numX; ++l) { int64_t sx = calc_level_size ( - dw.x_min, dw.x_max, l, EXR_GET_TILE_ROUND_MODE ((*tiledesc))); + dw.min.x, dw.max.x, l, EXR_GET_TILE_ROUND_MODE ((*tiledesc))); if (sx < 0 || sx > (int64_t) INT32_MAX) return ctxt->print_error ( ctxt, EXR_ERR_INVALID_ATTR, "Invalid data window x dims (%d, %d) resulting in invalid tile level size (%" PRId64 ") for level %d", - dw.x_min, - dw.x_max, + dw.min.x, + dw.max.x, sx, l); levcntX[l] = @@ -2039,15 +2039,15 @@ internal_exr_compute_tile_information ( for (int l = 0; l < numY; ++l) { int64_t sy = calc_level_size ( - dw.y_min, dw.y_max, l, EXR_GET_TILE_ROUND_MODE ((*tiledesc))); + dw.min.y, dw.max.y, l, EXR_GET_TILE_ROUND_MODE ((*tiledesc))); if (sy < 0 || sy > (int64_t) INT32_MAX) return ctxt->print_error ( ctxt, EXR_ERR_INVALID_ATTR, "Invalid data window y dims (%d, %d) resulting in invalid tile level size (%" PRId64 ") for level %d", - dw.y_min, - dw.y_max, + dw.min.y, + dw.max.y, sy, l); levcntY[l] = @@ -2074,7 +2074,7 @@ internal_exr_compute_chunk_offset_size (struct _internal_exr_part* curpart) uint64_t unpackedsize = 0; int64_t w; - w = (int64_t) dw.x_max - (int64_t) dw.x_min + 1; + w = ((int64_t) dw.max.x) - ((int64_t) dw.min.x) + 1; if (curpart->tiles) { @@ -2164,7 +2164,7 @@ internal_exr_compute_chunk_offset_size (struct _internal_exr_part* curpart) /* h = max - min + 1, but to do size / divide by round, * we'd do linePerChunk - 1, so the math cancels */ - retval = (dw.y_max - dw.y_min + linePerChunk) / linePerChunk; + retval = (dw.max.y - dw.min.y + linePerChunk) / linePerChunk; } return retval; } @@ -2232,9 +2232,7 @@ update_chunk_offsets ( static exr_result_t read_magic_and_flags ( - struct _internal_exr_context* ctxt, - uint32_t* outflags, - uint64_t* initpos) + struct _internal_exr_context* ctxt, uint32_t* outflags, uint64_t* initpos) { uint32_t magic_and_version[2]; uint32_t flags; @@ -2327,8 +2325,7 @@ internal_exr_parse_header (struct _internal_exr_context* ctxt) exr_result_t rv = EXR_ERR_UNKNOWN; rv = read_magic_and_flags (ctxt, &flags, &initpos); - if (rv != EXR_ERR_SUCCESS) - return rv; + if (rv != EXR_ERR_SUCCESS) return rv; rv = priv_init_scratch (ctxt, &scratch, initpos); if (rv != EXR_ERR_SUCCESS) diff --git a/src/lib/OpenEXRCore/part_attr.c b/src/lib/OpenEXRCore/part_attr.c index e018c96596..f6a266b5cf 100644 --- a/src/lib/OpenEXRCore/part_attr.c +++ b/src/lib/OpenEXRCore/part_attr.c @@ -209,7 +209,7 @@ exr_initialize_required_attr_simple ( int32_t height, exr_compression_t ctype) { - exr_attr_box2i_t dispWindow = { 0, 0, width - 1, height - 1 }; + exr_attr_box2i_t dispWindow = { .min={ .x=0, .y=0 }, .max={ .x=(width - 1), .y=(height - 1) } }; exr_attr_v2f_t swc = { .x = 0.f, .y = 0.f }; return exr_initialize_required_attr ( ctxt, diff --git a/src/lib/OpenEXRCore/validation.c b/src/lib/OpenEXRCore/validation.c index 6453875a7c..1b04c5a850 100644 --- a/src/lib/OpenEXRCore/validation.c +++ b/src/lib/OpenEXRCore/validation.c @@ -90,32 +90,32 @@ validate_image_dimensions ( par = curpart->pixelAspectRatio->f; sww = curpart->screenWindowWidth->f; - w = (int64_t) dw.x_max - (int64_t) dw.x_min + 1; - h = (int64_t) dw.y_max - (int64_t) dw.y_min + 1; + w = (int64_t) dw.max.x - (int64_t) dw.min.x + 1; + h = (int64_t) dw.max.y - (int64_t) dw.min.y + 1; - if (dspw.x_min > dspw.x_max || dspw.y_min > dspw.y_max || - dspw.x_min <= -kLargeVal || dspw.y_min <= -kLargeVal || - dspw.x_max >= kLargeVal || dspw.y_max >= kLargeVal) + if (dspw.min.x > dspw.max.x || dspw.min.y > dspw.max.y || + dspw.min.x <= -kLargeVal || dspw.min.y <= -kLargeVal || + dspw.max.x >= kLargeVal || dspw.max.y >= kLargeVal) return f->print_error ( f, EXR_ERR_INVALID_ATTR, "Invalid display window (%d, %d - %d, %d)", - dspw.x_min, - dspw.y_min, - dspw.x_max, - dspw.y_max); - - if (dw.x_min > dw.x_max || dw.y_min > dw.y_max || dw.x_min <= -kLargeVal || - dw.y_min <= -kLargeVal || dw.x_max >= kLargeVal || - dw.y_max >= kLargeVal) + dspw.min.x, + dspw.min.y, + dspw.max.x, + dspw.max.y); + + if (dw.min.x > dw.max.x || dw.min.y > dw.max.y || dw.min.x <= -kLargeVal || + dw.min.y <= -kLargeVal || dw.max.x >= kLargeVal || + dw.max.y >= kLargeVal) return f->print_error ( f, EXR_ERR_INVALID_ATTR, "Invalid data window (%d, %d - %d, %d)", - dw.x_min, - dw.y_min, - dw.x_max, - dw.y_max); + dw.min.x, + dw.min.y, + dw.max.x, + dw.max.y); if (maxw > 0 && maxw < w) return f->print_error ( @@ -183,8 +183,8 @@ validate_channels ( "request to validate channel list, but data window not set to validate against"); dw = curpart->data_window; - w = dw.x_max - dw.x_min + 1; - h = dw.y_max - dw.y_min + 1; + w = dw.max.x - dw.min.x + 1; + h = dw.max.y - dw.min.y + 1; for (int c = 0; c < channels->num_channels; ++c) { int32_t xsamp = channels->entries[c].x_sampling; @@ -203,21 +203,21 @@ validate_channels ( "channel '%s': y subsampling factor is invalid (%d)", channels->entries[c].name.str, ysamp); - if (dw.x_min % xsamp) + if (dw.min.x % xsamp) return f->print_error ( f, EXR_ERR_INVALID_ATTR, "channel '%s': minimum x coordinate (%d) of the data window is not a multiple of the x subsampling factor (%d)", channels->entries[c].name.str, - dw.x_min, + dw.min.x, xsamp); - if (dw.y_min % ysamp) + if (dw.min.y % ysamp) return f->print_error ( f, EXR_ERR_INVALID_ATTR, "channel '%s': minimum y coordinate (%d) of the data window is not a multiple of the y subsampling factor (%d)", channels->entries[c].name.str, - dw.y_min, + dw.min.y, ysamp); if (w % xsamp) return f->print_error ( diff --git a/src/test/OpenEXRCoreTest/compression.cpp b/src/test/OpenEXRCoreTest/compression.cpp index 55a49c8529..fa3347dfcd 100644 --- a/src/test/OpenEXRCoreTest/compression.cpp +++ b/src/test/OpenEXRCoreTest/compression.cpp @@ -759,10 +759,10 @@ doDecodeScan (exr_context_t f, pixels& p, int xs, int ys) bool first = true; EXRCORE_TEST_RVAL (exr_get_data_window (f, 0, &dw)); - EXRCORE_TEST (dw.x_min == IMG_DATA_X * xs); - EXRCORE_TEST (dw.x_max == IMG_DATA_X * xs + IMG_WIDTH * xs - 1); - EXRCORE_TEST (dw.y_min == IMG_DATA_Y * ys); - EXRCORE_TEST (dw.y_max == IMG_DATA_Y * ys + IMG_HEIGHT * ys - 1); + EXRCORE_TEST (dw.min.x == IMG_DATA_X * xs); + EXRCORE_TEST (dw.max.x == IMG_DATA_X * xs + IMG_WIDTH * xs - 1); + EXRCORE_TEST (dw.min.y == IMG_DATA_Y * ys); + EXRCORE_TEST (dw.max.y == IMG_DATA_Y * ys + IMG_HEIGHT * ys - 1); EXRCORE_TEST_RVAL (exr_get_scanlines_per_chunk (f, 0, &scansperchunk)); @@ -771,7 +771,7 @@ doDecodeScan (exr_context_t f, pixels& p, int xs, int ys) EXRCORE_TEST (stortype == EXR_STORAGE_SCANLINE); //const uint8_t* tmp; - for (int y = dw.y_min; y <= dw.y_max; y += scansperchunk) + for (int y = dw.min.y; y <= dw.max.y; y += scansperchunk) { EXRCORE_TEST_RVAL (exr_read_scanline_block_info (f, 0, y, &cinfo)); if (first) @@ -783,7 +783,7 @@ doDecodeScan (exr_context_t f, pixels& p, int xs, int ys) { EXRCORE_TEST_RVAL (exr_decoding_update (f, 0, &cinfo, &decoder)); } - int32_t idxoffset = ((y - dw.y_min) / ys) * p._stride_x; + int32_t idxoffset = ((y - dw.min.y) / ys) * p._stride_x; for (int c = 0; c < decoder.channel_count; ++c) { @@ -1131,10 +1131,10 @@ doWriteRead ( exr_context_initializer_t cinit = EXR_DEFAULT_CONTEXT_INITIALIZER; exr_attr_box2i_t dataW; - dataW.x_min = dwx; - dataW.y_min = dwy; - dataW.x_max = dwx + fw - 1; - dataW.y_max = dwy + fh - 1; + dataW.min.x = dwx; + dataW.min.y = dwy; + dataW.max.x = dwx + fw - 1; + dataW.max.y = dwy + fh - 1; std::cout << " " << pattern << " tiled: " << (tiled ? "yes" : "no") << " sampling " << xs << ", " << ys << " comp " << (int) comp diff --git a/src/test/OpenEXRCoreTest/performance.cpp b/src/test/OpenEXRCoreTest/performance.cpp index 646fc8b00f..9c91080baf 100644 --- a/src/test/OpenEXRCoreTest/performance.cpp +++ b/src/test/OpenEXRCoreTest/performance.cpp @@ -89,8 +89,8 @@ read_pixels_raw (exr_context_t f) exr_attr_box2i_t dw; if (EXR_ERR_SUCCESS != exr_get_data_window (f, 0, &dw)) throw std::logic_error ("Unable to query data window from part"); - int64_t w = (int64_t) dw.x_max - (int64_t) dw.x_min + (int64_t) 1; - int64_t h = (int64_t) dw.x_max - (int64_t) dw.x_min + (int64_t) 1; + int64_t w = (int64_t) dw.max.x - (int64_t) dw.min.x + (int64_t) 1; + int64_t h = (int64_t) dw.max.x - (int64_t) dw.min.x + (int64_t) 1; if (w <= 0) return ret; if (h <= 0) return ret; @@ -135,7 +135,7 @@ read_pixels_raw (exr_context_t f) TaskGroup taskgroup; ThreadPool& tp = ThreadPool::globalThreadPool (); - for (int y = dw.y_min; y <= dw.y_max;) + for (int y = dw.min.y; y <= dw.max.y;) { tp.addTask (new CoreReadTask (&taskgroup, f, y, imgptr)); imgptr += sizePerChunk; @@ -145,13 +145,13 @@ read_pixels_raw (exr_context_t f) #else exr_chunk_block_info_t cinfo = { 0 }; exr_decode_pipeline_t chunk = { 0 }; - for (int y = dw.y_min; y <= dw.y_max;) + for (int y = dw.min.y; y <= dw.max.y;) { exr_result_t rv = exr_read_scanline_block_info (f, 0, y, &cinfo); if (rv != EXR_ERR_SUCCESS) throw std::runtime_error ("unable to init scanline block info"); - if (y == dw.y_min) + if (y == dw.min.y) rv = exr_initialize_decoding (f, 0, &cinfo, &chunk); else rv = exr_decoding_update (f, 0, &cinfo, &chunk); @@ -198,7 +198,7 @@ read_pixels_raw (exr_context_t f) uint8_t *imgptr = rawBuf.data(); // random or increasing - for ( int y = dw.y_min; y <= dw.y_max; ) + for ( int y = dw.min.y; y <= dw.max.y; ) { exr_chunk_info_t chunk = {0}; if ( exr_compute_chunk_for_scanline( f, 0, y, &chunk ) ) diff --git a/src/test/OpenEXRCoreTest/read.cpp b/src/test/OpenEXRCoreTest/read.cpp index fc725a8453..57ffda4f85 100644 --- a/src/test/OpenEXRCoreTest/read.cpp +++ b/src/test/OpenEXRCoreTest/read.cpp @@ -275,11 +275,11 @@ testReadScans (const std::string& tempdir) EXRCORE_TEST_RVAL_FAIL ( EXR_ERR_INVALID_ARGUMENT, - exr_read_scanline_block_info (f, 0, dw.y_min - 1, &cinfo)); + exr_read_scanline_block_info (f, 0, dw.min.y - 1, &cinfo)); EXRCORE_TEST_RVAL_FAIL ( EXR_ERR_INVALID_ARGUMENT, - exr_read_scanline_block_info (f, 0, dw.y_max + 1, &cinfo)); - EXRCORE_TEST_RVAL (exr_read_scanline_block_info (f, 0, dw.y_min, &cinfo)); + 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)); uint64_t pchunksz = 0; EXRCORE_TEST_RVAL (exr_get_chunk_unpacked_size (f, 0, &pchunksz)); diff --git a/src/test/OpenEXRCoreTest/write.cpp b/src/test/OpenEXRCoreTest/write.cpp index f5d0a8b2ee..6de2dfacdb 100644 --- a/src/test/OpenEXRCoreTest/write.cpp +++ b/src/test/OpenEXRCoreTest/write.cpp @@ -790,19 +790,19 @@ testWriteAttrs (const std::string& tempdir) { exr_attr_box2i_t tb2i = { 1, 2, 3, 4 }; TEST_CORNER_CASE_NAME (box2i, tb2i, int); - EXRCORE_TEST (tb2i.x_min == 1); - EXRCORE_TEST (tb2i.y_min == 2); - EXRCORE_TEST (tb2i.x_max == 3); - EXRCORE_TEST (tb2i.y_max == 4); + EXRCORE_TEST (tb2i.min.x == 1); + EXRCORE_TEST (tb2i.min.y == 2); + EXRCORE_TEST (tb2i.max.x == 3); + EXRCORE_TEST (tb2i.max.y == 4); } { exr_attr_box2f_t tb2f = { 1.f, 2.f, 3.f, 4.f }; TEST_CORNER_CASE_NAME (box2f, tb2f, int); - EXRCORE_TEST (tb2f.x_min == 1.f); - EXRCORE_TEST (tb2f.y_min == 2.f); - EXRCORE_TEST (tb2f.x_max == 3.f); - EXRCORE_TEST (tb2f.y_max == 4.f); + EXRCORE_TEST (tb2f.min.x == 1.f); + EXRCORE_TEST (tb2f.min.y == 2.f); + EXRCORE_TEST (tb2f.max.x == 3.f); + EXRCORE_TEST (tb2f.max.y == 4.f); } { @@ -1165,10 +1165,10 @@ testWriteTiles (const std::string& tempdir) EXRCORE_TEST_RVAL (exr_get_data_window (outf, 0, &dw)); ty = 0; - for (int32_t y = dw.y_min; y <= dw.y_max; y += levelsy) + for (int32_t y = dw.min.y; y <= dw.max.y; y += levelsy) { tx = 0; - for (int32_t x = dw.x_min; x <= dw.x_max; x += levelsx) + for (int32_t x = dw.min.x; x <= dw.max.x; x += levelsx) { exr_chunk_block_info_t cinfo; EXRCORE_TEST_RVAL (