Welcome to our community

Be a part of something great, join today!

  • Hey all, just changed over the backend after 15 years I figured time to give it a bit of an update, its probably gonna be a bit weird for most of you and i am sure there is a few bugs to work out but it should kinda work the same as before... hopefully :)

Wavelet Compression Analyzed

Gavin Greenwalt

Well-known member
Joined
Dec 29, 2006
Messages
7,614
Reaction score
0
Points
36
Age
40
  • With permission this is from an article I wrote for Showreel Magazine. A Magazine I only just started reading when I got the last issue but is actually very exciting and I highly recommend picking up a subscription at http://www.showreel.org

    As a result I request that you do not repost this elsewhere. Thanks.

    - Gavin

Uncompressed images can be downloaded here:
http://www.mediafire.com/?e00ljjh9xjz

Let me begin this by prefacing that this is not an empirically accurate study on the effects of compression. Nor is it an evaluation of any one product, the goal is not to test any specific codec but rather a family of compression. If you are searching for a codec showdown you'll have to look elsewhere. However, what this article does hope to provide is a glimpse at the options that are available now or will become available in the near future and help you focus your attention on some options you might not have otherwise investigated.

The intent in these evaluations is to demonstrate a set of tests which could be carried out on one's own time without the need for rare or proprietary equipment. With a multitude of Ultra High Definition cameras on the horizon many of us are beginning to realize that holding onto an uncompressed workflow may be a luxury we can no longer afford. Hopefully when you’re done reading this article you’ll be able to walk away more confident in understanding the options available to you.

So what is a wavelet and how is it different from what you're already using? Well to answer that first we need to address how other widely used compression schemes work. I'll try to order them in it compression intelligence.

RLE and its friend Packbits are some of the least intelligent encoding schemes. These are your built-in compression options for Targa images. Both simply group together continuous sections of repeating data. For example if we have a row of pixels:
0 0 0 0 14 14 0 0 23 0 0 0 0 0.
RLE will group them into:
4 ‘0’s, 2 ‘14's, 2 ‘0’s, 1 ‘23’ and 5 ‘0’s.
This can save a great deal of space if your image has large blocks of solid color (for example alpha maps, text, motion graphics etc…) but does a very poor job on noisy images. If a solid block is 1 pixel wide or a thousand, it will take the same amount of bits to compress it with RLE.

Zip and LZW are the most common members of the next family of compression methods known as the “Dictionary Compressors”. The basic principle behind a dictionary compressor is similar to an RLE except instead of blindly operating in an order, a dictionary compressor finds repeating patterns wherever they might occur and calls on them later. For example if we have the sentence:
"I am hoping the article that I am writing will help you understand your compression options better"
The compressor will identify... 1:"I am" 2:"ing" 3:"you" 4:"ion" and 5:"th"... as recurring patterns to save in a library along with the data:
"1 hop2 5e article 5at 1 writ2 will help 3 understand 3r compress4 opt4ns better". On decompression the software will play a game of paint by numbers to fill in the data.

Both of these families of compression are mathematically lossless. The decompressed image is identical pixel for pixel to the original. However often on natural images they lose effectiveness and a more advanced compression scheme would do better.

The group of compression methods which we most often see in video is a family called DCT which is always lossy (The compressed image is similar but not identical to the original). This group encompesses JPEG, MPEG 1-4, HDCam, DV, and just about every other video compression system you'll probably encounter in your day to day work. Depending on the codec the image will be broken up into X pixel by Y pixel blocks. Each block, based on the quality setting, will attempt to discard all detail frequency above the specified quality threshold. The problem with this methodology is often some details don't fall entirely within neat little AxB sized boxes. As a detail, such as a strand of hair, extends through several boxes each box attempts to reduce itself into the most efficient box it can be regardless of what its neighbor is doing. If in the previous example the hair's contrast is low enough, it might be treated as a high frequency detail and discarded in one box, but not the next. This is where you often see zig-zaggy edges and is the bane of compositors everywhere.
DCTcompressionartifacts.jpg


