Search code examples
c++pngdeflate

how to decompress the DEFLATE compressed data


I wanted to create the internet trend BadApple in c++ console. By extracting every frame from the BadApple video using ffmpeg in .png format and reading RGB pixel data from it. I already have a boiler plate code on how to extract chunks by reading this article in Wikipedia. And I don't want to use any libraries.

I found many sources on how DEFLATE compression works and all the FILTER methods, but can't find sources for how to undo the FILTER methods and others.

Please Help.

Note: Some might suggest to use an easy extension like .bmp where we can ready the pixel data directly without any decompression, which I already did and completed the project. Here's the link. But I really want to learn how the algorithm works. Thanks


Solution

  • It's all in the PNG specification.

    Section 9.2

    Section 9.4