mirror of
https://github.com/exoticorn/upkr.git
synced 2026-01-20 19:46:42 +01:00
Compare commits
2 Commits
v0.2.0-pre
...
v0.2.0-pre
| Author | SHA1 | Date | |
|---|---|---|---|
| af5fe898bf | |||
| 331857a711 |
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "upkr"
|
name = "upkr"
|
||||||
version = "0.2.0-pre1"
|
version = "0.2.0-pre2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ pub struct Config {
|
|||||||
|
|
||||||
pub bitstream_is_big_endian: bool,
|
pub bitstream_is_big_endian: bool,
|
||||||
pub simplified_prob_update: bool,
|
pub simplified_prob_update: bool,
|
||||||
|
|
||||||
|
pub no_repeated_offsets: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Config {
|
impl Default for Config {
|
||||||
@@ -35,6 +37,8 @@ impl Default for Config {
|
|||||||
|
|
||||||
bitstream_is_big_endian: false,
|
bitstream_is_big_endian: false,
|
||||||
simplified_prob_update: false,
|
simplified_prob_update: false,
|
||||||
|
|
||||||
|
no_repeated_offsets: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ impl Op {
|
|||||||
}
|
}
|
||||||
&Op::Match { offset, len } => {
|
&Op::Match { offset, len } => {
|
||||||
encode_bit(coder, state, literal_base, config.is_match_bit);
|
encode_bit(coder, state, literal_base, config.is_match_bit);
|
||||||
if !state.prev_was_match {
|
if !state.prev_was_match && !config.no_repeated_offsets {
|
||||||
encode_bit(
|
encode_bit(
|
||||||
coder,
|
coder,
|
||||||
state,
|
state,
|
||||||
@@ -33,9 +33,9 @@ impl Op {
|
|||||||
(offset != state.last_offset) == config.new_offset_bit,
|
(offset != state.last_offset) == config.new_offset_bit,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
assert!(offset != state.last_offset);
|
assert!(offset != state.last_offset || config.no_repeated_offsets);
|
||||||
}
|
}
|
||||||
if offset != state.last_offset {
|
if offset != state.last_offset || config.no_repeated_offsets {
|
||||||
encode_length(
|
encode_length(
|
||||||
coder,
|
coder,
|
||||||
state,
|
state,
|
||||||
@@ -156,7 +156,8 @@ pub fn unpack(packed_data: &[u8], config: Config) -> Vec<u8> {
|
|||||||
if decoder.decode_with_context(&mut contexts.context_mut(literal_base))
|
if decoder.decode_with_context(&mut contexts.context_mut(literal_base))
|
||||||
== config.is_match_bit
|
== config.is_match_bit
|
||||||
{
|
{
|
||||||
if prev_was_match
|
if config.no_repeated_offsets
|
||||||
|
|| prev_was_match
|
||||||
|| decoder
|
|| decoder
|
||||||
.decode_with_context(&mut contexts.context_mut(256 * config.parity_contexts))
|
.decode_with_context(&mut contexts.context_mut(256 * config.parity_contexts))
|
||||||
== config.new_offset_bit
|
== config.new_offset_bit
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ fn main() -> Result<()> {
|
|||||||
config.use_bitstream = true;
|
config.use_bitstream = true;
|
||||||
config.bitstream_is_big_endian = true;
|
config.bitstream_is_big_endian = true;
|
||||||
}
|
}
|
||||||
|
Long("no-repeated-offsets") => config.no_repeated_offsets = true,
|
||||||
|
|
||||||
Long("z80") => {
|
Long("z80") => {
|
||||||
config.use_bitstream = true;
|
config.use_bitstream = true;
|
||||||
@@ -145,5 +146,6 @@ fn print_help(exit_code: i32) -> ! {
|
|||||||
eprintln!(" --invert-bit-encoding");
|
eprintln!(" --invert-bit-encoding");
|
||||||
eprintln!(" --simplified-prob-update");
|
eprintln!(" --simplified-prob-update");
|
||||||
eprintln!(" --big-endian-bitstream (implies --bitstream)");
|
eprintln!(" --big-endian-bitstream (implies --bitstream)");
|
||||||
|
eprintln!(" --no-repeated-offsets");
|
||||||
process::exit(exit_code);
|
process::exit(exit_code);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user