Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compact bitmap animation #10

Closed
fweiss opened this issue Jul 5, 2024 · 8 comments
Closed

Compact bitmap animation #10

fweiss opened this issue Jul 5, 2024 · 8 comments

Comments

@fweiss
Copy link
Owner

fweiss commented Jul 5, 2024

Currently, bitmap animations are defined with std::vector<uint32_t>. This gobbles up memory. Indeed, have to compile with -Os.

We propose a color table model like that used in Felix. Use std::vector<uint8_t> or std::vector<uint16_t> along with a color table of uint32_t[]``.

Comverting existing data should be easy using search and replace.

@fweiss
Copy link
Owner Author

fweiss commented Jul 9, 2024

Size reduction log:

  • baseline badge.bin binary size 0xdf9f0 bytes. Smallest app partition is 0x100000 bytes. 0x20610 bytes (13%) free.
  • felix badge.bin binary size 0xdfbe0 bytes. Smallest app partition is 0x100000 bytes. 0x20420 bytes (13%) free.

The felix refactoring actually added 496 bytes. Maybe due to initialization via copy?

Switching from int16_t to uint8_t enum size didn't make a difference.

Let's try alphabet, we expect an improvement of about 20KB.

@fweiss
Copy link
Owner Author

fweiss commented Jul 12, 2024

Alphabet size:

badge.bin binary size 0xdfd70 bytes. Smallest app partition is 0x100000 bytes. 0x20290 bytes (13%) free.

That's an increase of 400 bytes. Was expecting a much greater reduction.

OK, changed the ColorIndex to int16_t
badge.bin binary size 0xdf5b0 bytes. Smallest app partition is 0x100000 bytes. 0x20a50 bytes (13%) free.

Ahh, reduction of 1584.

And then, take ColorIndex to uin8_t:
badge.bin binary size 0xdf180 bytes. Smallest app partition is 0x100000 bytes. 0x20e80 bytes (13%) free.

That reduced by 2556 (over the Felix)

@fweiss
Copy link
Owner Author

fweiss commented Jul 12, 2024

Outputting the assembly code by adding set_target_properties(${COMPONENT_LIB} PROPERTIES COMPILE_FLAGS "-save-temps=obj") to CMakeLists.txt. The result is Alphabet.cpp.s in the folder build/esp-idf/main/CMakeFiles.

But the initialization is weird. It's broken into chunks somehow.

@fweiss
Copy link
Owner Author

fweiss commented Jul 13, 2024

Using a static pixelIndexes[52][64]:
badge.bin binary size 0xdebb0 bytes. Smallest app partition is 0x100000 bytes. 0x21450 bytes (13%) free.

Reduction from Felix is 4144. Still expecting better. By reducing each pixel from 4 bytes to 1 byte saves 3 bytes. Over a total of 52 x 64 pixels, that should reduce by 9984

The assembly code does have .byte 0 for a count of 3328 (52*64)

@fweiss
Copy link
Owner Author

fweiss commented Jul 13, 2024

Using [][] instead of vector provides reduction, but not as much as theoretically possible. I think it's best to leave it at that for now. The main test would be if after turning of -Os, the program can fit.

@fweiss
Copy link
Owner Author

fweiss commented Jul 18, 2024

After refactoring dice animation:
badge.bin binary size 0xdea00 bytes. Smallest app partition is 0x100000 bytes. 0x21600 bytes (13%) free.
This is a reduction of 4576 over felix

With ColorIndex : uint16_t, size was 0xdeb80, with uint32_t, size was 0xdee70

@fweiss
Copy link
Owner Author

fweiss commented Jul 19, 2024

After refactoring EmojiAnimation:
badge.bin binary size 0xde020 bytes. Smallest app partition is 0x100000 bytes. 0x21fe0 bytes (13%) free.

Reduction over Felix was 7104

fweiss added a commit that referenced this issue Jul 19, 2024
@fweiss
Copy link
Owner Author

fweiss commented Jul 19, 2024

Did not refactor all the animations becuse it got difficult. See #18. Did do the worst ones, Emoji and alphabet.

@fweiss fweiss closed this as completed Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant