[theora] Simple RGB->YUV Stuff...

Michael Smith msmith at xiph.org
Sun Aug 20 22:02:02 PDT 2006


On 8/21/06, Jeremy Moles <jeremy at emperorlinux.com> wrote:

> There are lots of different ways to do the per-pixel conversion from RGB
> to YUV that I've found online; I think I have this part down fairly
> well. Eventually, what I end up with are three buffers, each one as
> large as the other and containing the from-RGB-to-YUV values performed
> per-pixel. This is where I get hung up.
>
> To pass the YUV data to the various encode functions I have to create a
> yuv_buffer struct and set the widths, heights, and strides correctly.
> What I've been trying to use is:
>
>         yuv_buffer yuv;
>
>         yuv.y_width   = Width;
>         yuv.y_height  = Height;
>         yuv.y_stride  = Width;
>         yuv.uv_width  = Width;
>         yuv.uv_height = Height;
>         yuv.uv_stride = Width;
>         yuv.y         = YDATA;
>         yuv.u         = UDATA;
>         yuv.v         = VDATA;

Theora support several different pixel formats, but the libtheora
encoder only supports a single one of those. It's commonly called
"4:2:0", a notation which means that there's chroma subsampling both
horizontally and vertically.

What that means is that the two chroma planes ('u' and 'v') should
have half the width, and half the height, of the luminance ('y')
plane. You'll want to filter your existing data to do that.

Mike


More information about the theora mailing list