yihui10 2017-05-23 08:06 采纳率: 0%
浏览 2141
已结题

yuv到rgb视频格式转换

#define asm __asm

typedef unsigned char TUInt8; // [0..255]
typedef unsigned long TUInt32;
struct TARGB32 // 32 bit color
{
TUInt8 b,g,r,a; // a is alpha
};

struct TPicRegion // 一块颜色数据区的描述,便于参数传递
{
TARGB32 * pdata; // 颜色数据首地址
long byte_width; // 一行数据的物理宽度(字节宽度);
// abs(byte_width)有可能大于等于width*sizeof(TARGB32);
long width; // 像素宽度
long height; // 像素高度
};

// 那么访问一个点的函数可以写为:
__forceinline TARGB32 & Pixels( const TPicRegion & pic, const long x, const long y)
{
return ( (TARGB32 * )((TUInt8 * )pic.pdata + pic.byte_width * y) )[x];
}

// 颜色饱和函数
__forceinline long border_color( long color)
{
if (color > 255 )
return 255 ;
else if (color < 0 )
return 0 ;
else
return color;
}

__forceinline TARGB32 YUVToRGB32_float( const  TUInt8 Y, const  TUInt8 U, const  TUInt8 V)
{
    TARGB32 result;
    result.b= border_color( 1.164383 * (Y - 16) + 2.017232*(U - 128) );
    result.g= border_color( 1.164383 * (Y - 16) - 0.391762*(U - 128) - 0.812968*(V - 128) );
    result.r= border_color( 1.164383 * (Y - 16) + 1.596027*(V - 128) );
    result.a =   255 ;
     return  result;
}

void DECODE_YUYV_Float( const TUInt8 * pYUYV, const TPicRegion & DstPic)
{
assert((DstPic.width & 1 ) == 0 );

TARGB32 *  pDstLine = DstPic.pdata; 
 for  ( long  y = 0 ;y < DstPic.height; ++ y)
{
     for  ( long  x = 0 ;x < DstPic.width;x += 2 )
    {
        pDstLine[x + 0 ] = YUVToRGB32_float(pYUYV[ 0 ],pYUYV[ 1 ],pYUYV[ 3 ]);
        pDstLine[x + 1 ] = YUVToRGB32_float(pYUYV[ 2 ],pYUYV[ 1 ],pYUYV[ 3 ]);
        pYUYV += 4 ;
    }
    ((TUInt8 *& )pDstLine) += DstPic.byte_width;
}    

}

哪位大神帮忙写个 main()函数 让我看看具体输出是啥样的

  • 写回答

1条回答 默认 最新

  • 道亦无名 博客专家认证 2017-05-23 08:10
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试