Skip to content
Closed
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) Contributors to the OpenEXR Project.

[build-system]
requires = ["scikit-build-core==0.11.5", "pybind11"]
requires = ["scikit-build-core==0.11.6", "pybind11"]
build-backend = "scikit_build_core.build"

[project]
Expand Down
5 changes: 3 additions & 2 deletions src/lib/OpenEXR/ImfCRgbaFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ typedef struct ImfRgba ImfRgba;
#define IMF_B44A_COMPRESSION 7
#define IMF_DWAA_COMPRESSION 8
#define IMF_DWAB_COMPRESSION 9
#define IMF_HTJ2K_COMPRESSION 10
#define IMF_NUM_COMPRESSION_METHODS 11
#define IMF_HTJ2K256_COMPRESSION 10
#define IMF_HTJ2K32_COMPRESSION 11
#define IMF_NUM_COMPRESSION_METHODS 12

/*
** Channels; values must be the same as in Imf::RgbaChannels.
Expand Down
13 changes: 10 additions & 3 deletions src/lib/OpenEXR/ImfCompression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,17 @@ static const CompressionDesc IdToDesc[] = {
true,
false),
CompressionDesc (
"htj2k",
"High-Throughput JPEG 2000 (OpenJPH, 256 lines)",
"htj2k256",
"High-Throughput JPEG 2000 (256 lines)",
256,
true,
false),
CompressionDesc (
"htj2k32",
"High-Throughput JPEG 2000 (32 lines)",
32,
true,
false),
};
// clang-format on

Expand All @@ -198,7 +204,8 @@ static const std::map<std::string, Compression> CompressionNameToId = {
{"b44a", Compression::B44A_COMPRESSION},
{"dwaa", Compression::DWAA_COMPRESSION},
{"dwab", Compression::DWAB_COMPRESSION},
{"htj2k", Compression::HTJ2K_COMPRESSION},
{"htj2k256", Compression::HTJ2K256_COMPRESSION},
{"htj2k32", Compression::HTJ2K32_COMPRESSION},
};

#define UNKNOWN_COMPRESSION_ID_MSG "INVALID COMPRESSION ID"
Expand Down
4 changes: 3 additions & 1 deletion src/lib/OpenEXR/ImfCompression.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ enum IMF_EXPORT_ENUM Compression
// wise and faster to decode full frames
// than DWAA_COMPRESSION.

HTJ2K_COMPRESSION = 10, // High-Throughput JPEG2000 (HTJ2K), 256 scanlines
HTJ2K256_COMPRESSION = 10, // High-Throughput JPEG2000 (HTJ2K), 256 scanlines

HTJ2K32_COMPRESSION = 11, // High-Throughput JPEG2000 (HTJ2K), 32 scanlines

NUM_COMPRESSION_METHODS // number of different compression methods
};
Expand Down
9 changes: 7 additions & 2 deletions src/lib/OpenEXR/ImfCompressor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,14 @@ newCompressor (Compression c, size_t maxScanLineSize, const Header& hdr)
DwaCompressor::STATIC_HUFFMAN);
break;

case HTJ2K_COMPRESSION:
case HTJ2K256_COMPRESSION:

return new HTCompressor (hdr, static_cast<int> (maxScanLineSize), 256);

case HTJ2K32_COMPRESSION:

return new HTCompressor (hdr, static_cast<int> (maxScanLineSize), 32);

default: break;
}
// clang-format on
Expand Down Expand Up @@ -421,7 +425,8 @@ newTileCompressor (
DwaCompressor::STATIC_HUFFMAN);
break;

case HTJ2K_COMPRESSION:
case HTJ2K256_COMPRESSION:
case HTJ2K32_COMPRESSION:

return new HTCompressor (
hdr,
Expand Down
9 changes: 6 additions & 3 deletions src/lib/OpenEXRCore/compression.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,10 @@ int exr_compression_lines_per_chunk (exr_compression_t comptype)
case EXR_COMPRESSION_PIZ:
case EXR_COMPRESSION_B44:
case EXR_COMPRESSION_B44A:
case EXR_COMPRESSION_HTJ2K32:
case EXR_COMPRESSION_DWAA: linePerChunk = 32; break;
case EXR_COMPRESSION_DWAB: linePerChunk = 256; break;
case EXR_COMPRESSION_HTJ2K: linePerChunk = 256; break;
case EXR_COMPRESSION_HTJ2K256: linePerChunk = 256; break;
case EXR_COMPRESSION_LAST_TYPE:
default:
/* ERROR CONDITION */
Expand Down Expand Up @@ -377,7 +378,8 @@ exr_compress_chunk (exr_encode_pipeline_t* encode)
case EXR_COMPRESSION_B44A: rv = internal_exr_apply_b44a (encode); break;
case EXR_COMPRESSION_DWAA: rv = internal_exr_apply_dwaa (encode); break;
case EXR_COMPRESSION_DWAB: rv = internal_exr_apply_dwab (encode); break;
case EXR_COMPRESSION_HTJ2K:
case EXR_COMPRESSION_HTJ2K32:
case EXR_COMPRESSION_HTJ2K256:
rv = internal_exr_apply_ht (encode); break;
case EXR_COMPRESSION_LAST_TYPE:
default:
Expand Down Expand Up @@ -455,7 +457,8 @@ decompress_data (
rv = internal_exr_undo_dwab (
decode, packbufptr, packsz, unpackbufptr, unpacksz);
break;
case EXR_COMPRESSION_HTJ2K:
case EXR_COMPRESSION_HTJ2K256:
case EXR_COMPRESSION_HTJ2K32:
rv = internal_exr_undo_ht (
decode, packbufptr, packsz, unpackbufptr, unpacksz);
break;
Expand Down
3 changes: 2 additions & 1 deletion src/lib/OpenEXRCore/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ print_attr (const exr_attribute_t* a, int verbose)
"b44a",
"dwaa",
"dwab",
"htj2k"};
"htj2k256",
"htj2k32"};
printf (
"'%s'", (a->uc < EXR_COMPRESSION_LAST_TYPE ? compressionnames[a->uc] : "<UNKNOWN>"));
if (verbose) printf (" (0x%02X)", a->uc);
Expand Down
65 changes: 51 additions & 14 deletions src/lib/OpenEXRCore/internal_ht.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class staticmem_outfile : public ojph::outfile_base
* @param ptr is a pointer to new data.
* @param size the number of bytes in the new data.
*/
size_t write (const void* ptr, size_t sz)
size_t write (const void* ptr, size_t sz) override
{
assert (this->is_open);
assert (this->buf);
Expand Down Expand Up @@ -157,8 +157,8 @@ class staticmem_outfile : public ojph::outfile_base
ojph::ui8 *cur_ptr;
};

