Content

Understanding Codecs: Part 1-h.264

I hate video codecs.  When you use an HTPC for your home media viewing, they can cause you nothing but trouble.  Without the proper decoders installed they files won’t play.  Not only that but different decoder packages can interfere with each other causing all sorts of issues with video playback.  I decided it was time for me to learn a bit more about a few of these codecs and maybe figure out why there have to be so many.  This is the first in a series of articles which will focus on video codecs and the good, the bad, and the ugly of each one.

With this article we’ll focus on h.264 which is quickly becoming the standard format for HD video whether on Blu-ray or used in broadcast video.  There are several reasons for this and we’ll try and touch on each one.

History

H.264 is a method of video compression that was initially completed in May of 2003.  The codec is a motion compensated-based codec which was a joint effort of ITU-T Video Coding Experts Group(VCEG) together with the ISO/IEC Moving Picture Experts Group (MPEG).  The intended purpose of h.264 was to create a standard that would provide good video quality while allowing lower bit rates than previous standards.  The codec needed to be flexible enough to be applied to a wide variety of uses.

Encoder Process

H.264 processes a frame of video in units called Macroblocks.  These are 16×16 display pixels in size.  The encoder forms a prediction based on previously coded blocks, from either previous frames or intra prediction which uses data from the current frame.  The encoder then subtracts the prediction from the current macroblock to form a residual.  The prediction methods used by h.264 is a lot more flexible than previous standards and therefore enables much more accurate predictions and better compression.

There is of course a lot more that goes into the process including transformation and other steps.  See the diagram below for more information

Decoder Process

The decoder is basically the tool which will work the encoding process backwards, decoding and re-scaling the video signal.  The decoder receives the compressed h.264 bitstream and decodes each syntax and element and extracts the needed information to rebuild the stream.

The decoder uses each macroblock to form an identical prediction to the decoded residual to reconstruct a decoded macroblock.  These are then displayed as part of the video frame.  See Below:

CodingDiagram
Image courtesy of Yong Wang (http://www.ee.columbia.edu/~ywang/index.html)

The advantages of h.264 are quite simply, better quality video at the same bitrate as MPEG-2 or MPEG-4 visual or the same quality at a lower bitrate.  As an example, a DVD can hold around 2 hours of video if encoded using MPEG-2.  The same DVD could support around 4 hours of content using h.264 due to the ability to get the same quality of video at a much lower bitrate.

As stated earlier, h.264 is great for a wide variety of uses.  Notably, Blu-ray, European broadcast content as well as Apple video downloads.  The format has also been adopted by DirecTV and Dish Network in the US and SkyHD in the UK.  (Sky standard definition programming still uses MPEG-2) The reason for this is the built-in flexibility of the codec to be used for anything from HD content to video appropriately sized for cell phone and portable use.  It is this flexibility that will allow h.264 to start replacing (if it hasn’t already) many of the codecs used for current applications.

If you’d like more technical information on h.264 including more in depth diagrams on the inner workings of the encoding and decoding process, have a look at this PDF document.  It provides a great introduction including a more in depth history of the codec and its current applications.

Advertisement

About the author

Adam Thursby

Adam Thursby is the founder and creator of The Digital Media Zone.