x-zone

all about c++
<2025年7月>
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

统计

  • 随笔 - 1
  • 文章 - 3
  • 评论 - 0
  • 引用 - 0

常用链接

留言簿(1)

随笔档案

文章分类

文章档案

搜索

  •  

最新评论

yuv420平面格式转换为rgb24(带跨度,ddraw输出)

void yuv420_to_rgb24(unsigned char *pdata, int stride, int width, int height, unsigned char *pdst)
{
 const unsigned char *Y, *U, *V;
 unsigned char *RGB;
 int x, y;

 if (stride < 0) {
  Y = pdata - stride * (height - 1);
  U = pdata - (stride / 2) * (height * 5 / 2 - 1);
  V = pdata - (stride / 2) * (height * 3 - 1);
 } else {
  Y = pdata;
  U = pdata + stride * height;
  V = pdata + stride * height * 5 / 4;
 }
 RGB = pdst;
 for(y=0; y<height/2; y++)
 {
  unsigned char *pDst1 = RGB;
  unsigned char *pDst2 = RGB+width*3;
  const unsigned char *pYSrc1 = Y;
  const unsigned char *pYSrc2 = Y + stride;
  for(x=0; x<width/2; x++)
  {
   const int Uo = U[x]-128;
   const int Vo = V[x]-128;
   const int Ro = (91181*Uo)>>16;
   const int Go = (22553*Vo + 46801*Uo)>>16;
   const int Bo = (116129*Vo)>>16;

   TO_RGB24(pDst1,   pYSrc1)
    pDst1 +=6;
   pYSrc1+=2;
   TO_RGB24(pDst2,   pYSrc2)
    pDst2 +=6;
   pYSrc2+=2;
  }
  RGB  += width*6;
  Y    += 2*stride;
  U    += stride/2;
  V    += stride/2;
 }
}

posted on 2007-10-24 23:02 刘旭 阅读(2140) 评论(0)  编辑 收藏 引用 所属分类: RGB&&YUV