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

DWA compression: switch to compressBound() instead of manual zlib headroom computation #156

karlrasche opened this Issue Feb 18, 2015 · 0 comments


None yet
2 participants

karlrasche commented Feb 18, 2015

From Vasil Minkov on openexr-devel

While tracking an error report I found an issue with the DWA compression - it fails
to compress certain input data.
The problem is easily reproduced on attempt to store a small (8x8 pixels) single-channel (Luma only) EXR image using DWA compression.
An exception "Data compression (zlib) failed." is thrown in such case. The problem also occurs when compressing small and noisy RGB tiles.

It seems that the problem is in ImfDwaCompressor.cpp, in the following code fragment:

           uLongf destLen = (uLongf)
               (2 * (*totalAcUncompressedCount) * sizeof (unsigned short));

           if (Z_OK != ::compress2
                           ((Bytef *)outDataPtr, &destLen,
                            (Bytef *)_packedAcBuffer,
                                         * sizeof (unsigned short)),

Under certain circumstances compress2() output size may exceed its input size, as specified in zlib's docs.

There are a number of places in ImfDwaCompressor.cpp where the zlib headroom is manually computed, instead of using compressBound(). Switch over to use this helper function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment