diff options
author | Kostya Shishkov <kostya.shishkov@gmail.com> | 2021-11-01 18:16:17 +0100 |
---|---|---|
committer | Kostya Shishkov <kostya.shishkov@gmail.com> | 2021-11-01 18:16:17 +0100 |
commit | bc23de6bedc2e151caea241b073a65d30f62c134 (patch) | |
tree | c0f6a1e2cfcdaa1cce0676d03c3efe3d3ae70e54 | |
parent | b9995c2ca73cb50f1e9f2ad7a08c49b20135b041 (diff) | |
download | nihav-bc23de6bedc2e151caea241b073a65d30f62c134.tar.gz |
core/compr: allow inflate work with a custom dictionary
-rw-r--r-- | nihav-core/src/compr/deflate.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/nihav-core/src/compr/deflate.rs b/nihav-core/src/compr/deflate.rs index 7b36ead..b126661 100644 --- a/nihav-core/src/compr/deflate.rs +++ b/nihav-core/src/compr/deflate.rs @@ -356,6 +356,14 @@ impl Inflate { self.full_pos += len; Ok(()) } + ///! Sets custom history for decoding an update for already decoded data. + pub fn set_dict(&mut self, dict: &[u8]) { + let len = dict.len().min(self.buf.len()); + let start = dict.len() - len; + self.buf[..len].copy_from_slice(&dict[start..]); + self.bpos = len; + self.full_pos = len; + } ///! Reports whether decoder has finished decoding the input. pub fn is_finished(&self) -> bool { match self.state { |