#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()函数 让我看看具体输出是啥样的