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

Jeremy Moles jeremy at emperorlinux.com
Mon Aug 21 06:26:43 PDT 2006


On Mon, 2006-08-21 at 13:02 +0800, Michael Smith wrote:
> 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.

Thanks--got it working now; I was a bit mislead by the OC_PF_444 flag,
which I guess isn't supported at the moment. This would be nice,
however, since it would make it much easier in the future to do 1:1
mappings of standard RGB/RGBA buffers to Theora video streams w/out
having to do any subsampling.

Anyways, thanks a million for your help...

> Mike
> 



More information about the theora mailing list