Cairo is a simple streaming video codec that I created in 2011 as part of the (now discontinued) everyAir mobile cloud gaming project. Its original purpose was to help us experiment with low latency game streaming on early mobile hardware (original iPad, iPhone 3GS). Using a heavily tuned implementation, cairo enabled everyAir to stream PC, Mac, and even PS3 games to iOS devices with extremely low encode and decode latencies.


Cairo is the first of five evolutionary video codecs that focus on targeted solutions for specific use cases. The following diagram illustrates the high level progression of each codec in the family.


  Release Version Codename Target Features
  TBD EVX-5 Capri Massive media library compression Artificial intelligence, targeted compression
  2016 EVX-4 Cannes Mixed reality immersive content Virtual & augmented reality, 3D video format support
  2014 EVX-3 Chicago Ultra HD content Advanced transforms, large macroblock support
  2011 EVX-2 Chennai Medical and archival content Lossless compression, full rate YCbCr 4:4:4 mode
  2011 EVX-1 Cairo Low latency video streaming Experimental pipeline, video analysis & debugging tool


To download sample content as well as tools for playing cairo files and converting existing content to the cairo (evx) format, head over to the codec development tools page.



Design

The design of this codec borrows heavily from that of my previous codec, p.264, but with several notable refinements. Similar to most modern codecs, cairo uses a block based encoding scheme to transform, quantize, and entropy encode the video data. This codec supports self referencing intra frames as well as neighbor referencing inter frames (known as predicted frames in h.264 parlance).

The basic flow of cairo is depicted in the following image:


For a complete walkthrough of this diagram, check out my p.264 overview paper, or view my lecture covering the principles of video compression.



Features

Cairo supports the following features:

  1. Support for intra (i-frame) and inter (p-frame) frame prediction modes

  2. Motion compensation with half and quarter pixel precision

  3. Supports a virtually unlimited number of reference frames

  4. Variance adaptive quantization (both uniform and non-uniform)

  5. Intelligent skip block detection that minimizes visual artifacts

  6. Periodic intra frame insertion (useful for keyframing)

  7. Internal support for planar YUV 4:2:0 images

  1. Support for multiple lossless backend compressors involving:

    1. Adaptive binary arithmetic coding

    2. Exponential Golomb coding

    3. Huffman coding

    4. Run-length encoding

  2. Delta coded macroblocks and motion vectors

  3. In-loop deblocking filter

  4. 100% integer math

  5. Cross platform, fully portable code

  6. Code is simple and easy to read



Development Tools

A set of custom codec debugging tools were created during the development of cairo. These tools greatly assisted the process of converting content to the cairo format, replaying cairo content, analyzing the inner workings of the pipeline, and gathering performance metrics.

Use the following downloads to try out the tools and create/play/inspect your own cairo files:

  1. Convert tool (3.0 MB)    

  2. Player tool (124 KB)      

  3. Inspect tool (3.1 MB)    


For more information about these tools, or for sample evx video files, check out the video codec development tools project page.



Performance

It's difficult to compare video codecs because the measurement of image quality is heavily influenced by our subjective perception, and it's difficult to create fair and unbiased test cases. In my own experiments cairo achieves roughly 100:1 compression of raw image data with a PSNR of at least 39.00, and is generally about 15% to 20% worse than single pass h.264 main profile, but 4-5x faster.


For more information about cairo experimentation, check out this blog post.



Source code

Check out the source code for an early version of cairo at this github repo.

Note that the cairo source release contains an early and unoptimized version of the codec that demonstrates the basic functionality of the software. With the discontinuation of the everyAir product, cairo's new purpose is to serve as an educational resource for students who are interested in video compression. This release presents a simple and easy to read implementation that demonstrates several common techniques without the complexities of optimizations or platform dependencies.


For those interested in checking out optimized builds of cairo, check out the everyAir project that features cairo on PC, Mac, and iOS. For those interested in tuning the public cairo source release I would suggest a few low hanging fruit:


  1. Add multi-threading to process images in slices.

  2. Add vector instructions to improve convert.cpp, transform.cpp, and motion.cpp.

  3. Optimize transform.cpp using Chen et al.'s fast DCT algorithm (or similar).

  4. Move convert.cpp to the GPU (YUV to RGB right before presentation).


There are of course more involved optimizations (e.g. porting entirely to the GPU), but most of these are already in the production version of cairo and are less straightforward than the items listed above. If you absolutely need the extra performance then drop me a line and we'll see if we can save you a bit of time!



More Information

For more information about cairo, check out my blog for articles related to this codec and general video compression. For a deeper discussion that roughly compares cairo with h.264, check out this blog post.