News for hackers. Stuff that matters.
Re:Chromium: Add support for Animated PNG by nayuki on Tuesday March 14, 2017 @09:24PM (#13873092)
It is said that the MNG decoder uses a few hundred kilobytes of code whereas APNG reuses more code from the PNG library. APNG is sort of a hack where the first frame is a normal PNG and subsequent frames are hidden in custom chunks.

https://en.wikipedia.org/wiki/APNG

https://en.wikipedia.org/wiki/Multiple-image_Network_Graphic...

Re:Chromium: Add support for Animated PNG by striking on Tuesday March 14, 2017 @09:54PM (#13873180)
It's not that the first frame is a normal PNG and that the rest of the frames are hidden. That's close, but it's not exact.

PNGs are stored as files with multiple kinds of chunks inside. The relevant one here is the IDAT chunk, which holds image data. Most PNGs have just one IDAT, but APNGs carry multiple (one for each frame). Readers that don't care about animating will simply display the first IDAT and stop reading there.

So it's a bunch of PNGs, coalesced into one, with some frame timing data. And the code for reading them is tiny if you already have a PNG library, because you display them like you would a regular PNG, but making sure to read out every IDAT, at the speed denoted by the acTL and fcTL chunks.

Re:Chromium: Add support for Animated PNG by TwoBit on Wednesday March 15, 2017 @01:07AM (#13873951)
Hopefully there's some delta compression between the frames. Or something other than a dumb array of independent images.
Re:Chromium: Add support for Animated PNG by Dylan16807 on Wednesday March 15, 2017 @06:06AM (#13875036)
There's no true inter-frame compression, but frames layer on top of each other by default. Unchanged areas can be transparent.
Re:Chromium: Add support for Animated PNG by laurent123456 on Wednesday March 15, 2017 @06:40AM (#13875150)
So a player is basically compositing many alpha-transparent images on top of each others to create the video?
Re:Chromium: Add support for Animated PNG by maxst on Wednesday March 15, 2017 @06:52AM (#13875194)
Re:Chromium: Add support for Animated PNG by nayuki on Wednesday March 15, 2017 @09:25AM (#13875889)
Yes most PNGs have just one IDAT, but having multiple IDATs does not imply an animation. In a normal PNG, the specification says that the contents of the IDAT chunks are chained together.

This feature is used if the DEFLATE compressor only uses a small output buffer (because each chunk has a length and CRC). The feature is also used if the PNG is enormous, because the maximum size of a chunk is 2^31 - 1 bytes but by chaining IDATs it is legal to represent image data that can't fit in a single chunk.