pcwalton / rust-media

A free, comprehensive, and portable video/audio streaming library for Rust
Apache License 2.0
787 stars 57 forks source link

Full Gif Support #21

Open Gankra opened 9 years ago

Gankra commented 9 years ago

Currently Gif Looping doesn't really have a decent API, and the example doesn't really use it.

The example also has problems rendering RGBA8888 (looks like SDL2 is getting confused about the format or something).

pcwalton commented 9 years ago

I think we should have some unit tests that test various GIF files to make sure they decode right. What do you think?

Gankra commented 9 years ago

I've started work on building out a general testing framework.

Gankra commented 9 years ago

I've added a reftest framework using TGAs generated by imagemagick. Currently 16/22 tests pass, with the remaining failures revolving around the really tricky interaction between disposal methods and transparency. To be clear: these gifs are sufficiently degenerate that the various programs on my computer that claim to understand gifs are producing several different outputs. The only errors I'm getting are incorrect transparency. As such I'd say this is basically production-ready for the "real" gifs you'd see in the wild. In particular, my personal stress tests produce correct results.

Still, I think I need to talk to Seth to figure out what the right implementation should be for these transparency corner cases.

pcwalton commented 9 years ago

I hate to ask you to do more, but I wonder if GIF should be a separate crate from rust-media (maybe for eventual Gecko integration?)

Gankra commented 9 years ago

That's cool with me, but I don't know what sort of API a "general" gif library should expose.

Gankra commented 9 years ago

Also to be clear: 0 effort has been put into optimizing this, particularly in its memory footprint. Once you've read the gif through once you basically have a complete copy of each rendered frame allocated. That's not really fundamental to the design, though. It just didn't make sense to me to optimize it before it's integrated fully into something to properly profile usage for.

pcwalton commented 9 years ago

I dunno, maybe something like Golang's image/gif? I think we should move Servo's GIF decoder over to use this, because having two GIF decoders (one for animated GIFs, one for static GIFs) doesn't make sense.