Add DWA Compression #197
Labels
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
Why
Supporting the last missing compression format will increase reliability of the library. Currently, you can never be sure if an arbitrary image can be opened.
Implementation Approach
All code will go into a new
dwa
module that has to be created inside thesrc/compression/
folder. Look at./piz/mod.rs
and./b44/mod.rs
as a starting point.The functions in the new module will be called from
src/compression/mod.rs
. To be exact, it's called here for compression (probably two times, because DWA has two variants, DWAA and DWAB):exrs/src/compression/mod.rs
Line 175 in 66a2477
and also here for decompression, probably also two times:
exrs/src/compression/mod.rs
Line 216 in 66a2477
Here's the reference implementation, in C++:
https://github.com/AcademySoftwareFoundation/openexr/blob/main/src/lib/OpenEXR/ImfDwaCompressor.cpp
Note that the original implementation uses a
Compressor
class with mutable state. In the current Rust compression implementations, we only have two simple stateless functions instead:pub fn decompress(bytes, ...) -> bytes
andpub fn compress(bytes, ...) -> bytes
.What the code should look like
There's some functionality in the
compression::optimize_bytes
module that you might be able to re-use, especiallyconvert_little_endian_to_current
and friends. Note that the C++ implementation has a lot of code duplication, as each compression method implements this algorithm again, look out for that part.Of course, don't use unsafe code. For byte manipulations, have a look at the
exr::io::Data
trait. Also be sure to check out the existingpiz
andb44
Rust implementations if you are stuck. You can add unit tests in your new module. But even without any, you can still check your code simply by runningcargo test
. Big-endian support is not of high priority, so having little-endian alone would be great.The text was updated successfully, but these errors were encountered: