Coverage Report

Created: 2026-08-14 08:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/exr-1.74.2/src/compression/zip.rs
Line
Count
Source
1
// see https://github.com/openexr/openexr/blob/master/OpenEXR/IlmImf/ImfCompressor.cpp
2
3
use super::{optimize_bytes::*, *};
4
use crate::error::Result;
5
6
// scanline decompression routine, see https://github.com/openexr/openexr/blob/master/OpenEXR/IlmImf/ImfScanLineInputFile.cpp
7
// 1. Uncompress the data, if necessary (If the line is uncompressed, it's in
8
//    XDR format, regardless of the compressor's output format.)
9
// 3. Convert one scan line's worth of pixel data back from the
10
//    machine-independent representation
11
// 4. Fill the frame buffer with pixel data, respective to sampling and whatnot
12
13
0
pub fn decompress_bytes(
14
0
    channels: &ChannelList,
15
0
    data_le: ByteVec,
16
0
    rectangle: IntegerBounds,
17
0
    expected_byte_size: usize,
18
0
    _pedantic: bool,
19
0
) -> Result<ByteVec> {
20
0
    let options = zune_inflate::DeflateOptions::default()
21
0
        .set_limit(expected_byte_size)
22
0
        .set_size_hint(expected_byte_size);
23
0
    let mut decoder = zune_inflate::DeflateDecoder::new_with_options(&data_le, options);
24
0
    let mut decompressed_le =
25
0
        decoder.decode_zlib().map_err(|_| Error::invalid("zlib-compressed data malformed"))?;
26
27
0
    differences_to_samples(&mut decompressed_le);
28
0
    interleave_byte_blocks(&mut decompressed_le);
29
30
0
    super::convert_little_endian_to_current(decompressed_le, channels, rectangle)
31
    // TODO no alloc
32
0
}
33
34
0
pub fn compress_bytes(
35
0
    channels: &ChannelList,
36
0
    uncompressed_ne: ByteVec,
37
0
    rectangle: IntegerBounds,
38
0
) -> Result<ByteVec> {
39
    // see https://github.com/AcademySoftwareFoundation/openexr/blob/3bd93f85bcb74c77255f28cdbb913fdbfbb39dfe/OpenEXR/IlmImf/ImfTiledOutputFile.cpp#L750-L842
40
0
    let mut packed_le = convert_current_to_little_endian(uncompressed_ne, channels, rectangle)?;
41
42
0
    separate_bytes_fragments(&mut packed_le);
43
0
    samples_to_differences(&mut packed_le);
44
45
0
    Ok(miniz_oxide::deflate::compress_to_vec_zlib(packed_le.as_slice(), 4))
46
0
}