add more RLE variants that barely help

This commit is contained in:
Crispy 2025-06-17 16:02:34 +02:00
parent d44e5d9c55
commit c5f7c245d2
3 changed files with 172 additions and 18 deletions

View file

@ -11,15 +11,17 @@ pub use util::*;
const INSPECT_ENC: bool = false;
const INSPECT_DEC: bool = false;
const MAX_ERROR: usize = 0; // max wrong pixels
const MAX_LOSS: usize = 16; // highest "loss" value tried for all lossy encodings
const MAX_LOSS: usize = 0; // highest "loss" value tried for all lossy encodings
const LOSSLESS_ENCODINGS: &[FrameEncoder] = &[
enc::rle_horizontal,
enc::rle_horizontal_ext,
enc::rle_vertical,
enc::rle_vertical_ext,
enc::rle_vertical_var,
enc::rle_vertical_16,
// enc::rle_diff_horizontal,
// enc::rle_diff_vertical,
enc::rle_diff_horizontal,
enc::rle_diff_vertical,
// enc::bg_strips_horizontal_16, // only works for the tiny display
enc::bg_strips_horizontal_24, // intended for the 240x320 display
// enc::tree_16,// turns out to be useless
@ -131,12 +133,6 @@ fn encode(frames: &[Frame]) -> Vec<u8> {
let decoded = decode(&last_frame, &encoded.data, &mut 0);
let error = frame_error(frame, &decoded);
// if error > 0 && loss == 0 {
// dbg!(&encoded);
// println!("{:?}, error: {error}, frame: {_i}", encoded.encoding);
// render_images(&frame, &decoded);
// panic!("error in 'loss 0' compression");
// }
if error <= MAX_ERROR {
options.push(encoded);
} else {
@ -172,8 +168,10 @@ enum Encoding {
FillBlack,
FillWhite,
RLEHorizontal,
RLEHorizontalExt,
RLEVertical,
RLEVerticalExt,
RLEVerticalVar,
RLEVertical16,
RLEDiffHorizontal,
RLEDiffVertical,
@ -198,8 +196,10 @@ fn get_matching_decoder(encoding: Encoding) -> FrameDecoder {
Encoding::FillWhite => dec::fill_white,
Encoding::FillBlack => dec::fill_black,
Encoding::RLEHorizontal => dec::rle_horizontal,
Encoding::RLEHorizontalExt => dec::rle_horizontal_ext,
Encoding::RLEVertical => dec::rle_vertical,
Encoding::RLEVerticalExt => dec::rle_vertical_ext,
Encoding::RLEVerticalVar => dec::rle_vertical_var,
Encoding::RLEVertical16 => dec::rle_vertical_16,
Encoding::RLEDiffHorizontal => dec::rle_diff_horizontal,
Encoding::RLEDiffVertical => dec::rle_diff_vertical,