YUV422转RGB

来源:互联网 发布:武汉网络推广jw100 编辑:程序博客网 时间:2024/06/05 14:45

YUV422格式为YV16,YV16的存储方式是3 planer,即先存储所有的y,然后是所有的u,最后是所有的v。

public static int[] YV16ToRGB(byte[] src, int width, int height){int numOfPixel = width * height;int positionOfU = numOfPixel;int positionOfV = numOfPixel/2 + numOfPixel;int[] rgb = new int[numOfPixel*3];for(int i=0; i<height; i++){int startY = i*width;int step = i*width/2;int startU = positionOfU + step;int startV = positionOfV + step;for(int j = 0; j < width; j++){int Y = startY + j;int U = startU + j/2;int V = startV + j/2;int index = Y*3;rgb[index+R] = (int)((src[Y]&0xff) + 1.4075 * ((src[V]&0xff)-128));rgb[index+G] = (int)((src[Y]&0xff) - 0.3455 * ((src[U]&0xff)-128) - 0.7169*((src[V]&0xff)-128));rgb[index+B] = (int)((src[Y]&0xff) + 1.779 * ((src[U]&0xff)-128));}}return rgb;}


3 1
原创粉丝点击