camera/yuv2rgb.c
static int yuv420_to_rgbmodel(VidFrame *src,VidFrame *dest,unsigned int rgbModel[]){ 
	unsigned char *d,*_d;
	unsigned char *y,*u,*v;
	unsigned char *_u,*_v;
	int i,j;
	unsigned int channel[3];
	
	int w=vidFrameGetWidth(src);
	int h=vidFrameGetHeight(src);

	dest->bytesperline = w * 3;

	d = vidFrameGetImageData(dest);

	y = vidFrameGetImageData(src);
	u = y +w*h;
	v = u+(w*h)/4;
	
	for (i=0;i<h;i++) {
		_u = u; _v = v; _d = d;
		for (j=0;j<w;j+=2) {
			channel[0] = R(*y,*v);
			channel[1] = G(*y,*u,*v);
			channel[2] = B(*y,*u);
			*(d++) = channel[ rgbModel[0] ];
			*(d++) = channel[ rgbModel[1]];
			*(d++)  = channel[rgbModel[2]];
			y++;
			
			channel[0] = R(*y,*v);
			channel[1] = G(*y,*u,*v);
			channel[2] = B(*y,*u);
			
			*(d++) = channel[ rgbModel[0] ];
			*(d++) = channel[ rgbModel[1]];
			*(d++)  = channel[rgbModel[2]];
			y++;u++;v++;
		}
		
		if ( !(i % 2) ){
			u = _u; v = _v;
		}
	}
	
	return 0;
}
/**
 * yuv420_to_rgbmodel:
 * @param frame The source video frame
 * @param dest The destination buffer. (It must be large enough to hold the final image)
 * @param rgbModel: An array to describe the order of 'R','G','B" color model.
 *  Convert a YUV420/YU12 pixel into RGB24|BGR24
 * 
 */
@param frame The source video frame
@param dest The destination buffer.
@param frame The source video frame @param dest The destination buffer .
static int yuv420_to_rgbmodel(VidFrame *src,VidFrame *dest,unsigned int rgbModel[]){ 
	unsigned char *d,*_d;
	unsigned char *y,*u,*v;
	unsigned char *_u,*_v;
	int i,j;
	unsigned int channel[3];
	int w=vidFrameGetWidth(src);
	int h=vidFrameGetHeight(src);
	dest->bytesperline = w * 3;
	d = vidFrameGetImageData(dest);
	y = vidFrameGetImageData(src);
	u = y +w*h;
	v = u+(w*h)/4;
	for (i=0;i<h;i++) {
		_u = u; _v = v; _d = d;
		for (j=0;j<w;j+=2) {
			channel[0] = R(*y,*v);
			channel[1] = G(*y,*u,*v);
			channel[2] = B(*y,*u);
			*(d++) = channel[ rgbModel[0] ];
			*(d++) = channel[ rgbModel[1]];
			*(d++)  = channel[rgbModel[2]];
			y++;
			channel[0] = R(*y,*v);
			channel[1] = G(*y,*u,*v);
			channel[2] = B(*y,*u);
			*(d++) = channel[ rgbModel[0] ];
			*(d++) = channel[ rgbModel[1]];
			*(d++)  = channel[rgbModel[2]];
			y++;u++;v++;
		}
		if ( !(i % 2) ){
			u = _u; v = _v;
		}
	}
	return 0;
}
static int yuv420_to_rgbmodel ( VidFrame * src , VidFrame * dest , unsigned int rgbModel [ ] ) { unsigned char * d , * _d ; unsigned char * y , * u , * v ; unsigned char * _u , * _v ; int i , j ; unsigned int channel [ 3 ] ; int w = vidFrameGetWidth ( src ) ; int h = vidFrameGetHeight ( src ) ; dest -> bytesperline = w * 3 ; d = vidFrameGetImageData ( dest ) ; y = vidFrameGetImageData ( src ) ; u = y + w * h ; v = u + ( w * h ) / 4 ; for ( i = 0 ; i < h ; i ++ ) { _u = u ; _v = v ; _d = d ; for ( j = 0 ; j < w ; j += 2 ) { channel [ 0 ] = R ( * y , * v ) ; channel [ 1 ] = G ( * y , * u , * v ) ; channel [ 2 ] = B ( * y , * u ) ; * ( d ++ ) = channel [ rgbModel [ 0 ] ] ; * ( d ++ ) = channel [ rgbModel [ 1 ] ] ; * ( d ++ ) = channel [ rgbModel [ 2 ] ] ; y ++ ; channel [ 0 ] = R ( * y , * v ) ; channel [ 1 ] = G ( * y , * u , * v ) ; channel [ 2 ] = B ( * y , * u ) ; * ( d ++ ) = channel [ rgbModel [ 0 ] ] ; * ( d ++ ) = channel [ rgbModel [ 1 ] ] ; * ( d ++ ) = channel [ rgbModel [ 2 ] ] ; y ++ ; u ++ ; v ++ ; } if ( ! ( i % 2 ) ) { u = _u ; v = _v ; } } return 0 ; }
yuv420_to_rgbmodel:
 @param frame The source video frame
 @param dest The destination buffer.
yuv420_to_rgbmodel : @param frame The source video frame @param dest The destination buffer .