Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
×
Math Media Open Source

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

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.
This discussion has been archived. No new comments can be posted.

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

Comments Filter:
  • by QuietLagoon ( 813062 ) on Friday August 28, 2015 @03:22PM (#50412317)

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

    • by suutar ( 1860506 )

      bit-exact is easier to test than "image quality". I suspect a less than tech-savvy reporter heard "no loss" and stuck in "notable".

    • Re: (Score:3, Interesting)

      by JoeMerchant ( 803320 )

      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.

      • by mentil ( 1748130 )

        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.

        • Sorry, I was probably off on the price point - technology has moved on. Still, it wasn't a widely advertised fact that almost all "gaming" LCD monitors sold before IPS were 6 bit, or 6 bit with "dithering" which is not really much better.

      • That's complete nonsense and easy to disprove.

        Your are claiming only 18-bit color - a total of (2^6)^3 = 262144 colors; or 2^6 = 64 colors for primary RGB gradients. That would mean every 4 colors out of 256 primaries you wouldn't be able to tell the difference! Since one can easily tell the difference between:

        0xFF, 0xFE, 0xFD, 0XFC, 0xFB

        That means your claim is complete bullshit.

        QED.

        • Depends on your monitor, of course, but a whole (recent) generation of "LCD gaming screens" only showed 6 bits of color depth:

          http://compreviews.about.com/o... [about.com]

          Also, even when you show people the bottom 2 bits, they usually don't perceive them:

          http://rahuldotgarg.appspot.co... [appspot.com]

          • And the specific manufacturers and models listed with 18-bit are listed where again???

            Oh wait, they aren't.

            Stop spouting bullshit. At least link to an article with hard facts and a timestamp.

            • by AaronW ( 33736 )

              This information is often transmitted over EDID from the monitor to the host computer. Some graphics cards can use this information to automatically turn on and configure temporal dithering. The Linux nVidia driver can do this with the nvidia-settings utility. It will also report what the monitor is actually capable of.

          • by AaronW ( 33736 )

            There are a couple settings in the nVidia tool for Linux to turn on the temporal dithering so it can be done in the graphics card when the monitor doesn't do it. It's easy to turn on in nvidia-settings.

          • I said **primary RGB gradients**, as in, Red, Green, Blue or White for a reason.

            Quit changing the topic to steganography which is an apples to oranges comparison and no one gives a shit about _that_ to tell if your monitor is 24-bit.

            • by Khyber ( 864651 )

              "no one gives a shit about _that_ to tell if your monitor is 24-bit."

              As I said before, get with real fucking technology. Catch up, you're way the fuck behind. 10-bit (that's 30-bit A-RGB colorspace) 4K monitors, S-IPS, 28" for $600.

              Yawn. As I told you before, we're not in the days of your shitty Apple displays.

        • There used to be a web page called "Your Eyes Suck at Blue". You might find it on the Wayback machine.

          You can tell the luminance of each individual channel more precisely than you can perceive differences in mixed color. This is due to the difference between rod and cone cells. Your perception of the color gamut is, sorry, imprecise. I'm sure that you really can't discriminate 256 bits of blue in the presence of other, varying, colors.

    • by danielreiterhorn ( 4241309 ) on Friday August 28, 2015 @03:42PM (#50412471)
      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.... [githubusercontent.com] It is bit exact and lossless: you can get the exact bits of the file back :-)
      • 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 memor

        • And just to reply to myself.. it is generally a BAD idea to imply you have an encoding method better than arithmetic (lets hope
          the article horrible miss quoted you there..
          'yet it is well known that applying an additional arithmetic coder to existing JPEG files brings a further 10% reduction in file size at no cost to the file," he says. "Our Pied Piper algorithm aims to go even further with a more efficient encoding algorithm that maps perfectly back to existing formats."'
          As of course it is a numerical impo

          • by danielreiterhorn ( 4241309 ) on Friday August 28, 2015 @04:49PM (#50412913)
            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.
            • You seem to be confused as to what arithmetic coding is..
              What you seem to be talking about is the accuracy of the token counts being used to drive the arith coder.. arithmetic coding says nothing about those, except that they have to exist.
              Beating a given implementation? of course, there are several ways..
              But claiming to have better arithmetic coding itself is silly, what you have is better token distribution figures.

              Want to pony up some estimates on performance and memory requirements?

            • by AaronW ( 33736 )

              That jives with my experience when I took a class that covered compression back in college. The professor, Glen Langdon held a bunch of patents at the time on arithmetic coding. Encoding efficiency could be improved by having it forget old data and making it more dynamic as I recall.

              • by fnj ( 64210 )

                That jives with my experience

                It is always jarring to find a college grad who is not fluent in the difference between such common words as jive and jibe.
                "Harlem jive is the argot of jazz."
                "Your belief does not jibe with reality."

          • by Cassini2 ( 956052 ) on Friday August 28, 2015 @05:08PM (#50413025)

            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.

        • by danielreiterhorn ( 4241309 ) on Friday August 28, 2015 @04:47PM (#50412897)
          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!
          • 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 i

            • 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
              • I would really REALLY suggest you spend a little more time researching those other compressors you so easily consider to be 'text streams', they are not.
                for example, one of them also happens to hold the current record for non lossy image compression..

                Its all a matter of feeding them the right models, and I can guarantee that a good PPM or CM set of models will do much better than a weeks worth
                of model development - but of course they reason they WILL is because they take care of the downstream details - the

      • by Punto ( 100573 )

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

      • by AmiMoJo ( 196126 )

        So, correct me if I'm wrong, but you are basically fixing a few known limitations of JPEG and mobile recorded video files.

        For example JPEG uses RLE, and for decades we have been able to shave about the same as you do off their size by replacing that with a more efficient compression scheme in a lossless way. Mobile recorded video makes similar compromises to reduce processing overhead.

        To be clear, you have no invented a really new, revolutionary compression algorithm like the TV show. No 4k uncompressed vid

        • by danielreiterhorn ( 4241309 ) on Friday August 28, 2015 @05:07PM (#50413021)
          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 :-)
          • by AmiMoJo ( 196126 )

            Sure, I'm not saying it isn't useful, it certainly is... But Pied Piper, really?

            It's a good project, no need to over-sell it.

          • No one has tried to undo and redo compression of video files before.

            Great job! I've thought about it before, as clearly have others given those doom9 posts. I'm glad to hear it works well and that someone's done it! It sounds like you were going for 4mb blocks if I gather correctly?

            How much do you gain/lose going to 8 or 2mb block.

          • by Khyber ( 864651 )

            "No one has tried to undo and redo compression of video files before."

            I'm sorry, that's just nonsense. What do you think a format converter does?

    • by gtwrek ( 208688 )

      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.

      • Re: (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.matthiasst [matthiasstirner.com]
        • I'm curious to know if you've tried this on a video compressed using the H.264 lossless compression settings.
  • "22% better compression" without "notable" quality loss on files which are ALREADY compressed in formats in which loss may be apparent is a far cry from their ultimate "goal" of "lossless" compression.
  • by Ionized ( 170001 ) on Friday August 28, 2015 @03:35PM (#50412417) Journal

    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.

    • by Dahamma ( 304068 )

      Except unless standard DECODERS can handle them it's fairly useless in practice.

      From what I can tell from the source & description posted it does NOT conform to H.264, so what's the point? SOMETHING has to decode it, and it's clearly not going to be standard hardware decoders. So it's useless as CDN storage. Same applies to PNGs for most usage.

      And besides, H.265 implements everything they did and MUCH more. And if you want even further lossless compression that humans can't notice there are proprie

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

      • by SirSlud ( 67381 )

        Jesus dude. Dropbox controls the in and the out of the pipe. So their client can compress further on upload and decompress when downloading/streaming. I don't understand how a simple business case can be so confusing for people.

  • Time for the new wave of Stacker clones, maybe a new DoubleSpace err DriveSpace?
    • I'd settle for Mr. 7-Zip (Igor Pavlov) to add this method to his program.

      With a BSD license, he should be able to do it. (Time permitting)

  • by leipzig3 ( 528671 ) on Friday August 28, 2015 @03:51PM (#50412547)
    Can it compress 3d videos? That seems to be a real challenge.
    • 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!
  • 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.

    • by godrik ( 1287354 )

      Indeed, CPU cost is a real problem. The key in a compression algorithm for a network storage server is to be able to perform compression/decompression without much impact on latency and bandwidth. Also in these days of massive server farm, the impact on energy consumption might be interesting to see; but it is difficult to measure directly as compression might result in less disk spinning, machine kept on, but more CPU usage.
      An interesting engineering problem overall.

    • by AaronW ( 33736 )

      This would be better suited for FUSE.

  • when they have made Nip Alert a reality.

  • Lossy codecs typically have two major stages -- the lossy parts (e.g. dct while throwing out some component frequencies, motion prediction, etc.) -- followed by lossless entropy coding (e.g. Huffman in JPEG) to further compress the resultant data.

    These compression algorithms just decompress the lossless part of the process and then recompress it with a more efficient lossless algorithm. On decompression, it then recompresses with the standard algorithm. In some cases (e.g. JPEG) you can keep a copy of the H

    • by Dahamma ( 304068 )

      Postprocessing software like Beamr (look it up yourself...) can often do even better for video. Basically the H.264 codecs are fairly conservative on their quantizers, with a minimum that's way above what they could get away with. Way better off throwing away useless data than figuring out how to compress it.

You are always doing something marginal when the boss drops by your desk.

Working...