extern "C" exr_result_t
internal_exr_undo_ht (
static exr_result_t
ht_undo_impl (
exr_decode_pipeline_t* decode,
const void* compressed_data,
uint64_t comp_buf_size,
Expand All @@ -177,18 +177,17 @@ internal_exr_undo_ht (
if (decode->channel_count != cs_to_file_ch.size ())
throw std::runtime_error ("Unexpected number of channels");

std::vector<size_t> offsets (decode->channel_count);
offsets[0] = 0;
for (int file_i = 1; file_i < decode->channel_count; file_i++)
{
offsets[file_i] = offsets[file_i - 1] +
decode->channels[file_i - 1].width *
decode->channels[file_i - 1].bytes_per_element;
}
for (int cs_i = 0; cs_i < decode->channel_count; cs_i++)
{
cs_to_file_ch[cs_i].raster_line_offset =
offsets[cs_to_file_ch[cs_i].file_index];
int file_i = cs_to_file_ch[cs_i].file_index;
if (file_i >= decode->channel_count)
return EXR_ERR_CORRUPT_CHUNK;

size_t computedoffset = 0;
for (int i = 0; i < file_i; ++i)
computedoffset += decode->channels[i].width *
decode->channels[i].bytes_per_element;
cs_to_file_ch[cs_i].raster_line_offset = computedoffset;
}

ojph::mem_infile infile;
Expand Down Expand Up @@ -329,7 +328,31 @@ internal_exr_undo_ht (
}

extern "C" exr_result_t
internal_exr_apply_ht (exr_encode_pipeline_t* encode)
internal_exr_undo_ht (
exr_decode_pipeline_t* decode,
const void* compressed_data,
uint64_t comp_buf_size,
void* uncompressed_data,
uint64_t uncompressed_size)
{
try
{
return ht_undo_impl (decode, compressed_data, comp_buf_size,
uncompressed_data, uncompressed_size);
}
catch ( ... )
{
}

return EXR_ERR_CORRUPT_CHUNK;
}


////////////////////////////////////////


static exr_result_t
ht_apply_impl (exr_encode_pipeline_t* encode)
{
exr_result_t rv = EXR_ERR_SUCCESS;

Expand Down Expand Up @@ -504,3 +527,17 @@ internal_exr_apply_ht (exr_encode_pipeline_t* encode)

return rv;
}

extern "C" exr_result_t
internal_exr_apply_ht (exr_encode_pipeline_t* encode)
{
try
{
return ht_apply_impl (encode);
}
catch ( ... )
{
}

return EXR_ERR_INCORRECT_CHUNK;
}
3 changes: 2 additions & 1 deletion src/lib/OpenEXRCore/openexr_attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ typedef enum
EXR_COMPRESSION_B44A = 7,
EXR_COMPRESSION_DWAA = 8,
EXR_COMPRESSION_DWAB = 9,
EXR_COMPRESSION_HTJ2K = 10,
EXR_COMPRESSION_HTJ2K256 = 10,
EXR_COMPRESSION_HTJ2K32 = 11,
EXR_COMPRESSION_LAST_TYPE /**< Invalid value, provided for range checking. */
} exr_compression_t;

Expand Down
4 changes: 2 additions & 2 deletions src/test/OpenEXRTest/testCompressionApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ testCompressionApi (const string& tempDir)
cout << "Testing compression API functions." << endl;

// update this if you add a new compressor.
string codecList = "none/rle/zips/zip/piz/pxr24/b44/b44a/dwaa/dwab/htj2k";
string codecList = "none/rle/zips/zip/piz/pxr24/b44/b44a/dwaa/dwab/htj2k256/htj2k32";

int numMethods = static_cast<int> (NUM_COMPRESSION_METHODS);
// update this if you add a new compressor.
assert (numMethods == 11);
assert (numMethods == 12);

for (int i = 0; i < numMethods; i++)
{
Expand Down
5 changes: 3 additions & 2 deletions src/wrappers/python/Imath.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ class Compression(Enumerated):
B44A_COMPRESSION = 7
DWAA_COMPRESSION = 8
DWAB_COMPRESSION = 9
HTJ2K_COMPRESSION = 10
HTJ2K256_COMPRESSION = 10
HTJ2K32_COMPRESSION = 11
names = [
"NO_COMPRESSION", "RLE_COMPRESSION", "ZIPS_COMPRESSION", "ZIP_COMPRESSION", "PIZ_COMPRESSION", "PXR24_COMPRESSION",
"B44_COMPRESSION", "B44A_COMPRESSION", "DWAA_COMPRESSION", "DWAB_COMPRESSION", "HTJ2K_COMPRESSION"
"B44_COMPRESSION", "B44A_COMPRESSION", "DWAA_COMPRESSION", "DWAB_COMPRESSION", "HTJ2K256_COMPRESSION", "HTJ2K32_COMPRESSION"
]

class PixelType(Enumerated):
Expand Down
6 changes: 4 additions & 2 deletions src/wrappers/python/PyOpenEXR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2360,7 +2360,8 @@ PYBIND11_MODULE(OpenEXR, m)
.value("B44A_COMPRESSION", B44A_COMPRESSION)
.value("DWAA_COMPRESSION", DWAA_COMPRESSION)
.value("DWAB_COMPRESSION", DWAB_COMPRESSION)
.value("HTJ2K_COMPRESSION", HTJ2K_COMPRESSION)
.value("HTJ2K256_COMPRESSION", HTJ2K256_COMPRESSION)
.value("HTJ2K32_COMPRESSION", HTJ2K32_COMPRESSION)
.value("NUM_COMPRESSION_METHODS", NUM_COMPRESSION_METHODS)
.export_values();

Expand Down Expand Up @@ -2713,7 +2714,8 @@ PYBIND11_MODULE(OpenEXR, m)
B44A_COMPRESSION
DWAA_COMPRESSION
DWAB_COMPRESSION
HTJ2K_COMPRESSION
HTJ2K256_COMPRESSION
HTJ2K32_COMPRESSION
)pbdoc")
.def_readwrite("header", &PyPart::header,
R"pbdoc(
Expand Down
7 changes: 5 additions & 2 deletions website/OpenEXRFileLayout.rst
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,10 @@ per block depends on how the pixel data are compressed:
- 32
* - ``DWAB_COMPRESSION``
- 256
* - ``HTJ2K_COMPRESSION``
* - ``HTJ2K256_COMPRESSION``
- 256
* - ``HTJ2K32_COMPRESSION``
- 32

Each scan line block has a y coordinate of type ``int``. The block's y
coordinate is equal to the pixel space y coordinate of the top scan line
Expand Down Expand Up @@ -934,7 +936,8 @@ The OpenEXR library predefines the following attribute types:
| | * ``B44A_COMPRESSION`` = 7 |
| | * ``DWAA_COMPRESSION`` = 8 |
| | * ``DWAB_COMPRESSION`` = 9 |
| | * ``HTJ2K_COMPRESSION`` = 10 |
| | * ``HTJ2K256_COMPRESSION`` = 10 |
| | * ``HTJ2K32_COMPRESSION`` = 11 |
| | |
+--------------------+-----------------------------------------------------------------+
| ``double`` | ``double`` |
Expand Down
69 changes: 37 additions & 32 deletions website/ReadingAndWritingImageFiles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1751,38 +1751,43 @@ on the ``Header`` object:

Supported compression types are:

+-------------------+------------------------------------------------+
| RLE_COMPRESSION | run length encoding |
+-------------------+------------------------------------------------+
| ZIPS_COMPRESSION | zlib compression, one scan line at a time |
+-------------------+------------------------------------------------+
| ZIP_COMPRESSION | zlib compression, in blocks of 16 scan lines |
+-------------------+------------------------------------------------+
| PIZ_COMPRESSION | piz-based wavelet compression |
+-------------------+------------------------------------------------+
| PXR24_COMPRESSION | lossy 24-bit float compression |
+-------------------+------------------------------------------------+
| B44_COMPRESSION | lossy 4-by-4 pixel block compression, |
| | fixed compression rate |
+-------------------+------------------------------------------------+
| B44A_COMPRESSION | lossy 4-by-4 pixel block compression, |
| | flat fields are compressed more |
+-------------------+------------------------------------------------+
| DWAA_COMPRESSION | lossy DCT based compression, in blocks of |
| | 32 scanlines. More efficient for partial |
| | buffer access. |
+-------------------+------------------------------------------------+
| DWAB_COMPRESSION | lossy DCT based compression, in blocks of 256 |
| | scanlines. More efficient space-wise and |
| | faster to decode full frames than |
| | ``DWAA_COMPRESSION``. |
+-------------------+------------------------------------------------+
| HTJ2K_COMPRESSION | JPEG 2000 lossless coding, in blocks of 256 |
| | scanlines and using the High-Throughput block |
| | coder specified in Rec. ITU-T T.814 and |
| | ISO/IEC 15444-15. The compressor offers both |
| | speed and high coding efficiency. |
+-------------------+------------------------------------------------+
+----------------------+------------------------------------------------+
| RLE_COMPRESSION | run length encoding |
+----------------------+------------------------------------------------+
| ZIPS_COMPRESSION | zlib compression, one scan line at a time |
+----------------------+------------------------------------------------+
| ZIP_COMPRESSION | zlib compression, in blocks of 16 scan lines |
+----------------------+------------------------------------------------+
| PIZ_COMPRESSION | piz-based wavelet compression |
+----------------------+------------------------------------------------+
| PXR24_COMPRESSION | lossy 24-bit float compression |
+----------------------+------------------------------------------------+
| B44_COMPRESSION | lossy 4-by-4 pixel block compression, |
| | fixed compression rate |
+----------------------+------------------------------------------------+
| B44A_COMPRESSION | lossy 4-by-4 pixel block compression, |
| | flat fields are compressed more |
+----------------------+------------------------------------------------+
| DWAA_COMPRESSION | lossy DCT based compression, in blocks of |
| | 32 scanlines. More efficient for partial |
| | buffer access. |
+----------------------+------------------------------------------------+
| DWAB_COMPRESSION | lossy DCT based compression, in blocks of 256 |
| | scanlines. More efficient space-wise and |
| | faster to decode full frames than |
| | ``DWAA_COMPRESSION``. |
+----------------------+------------------------------------------------+
| HTJ2K256_COMPRESSION | JPEG 2000 lossless coding, in blocks of 256 |
| | scanlines and using the High-Throughput block |
| | coder specified in Rec. ITU-T T.814 and |
| | ISO/IEC 15444-15. The compressor offers both |
| | speed and high coding efficiency. |
+----------------------+------------------------------------------------+
| HTJ2K32_COMPRESSION | Same as ``HTJ2K256_COMPRESSION``, but in |
| | blocks of 32 scanlines, More efficient for |
| | partial buffer access, but slightly less |
| | efficient space-wise. |
+----------------------+------------------------------------------------+

``ZIP_COMPRESSION`` and ``DWA`` compression compress to a
user-controllable compression level, which determines the space/time
Expand Down
3 changes: 2 additions & 1 deletion website/StandardAttributes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ Basic Attributes
<li> <tt> B44A_COMPRESSION </tt> - lossy 4-by-4 pixel block compression, flat fields are compressed more </li>
<li> <tt> DWAA_COMPRESSION </tt> - lossy DCT based compression, in blocks of 32 scanlines. More efficient for partial buffer access. </li>
<li> <tt> DWAB_COMPRESSION </tt> - lossy DCT based compression, in blocks of 256 scanlines. More efficient space wise and faster to decode full frames than <tt>DWAA_COMPRESSION</tt>. </li>
<li> <tt> HTJ2K_COMPRESSION </tt> - JPEG 2000 lossless coding, in blocks of 256 scanlines and using the High-Throughput (HT) blocker. Offers both speed and high-coding efficiency. </li>
<li> <tt> HTJ2K256_COMPRESSION </tt> - JPEG 2000 lossless coding, in blocks of 256 scanlines and using the High-Throughput (HT) blocker. Offers both speed and high-coding efficiency. </li>
<li> <tt> HTJ2K32_COMPRESSION </tt> - JPEG 2000 lossless coding, in blocks of 32 scanlines and using the High-Throughput (HT) blocker. Offers both speed and high-coding efficiency. </li>
</ul>
</p>
</td>
Expand Down
Loading
Loading