Finally we have Wavelets which come in both lossless and lossy flavors. Despite the recent spike in interest in wavelets they aren’t some crazy new fangled invention. Several solutions have been commercially available for several years such as Bink Video which uses a hybrid wavelet/DCT scheme to compress videos for in-game cinematics. Fundamentally Wavelets share a great deal in common with DCT compression however it features one important distinction. A wavelet image is able to scale its sample size from a single pixel to the entire image depending on the content. If an image is 32pixels by 32pixels the wavelet will first evaluate all 32x32 boxes, then reduce it to 16x16, 8x8...and so on and so forth until finally reducing the image to a 1x1 pixel sample. Where there is fine detail, smaller, more refined boxes will be used. If the image detail is courser than the designated quality setting requires the encoder will discard those samples 'revealing' the lower resolution below. This results in more detail remaining in the areas that need it most and less detail where it would be unnecessary. It’s all very similar to how a painter will build up from large general brushes and washes to smaller detailed brushes. This method works especially well when you’re ‘short’ on bandwidth and require heavy compression. Wavelets also work especially well on many digital cinema cameras due to the lack of high frequency grain allowing them to heavily compress low contrast areas without a reduction in the SNR. It’s actually that side effect which has led to wavelets being employed as a noise and grain reduction algorithm.
Waveletcompressionartifacts.jpg


So are Wavelets the be-all-end-all compression scheme? As all things in this world it isn’t as cut and dry as one might hope. Wavelets do offer some very distinct advantages over DCT. As the file size decreases the image tends to degrade much more gracefully and organically. Instead of ending up with a bunch of unnatural blocks wavelets tend to leave the noisy, low contrast areas of the image softer. In green screen scenarios this can actually be advantageous as it’ll intelligently reduce the noise in the large flat green areas while holding on to detail in the edges and hair. However all of this adaptive intelligence comes at a cost in speed. Compared to most DCT implementations your average Wavelet is downright sluggish, a fact which has kept wavelets out of the mainstream until now. That being said, wavelets have one last trick in their bag which is a feature pretty much incidental to their design. Because a wavelet is built up of progressively more refined levels of detail, stripping off a few top layers is relatively trivial. By specifying the “top” resolution you want decoded your wavelet footage can appear to the application as any 1/(2^N) resolution proxy without re-encoding. In editing scenarios this allows you to edit at 1k and then render out a 4k conformed timeline with the flip of a switch. Theoretically one should be able to do this in any Quicktime compatible editing or compositing application, however it is my experience that at the moment compatibility is still pretty spotty.
 
Just how bad is wavelet performance? Actually not as bad as I might have made it out to sound.

To evaluate the performance of our options I setup a very simple composite in Fusion 5. I rendered out 3 Quicktimes of the “Dead in Street” uncompressed 4k image available from Dalsa selecting the “None” (Uncompressed), Jpeg A (DCT) and Jpeg2000 (Wavelet) compression methods. Although I was unable to perform benchmarks on either Cineform’s Neo 4:4:4 codec or Red’s REDCode, David Newman from Cineform informs me that they usually see about a 4-5x increase in performance over JPEG2k. So taking David at his word I’ve created a fictitious modern digital cinema wavelet which is nothing more than a 4x reference of JPEG2k’s stats.

The composite consisted of a node which loaded the footage, a second node which cropped it down to 1px tall by 1px wide and an export node which saved it to a tiff on a separate hard drive. This was in an effort to reduce the benchmark to just open/decode times. In order to benchmark how much overhead the compositing application and save-out was introducing I also performed the same test using an internally generated black 4k plate. This test is represented by “Null”.

All tests were performed on an AMD Athlon 2200 XP+ with 2GB of RAM and two 300GB Seagate 7200.8 HDDs (not in a RAID configuration) running WindowsXP SP2. I used Fusion 5.1 for the render and QuickTime 7.1.5 Pro to generate the ‘source material’.

Render Time per Frame
(Lower is better) CPU Load Avg. Transfer Rate
Null .002 Seconds <1% --
Uncompressed 1.44 25.5% 17.18 MB/s
DCT (Jpeg A) at ~50MB/s .641 100% 3.2
Wavelet (Jpeg2k) at ~50MB/s 3.14 100% 0.71
Estimated Modern Wavelet 0.785 100% 2.84


One of the goals of this test was to emphasize the trouble with bottlenecks in one’s pipeline. First up we have uncompressed QuickTime which is using only 25% of the CPU available to it and yet can’t seem to pull ahead in render performance from DCT or even our theoretical Modern Wavelet competitor. We can’t know for sure but it would appear most likely that the hard drive is to blame. Next up every single one of our compression schemes maxed out the CPU. So from a raw performance stand point something has “gotta give” are we going to upgrade our bandwidth for uncompressed or are we going to upgrade the processor to improve our decompression times. Which is it going to be?

Admittedly in computer years this system is a dinosaur and for about $4000 you could easily purchase a new 8 Core fire breathing beast with 4GB of RAM and a 1TB RAID of attached storage from any major PC or Mac workstation provider. You would probably even see over an 8+ times increase in decode performance. Not to mention once programmers begin to deliver multi-thread optimized applications to take advantage of all those shiny new multi-processor, multi-core hotrods those numbers are expected only to rise. Let’s also not forget over at Intel and AMD’s plants Moore’s law is still alive and well. It’s a safe bet to expect processor power to double about every 18 months or so for the foreseeable future.

