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.

37 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 JoeMerchant · · Score: 2, Interesting

      If you are viewing images on an LCD monitor, the first thing you can do is strip them down from 24bit color to 18bit color, because your sub-$1000 monitors don't display more than 6 bits per color channel.

    2. 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 :-)

    3. Re:From TFA: bit-exact or not? by gtwrek · · Score: 2

      Both the summary and the article are a little light on details, however the article mentions replacing, (or extending) the arithmetic (lossless) encoder - i.e. Huffman - used within the JPEG and H264 standards.

      This would result in a lossless reduction in size of those files.

      Again, short on details. Any size reduction claims are sorta hand wavy without more details.

      But I'd think the loss-less label (or bit-exact) are ok in this context. Loss less from Jpeg -> DropJpeg.

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

      Compress his comment and all the redundancy will be gone.

    5. 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

    6. Re:From TFA: bit-exact or not? by mentil · · Score: 2

      Even cheap TN monitors use FRC to interpolate to 8-bit, which is better than nothing. IPS monitors can be had for $120, with an 8-bit color panel. Several gaming monitors use native 8-bit with FRC to 10-bit for less than $800, and a few even use native 10-bit.

      --
      Corruption is convincing someone that the selfless ideal is the same as their selfish ideal.
    7. Re:From TFA: bit-exact or not? by thesupraman · · Score: 2

      OK, As you are the author..
      Care to comment to the performance and window length of your encode/decode?

      As of course there is an innate difference between algorithms that must run streaming (for example... h264) and ones
      that can consider all of the content - the same for computational complexity - for video to be useful it must decode in
      real time on 'normal' machines.. Memory footprint for the compression window also matters a lot..

      My guess is that your decode overhead is not high, but you need a LOT of memory resource to hold your decode window,
      and that encode performance is horrific as you need to search a long way for matches.

      If that is true, then its (unfortunately) just a case of not much to see here - as I am sure you know longer windows = better
      compression. If it is not true (you are doing this with short windows and low encode overhead, then congratulations, it
      may well matter.

      jpeg is well known these days as leaving significant lossless rate on the table due to computational limitations when it was
      created. h264 does the same because of its need to support reasonably live streaming latency and be implemented in hardware.

    8. 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!

    9. Re:From TFA: bit-exact or not? by Punto · · Score: 2

      That's nice but did you ever find out what is the optimal way to jerk off all those people?

      --

      --
      Stay tuned for some shock and awe coming right up after this messages!

    10. 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.

    11. 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 :-)

    12. 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.

    13. 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

    14. Re:From TFA: bit-exact or not? by thesupraman · · Score: 2

      Its good that you understand that bold claims require clear evidence.. Thank you for replying.

      It is not surprising you can compress h264 using a 4mb block and token decode/recode, because of course that means you are using more resources than it (as you state) and removing functionality..
      I refer you to the following, hopefully you are aware of it..
      http://mattmahoney.net/dc/text.html
      Perhaps you should try your core modeling/tokenising against that, then consider how the ones that beat you do so.. not as an insult to your systems
      but as a guide to current advanced techniques. IF you cannot match them, perhaps you should consider why and if using some of those techniques
      would help... (hint: they will)

      BTW, by your description your system is not useful for streaming - streaming requires the ability to both recover from errors rapidly and to enter a live
      stream at an point withing a small window - that is pretty much WHY h264 has to reset state with great regularity. If you cannot do that then you do
      not support streaming.

      Towards the end you seem to be talking at odds to your 4MB block.. you claim you only need a single previous frame for decode, and that your memory requirements are small.. If that is so then I would suggest that there is other memory also being used.. or you are not fully utilising your 4MB block.

      Just a suggestion, you should compare yourselves with h264 that is extended to use similar resources - that can still be beaten (as it must support streaming and you dont), but you will find its compression goes up significantly - even though you are going 'off book' with respect to its standards.

      What you seem to be doing in effect is decoding the h264 token stream and then recompressing that without some of the functional demands that cause h264 to be structured as it is - that works, just be aware of the limitations you create - they are not just there because of 'committee'.

    15. 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.

    16. Re:From TFA: bit-exact or not? by davester666 · · Score: 2

      There's always somebody who will say they can tell the difference between the original file and the compressed/decompressed copy...

      --
      Sleep your way to a whiter smile...date a dentist!
    17. 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.

    18. Re:From TFA: bit-exact or not? by UnknownSoldier · · Score: 2

      Look, it is real easy to prove whether a monitor is 24-bit or 18-bit:

      * https://imgur.com/XF3LBOz

      Do you see Mach banding in the rows? (Easiest to tell in the greens and grays)

      Yes - your monitor is 24-bit
      No - your monitor is 18-bit

      Show me proof of _any_ LCD monitors that are 18-bit.

    19. Re:From TFA: bit-exact or not? by danielreiterhorn · · Score: 2

      Fair, but not all streaming use cases require seeking within a 4MB block (depends on the application). For those applications that require sub-4MB seeking, this won't be a good algorithm.

      Also there is a branch off the master repo that is exactly "h264 that is extended to use similar resources." (branch name h264priors) So yes--great idea.
      h264priors does pretty well, but not quite as good as the master branch--we're still getting to the bottom of how it does on a representative set of videos-- this is a week's work so far, not a dissertation :-)

      This won't work on text data since it uses state deep within a video decoder that doesn't apply to text streams (like what above-neighbor color presence bits are set).

  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.

    1. Re:naysayers are missing the point by mobby_6kl · · Score: 2

      It's not useless - it can be decoded by dropbox when serving the files.

      Seriously, it's that simple: users upload existing files to dropbox, they get loslessly compressed by this algorithm, and decompressed on access. Bam.

  4. Re:Benchmarks by Bengie · · Score: 2

    Would be nice to compare it against PNG, but the context is if you're storing other people's data and you have no control of what format they use.

  5. 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.

  6. Re:No description by harrkev · · Score: 2, Insightful

    And yet you can download the source code yourself and compile it.

    --
    "-1 Troll" is the apparently the same as "-1 I disagree with you."
  7. 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.

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

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

    1. Re:Can it compress 3d videos? by danielreiterhorn · · Score: 2

      If you organize the pixel data of the 3d movie into a spiral, then the algorithm my 9 colleagues and I put together will operate on it "middle-out". This can allow us to compress movies with a Weissman score that's off the chart!

  9. Image/Video libraries by phorm · · Score: 2

    I wonder if somebody can develop this into a transparent kernel-module.
    13-22% of a video library could mean saving several hundred GB on a multi-terabyte collection. Depending on if it decompresses on-the-fly and how hard it is on a CPU, it may also reduce disk I/O somewhat.

  10. 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.

  11. 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
  12. bah, I've got it down to 50% compression: by Thud457 · · Score: 2

    switch (rand % 2)
    {
    case 0 : /* here's some pr0n */;
    break;
    case 1 : /* here's a funny cat pikshur */;
    default : /* are you're really sure you aren't looking for some pr0n? */
    }

    --

    the preceding comment is my own and in no way reflects the opinion of the Joint Chiefs of Staff

  13. Re: Hard to believe by ttucker · · Score: 2

    Try the -h param for ls, calculating is for computers.

    Not really useful in this context, because it truncates significant digits.

  14. 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.
  15. Re:Hard to believe by sribe · · Score: 2

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

    Bullshit. JPEG, *by its definition*, after the quantization step, uses a fairly modest & inefficient compression algorithm, because it was designed to be run on embedded systems with very modest processing power.

  16. 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.