staticvoidrgb8888_2_nv21(unsignedchar*s,unsignedchar*iYuv,int width,int height){int ui = width * height;int i =0;int j, k;unsignedchar sR,sG,sB;for(j =0; j < height; j++){for(k =0; k < width; k++){// Y value is generated for each pixel
sR =*s;
sG =*(s+1);
sB =*(s+2);
iYuv[i]=(unsignedchar)((66* sR +129* sG +25* sB +128)>>8)+16;if(0== j %2&&0== k %2){
iYuv[ui++]=(unsignedchar)((112* sR -94* sG -18* sB +128)>>8)+128;
iYuv[ui++]=(unsignedchar)((-38* sR -74* sG +112 sB +128)>>8)+128;}
i++;
s +=3;}}return;}
YUYV_2_NV21
voidYUYV2NV21(unsignedchar*src,unsignedchar*dst,int width,int height){for(int i =0; i < width * height *2; i +=2){*dst++=*(src + i);}for(int y =0; y < height -1; y +=2){for(int j =0; j < width *2; j +=4){*dst++=(*(src +3+ j)+*(src +3+ j + width *2)+1)>>1;*dst++=(*(src +1+ j)+*(src +1+ j + width *2)+1)>>1;}
src += width *2*2;}}
UYVY_2_NV21
voidUYVY_2_NV21(unsignedchar*src,unsignedchar*dst,int width,int height){int i =0;int j =0;int y =0;//int k = 0;for(i =0; i < width * height *2; i +=2){*dst++=*(src + i +1);}for(y =0; y < height -1; y +=2){for(j =0; j < width *2; j +=4){*dst++=(*(src +2+ j)+*(src +2+ j + width *2)+1)>>1;*dst++=(*(src + j)+*(src + j + width *2)+1)>>1;}
src += width *2*2;}}
yuv_to_rgb32
voidyuv_to_rgb32(char y,char u,char v,char*rgb){int r,g,b;
r =(1192*(y -16)+1634*(v -128))>>10;
g =(1192*(y -16)-833*(v -128)-400*(u -128))>>10;
b =(1192*(y -16)+2066*(u -128))>>10;
r = r >255?255: r <0?0: r;
g = g >255?255: g <0?0: g;
b = b >255?255: b <0?0: b;/*ARGB*/*rgb =(unsignedchar)r;
rgb++;*rgb =(unsignedchar)g;
rgb++;*rgb =(unsignedchar)b;
rgb++;*rgb =0xff;}