If after all this your computer still isn’t delivering on the promise of realtime 4k or you’re trying to edit in the field on a laptop don’t forget you get ‘free proxies’ out of wavelets which will simultaneously reduce your bandwidth and processor requirements. In the case of compositing I also carried out one test which is not represented on the chart but was a “real world” test just for a reference point. With some basic color correction on the layer alone the render times increased by 6 seconds. Now I’m a stickler for performance in my composites and am always looking for places to ensure my nodes are concatenating like a good boy should but I really wonder how many people would notice a less than .785 second increase in render time per 4k footage node. As perhaps a more relevant benchmark I also found .785 seconds is less than half the increase in render time while playing a single MP3 and watching a YouTube video in the background caused. Although I’m sure you’re far more productive during your render times than I am... right?

So what do we do about Uncompressed? Well… not a whole lot actually. Upgrading to a new system will probably help but quite honestly the only thing really holding back our uncompressed benchmark is bandwidth. We could pile in $5,000 worth of extra HDDs and fiber cards however it’s still unlikely we’ll achieve that Holy Grail of 250+ MBs required just for Uncompressed RAW 4k footage. Expect to easily shell out 5-6 figures on storage and networking to get a studio capable of sharing uncompressed 4k in real time. Also be aware that by investing in storage you’re hitching your wagon up to the slow train. Over the last decade sequential read performance in hard drives has only marginally improved from year to year. Networks have done a bit better historically; however, the demand for 10 GigEthernet doesn’t look to be growing by leaps and bounds. I would expect to pay a hefty premium for at least the next 4 or 5 years unless the home and small business market can find a use for lightning fast networking to drive down prices.

But I’m getting ahead of myself. It doesn’t matter if 4k Wavelets can play on your daughter’s Barbie™ Etch-a-Sketch™ if the quality isn’t there. Is this all just another case of a bunch of tight wadded independents and hobbyists singing praises to what they can afford or is compression really ready to unseat the holy saints of Tiff, Targa and DPX? Is debating whether DCT or wavelet compression akin to trying to decide which evil step sister has the nicest teeth? See for yourself.
 
To try and present something we’re all familiar with and to keep within the established goals of “something you can test on your own” I’ve created a reference image from publicly available elements. Our Frankenstein test chart consists of our previously introduced “Dead in Street” tiff from Dalsa. This image is a wonderful array of gritty fine details, hair, textures and smooth gradients; it should prove a challenge to any compression method. But that’s not enough for this test; we aren’t going to let it off that easy. If these wavelets are supposed to replace uncompressed workflows they’ve got to prove they have what it takes. So digitally duct taped to our test chart is a flute from an ISO 12233 MTF chart created by Stephen Westin of Cornell University which I rendered from a vector image at 10k and then downscaled using a Bi-Cubic scale to 4k. But wait there’s more! To ensure these codecs can stand up to any punishment, included is a bizarre, unnatural little patchwork of single pixel arrays and boxes to ensure each pixel stays where it belongs.

BoxesandPixelJigs.jpg


Spreads which include a set of difference mattes have had contrast increased by about 10x for clarity. Both the DCT representative (JPEG again) and our wavelet competitor (JPEG2k) have been created from an 8bit version of the test chart. 8bit was chosen so that there would be a reduced risk of mixed bit-depth wonkiness. Also both files are the same image size of ~50MB/s at 12bits (1.4MB 8bit files * 1.5 for 12bits * 24 frames = 50.4MB/s) Note that if these were shot with a D-Cinema camera you could most likely divide that number by 3 since it would be captured in Bayer RAW)

So without further ado let the games begin! Our first set is going to be the “elbow” test which if you haven’t guessed it yet… is of the dead guy’s elbow.

Elbow.jpg


In our first test I was actually a little surprised to notice blocking in the original uncompressed image. These Dalsa shots are supposed to be uncompressed so I could only surmise that the mild blocking is a result of the debayering algorithm. By playing with the contrast and sharpening filters I was able to massage out the telltale alternating checker pattern of the debayer process. Most of these artifacts tended to be concentrated around areas of “blockiness” so I’m going to wildly speculate that if you don’t get your debayer process just right it can give the appearance of DCT-esque blocking. Wavelet, if anything, to my eyes actually reduced the blockiness and in doing so improved the image. DCT did a very good job on the grit however as it moves into the flatter low contrast region on the left the telltale little squares begin emerge. Most of this however, is extremely nitpicky, even in the case of the DCT. To keep things in perspective I’ve also included a 2k downscale in all of the tests. One thing to consider is, just about no matter how bad the compression gets it’s still probably going to look better than an uncompressed 2k image. Capturing in 4k compressed and super sampling to 2k also gets you one added bonus with DCT. Remember how I said earlier that DCT sampling operated on a constant scale. Well for what it’s worth, by super sampling you’ve just scaled the blocks by half.

