[cairo] Video Hackfest conclusions
spitzak at gmail.com
Wed Dec 2 15:00:26 PST 2009
Siarhei Siamashka wrote:
> I would like to have some clarification regarding forcing BILINEAR filter for
> nonscaled YCbCr images.
> What happens if some YCbCr image is used as both source and destination if we
> want to draw some RGB stuff on top of video frame? In this case the operation
> will be split into fetching YCbCr data into temporary scanline buffer (and
> converting it to a8r8g8b8 format), doing the operation and writing data back,
> converting it to YCbCr. For this kind of operation, any distortions in the
> original image are probaby not desired. A test can involve trying to do OVER
> compositing operation with fully transparent RGB source and YCbCr as
> the destination. Optimistically, the destination image should not change at
> all. But in reality, some of the pixels have to be clamped to [0, 255] range
> when converting to RGB. So the requirement can be relaxed to requiring
> YCbCr -> RGB -> YCbCr roundtrip to only be allowed to modify the values which
> are clamped during this conversion. It can be treated somewhat similar to
> handling top 8 bits in x8r8g8b8 format. Some different YCbCr pixel values map
> to the same a8r8g8b8 value, but so do x8r8g8b8 pixels.
> Using bilinear filter on YCbCr -> RGB -> YCbCr roundtrip would introduce some
> blur unless I'm mistaken. But this filter may still be a good idea when
> generating a final RGB picture. BTW, introducing a dithering filter for doing
> final conversion into r5g6b5 format may be a good idea too.
I think he is talking about using bilinear to get the Cb and Cr
intermediate data from 4:2:2 or 4:1:1 YCbCr data. This would be lossless
(other than the rounding and truncation) provided one pixel has the
exact original Cb or Cr value. The pixels between that one and the next
exact pixel would have an interpolated value. Then the encoder and
decoder have to agree to use the same pixels.
It would lose a lot of data however if the image is shifted by 1 pixel
and then converted back. In effect it would blur the Cb and Cr channels
by a 2-pixel box filter. If that is a concern, I do see it working
better to dupliate the Cb and Cr exactly to a block of 2 or 4 pixels
when converting from 4:2:2 or 4:1:1.
More information about the cairo