optimise ch32 code further

This commit is contained in:
Crispy 2025-06-19 01:03:55 +02:00
parent 382cd92629
commit a2b7e26ace
4 changed files with 223 additions and 228 deletions

View file

@ -16,24 +16,24 @@ 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_horizontal_ext_2,
// enc::rle_horizontal_ext_2,
enc::rle_vertical,
// enc::rle_vertical_ext,
enc::rle_vertical_ext_2,
// enc::rle_vertical_ext_2,
// enc::rle_vertical_var, // not worth
// enc::rle_vertical_16, // not worth
// 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_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
enc::cell_diff_8_vertical_big,
// enc::cell_diff_8_vertical_big,
];
const LOSSY_ENCODINGS: &[FrameEncoderLossy] = &[
enc::fill_white,
enc::fill_black,
// todo: adapt for big display
// enc::cell_diff_8_vertical,
enc::cell_diff_8_vertical,
// enc::cell_diff_4_vertical,
];
@ -90,8 +90,7 @@ fn main() {
}
}
export_string += "} Encoding_t;\n\n";
export_string += "const unsigned char video[] = {";
// export_string += &format!("const unsigned char video[{}] = {{", encoded.len());
export_string += &format!("const unsigned char video[{}] = {{", encoded.len());
let mut i = 99;
for byte in encoded {
if i > 15 {
@ -173,22 +172,22 @@ enum Encoding {
FillBlack,
FillWhite,
RLEHorizontal,
RLEVertical,
BGStripsH16,
CellDiff8V,
RLEHorizontalExt,
RLEHorizontalExt2,
RLEVertical,
RLEVerticalExt,
RLEVerticalExt2,
RLEVerticalVar,
RLEVertical16,
RLEDiffHorizontal,
RLEDiffVertical,
BGStripsH16,
BGStripsH24,
// BGStripsV,
// QuadTree,
// DrawCommands,
// CellDiff8H,
CellDiff8V,
CellDiff8VBig,
// CellDiff4HH,
// CellDiff4HV,

View file

@ -5,10 +5,12 @@ use std::{
use image::{self, DynamicImage, GenericImageView, ImageFormat, Rgba};
// pub const OUTPUT_DIR: &str = "ch32_decoder";
pub const OUTPUT_DIR: &str = "pico_decoder/src";
pub const WIDTH: usize = 320;
pub const HEIGHT: usize = 240;
pub const OUTPUT_DIR: &str = "ch32_decoder";
pub const WIDTH: usize = 40;
pub const HEIGHT: usize = 32;
// pub const OUTPUT_DIR: &str = "pico_decoder/src";
// pub const WIDTH: usize = 320;
// pub const HEIGHT: usize = 240;
pub const FRAME_SIZE: usize = WIDTH * HEIGHT;
pub type Frame = [[u8; HEIGHT]; WIDTH];