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

WebP animation decoder requires all frames to be decoded up front #2359

Closed
Shnatsel opened this issue Oct 22, 2024 · 2 comments
Closed

WebP animation decoder requires all frames to be decoded up front #2359

Shnatsel opened this issue Oct 22, 2024 · 2 comments
Labels
kind: slow Not wrong, but still unusable

Comments

@Shnatsel
Copy link
Contributor

As of v0.25.4, WebPDecoder::into_frames() decodes the entire animation up front, as opposed letting the user read frames one by one.

This is a blocker for Oculante to migrate away from libwebp-sys + webp-animation to image's memory-safe WebP animation decoder: woelper/oculante#252 (comment)

This will also be an issue for wondermagick which will need to support decoding a set of specific frames, and always decoding all of the frames will be slow.

@fintelia
Copy link
Contributor

Are you sure? Looking at the code, it seems that next_frame is called lazily within webp::FramesInner::next each time a new frame is requested. Though if you call collect on the iterator it'll of course decode all the frames.

image-webp does scan the chunk headers for each frame of the animation when creating the decoder (to determine the animation runtime and determine whether the image uses lossy compression), but I'd expect that to be comparatively cheap.

@Shnatsel
Copy link
Contributor Author

That was an incorrect assumption, the performance bottleneck is elsewhere: woelper/oculante#252 (comment)

I'll investigate and open an issue with a profile.

@Shnatsel Shnatsel closed this as not planned Won't fix, can't repro, duplicate, stale Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: slow Not wrong, but still unusable
Projects
None yet
Development

No branches or pull requests

2 participants