[Theora-dev] YUV and Direct3D

Paulo Zaffari paulo at singularstudios.com
Tue Oct 11 15:39:49 PDT 2005


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:

  for (nSubSampledY=0;nSubSampledY<stYUVData.uv_height;nSubSampledY++)
  {
    for (nSubSampledX=0;nSubSampledX<stYUVData.uv_width;nSubSampledX++)
    {

auchTextureData[nSubSampledX*4+0+nSubSampledY*nPitch]=stYUVData.u[nSubSample
dX+nSubSampledY*stYUVData.uv_stride];

auchTextureData[nSubSampledX*4+1+nSubSampledY*nPitch]=stYUVData.y[nSubSample
dX*nUVHorizontalSubSamplingFactor+nSubSampledY*stYUVData.y_stride*nUVHorizon
talSubSamplingFactor];

auchTextureData[nSubSampledX*4+2+nSubSampledY*nPitch]=stYUVData.v[nSubSample
dX+nSubSampledY*stYUVData.uv_stride];

auchTextureData[nSubSampledX*4+3+nSubSampledY*nPitch]=stYUVData.y[nSubSample
dX*nUVVerticalSubSamplingFactor+1+nSubSampledY*stYUVData.y_stride*nUVVertica
lSubSamplingFactor];
    }
  }

    In short, I am considering stYUVData.y is a unsigned char array as well
as stYUVData.u and stYUVData.v. I am also counting on a 2x1 sampling
interval.
    The results are distorted colors.
    Could anyone, please, give me a hint on how can I display the images
correctly? A tip on wich D3DFMT to use would be welcome as well.

Thank you all very much.
Paul.



More information about the Theora-dev mailing list