X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fgamma%2Fgamma.C;h=32312105992fee023a02aeb3bf12dc72b4b76778;hb=418e8644335db47143bc421f11be2c2e68901d45;hp=23026f07a5dbf5a615d13af4d0f2ba0caf8da725;hpb=30bdb85eb33a8ee7ba675038a86c6be59c43d7bd;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/plugins/gamma/gamma.C b/cinelerra-5.1/plugins/gamma/gamma.C index 23026f07..32312105 100644 --- a/cinelerra-5.1/plugins/gamma/gamma.C +++ b/cinelerra-5.1/plugins/gamma/gamma.C @@ -2,21 +2,21 @@ /* * CINELERRA * Copyright (C) 2008 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 - * + * */ #include "bcsignals.h" @@ -25,7 +25,7 @@ #include "gamma.h" #include "bchash.h" #include "language.h" -#include "cicolors.h" +#include "bccolors.h" #include "../interpolate/aggregated.h" #include "playback3d.h" #include "workarounds.h" @@ -51,7 +51,7 @@ GammaConfig::GammaConfig() int GammaConfig::equivalent(GammaConfig &that) { - return (EQUIV(max, that.max) && + return (EQUIV(max, that.max) && EQUIV(gamma, that.gamma) && automatic == that.automatic) && plot == that.plot; @@ -65,10 +65,10 @@ void GammaConfig::copy_from(GammaConfig &that) plot = that.plot; } -void GammaConfig::interpolate(GammaConfig &prev, - GammaConfig &next, - int64_t prev_frame, - int64_t next_frame, +void GammaConfig::interpolate(GammaConfig &prev, + GammaConfig &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); @@ -107,7 +107,7 @@ GammaUnit::GammaUnit(GammaMain *plugin) this->plugin = plugin; } - + void GammaUnit::process_package(LoadPackage *package) { GammaPackage *pkg = (GammaPackage*)package; @@ -177,7 +177,7 @@ void GammaUnit::process_package(LoadPackage *package) y /= 0xff; u = (float)((u - 0x80) / 0xff); v = (float)((v - 0x80) / 0xff); - YUV::yuv_to_rgb_f(r, g, b, y, u, v); + YUV::yuv.yuv_to_rgb_f(r, g, b, y, u, v); HISTOGRAM_TAIL(3) break; case BC_YUVA8888: @@ -188,7 +188,7 @@ void GammaUnit::process_package(LoadPackage *package) y /= 0xff; u = (float)((u - 0x80) / 0xff); v = (float)((v - 0x80) / 0xff); - YUV::yuv_to_rgb_f(r, g, b, y, u, v); + YUV::yuv.yuv_to_rgb_f(r, g, b, y, u, v); HISTOGRAM_TAIL(4) break; } @@ -275,9 +275,9 @@ void GammaUnit::process_package(LoadPackage *package) y /= 0xff; u = (float)((u - 0x80) / 0xff); v = (float)((v - 0x80) / 0xff); - YUV::yuv_to_rgb_f(r, g, b, y, u, v); + YUV::yuv.yuv_to_rgb_f(r, g, b, y, u, v); GAMMA_MID - YUV::rgb_to_yuv_f(r, g, b, y, u, v); + YUV::yuv.rgb_to_yuv_f(r, g, b, y, u, v); y *= 0xff; u = u * 0xff + 0x80; v = v * 0xff + 0x80; @@ -294,9 +294,9 @@ void GammaUnit::process_package(LoadPackage *package) y /= 0xff; u = (float)((u - 0x80) / 0xff); v = (float)((v - 0x80) / 0xff); - YUV::yuv_to_rgb_f(r, g, b, y, u, v); + YUV::yuv.yuv_to_rgb_f(r, g, b, y, u, v); GAMMA_MID - YUV::rgb_to_yuv_f(r, g, b, y, u, v); + YUV::yuv.rgb_to_yuv_f(r, g, b, y, u, v); y *= 0xff; u = u * 0xff + 0x80; v = v * 0xff + 0x80; @@ -320,7 +320,7 @@ void GammaUnit::process_package(LoadPackage *package) GammaEngine::GammaEngine(GammaMain *plugin) - : LoadServer(plugin->get_project_smp() + 1, + : LoadServer(plugin->get_project_smp() + 1, plugin->get_project_smp() + 1) { this->plugin = plugin; @@ -388,17 +388,17 @@ GammaMain::GammaMain(PluginServer *server) : PluginVClient(server) { engine = 0; - + } GammaMain::~GammaMain() { - + delete engine; } -const char* GammaMain::plugin_title() { return _("Gamma"); } +const char* GammaMain::plugin_title() { return N_("Gamma"); } int GammaMain::is_realtime() { return 1; } @@ -423,12 +423,12 @@ int GammaMain::process_buffer(VFrame *frame, frame->get_params()->update("GAMMA_MAX", config.max); int use_opengl = get_use_opengl() && - !config.automatic && + !config.automatic && (!config.plot || !gui_open()); - read_frame(frame, - 0, - start_position, + read_frame(frame, + 0, + start_position, frame_rate, use_opengl); @@ -440,7 +440,7 @@ int GammaMain::process_buffer(VFrame *frame, if(next_effect_is(_("Color Balance"))) return 0; - + return run_opengl(); } else @@ -451,7 +451,7 @@ int GammaMain::process_buffer(VFrame *frame, send_render_gui(this); } else - if(config.plot) + if(config.plot) { send_render_gui(this); } @@ -502,8 +502,8 @@ void GammaMain::render_gui(void *data) if(!engine) engine = new GammaEngine(this); if(ptr->engine && ptr->config.automatic) { - memcpy(engine->accum, - ptr->engine->accum, + memcpy(engine->accum, + ptr->engine->accum, sizeof(int) * HISTOGRAM_SIZE); thread->window->lock_window("GammaMain::render_gui"); ((GammaWindow*)thread->window)->update(); @@ -511,7 +511,7 @@ void GammaMain::render_gui(void *data) } else { - engine->process_packages(GammaEngine::HISTOGRAM, + engine->process_packages(GammaEngine::HISTOGRAM, ptr->frame); thread->window->lock_window("GammaMain::render_gui"); ((GammaWindow*)thread->window)->update_histogram(); @@ -573,43 +573,30 @@ int GammaMain::handle_opengl() get_output()->to_texture(); get_output()->enable_opengl(); + const char *shader_stack[16]; + memset(shader_stack,0, sizeof(shader_stack)); + int current_shader = 0; - const char *shader_stack[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - 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; // Aggregate with interpolate - int aggregate = 0; - if(prev_effect_is(_("Interpolate Pixels"))) - { - aggregate = 1; - INTERPOLATE_COMPILE(shader_stack, current_shader) - } + int aggregate = prev_effect_is(_("Interpolate Pixels")) ? 1 : 0; + if( aggregate ) + INTERPOLATE_COMPILE(shader_stack, current_shader); GAMMA_COMPILE(shader_stack, current_shader, aggregate); - unsigned int 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) - { + shader_stack[current_shader] = 0; + unsigned int shader = VFrame::make_shader(shader_stack); + if( shader > 0 ) { glUseProgram(shader); glUniform1i(glGetUniformLocation(shader, "tex"), 0); - if(aggregate) - { - INTERPOLATE_UNIFORMS(shader) - } - GAMMA_UNIFORMS(shader) + INTERPOLATE_UNIFORMS(shader); + GAMMA_UNIFORMS(shader); + if( need_color_matrix ) BC_GL_COLORS(shader); } get_output()->init_screen();