[Theora] problems understanding yuv_buffer format
giles at xiph.org
Wed Sep 28 09:57:07 PDT 2005
On Wed, Sep 28, 2005 at 04:43:51PM +0200, Michael Smith wrote:
> Each row is indeed contiguous in memory, with buffer->y_width pixels
> in each row. Note that this (the frame width) is NOT equal to the
> stride. The stride gives you the offset between each row.
Er, to clarify. The example encoder creates buffers where the rows
(and planes) are contiguous in memory, but the point of the stride
field is that they MAY NOT BE CONTIGUOUS! You must treat each row
independently, and add the stride to the byte offset of each row to
obtain the byte offset of the next. You can (only) assume the data
in each row is contiguous.
Strides were invented to allow byte-aligning rows in bitmaps that
didn't have an integral number of bytes per pixel, and later used
to word-align rows for speed and convenience. Alignment usually isn't
a problem with the theora yuv_buffer because the width is a multiple
of 16, but it's still useful for some tricks. For example, specifying
a stride larger than the width lets you pull or push a subregion of
a larger image without doing a copy, and by making the stride negative,
you can flip the image vertically without having to do a copy.
More information about the Theora