[Theora-dev] YUV and Direct3D

Mike Melanson mike at multimedia.cx
Tue Oct 11 15:53:41 PDT 2005

Paulo Zaffari wrote:
> Hi all,
>     I am developing a Theora player wich I intend to use with 3D
> applications in a near future.
> I have quite a few doubts wich I belive might be cleared by those reading
> this e-mail... or so I hope.
>     In order to have maximum performance I would like a hint on what D3DFMT
> to use while creating a texture. So far my guess is D3DFMT_UYVY, but
> something seems to be wrong in my texture update routine.
>     I am using the following code:

     Hmm: Apple, meet orange; orange, apple. "Not the same thing" is 
what I am trying to say here. It looks like Direct3D allows you to 
create textures using "packed" YUV formats. This means that the Y, U, 
and V samples are interleaved. Most modern video codecs, Theora 
included, decode to "planar" YUV formats. In memory, there is Y data, 
followed by U data, followed by V data. More on planar and packed formats:


I did a quick Google search on "D3DFMT_I420" and "D3DFMT_YV12" (YUV 
4:2:0 planar formats). Neither identifier appears to exist. In my 
(limited) experience with 3D graphics, the special hardware generally 
deals with packed pixel formats only.

     Short answer: You will have to convert YUV 4:2:0 data to another 
format. Either that, or use the appropriate Windows video API to display 
the YUV data directly (DirectShow?). Alternatively, you can take a look 
at this paper regarding a method for displaying planar YUV data using 3D 
blending hardware:


I got it to work on the Sega Dreamcast hardware. I have always wondered 
how it would work on other hardware.

	-Mike Melanson

More information about the Theora-dev mailing list