Thursday May 24, 2012 1:13 AM AEST

Everything you ever wanted to know about video codecs.

By David Field
17:00 Jun 6, 2007
Tags: video | codecs | codec | x264 | xvid | h264 | wmv | cinepak | multimedia | divx | mayo | MPEG | how | works
«  »
Everything you ever wanted to know about video codecs.
New school
x264
Reverse-engineering industry standards is a great open source tradition, and x264 is the result of the video industry’s new wonder codec, H.264, being given the treatment. H.264 is a joint venture between the video arm of the telecommunications standardisation sector (think video-conferencing) and the Moving Picture Experts Group, and it’s encapsulated in the behemoth that is the MPEG-4 standard. It’s very different to and much more processor intensive than standard MPEG-4, which is why it’s used with HD-DVD and Blu-ray, some hard drive-based HD cameras and, perhaps most importantly, broadcasting.

Like H.264, x264’s strength lies in the way it treats macroblocks. It can work with standard 8 x 8 pixel macroblocks as well as 4 x 4 blocks and rectangular macroblocks if a frame is detailed enough to warrant it. It also supports cut detection for better I-frame placement and motion compensation. If you’re game, you can even toy with custom quantisation matrices. x264’s roots may be deeply entrenched in H.264’s heart, but its slight differences make it unsuitable for broadcast. We included it in our test because it’s better suited to PC-based archival and we already have a broadcast codec in the roundup.

WMV9
We couldn’t let Windows Media 9 slip underneath the radar for a few reasons. Its SMPTE-approved identical twin VC-1 is driving the images on HD-DVD and Blu-ray, and it uses the same fundamental coding mathematics (DCT) as MPEG without, er, ‘borrowing’ MPEG theory. One such technique involves using what are known as zig-zag tables to reorder the data into one of 13 preset patterns. One of these patterns will yield better compression.

WMV and VC-1 aren’t as demanding as x264 and H.264, but in comparison to the other codecs available, they’re both highly asymmetrical – they take a lot more time to encode something than decode it. They also need a lot of processing power to draw a series of frames based on the encoded data. This is why, when H.264 found its way onto the iPod in an effort to reduce the video file size but maintain the quality level, a dedicated decoder chip found its way into the circuitry to tackle the encoding.


Old school
DivX
Originally created from the ashes of an early build of a Microsoft MPEG-4 based codec, DivX has evolved into a container format and has developed a reasonably friendly user interface. It’s maintained in-house by DivX Networks, a company that earns a multi-million dollar crust by licensing out its codec for use in DVD players and providing a high quality alternative to YouTube.

XviD
Before DivX went commercial, it launched Project Mayo, an open(ish) source multimedia project. It was eventually scrapped, at which point some of the contributors to Project Mayo took their work and retooled it into XviD. It too is based on MPEG-4.

XviD uses global motion compensation to handle camera tilts and pans as well as quarter-pixel block motion compensation for movement of fine detail. It works best on two-pass encoding and is quite refined thanks to its popularity with users and project contributors.


Really old school
Cinepak
The geriatric of the bunch, Cinepak arrived on the scene in 1992, just after the dawn of QuickTime. Cinepak was the first non-Apple codec ever added to Apple’s multimedia framework, and in 1993 went on to be the first non-Microsoft codec to be added to Video for Windows – which predated DirectX and DirectShow. It was also responsible for FMV in early games, both on PCs and consoles like the Sega Saturn.

Unlike most DCT-based codecs, Cinepak uses the simpler vector quantisation combined with motion keyframes to reproduce blocky images, albeit with processor requirements from the early ‘90s. It works by dividing the image into sections and assigning each its own 256-colour palette. These sections are then subdivided into blocks of 4 x 4 pixels, which instead of being assigned colours are given references to a section’s colour palette and told how to assign colour to the pixels in the block.

Originally, it provided 320 x 240 video at bitrates within the reach of x1 CD-ROM drives, but has been improved since then. Although we’ve included it in out tests for reference, you’re crazy if you use it for anything serious.

It’s been well and truly eclipsed.


To The Labs!
We picked a few choice DVDs from our collection that we felt would provide the codecs with a good spectrum of different material to work with. We cropped out 40 frames, exported them as an uncompressed RGB sequence, then exported this with VirtualDub Mod into different codecs with different settings. And we did this over and over and over again. We used the default codec settings, but tweaked any choices between quality and render time to maximum quality, as well as setting all the codecs to two-pass variable bitrate with a specified target.

We wound up with three sequences encoded in 300, 700, 1500 and 3000Kb/s in five different codecs. DivX and XviD were chosen because the similarities in their lineage allow us to see the work of the open source movement pitted against proprietary software. Windows Media 9 (WMV9) is almost exactly the same as VC-1 – Microsoft’s HD-DVD/Blu-ray codec – only with more options. It’s not based on an MPEG standard either; so in it went. x264 (H.264’s open source equivalent) was thrown into the mix too, as it represents the new wave of computer-based open source codecs. Cinepak was added just for laughs and to see what a difference 15 years makes in codec land.

We dropped every encoded sequence back into VirtualDub and picked one frame that we felt demonstrated the encoder’s prowess, checked that none of the sequences used that particular frame as a keyframe and then exported the frame as an image. After all, we wanted to see what the encoders were doing, not what they were relying on.

One small caveat: The WMV encodes weren't done with VirtualDubMod; they were done with Adobe Premiere Pro 2. We also used Premiere to export the WMV frames used in the comparison tables.

 
«  »
 
This article appeared in the June, 2007 issue of Atomic.

Aliens: Colonial Marines in depth; Z-77 Motherboard round-up; strategy gaming special; Home Server tutorial. PLUS MUCH MORE - ON SALE NOW!
 
Atomic Magazine

Issue: 137 | June, 2012

Atomic is a magazine aimed squarely at computer enthusiasts, gamers, and serious PC upgraders.

Every month we bring you the latest reviews of new technology and PC components, in depth features on everything from overclocking to console hacking, and gaming previews and interviews.
 
Latest Comments
 
Latest User Reviews
Battlefield 3 is the new benchmark online FPS
90%
A very fun and realistic multiplayer ride.
 
Antec Kuhler 920 - liquid cool
90%
Antec Kuhler 920 silent but effientive out of the box no maintence water cooling kit
 
Antec's Lanboy Air - our new favourite case
90%
Antec Lan boy Air in red a very cool design
 
Antec's Lanboy Air - our new favourite case
90%
This product overall is awesome.
 
MSI's GT780 laptop as fast as it gets
90%
Nice laptop