Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@skidder
Copy link
Contributor

@skidder skidder commented Nov 7, 2024

Description

This PR adds functionality to detect and propagate loop count information from animated GIF sources to WebP outputs. Previously, all GIFs were treated as infinitely looping, but this change allows proper handling of GIFs with specific loop counts (e.g., play once, play N times).

Changes

  • Added giflib_decoder_get_loop_count() C++ function to parse NETSCAPE2.0 extension blocks
  • Extended Go GIF decoder struct to cache loop count information
  • Updated GIF decoder's LoopCount() method to return actual loop count
  • Added test case using a non-looping GIF file

Technical Details

  • The NETSCAPE2.0 extension block is parsed to extract loop count information
  • Default loop count is 1 (play once) if no extension block is found
  • Loop count of 0 indicates infinite looping
  • Loop count information is cached to avoid repeated parsing

Testing

  • Added test case with a non-looping GIF file
  • Verified loop count propagation through the WebP encoder pipeline
  • Existing tests continue to pass

- Enhance loop count detection to handle multiple extension blocks
- Add proper cleanup and error handling in GIF parsing
- Add test cases for duplicate loop counts and multiple extensions
@skidder skidder merged commit 2a8aa7e into master Nov 7, 2024
2 checks passed
@skidder skidder deleted the skidder/preserve-animated-gif-loop-count branch November 7, 2024 19:02
skidder added a commit that referenced this pull request Nov 7, 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

Successfully merging this pull request may close these issues.

3 participants