Encoders Aren’t Commodities

My partner Ben Mesander had a really cool post the other day: An H.264 encoder written in 30 lines of C code.

Ben’s encoder outputs completely valid H.264, but it doesn’t actually compress anything. (What do you expect from 30 lines!) In fact, because of the necessary H.264 headers, the output of Ben’s encoder is larger than the input.

This is a dramatic example of something that I find interesting about the codec marketplace: Decoders are commodities, but encoders are highly differentiated. People often misunderstand this dynamic, however.

A video decoder, if it works, has to follow the relevant specification. There are hundreds of “tricks” that a baseline profile H.264 encoder could use, and so a baseline-profile decoder must be able to handle all of them. So there’s really not room for a lot of differentiation between H.264 decoders. Sure, one decoder might use less CPU than another. But mostly, if you’re looking to buy a decoder, you should shop based on price.

Another way to say the same thing is that a codec specification details — how to write a decoder. The spec lays out what a compliant bitstream looks like, and specifies how you turn that bitstream into video or audio.

Encoders, as Ben showed, are completely different beasts. An encoder author can pick which of the tools provided by the standard he or she will use. In the extreme case, as Ben did, he can choose to use almost none of the tools. Therefore, there can be a huge difference in compression efficiency — and thus video quality — between two encoders.

You might think this is obvious, but if so you should walk around the security industry’s ISC West trade show this week. You will find all sorts of vendors claiming that their H.264 DVR is the same as their competitor’s DVR or claiming that their H.264 IP camera is better than a MPEG-4 IP camera. Maybe so and maybe not: Just because H.264 is a more modern and complex codec than MPEG-4 part 2, it doesn’t automatically follow that a particular H.264 encoder is better than a particular MPEG-4 encoder.

Ultimately, the only way to compare two encoders is a head-to-head bakeoff, where each encoder is set to the same data rate and fed the same content, and you view decoded video from the two at the same time.

Howdy Pierce is a managing partner of Cardinal Peak, with a technical background in multimedia systems, software engineering and operating systems.