use super::*;
use super::optimize_bytes::*;
use crate::error::Result;
pub fn decompress_bytes(
channels: &ChannelList,
data: ByteVec,
rectangle: IntegerBounds,
expected_byte_size: usize,
_pedantic: bool,
) -> Result<ByteVec> {
let options = zune_inflate::DeflateOptions::default().set_limit(expected_byte_size).set_size_hint(expected_byte_size);
let mut decoder = zune_inflate::DeflateDecoder::new_with_options(&data, options);
let mut decompressed = decoder.decode_zlib()
.map_err(|_| Error::invalid("zlib-compressed data malformed"))?;
differences_to_samples(&mut decompressed);
interleave_byte_blocks(&mut decompressed);
Ok(super::convert_little_endian_to_current(decompressed, channels, rectangle))}
pub fn compress_bytes(channels: &ChannelList, uncompressed: ByteVec, rectangle: IntegerBounds) -> Result<ByteVec> {
let mut packed = convert_current_to_little_endian(uncompressed, channels, rectangle);
separate_bytes_fragments(&mut packed);
samples_to_differences(&mut packed);
Ok(miniz_oxide::deflate::compress_to_vec_zlib(packed.as_slice(), 4))
}