Next up we have a spread from the flute and boxes (and no I know what you’re thinking but that’s not some new indie rock band from Ireland)

flute.jpg


Even after 10x contrast enhancement wavelet is still holding in like a champ. DCT on the other hand is having some serious issues with high contrast geometric shapes (which I’ll address in a second) although it’s doing a good job on the flute. I should mention the reason I didn’t include any comparisons is because both of the compression schemes did a quite admirable job on the flute itself. Wavelet performed exactly like it should, using a low resolution sample rate on the solid white surface and then transitioning without any jaggies into high frequency flute. There were also no jaggies that I could see in the DCT image.

Boxes.jpg


And…. a detail on the boxes. While there was no apparent smoothing or loss of edge in either compressions, DCT did introduced noticeable amounts of garbage around the boxes and their edges. The garbage tended to be in the same pattern in both wavelets and DCT however there was about a 4x greater difference in the DCT image and it lacked the wavelet’s preferable method of at least blurring its garbage to be less noticeable. There has been some discussion about adding a sub algorithm to Jpeg2k to allow it to identify graphic material and to switch to an RLE based compression scheme. For those who work with a lot of motion graphics this may be a development to pay keen attention to. The ability to switch between a lossless RLE and lossy wavelet based on the nature of the material within one image could dramatically increase its performance in many broadcast specific applications.

Finally I had hoped to also do a spread of differences between multiple wavelet generations but when I finished a 6 generation loop (Save to Jpeg2k -> Save to Uncompressed -> Save to Jpeg2k) the first generation exhibited identical results to the other difference spreads you’ve seen just as expected, however, the rest appeared to be black even after applying an x10 increase in contrast. Hunting for trouble and not willing to believe the compression was lossless the second time around, I went ahead and applied an “add” modifier so that the all 5 generations after the first would be added together. Nothing. So I doubled the contrast again. Now there was a faint multicolored splotch almost entirely in the white region of the flute. I isolated just that section of the image, averaged the pixels and found there was a .7% luma shift. That means in the 5 generations after the first encoding the image only changed by a combined amount of (.7%)/2/10 = .035% in a small unnatural graphic. If you break that down into how much on average each of those generations contributed to that shift it’s comes down to only .007%. Now .007% does not = 0 but I have to ask. Does anybody actually think they’ll miss it? If you’ve received footage captured on set or from a film scanner that has already been compressed, 99% of the damage has already been done and there is no reason to not continue using the codec.

I would like to issue a special thanks to David Newman of Cineform and Nathan Vegdahl for being so generous with their knowledge. For those who wish to know more about wavelets I highly recommend David Newman’s blog (http://cineform.blogspot.com/) as a resource and source of compression news.

4k Images were obtained from Dalsa's website: Dalsa.com

Photo used in DCT/Wavelet comparisons is courtesy of Sean Kraft - http://kraftarts.com/ (Someone give that guy a job already!) ;)

4k ISO 12233 reproduction can be downloaded from Stephen H Westin's Cornell University page found at: http://www.graphics.cornell.edu/~westin/misc/res-chart.html
 
Gavin, quite excellent. Very cool Showreel allowed the post.

Can you do me a favor and let your editor, Steve Parker, know I received a call for him a week or so ago? I gave the production as much info as I could:usd:
 
This should go straight into IBlooms new Red-Wiki pedia thing.
 
Gavin this is great! So many people are posting good information today. There should definitely be more information posted like this. Keep up the good work.
 
This should go straight into IBlooms new Red-Wiki pedia thing.

  • With permission this is from an article I wrote for Showreel Magazine. A Magazine I only just started reading when I got the last issue but is actually very exciting and I highly recommend picking up a subscription at http://www.showreel.org

    As a result I request that you do not repost this elsewhere. Thanks.

    - Gavin

See quote.
 
Excellent articles Gavin! I have to read it a couple more times trying to understand..
I wonder if you or someone else is capable to describe also the differences and advantages between usiing Bayer filters (like Red,Dalsa,Arri) and the RGB stripe method like Panavision is using?

Ed
 
Back
Top