void RGBb_to_YUVb(const uint8 *RGB,uint8 *YUV) { int R = RGB[0], G = RGB[1], B = RGB[2]; YUV[0] = Y_RGB(R,G,B); YUV[1] = U_RGB(R,G,B) + 127; YUV[2] = V_RGB(R,G,B) + 127; }
void RGBb_to_YUVi(const uint8 *RGB,int *Y,int *U,int *V) { int R = RGB[0], G = RGB[1], B = RGB[2]; *Y = Y_RGB(R,G,B); *U = U_RGB(R,G,B) + 127; *V = V_RGB(R,G,B) + 127; assert( isinrange(*Y,0,255) ); assert( isinrange(*U,0,255) ); assert( isinrange(*V,0,255) ); }
void RGBb_to_YUVb_line(const uint8 *RGB,uint8 *YUV,int len) { int R,G,B; while(len--) { R = *RGB++; G = *RGB++; B = *RGB++; *YUV++ = Y_RGB(R,G,B); *YUV++ = U_RGB(R,G,B) + 127; *YUV++ = V_RGB(R,G,B) + 127; } }
void RGBi_to_YUVi(int R,int G,int B,int *Y,int *U,int *V) { assert( isinrange(R,0,255) ); assert( isinrange(G,0,255) ); assert( isinrange(B,0,255) ); *Y = Y_RGB(R,G,B); *U = U_RGB(R,G,B) + 127; *V = V_RGB(R,G,B) + 127; assert( isinrange(*Y,0,255) ); assert( isinrange(*U,0,255) ); assert( isinrange(*V,0,255) ); }
// Update the YUV plots void sample_update_yuv() { int i; int pixel, r, g, b; rtk_fig_clear(sample->vufig); rtk_fig_clear(sample->yufig); rtk_fig_clear(sample->vyfig); for (i = 0; i < sample->pixel_count; i++) { pixel = sample->pixels[i]; if (sample->mmap->depth == 16) { r = R_RGB16(pixel); g = G_RGB16(pixel); b = B_RGB16(pixel); } else if (sample->mmap->depth == 32) { r = R_RGB32(pixel); g = G_RGB32(pixel); b = B_RGB32(pixel); } rtk_fig_color(sample->vufig, r / 256.0, g / 256.0, b / 256.0); rtk_fig_rectangle(sample->vufig, V_RGB(r, g, b), U_RGB(r, g, b), 0, 2, 2, 1); rtk_fig_color(sample->yufig, r / 256.0, g / 256.0, b / 256.0); rtk_fig_rectangle(sample->yufig, Y_RGB(r, g, b), U_RGB(r, g, b), 0, 2, 2, 1); rtk_fig_color(sample->vyfig, r / 256.0, g / 256.0, b / 256.0); rtk_fig_rectangle(sample->vyfig, V_RGB(r, g, b), Y_RGB(r, g, b), 0, 2, 2, 1); } }