5 //c++ -g -I../guicast test5.C ../guicast/x86_64/libguicast.a \
6 // -DHAVE_GL -DHAVE_XFT -I/usr/include/freetype2 -lGL -lX11 -lXext \
7 // -lXinerama -lXv -lpng -lfontconfig -lfreetype -lXft -pthread
9 int main(int ac, char **av)
11 int rgb2yuv = atoi(av[1]);
12 int color = atoi(av[2]);
13 int range = atoi(av[3]);
15 YUV::yuv.yuv_set_colors(color, range);
17 for( int y=0; y<0x100; ++y ) {
18 for( int u=0; u<0x100; ++u ) {
19 for( int v=0; v<0x100; ++v ) {
20 float fy = y/255.f, fu = u/255.f - 0.5f, fv = v/255.f - 0.5f;
21 float fr, fg, fb; YUV::yuv.yuv_to_rgb_f(fr,fg,fb, fy,fu,fv);
22 if( fr<0 || fr>1 || fg<0 || fg>1 || fb<0 || fb>1 )
24 float yy, uu, vv; YUV::yuv.rgb_to_yuv_f(fr,fg,fb, yy,uu,vv);
25 float d = fabsf(fy-yy) + fabsf(fu-uu) + fabsf(fv-vv);
26 int rr = fr*256, gg = fg*256, bb = fb*256;
27 CLAMP(rr,0,255); CLAMP(gg,0,255); CLAMP(bb,0,255);
28 printf("yuv 0x%02x 0x%02x 0x%02x =%f,%f,%f, "
29 "rgb 0x%02x 0x%02x 0x%02x =%f,%f,%f, "
31 y,u,v, fy,fu,fv, rr,gg,bb, fr,fg,fb, yy,uu,vv, d);
37 for( int r=0; r<0x100; ++r ) {
38 for( int g=0; g<0x100; ++g ) {
39 for( int b=0; b<0x100; ++b ) {
40 float fr = r/255.f, fg = g/255.f, fb = b/255.f;
41 float fy, fu, fv; YUV::yuv.rgb_to_yuv_f(fr,fg,fb, fy,fu,fv);
42 if( fy<0 || fy>1 || fu<0 || fu>1 || fv<0 || fv>1 )
44 float rr, gg, bb; YUV::yuv.yuv_to_rgb_f(rr,gg,bb, fy,fu,fv);
45 float d = fabsf(fr-rr) + fabsf(fg-gg) + fabsf(fb-bb);
46 int yy = fy*256, uu = fu*256, vv = fv*256;
47 CLAMP(yy,0,255); CLAMP(uu,0,255); CLAMP(vv,0,255);
48 printf("rgb 0x%02x 0x%02x 0x%02x =%f,%f,%f, "
49 "yuv 0x%02x 0x%02x 0x%02x =%f,%f,%f, "
51 r,g,b, fr,fg,fb, yy,uu,vv, fy,fu,fv, rr,gg,bb, d);