add RLEVerticalExt (16 bit run length support)

This commit is contained in:
Crispy 2025-06-16 23:46:01 +02:00
parent 90f648e0b0
commit 62ee8a6efa
8 changed files with 77689 additions and 106875 deletions

View file

@ -16,17 +16,18 @@ const MAX_LOSS: usize = 16; // highest "loss" value tried for all lossy encoding
const LOSSLESS_ENCODINGS: &[FrameEncoder] = &[
enc::rle_horizontal,
enc::rle_vertical,
enc::rle_diff_horizontal,
enc::rle_diff_vertical,
enc::rle_vertical_ext,
// 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::bg_strips_horizontal_24, // intended for the 240x320 display
];
const LOSSY_ENCODINGS: &[FrameEncoderLossy] = &[
enc::fill_white,
enc::fill_black,
// todo: adapt these for big display
// todo: adapt for big display
// enc::cell_diff_8_vertical,
// enc::cell_diff_4_vertical_small,
// enc::cell_diff_4_vertical,
];
fn main() {
@ -80,6 +81,7 @@ fn main() {
}
export_string += "} Encoding_t;\n\n";
export_string += "const unsigned char video[] = {";
// export_string += &format!("const unsigned char video[{}] = {{", encoded.len());
let mut i = 99;
for byte in encoded {
if i > 15 {
@ -108,7 +110,9 @@ fn encode(frames: &[Frame]) -> Vec<u8> {
options.push(encoded);
} else {
dbg!(&encoded);
eprintln!("{:?}, error: {error}, frame: {_i}", encoded.encoding);
println!("{:?}, error: {error}, frame: {_i}", encoded.encoding);
println!("original | decoded");
render_images(&frame, &decoded);
panic!("error in lossless compression");
}
@ -161,6 +165,7 @@ enum Encoding {
FillWhite,
RLEHorizontal,
RLEVertical,
RLEVerticalExt,
RLEDiffHorizontal,
RLEDiffVertical,
BGStripsH16,
@ -173,7 +178,7 @@ enum Encoding {
// CellDiff4HH,
// CellDiff4HV,
// CellDiff4VH,
CellDiff4VV_small,
CellDiff4VV,
// CellDiff4VV_large,
}
@ -183,6 +188,7 @@ fn get_matching_decoder(encoding: Encoding) -> FrameDecoder {
Encoding::FillBlack => dec::fill_black,
Encoding::RLEHorizontal => dec::rle_horizontal,
Encoding::RLEVertical => dec::rle_vertical,
Encoding::RLEVerticalExt => dec::rle_vertical_ext,
Encoding::RLEDiffHorizontal => dec::rle_diff_horizontal,
Encoding::RLEDiffVertical => dec::rle_diff_vertical,
Encoding::BGStripsH16 => dec::bg_strips_horizontal16,
@ -195,8 +201,7 @@ fn get_matching_decoder(encoding: Encoding) -> FrameDecoder {
// Encoding::CellDiff4HH => todo!(),
// Encoding::CellDiff4HV => todo!(),
// Encoding::CellDiff4VH => todo!(),
Encoding::CellDiff4VV_small => dec::cell_diff_4_vertical_small,
// Encoding::CellDiff4VV_large => dec::cell_diff_4_vertical_large,
Encoding::CellDiff4VV => dec::cell_diff_4_vertical,
}
}