[cairo] Planar YUV support

Bill Spitzak spitzak at gmail.com
Thu May 13 10:15:29 PDT 2010


Benjamin Otte wrote:

> I added unmultiplied support for one simple reason really: YCbCr with
> alpha channel is unmultiplied. So it seemed rather trivial to support
> unmultiplied ARGB, too.

Actually YCbCr can be "premulitiplied". It is a linear transform of some 
RGB data and since RGB can be premultiplied YCbCr can be as well.

The difference is that there is an offset in the CbCr channels. 
Multiplying a YCbCr sample by a constant should multiply the difference 
of Cb and Cr from the center value by this constant, rather than the 
difference from zero.

I do think it is possible that non-premultiplied YCbCr data is more 
popular, but there is no requirement that it be so.

> I'm also not sure where in interpolation or resampling an operation is
> non-linear and would result in wrong values for unmultiplied color
> spaces, but in those few cases, it seems worthwhile to use a different
> function that handles those correctly, no?

Again, once you take into account the center CbCr values, it is just as 
linear or non-linear as the original RGB data.

I think many, if not all, of the compositing operations defined in RGB 
spaces can be mathematically converted to work directly on YCbCr data. 
There will be some differences because of clamping, but any composites 
where the results are inside the gamut of both spaces will be identical.


More information about the cairo mailing list