Skip to content

IMG_webp: Incorrect frame composition in animated WebP loading #521

Open
@inigomonyota

Description

@inigomonyota

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions