| 1 | |
| 2 | // see https://github.com/openexr/openexr/blob/master/OpenEXR/IlmImf/ImfCompressor.cpp |
| 3 | |
| 4 | |
| 5 | use superrust-analyzer cargo exr 1.74.0 compression/::*; |
| 6 | use superrust-analyzer cargo exr 1.74.0 compression/::optimize_bytesrust-analyzer cargo exr 1.74.0 compression/optimize_bytes/::*; |
| 7 | use craterust-analyzer cargo exr 1.74.0 crate/::errorrust-analyzer cargo exr 1.74.0 error/::Resultrust-analyzer cargo exr 1.74.0 error/Result#; |
| 8 | |
| 9 | // scanline decompression routine, see https://github.com/openexr/openexr/blob/master/OpenEXR/IlmImf/ImfScanLineInputFile.cpp |
| 10 | // 1. Uncompress the data, if necessary (If the line is uncompressed, it's in XDR format, regardless of the compressor's output format.) |
| 11 | // 3. Convert one scan line's worth of pixel data back from the machine-independent representation |
| 12 | // 4. Fill the frame buffer with pixel data, respective to sampling and whatnot |
| 13 | |
| 14 | |
| 15 | pub fn decompress_bytesrust-analyzer cargo exr 1.74.0 compression/zip/decompress_bytes().( |
| 16 | channels: &ChannelListrust-analyzer cargo exr 1.74.0 meta/attribute/ChannelList#, |
| 17 | data_le: ByteVecrust-analyzer cargo exr 1.74.0 compression/ByteVec#, |
| 18 | rectangle: IntegerBoundsrust-analyzer cargo exr 1.74.0 meta/attribute/IntegerBounds#, |
| 19 | expected_byte_size: usize, |
| 20 | _pedantic: bool, |
| 21 | ) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<ByteVecrust-analyzer cargo exr 1.74.0 compression/ByteVec#> { |
| 22 | let options = zune_inflaterust-analyzer cargo zune-inflate 0.2.54 crate/::DeflateOptionsrust-analyzer cargo zune-inflate 0.2.54 decoder/DeflateOptions#::defaultrust-analyzer cargo zune-inflate 0.2.54 decoder/impl#[DeflateOptions][Default]default().().set_limitrust-analyzer cargo zune-inflate 0.2.54 decoder/impl#[DeflateOptions]set_limit().(expected_byte_size).set_size_hintrust-analyzer cargo zune-inflate 0.2.54 decoder/impl#[DeflateOptions]set_size_hint().(expected_byte_size); |
| 23 | let mut decoder = zune_inflaterust-analyzer cargo zune-inflate 0.2.54 crate/::DeflateDecoderrust-analyzer cargo zune-inflate 0.2.54 decoder/DeflateDecoder#::new_with_optionsrust-analyzer cargo zune-inflate 0.2.54 decoder/impl#[`DeflateDecoder<'a>`]new_with_options().(&data_le, options); |
| 24 | let mut decompressed_le = decoder.decode_zlibrust-analyzer cargo zune-inflate 0.2.54 decoder/impl#[`DeflateDecoder<'a>`]decode_zlib().() |
| 25 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|_| Errorrust-analyzer cargo exr 1.74.0 error/Error#::invalidrust-analyzer cargo exr 1.74.0 error/impl#[Error]invalid().("zlib-compressed data malformed"))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 26 | |
| 27 | differences_to_samplesrust-analyzer cargo exr 1.74.0 compression/optimize_bytes/differences_to_samples().(&mut decompressed_le); |
| 28 | interleave_byte_blocksrust-analyzer cargo exr 1.74.0 compression/optimize_bytes/interleave_byte_blocks().(&mut decompressed_le); |
| 29 | |
| 30 | superrust-analyzer cargo exr 1.74.0 compression/::convert_little_endian_to_currentrust-analyzer cargo exr 1.74.0 compression/convert_little_endian_to_current().(decompressed_le, channels, rectangle) // TODO no alloc |
| 31 | } |
| 32 | |
| 33 | pub fn compress_bytesrust-analyzer cargo exr 1.74.0 compression/zip/compress_bytes().(channels: &ChannelListrust-analyzer cargo exr 1.74.0 meta/attribute/ChannelList#, uncompressed_ne: ByteVecrust-analyzer cargo exr 1.74.0 compression/ByteVec#, rectangle: IntegerBoundsrust-analyzer cargo exr 1.74.0 meta/attribute/IntegerBounds#) -> Resultrust-analyzer cargo exr 1.74.0 error/Result#<ByteVecrust-analyzer cargo exr 1.74.0 compression/ByteVec#> { |
| 34 | // see https://github.com/AcademySoftwareFoundation/openexr/blob/3bd93f85bcb74c77255f28cdbb913fdbfbb39dfe/OpenEXR/IlmImf/ImfTiledOutputFile.cpp#L750-L842 |
| 35 | let mut packed_le = convert_current_to_little_endianrust-analyzer cargo exr 1.74.0 compression/convert_current_to_little_endian().(uncompressed_ne, channels, rectangle)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 36 | |
| 37 | separate_bytes_fragmentsrust-analyzer cargo exr 1.74.0 compression/optimize_bytes/separate_bytes_fragments().(&mut packed_le); |
| 38 | samples_to_differencesrust-analyzer cargo exr 1.74.0 compression/optimize_bytes/samples_to_differences().(&mut packed_le); |
| 39 | |
| 40 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(miniz_oxiderust-analyzer cargo miniz_oxide 0.8.9 crate/::deflaterust-analyzer cargo miniz_oxide 0.8.9 deflate/::compress_to_vec_zlibrust-analyzer cargo miniz_oxide 0.8.9 deflate/compress_to_vec_zlib().(packed_le.as_slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]as_slice().(), 4)) |
| 41 | } |