Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does lossy decompression always generate same output?

Considering lossy compression formats (for images, audio, video etc...) and given that it only operates on the same compressed input file, does the same decompression algorithm always generate the same output? And what about different flavours of decompressors, do they generate the same output with the same input? I've read somewhere that some jpeg-decompression algorithms trade quality for speed, meaning that they wouldn't produce the same output.

So to summarize, given that we can know both the compression and decompression algorithms in use, will we be able to rely on the output always being the same. Can one get deterministic behaviour by controlling which algorithms are put to use?

Note. It doesn't necessarily have to output the original input though.

like image 994
mickey Avatar asked Aug 14 '14 08:08

mickey


1 Answers

It depends on the compression standard. Modern standards, such as H.264, have strict specs and reference decoders, and any compliant decoder should output bitwise exactly the same output as the reference decoder (modulo bugs of course). Older video codecs (such as MPEG-4 Part 2) don't specify the complete process in quite as much detail, so different implementations may output slightly different data (looking roughly similar but with minor differences in rounding). With inter-frame codecs, where future frames depend on earlier, such rounding errors can accumulate though.

For audio codecs, a compliant decoder mostly needs to come close to a reference signal while allowing for some implementation/rounding differences.

In most cases, the trading of quality for speed is done in the encoder, but some decoders also have options for deviating from the standards, to increase decoding speed but not outputting the exact correct image.

So it all comes down to both what codec standards you're using (whether they're written precisely enough to allow independent, bitexact implementations of them) and the actual decoder implementations.

like image 190
mstorsjo Avatar answered Oct 07 '22 06:10

mstorsjo