/src/openexr/src/lib/OpenEXR/ImfPxr24Compressor.cpp
Line | Count | Source |
1 | | // |
2 | | // SPDX-License-Identifier: BSD-3-Clause |
3 | | // Copyright (c) Pixar Animation Studios and Contributors of the OpenEXR Project |
4 | | // |
5 | | |
6 | | //----------------------------------------------------------------------------- |
7 | | // |
8 | | // class Pxr24Compressor |
9 | | // |
10 | | // This compressor is based on source code that was contributed to |
11 | | // OpenEXR by Pixar Animation Studios. The compression method was |
12 | | // developed by Loren Carpenter. |
13 | | // |
14 | | // The compressor preprocesses the pixel data to reduce entropy, |
15 | | // and then calls zlib. |
16 | | // |
17 | | // Compression of HALF and UINT channels is lossless, but compressing |
18 | | // FLOAT channels is lossy: 32-bit floating-point numbers are converted |
19 | | // to 24 bits by rounding the significand to 15 bits. |
20 | | // |
21 | | // When the compressor is invoked, the caller has already arranged |
22 | | // the pixel data so that the values for each channel appear in a |
23 | | // contiguous block of memory. The compressor converts the pixel |
24 | | // values to unsigned integers: For UINT, this is a no-op. HALF |
25 | | // values are simply re-interpreted as 16-bit integers. FLOAT |
26 | | // values are converted to 24 bits, and the resulting bit patterns |
27 | | // are interpreted as integers. The compressor then replaces each |
28 | | // value with the difference between the value and its left neighbor. |
29 | | // This turns flat fields in the image into zeroes, and ramps into |
30 | | // strings of similar values. Next, each difference is split into |
31 | | // 2, 3 or 4 bytes, and the bytes are transposed so that all the |
32 | | // most significant bytes end up in a contiguous block, followed |
33 | | // by the second most significant bytes, and so on. The resulting |
34 | | // string of bytes is compressed with zlib. |
35 | | // |
36 | | //----------------------------------------------------------------------------- |
37 | | |
38 | | #include "ImfPxr24Compressor.h" |
39 | | |
40 | | OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_ENTER |
41 | | |
42 | | Pxr24Compressor::Pxr24Compressor ( |
43 | | const Header& hdr, size_t maxScanLineSize, int numScanLines) |
44 | 902 | : Compressor (hdr, EXR_COMPRESSION_PXR24, maxScanLineSize, numScanLines) |
45 | 902 | { |
46 | 902 | } |
47 | | |
48 | | Pxr24Compressor::~Pxr24Compressor () |
49 | 902 | { |
50 | 902 | } |
51 | | |
52 | | OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EXIT |