Hacker News new | ask | show | jobs
by nneonneo 107 days ago
This is one of the reasons I like the PNG format - it has checksums. You can fix a surprising number of broken files by bruteforce testing plausible errors until the checksum passes.

With JPEG one of the big problems is that the data is Huffman-encoded without any inter-block markers (except maybe Restart Markers, if you're lucky). This means that a single bitflip can result in a code changing length, causing frameshifts in many subsequent blocks and rendering them all undecodable. If you have a large block of missing data (e.g. a 4k-byte sector of zeros), then you have to guess where in the image the bitstream resumes, in addition to guessing the value of the running DC components.