Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Use same struct scheme as box from imath for consistency #1073

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 49 additions & 49 deletions src/lib/OpenEXRCore/chunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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)));
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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)));
}

Expand Down Expand Up @@ -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)
Expand Down
20 changes: 10 additions & 10 deletions src/lib/OpenEXRCore/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/lib/OpenEXRCore/internal_structs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
32 changes: 14 additions & 18 deletions src/lib/OpenEXRCore/openexr_attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand Down
Loading