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

feat: consume frame after added, for reducing memory usage #32

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

meowtec
Copy link

@meowtec meowtec commented Nov 4, 2023

If we encode a WebP animation with many frames, caching all frames into a Vec and then adding them all to the encoder at once is not a good approach. This could potentially lead to excessive memory usage.

It is better to consume each frames after they are added.

API BREAKING CHANGE

AnimEncoder::add_frame() should return a Result.
(AnimEncoder::encode maybe should rename to AnimEncoder::finish, I'm not sure.)

In addition I update the example code to create a more complex and beautiful animation.

BTW, the animation decoder should return a iterator instead of a vector for the same reason.

@langyo

This comment was marked as outdated.

@meowtec meowtec force-pushed the feat/memory-reduce branch from 10a3a12 to 8ad7c9d Compare March 28, 2024 16:00
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

Successfully merging this pull request may close these issues.

2 participants