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

IMG_webp: Incorrect frame composition in animated WebP loading #521

Open
inigomonyota opened this issue Feb 13, 2025 · 1 comment
Open

Comments

@inigomonyota
Copy link

inigomonyota commented Feb 13, 2025

The current animated WebP loader in SDL_image has incorrect frame composition behavior, leading to visual artifacts in animated WebP files. This is particularly noticeable in WebP animations that use transparency or have overlapping frames with different disposal methods.

Current Behavior

  • Frame disposal operations occur at the wrong time in the composition sequence
  • Transparency and background color handling does not respect the WebP alpha channel status
  • Frames are blended incorrectly, causing remnants of previous frames to persist
  • WEBP_MUX_DISPOSE_BACKGROUND is not properly clearing frame regions

Expected Behavior

  1. Frame disposal should occur before drawing the new frame
  2. Initial canvas state should:
    • Use transparency for WebPs with alpha channel
    • Use background color for non-alpha WebPs
  3. Frame composition should use SDL_BLENDMODE_NONE to ensure accurate pixel replacement
  4. Frame disposal should only affect the region of the disposed frame

Technical Details

The core issue is in IMG_LoadWEBPAnimation_RW where the frame composition logic doesn't match the WebP specification requirements

Test Case

Any animated WebP with:
-Transparent regions
-Overlapping frames
-Mixed disposal methods (WEBP_MUX_DISPOSE_BACKGROUND and WEBP_MUX_DISPOSE_NONE)

inigomonyota@7ace470

@slouken
Copy link
Collaborator

slouken commented Feb 13, 2025

Can you create a PR and add links to test images?

Thanks!

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

2 participants