X-Git-Url: http://git.cinelerra-gg.org/git/?p=goodguy%2Fhistory.git;a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fcolor3way%2Fcolor3way.C;h=ba1f0094fcc924c36019573138d4ff46d26f4791;hp=09908686a428fb3010c074535065cd60245ee2c2;hb=723142d62d61cde588e961426440f839ca9dcda9;hpb=30bdb85eb33a8ee7ba675038a86c6be59c43d7bd diff --git a/cinelerra-5.1/plugins/color3way/color3way.C b/cinelerra-5.1/plugins/color3way/color3way.C index 09908686..ba1f0094 100644 --- a/cinelerra-5.1/plugins/color3way/color3way.C +++ b/cinelerra-5.1/plugins/color3way/color3way.C @@ -2,21 +2,21 @@ /* * CINELERRA * Copyright (C) 1997-2011 Adam Williams - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * + * */ @@ -27,10 +27,6 @@ #include "language.h" #include "playback3d.h" -#include "aggregated.h" -#include "../interpolate/aggregated.h" -#include "../gamma/aggregated.h" - #include #include @@ -72,10 +68,10 @@ void Color3WayConfig::copy_from(Color3WayConfig &that) } } -void Color3WayConfig::interpolate(Color3WayConfig &prev, - Color3WayConfig &next, - int64_t prev_frame, - int64_t next_frame, +void Color3WayConfig::interpolate(Color3WayConfig &prev, + Color3WayConfig &next, + int64_t prev_frame, + int64_t next_frame, int64_t current_frame) { double next_scale = (double)(current_frame - prev_frame) / (next_frame - prev_frame); @@ -98,7 +94,7 @@ void Color3WayConfig::boundaries() float point_radius = sqrt(SQR(hue_x[i]) + SQR(hue_y[i])); if(point_radius > 1) { - float angle = atan2(hue_x[i], + float angle = atan2(hue_x[i], hue_y[i]); hue_x[i] = sin(angle); hue_y[i] = cos(angle); @@ -141,7 +137,7 @@ Color3WayPackage::Color3WayPackage() -Color3WayUnit::Color3WayUnit(Color3WayMain *plugin, +Color3WayUnit::Color3WayUnit(Color3WayMain *plugin, Color3WayEngine *server) : LoadClient(server) { @@ -183,12 +179,13 @@ Color3WayUnit::Color3WayUnit(Color3WayMain *plugin, r = r + TOTAL_TRANSFER(r, r_factor); \ g = g + TOTAL_TRANSFER(g, g_factor); \ b = b + TOTAL_TRANSFER(b, b_factor); \ + r = CLAMP(r,0,1); g = CLAMP(g,0,1); b = CLAMP(b,0,1); \ /* Apply saturation/value */ \ float h, s, v; \ HSV::rgb_to_hsv(r, g, b, h, s, v); \ v += TOTAL_TRANSFER(v, v_factor); \ s += TOTAL_TRANSFER(s, s_factor); \ - s = MAX(s, 0); \ + s = CLAMP(s,0,1); v = CLAMP(v,0,1); \ HSV::hsv_to_rgb(r, g, b, h, s, v); @@ -196,54 +193,35 @@ Color3WayUnit::Color3WayUnit(Color3WayMain *plugin, { \ type *in = (type*)plugin->get_input()->get_rows()[i]; \ type *out = (type*)plugin->get_input()->get_rows()[i]; \ - for(int j = 0; j < w; j++) \ - { \ + for(int j = 0; j < w; j++) { \ /* Convert to RGB float */ \ - float r; \ - float g; \ - float b; \ - if(is_yuv) \ - { \ - YUV::yuv_to_rgb_f(r, \ - g, \ - b, \ - (float)in[0] / max, \ - (float)in[1] / max - 0.5, \ - (float)in[2] / max - 0.5); \ - in += 3; \ + float r, g, b; \ + if( !is_yuv ) { \ + r = (float)in[0] / max; \ + g = (float)in[1] / max; \ + b = (float)in[2] / max; \ } \ else \ - { \ - r = (float)*in++ / max; \ - g = (float)*in++ / max; \ - b = (float)*in++ / max; \ - } \ + YUV::yuv.yuv_to_rgb_f(r, g, b, in[0], in[1], in[2]); \ \ PROCESS_PIXEL(r, g, b) \ \ + if( !is_yuv ) { \ /* Convert to project colormodel */ \ - if(is_yuv) \ - { \ - float y, u, v; \ - YUV::rgb_to_yuv_f(r, g, b, y, u, v); \ - r = y; \ - g = u + 0.5; \ - b = v + 0.5; \ - } \ - if(max == 0xff) \ - { \ - CLAMP(r, 0, 1); \ - CLAMP(g, 0, 1); \ - CLAMP(b, 0, 1); \ - } \ - *out++ = (type)(r * max); \ - *out++ = (type)(g * max); \ - *out++ = (type)(b * max); \ - if(components == 4) \ - { \ - in++; \ - out++; \ + if(max == 0xff) { \ + CLAMP(r, 0, 1); \ + CLAMP(g, 0, 1); \ + CLAMP(b, 0, 1); \ + } \ + out[0] = (type)(r * max); \ + out[1] = (type)(g * max); \ + out[2] = (type)(b * max); \ } \ + else \ + YUV::yuv.rgb_to_yuv_f(r, g, b, out[0], out[1], out[2]); \ + \ + in += components; \ + out += components; \ } \ } @@ -268,16 +246,16 @@ void Color3WayUnit::process_package(LoadPackage *package) for(int i = 0; i < SECTIONS; i++) { plugin->calculate_factors(&r_factor[i], &g_factor[i], &b_factor[i], i); - CALCULATE_FACTORS(s_factor[i], - v_factor[i], - plugin->config.saturation[i], + CALCULATE_FACTORS(s_factor[i], + v_factor[i], + plugin->config.saturation[i], plugin->config.value[i]) -// printf("Color3WayUnit::process_package %d %f %f %f %f %f\n", -// __LINE__, -// r_factor[i], -// g_factor[i], -// b_factor[i], -// s_factor[i], +// printf("Color3WayUnit::process_package %d %f %f %f %f %f\n", +// __LINE__, +// r_factor[i], +// g_factor[i], +// b_factor[i], +// s_factor[i], // v_factor[i]); } @@ -331,9 +309,9 @@ void Color3WayEngine::init_packages() printf("Color3WayEngine::init_packages %d\n", __LINE__); for(int i = 0; i <= 255; i++) { - printf("%f\t%f\t%f\n", - SHADOW_CURVE((float)i / 255), - MIDTONE_CURVE((float)i / 255), + printf("%f\t%f\t%f\n", + SHADOW_CURVE((float)i / 255), + MIDTONE_CURVE((float)i / 255), HIGHLIGHT_CURVE((float)i / 255)); } #endif @@ -378,25 +356,25 @@ Color3WayMain::Color3WayMain(PluginServer *server) Color3WayMain::~Color3WayMain() { - + delete engine; } -const char* Color3WayMain::plugin_title() { return _("Color 3 Way"); } +const char* Color3WayMain::plugin_title() { return N_("Color 3 Way"); } int Color3WayMain::is_realtime() { return 1; } int Color3WayMain::reconfigure() { - + return 0; } void Color3WayMain::process_pixel(float *r, float *g, float *b, - float r_in, - float g_in, + float r_in, + float g_in, float b_in, float x, float y) @@ -408,24 +386,24 @@ void Color3WayMain::process_pixel(float *r, float v_factor[SECTIONS]; for(int i = 0; i < SECTIONS; i++) { - calculate_factors(r_factor + i, - g_factor + i, - b_factor + i, - x, + calculate_factors(r_factor + i, + g_factor + i, + b_factor + i, + x, y); CALCULATE_FACTORS(s_factor[i], v_factor[i], 0, 0) } - + PROCESS_PIXEL(r_in, g_in, b_in); *r = r_in; *g = g_in; *b = b_in; } -void Color3WayMain::calculate_factors(float *r, - float *g, - float *b, - float x, +void Color3WayMain::calculate_factors(float *r, + float *g, + float *b, + float x, float y) { // float h = atan2(-x, -y) * 360 / 2 / M_PI + 180; @@ -470,7 +448,7 @@ int Color3WayMain::process_buffer(VFrame *frame, { need_reconfigure |= load_configuration(); - if(!engine) engine = new Color3WayEngine(this, + if(!engine) engine = new Color3WayEngine(this, // 1); PluginClient::smp + 1); @@ -495,11 +473,8 @@ int Color3WayMain::process_buffer(VFrame *frame, get_aggregation(&aggregate_interpolate, &aggregate_gamma); - - engine->process_packages(); - return 0; } @@ -548,7 +523,7 @@ void Color3WayMain::save_data(KeyFrame *keyframe) output.tag.set_property("W", w); output.tag.set_property("H", h); } - + output.append_tag(); output.tag.set_title("/COLOR3WAY"); output.append_tag(); @@ -583,7 +558,7 @@ void Color3WayMain::read_data(KeyFrame *keyframe) config.value[i] = input.tag.get_property(string, config.value[i]); sprintf(string, "SATURATION_%d", i); config.saturation[i] = input.tag.get_property(string, config.saturation[i]); - + if(is_defaults()) { sprintf(string, "COPY_TO_ALL_%d", i); @@ -622,68 +597,4 @@ void Color3WayMain::get_aggregation(int *aggregate_interpolate, } } -int Color3WayMain::handle_opengl() -{ -#ifdef HAVE_GL - - get_output()->to_texture(); - get_output()->enable_opengl(); - - unsigned int shader = 0; - const char *shader_stack[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - int current_shader = 0; - int aggregate_interpolate = 0; - int aggregate_gamma = 0; - - get_aggregation(&aggregate_interpolate, - &aggregate_gamma); - -printf("Color3WayMain::handle_opengl %d %d\n", aggregate_interpolate, aggregate_gamma); - if(aggregate_interpolate) - INTERPOLATE_COMPILE(shader_stack, current_shader) - - if(aggregate_gamma) - GAMMA_COMPILE(shader_stack, current_shader, aggregate_interpolate) - - COLORBALANCE_COMPILE(shader_stack, - current_shader, - aggregate_gamma || aggregate_interpolate) - - shader = VFrame::make_shader(0, - shader_stack[0], - shader_stack[1], - shader_stack[2], - shader_stack[3], - shader_stack[4], - shader_stack[5], - shader_stack[6], - shader_stack[7], - 0); - - if(shader > 0) - { - glUseProgram(shader); - glUniform1i(glGetUniformLocation(shader, "tex"), 0); - - if(aggregate_interpolate) INTERPOLATE_UNIFORMS(shader); - if(aggregate_gamma) GAMMA_UNIFORMS(shader); - - COLORBALANCE_UNIFORMS(shader); - - } - - get_output()->init_screen(); - get_output()->bind_texture(0); - get_output()->draw_texture(); - glUseProgram(0); - get_output()->set_opengl_state(VFrame::SCREEN); -#endif - return 0; -} - - - - - -