X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;ds=sidebyside;f=cinelerra-5.1%2Fguicast%2Fbccolors.C;h=e587321d5d347f597e962fe752dccac642d3330f;hb=c279e21fc2394a7908bbd1ba8c79b116fe9fb14a;hp=a287fb78c64fa7ee2bb0dedfb34483f160aa8df9;hpb=243336668c89096732786c6b3f3c5918aa2eff26;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/guicast/bccolors.C b/cinelerra-5.1/guicast/bccolors.C index a287fb78..e587321d 100644 --- a/cinelerra-5.1/guicast/bccolors.C +++ b/cinelerra-5.1/guicast/bccolors.C @@ -126,6 +126,9 @@ int HSV::hsv_to_yuv(int &y, int &u, int &v, float h, float s, float va, int max) YUV YUV::yuv; +float YUV::yuv_to_rgb_matrix[9]; +float YUV::rgb_to_yuv_matrix[9]; +float *const YUV::rgb_to_y_vector = YUV::rgb_to_yuv_matrix; YUV::YUV() { @@ -140,13 +143,14 @@ void YUV::yuv_set_colors(int color_space, int color_range) int mpeg; switch( color_space ) { default: - case 0: kr = BT601_Kr; kb = BT601_Kb; break; - case 1: kr = BT709_Kr; kb = BT709_Kb; break; + case BC_COLORS_BT601: kr = BT601_Kr; kb = BT601_Kb; break; + case BC_COLORS_BT709: kr = BT709_Kr; kb = BT709_Kb; break; + case BC_COLORS_BT2020: kr = BT2020_Kr; kb = BT2020_Kb; break; } switch( color_range ) { default: - case 0: mpeg = 0; break; - case 1: mpeg = 1; break; + case BC_COLORS_JPEG: mpeg = 0; break; + case BC_COLORS_MPEG: mpeg = 1; break; } init(kr, kb, mpeg); } @@ -219,6 +223,27 @@ void YUV::init(double Kr, double Kb, int mpeg) vtor8f, vtog8f, utog8f, utob8f); init_tables(0x10000, vtor16f, vtog16f, utog16f, utob16f); + + rgb_to_yuv_matrix[0] = r_to_y; + rgb_to_yuv_matrix[1] = g_to_y; + rgb_to_yuv_matrix[2] = b_to_y; + rgb_to_yuv_matrix[3] = r_to_u; + rgb_to_yuv_matrix[4] = g_to_u; + rgb_to_yuv_matrix[5] = b_to_u; + rgb_to_yuv_matrix[6] = r_to_v; + rgb_to_yuv_matrix[7] = g_to_v; + rgb_to_yuv_matrix[8] = b_to_v; + + float yscale = 1.f / yrangef; + yuv_to_rgb_matrix[0] = yscale; + yuv_to_rgb_matrix[1] = 0; + yuv_to_rgb_matrix[2] = v_to_r; + yuv_to_rgb_matrix[3] = yscale; + yuv_to_rgb_matrix[4] = u_to_g; + yuv_to_rgb_matrix[5] = v_to_g; + yuv_to_rgb_matrix[6] = yscale; + yuv_to_rgb_matrix[7] = u_to_b; + yuv_to_rgb_matrix[8] = 0; } void YUV::init_tables(int len,