add 16 wide, 2 deep tree with RLE at the end. turns out to be worse than other algs

This commit is contained in:
Crispy 2025-06-17 15:21:20 +02:00
parent a1bcf7d90b
commit d44e5d9c55
3 changed files with 144 additions and 6 deletions

View file

@ -1,4 +1,4 @@
use std::{fs::File, io::Write};
use std::{fs::File, io::{stdout, Write}};
use enum_map::{Enum, EnumMap};
use num_enum::TryFromPrimitive;
@ -22,6 +22,7 @@ const LOSSLESS_ENCODINGS: &[FrameEncoder] = &[
// 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
];
const LOSSY_ENCODINGS: &[FrameEncoderLossy] = &[
enc::fill_white,
@ -101,7 +102,11 @@ fn main() {
fn encode(frames: &[Frame]) -> Vec<u8> {
let mut out = Vec::new();
let mut last_frame = FRAME_0;
print!("encoding frames");
let frame_count = frames.len();
for (_i, frame) in frames.iter().enumerate() {
print!("\rencoding frame {_i} of {frame_count}");
stdout().flush().unwrap();
let mut options = Vec::new();
for encode in LOSSLESS_ENCODINGS.iter() {
let encoded = encode(&last_frame, frame);
@ -157,6 +162,7 @@ fn encode(frames: &[Frame]) -> Vec<u8> {
out.extend_from_slice(&best_encoding);
last_frame = *frame;
}
println!();
out
}
@ -184,6 +190,7 @@ enum Encoding {
// CellDiff4VH,
CellDiff4VV,
// CellDiff4VV_large,
Tree16,
}
fn get_matching_decoder(encoding: Encoding) -> FrameDecoder {
@ -208,6 +215,7 @@ fn get_matching_decoder(encoding: Encoding) -> FrameDecoder {
// Encoding::CellDiff4HV => todo!(),
// Encoding::CellDiff4VH => todo!(),
Encoding::CellDiff4VV => dec::cell_diff_4_vertical,
Encoding::Tree16 => dec::tree_16,
}
}