Slashdot Mirror


Ten Dropbox Engineers Build BSD-licensed, Lossless 'Pied Piper' Compression Algorithm

An anonymous reader writes: In Dropbox's "Hack Week" this year, a team of ten engineers built the fantasy Pied Piper algorithm from HBO's Silicon Valley, achieving 13% lossless compression on Mobile-recorded H.264 videos and 22% on arbitrary JPEG files. Their algorithm can return the compressed files to their bit-exact values. According to FastCompany, "Its ability to compress file sizes could actually have tangible, real-world benefits for Dropbox, whose core business is storing files in the cloud."The code is available on GitHub under a BSD license for people interested in advancing the compression or archiving their movie files.

20 of 174 comments (clear)

  1. From TFA: bit-exact or not? by QuietLagoon · · Score: 4, Interesting

    ...Horn and his team have managed to achieve a 22% reduction in file size for JPEG images without any notable loss in image quality....

    Without any notable loss in image quality.

    .
    Hmmm... that does not sound like "bit-exact" to me.

    1. Re:From TFA: bit-exact or not? by danielreiterhorn · · Score: 5, Informative

      I'm the author of the algorithm and it's bit-exact. It has no quality loss. I just committed a description of the algorithm https://raw.githubusercontent.... It is bit exact and lossless: you can get the exact bits of the file back :-)

    2. Re:From TFA: bit-exact or not? by dskoll · · Score: 4, Funny

      Compress his comment and all the redundancy will be gone.

    3. Re:From TFA: bit-exact or not? by danielreiterhorn · · Score: 3, Informative

      This is an excellent summary and spot on! Our movie reduction claims are still early on. We'll need to find a more comprehensive set of H.264 movies to test on--and that requires the algorithm to understand B-slices and CABAC. These are both very close, but the code was only very recently developed. We're confident about the JPEG size reduction, however. If you want to learn more about how the JPEG stuff works, you can start with the open source repository from Matthias Stirner here http://www.matthiasstirner.com... Our work on JPEGs is very similarly inspired, but is completely streaming and works on partial JPEGs as well

    4. Re:From TFA: bit-exact or not? by danielreiterhorn · · Score: 5, Interesting

      Very insightful comments... let me go into detail
      I would say we have several advantages over H.264
      a) Pied Piper has more memory to work with than an embedded device (bigger model)
      b) Pied Piper does not need to seek within a 4 Megabyte block (though it must be able to stream through that block on decode) whereas H.264 requires second-by-second seekability (more samples in model).
      c) Pied Piper does not need to reset the decoder state on every few macroblocks (known as a slice), whereas H.264 requires this for hardware encoders (again, more samples per model).
      d) As opposed to a committee that designed H.264, Pied Piper had a team of 10 creative Dropboxers and guests, spending a whole week identifying correlations between the decoder state and the future stream. That is a big source of creativity! (design by commit, not committee)
      Our algorithm is, however streaming---and it's happiest to work with 4 MB videos or bigger
      Our decode window is a single previous frame--so we can pull in past information about the same macroblock-- but we only work in frequency space right now (there are some pixel space branches just to play with, but none has yielded any fruit so far) so the memory requirements are quite small.
      We are doing this streaming with just the previous frame as our state--- and it may matter--but we have a lot of work to do to get very big wins on CABAC... but given that we're not limited by the very small window and encoding parallelization requirements that CABAC is tied to, Pied Piper could well be useful soon!

    5. Re:From TFA: bit-exact or not? by danielreiterhorn · · Score: 5, Informative

      We also use arithmetic coding...but the gist of the improvement is that we have a much better model and a much better arithmetic coder (the one that VP8 uses) than JPEG did back then. I tried putting the JPEG arithmetic coder into the algorithm and compression got several percent worse, because that table-driven Arithmetic Coder just isn't quite as accurate as keeping counts as the VP8 one.

    6. Re:From TFA: bit-exact or not? by danielreiterhorn · · Score: 5, Interesting

      No one has tried to undo and redo compression of video files before. There are still doom9 forum posts asking for this feature from 12 years ago. I would say that saving lossless percentage points off of real world files is novel and important. And, since it's open source, if someone else gets more %age improvement than what we have, it could become as transformative as you describe.
      But the point is that we have something that's currently useful. It's out there and ready to be improved. It's lossless. And it has never before been tried.
      Also we did the entire algorithm in a week and aren't out of ideas!
      Besides we never claimed it was a revolution--leave that sort of spin to the marketeers...
      we're engineers trying to make things more efficient, a few percentage points at a time :-)

    7. Re:From TFA: bit-exact or not? by Cassini2 · · Score: 3, Interesting

      The grandparent poster is talking about compressing videos. If something is known about the data being encoded, then it is trivial to show that you can exceed the performance of arithmetic coding, because arithmetic coding makes no assumptions about the underlying message.

      For instance, suppose I was encoding short sequences of positions that are random integer multiples of pi. Expressed as decimal or binary numbers, the message will seem highly random, because of the multiplication by an irrational number (pi). However, if I can back out the randomness introduced by pi, then the compression of the resulting algorithm can be huge.

      The same applies to video. If it is possible to bring more knowledge of the problem domain to the application, then it is possible to do better on encoding. Especially with real-life video, there are endless cheats to optimize compression. Also, Dropbox may not be limited by real-time encoding. Drop-box might not even need intermediate frames to deal with fast-forward and out-of-order viewing. Dropbox may be solely interested in creating an exact image of the original file. Knowing the application affects compression dramatically.

      Lastly, application specific cheats can save real-world companies and individuals money and time. Practical improvements count as advancements too.

    8. Re:From TFA: bit-exact or not? by pla · · Score: 3, Interesting

      Interpolation is WORSE than nothing. you're discarding signal then adding noise in the hopes that it matches up with what should've been there kinda okay.

      1, 2, 3, X, 5, 6. Guess the value of X... Congratulations, you just interpolated the right answer.

      In the case of what the GP described, though, it works out even better than that, because the panel actually "knows" the right answer, so it hasn't "thrown away" information; it just lacks the luminance resolution to display it. It can, however, interpolate in the temporal domain way, way faster than the human eye can tell, to create a color we perceive as the correct value.

      / Go ahead, twitch gamers, tell us all about your ability to resolve sub-millisecond 1.5% color changes. XD

    9. Re:From TFA: bit-exact or not? by Megol · · Score: 4, Informative

      Interpolation isn't about adding noise.

      6 bit (per component) LCDs have for at least 10 years and probably much longer used dithering techniques to produce effective 16.2M colors (compared to a true 8 bit panel with 16.7M colors). This works very well for almost all use cases and provides smooth gradients but have the disadvantage that some image patters can produce flashing due to interference with the dithering algorithm.

      Dithering isn't about adding noise either BTW.

    10. Re:From TFA: bit-exact or not? by Bruce+Perens · · Score: 5, Insightful

      Rather than abuse every commenter who has not joined your specialty on Slashdot, please take the source and write about what you find.

      Given that CPU and memory get less expensive over time, it is no surprise that algorithms work practically today that would not have when various standards groups started meeting. Ultimately, someone like you can state what the trade-offs are in clear English, and indeed whether they work at all, which is more productive than trading naah-naahs.

  2. Re:Real Numbers? by HornWumpus · · Score: 3, Insightful

    How much CPU time to compress/decompress. Standard compression is hardly the best, just a good compromise between compression and usability.

    --
    John McAfee 'It was like that time I hired that Bangkok prostitute; to do my taxes, while I fucked my accountant'
  3. naysayers are missing the point by Ionized · · Score: 4, Informative

    comparing this to PNG or h.265 is missing the point - this is not a compression algorithm for creating new files. this is a way to take files you already have and make them smaller. users are going to upload JPG and h.264 files to dropbox, that is a given - so saying PNG is better is moot.

  4. Re:Real Numbers? by Anonymous Coward · · Score: 3, Funny

    Meh, doesn't matter. Any processing load will be moved to an unoptimized javascript implementation that runs in the end users browser.

  5. Re:No description by danielreiterhorn · · Score: 3, Informative

    Link to a layman's description of the algorithm here: https://raw.githubusercontent.... It's bit exact and lossless. We haven't done comprehensive studies, but on the included test files it gets 13% compression on H.264 movies. Similarly the not-committed, but similar JPEG algorithm gets 22% on a comprehensive sample set of photos from a variety of devices.

  6. Can it compress 3d videos? by leipzig3 · · Score: 4, Funny

    Can it compress 3d videos? That seems to be a real challenge.

  7. Re:Hard to believe by unrtst · · Score: 3, Informative

    H.264 and JPEG are supposed to output random-looking bytes, by definitions.

    If you can compress those, something is very wrong.

    Where'd you get that idea?

    $ bzip2 test.jpg
    $ gzip -9 test.jpg
    $ ls -la
    -rw-r--r-- 1 me me 1519279 Feb 7 2012 test.jpg
    -rw-r--r-- 1 me me 1430059 Aug 28 16:42 test.jpg.bz2
    -rw-r--r-- 1 me me 1427872 Aug 28 16:44 test.jpg.gz ... I also tried it on a max-compressed file. Opened that test.jpg up in gimp, then saved with quality at 0 (lowest), and re-did the compressing on both:
    -rw-rw-r-- 1 me me 189230 Aug 28 16:50 test2.jpg
    -rw-rw-r-- 1 me me 111623 Aug 28 16:50 test2.jpg.bz2
    -rw-rw-r-- 1 me me 117971 Aug 28 16:51 test2.jpg.gz

    Feel free to try the same experiment yourself on random jpg's you find online, or your own.

    The goal of H.264 and JPEG isn't minimum file size at all costs. It's also not encryption. Your premise is wrong, and even old tech can compress this stuff further than it may already be.

  8. Re:Hard to believe by Kjella · · Score: 3, Interesting

    H.264 and JPEG are supposed to output random-looking bytes, by definitions. If you can compress those, something is very wrong.

    Well, it seems to be applied per codec not a general compression algorithm like zip. And they probably say mobile-encoded for a reason, simple encoders have to work on low power and in real time, random JPGs from the Internet is probably the same. From what I can gather the algorithm basically take a global scan of the whole media and applies an optimized variable-length transformation making commonly used values shorter at the expense of making less commonly used values longer. Nothing you couldn't do with a proper two-pass encoding in the codec itself, the neat trick is doing it to someone else's already compressed media afterwards in a bit-reversible way. Very nice when you're a third party host, assuming the increase in CPU time is worth it but not so useful for everyone else.

    --
    Live today, because you never know what tomorrow brings
  9. Re:No description by ottothecow · · Score: 3, Insightful
    Yeah, but I've got to say that it is nice to see a bunch of comments actually talking about the compression algorithm.

    The tiny bit of slashdot community that is left still talks about the actual things. If this were on Reddit, it would just be a stream of lame, overused references to the Silicon Valley show. Somebody would say "This guy fucks". Somebody else would make a joke about "Optimal tip-to-tip efficiency". Then somebody would ask "Do you know what tres commas means".

    Those things were hilarious when put forth by a group of comedic actors. They are incredibly lame when they are overused every single time something even comes tangentially close to referencing them.

    So while this particular story still sucks...it could be a lot worse.

    --
    Bottles.
  10. Re: No description by danielreiterhorn · · Score: 3, Interesting

    It depends if the goal is to a) market a hip algorithm or b) store movies more efficiently.

    Open source makes it easy for anyone to contribute to the algorithm.
    The more people contribute, the better the code will be at compressing movies.

    The better it is at compressing movies, the fewer resources it will take to store them.
    This isn't a zero-sum game we're talking about: it's about making the world a more efficient place, one bit at a time.

    But the bottom line is that, it's a lot easier for many organizations to contribute to a code base if there are no strings attached.

    Interest from an article like this can get people playing around with compression.
    Maybe another 10% gain is right around the corner.