X-Git-Url: http://git.cinelerra-gg.org/git/?p=goodguy%2Fhistory.git;a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fhuesaturation%2Fhuesaturation.C;h=5800928e08be79e7830a70a4edbcaa7c834c2fd6;hp=f7f04f24c130c9c6ee6f07b2a601f0066b20bd37;hb=723142d62d61cde588e961426440f839ca9dcda9;hpb=9d832a1fff11b11aaa1108c460690ed05e2bdc05 diff --git a/cinelerra-5.1/plugins/huesaturation/huesaturation.C b/cinelerra-5.1/plugins/huesaturation/huesaturation.C index f7f04f24..5800928e 100644 --- a/cinelerra-5.1/plugins/huesaturation/huesaturation.C +++ b/cinelerra-5.1/plugins/huesaturation/huesaturation.C @@ -19,6 +19,7 @@ * */ +#include "bccolors.h" #include "bcdisplayinfo.h" #include "clip.h" #include "bchash.h" @@ -128,7 +129,6 @@ public: HueUnit(HueEffect *plugin, HueEngine *server); void process_package(LoadPackage *package); HueEffect *plugin; - YUV yuv; }; class HueEffect : public PluginVClient @@ -399,9 +399,9 @@ HueUnit::HueUnit(HueEffect *plugin, HueEngine *server) u = (int)in_row[1]; \ v = (int)in_row[2]; \ if(max == 0xffff) \ - yuv.yuv_to_rgb_16(r_i, g_i, b_i, y, u, v); \ + YUV::yuv.yuv_to_rgb_16(r_i, g_i, b_i, y, u, v); \ else \ - yuv.yuv_to_rgb_8(r_i, g_i, b_i, y, u, v); \ + YUV::yuv.yuv_to_rgb_8(r_i, g_i, b_i, y, u, v); \ HSV::rgb_to_hsv((float)r_i / max, \ (float)g_i / max, \ (float)b_i / max, \ @@ -568,7 +568,7 @@ int HueEffect::process_buffer(VFrame *frame, return 0; } -const char* HueEffect::plugin_title() { return _("Hue saturation"); } +const char* HueEffect::plugin_title() { return N_("Hue saturation"); } int HueEffect::is_realtime() { return 1; } NEW_WINDOW_MACRO(HueEffect, HueWindow) @@ -677,38 +677,26 @@ int HueEffect::handle_opengl() get_output()->to_texture(); get_output()->enable_opengl(); - unsigned int frag_shader = 0; - switch(get_output()->get_color_model()) - { - case BC_YUV888: - case BC_YUVA8888: -// This is a lousy approximation but good enough for the masker. - if(EQUIV(config.hue, 0)) - frag_shader = VFrame::make_shader(0, - yuv_saturation_frag, - 0); - else - frag_shader = VFrame::make_shader(0, - yuv_frag, - 0); - break; - default: - frag_shader = VFrame::make_shader(0, - rgb_frag, - 0); - break; - } - - - if(frag_shader > 0) - { - glUseProgram(frag_shader); - glUniform1i(glGetUniformLocation(frag_shader, "tex"), 0); - glUniform1f(glGetUniformLocation(frag_shader, "h_offset"), config.hue); - glUniform1f(glGetUniformLocation(frag_shader, "s_offset"), + const char *shader_stack[16]; + memset(shader_stack,0, sizeof(shader_stack)); + int current_shader = 0; + + int need_color_matrix = BC_CModels::is_yuv(get_output()->get_color_model()) ? 1 : 0; + if( need_color_matrix ) shader_stack[current_shader++] = bc_gl_colors; + shader_stack[current_shader++] = !need_color_matrix ? rgb_frag : + EQUIV(config.hue, 0) ? yuv_saturation_frag: yuv_frag ; + + shader_stack[current_shader] = 0; + unsigned int shader = VFrame::make_shader(shader_stack); + if(shader > 0) { + glUseProgram(shader); + glUniform1i(glGetUniformLocation(shader, "tex"), 0); + glUniform1f(glGetUniformLocation(shader, "h_offset"), config.hue); + glUniform1f(glGetUniformLocation(shader, "s_offset"), ((float)config.saturation - MINSATURATION) / MAXSATURATION); - glUniform1f(glGetUniformLocation(frag_shader, "v_offset"), + glUniform1f(glGetUniformLocation(shader, "v_offset"), ((float)config.value - MINVALUE) / MAXVALUE); + if( need_color_matrix ) BC_GL_COLORS(shader); } get_output()->init_screen();