/*
* CINELERRA
* Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
- *
+ *
* 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 "bccolors.h"
#include "filexml.h"
#include "clip.h"
#include "colorbalance.h"
int ColorBalanceConfig::equivalent(ColorBalanceConfig &that)
{
- return (cyan == that.cyan &&
- magenta == that.magenta &&
- yellow == that.yellow &&
- lock_params == that.lock_params &&
+ return (cyan == that.cyan &&
+ magenta == that.magenta &&
+ yellow == that.yellow &&
+ lock_params == that.lock_params &&
preserve == that.preserve);
}
preserve = that.preserve;
}
-void ColorBalanceConfig::interpolate(ColorBalanceConfig &prev,
- ColorBalanceConfig &next,
- int64_t prev_frame,
- int64_t next_frame,
+void ColorBalanceConfig::interpolate(ColorBalanceConfig &prev,
+ ColorBalanceConfig &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);
switch(input->get_color_model())
{
case BC_RGB888:
- PROCESS(yuv.yuv_to_rgb_8, yuv.rgb_to_yuv_8,
- r_lookup_8, g_lookup_8, b_lookup_8,
+ PROCESS(YUV::yuv.yuv_to_rgb_8, YUV::yuv.rgb_to_yuv_8,
+ r_lookup_8, g_lookup_8, b_lookup_8,
unsigned char, 0xff, 3, 0);
break;
break;
case BC_YUV888:
- PROCESS(yuv.yuv_to_rgb_8, yuv.rgb_to_yuv_8,
- r_lookup_8, g_lookup_8, b_lookup_8,
+ PROCESS(YUV::yuv.yuv_to_rgb_8, YUV::yuv.rgb_to_yuv_8,
+ r_lookup_8, g_lookup_8, b_lookup_8,
unsigned char, 0xff, 3, 1);
break;
-
+
case BC_RGBA_FLOAT:
PROCESS_F(4);
break;
case BC_RGBA8888:
- PROCESS(yuv.yuv_to_rgb_8, yuv.rgb_to_yuv_8,
- r_lookup_8, g_lookup_8, b_lookup_8,
+ PROCESS(YUV::yuv.yuv_to_rgb_8, YUV::yuv.rgb_to_yuv_8,
+ r_lookup_8, g_lookup_8, b_lookup_8,
unsigned char, 0xff, 4, 0);
break;
case BC_YUVA8888:
- PROCESS(yuv.yuv_to_rgb_8, yuv.rgb_to_yuv_8,
- r_lookup_8, g_lookup_8, b_lookup_8,
+ PROCESS(YUV::yuv.yuv_to_rgb_8, YUV::yuv.rgb_to_yuv_8,
+ r_lookup_8, g_lookup_8, b_lookup_8,
unsigned char, 0xff, 4, 1);
break;
-
+
case BC_YUV161616:
- PROCESS(yuv.yuv_to_rgb_16, yuv.rgb_to_yuv_16,
- r_lookup_16, g_lookup_16, b_lookup_16,
+ PROCESS(YUV::yuv.yuv_to_rgb_16, YUV::yuv.rgb_to_yuv_16,
+ r_lookup_16, g_lookup_16, b_lookup_16,
u_int16_t, 0xffff, 3, 1);
break;
case BC_YUVA16161616:
- PROCESS(yuv.yuv_to_rgb_16, yuv.rgb_to_yuv_16,
- r_lookup_16, g_lookup_16, b_lookup_16,
+ PROCESS(YUV::yuv.yuv_to_rgb_16, YUV::yuv.rgb_to_yuv_16,
+ r_lookup_16, g_lookup_16, b_lookup_16,
u_int16_t, 0xffff, 4, 1);
break;
}
-
-
+
+
output_lock.unlock();
}
}
{
need_reconfigure = 1;
engine = 0;
-
+
}
ColorBalanceMain::~ColorBalanceMain()
{
-
+
if(engine)
}
}
-const char* ColorBalanceMain::plugin_title() { return _("Color Balance"); }
+const char* ColorBalanceMain::plugin_title() { return N_("Color Balance"); }
int ColorBalanceMain::is_realtime() { return 1; }
RECONFIGURE(r_lookup_8, g_lookup_8, b_lookup_8, 0xff);
RECONFIGURE(r_lookup_16, g_lookup_16, b_lookup_16, 0xffff);
-
+
return 0;
}
int ColorBalanceMain::synchronize_params(ColorBalanceSlider *slider, float difference)
{
- if(thread && config.lock_params)
- {
- if(slider != ((ColorBalanceWindow*)thread->window)->cyan)
- {
- config.cyan += difference;
- test_boundary(config.cyan);
- ((ColorBalanceWindow*)thread->window)->cyan->update((int64_t)config.cyan);
- }
- if(slider != ((ColorBalanceWindow*)thread->window)->magenta)
- {
- config.magenta += difference;
- test_boundary(config.magenta);
- ((ColorBalanceWindow*)thread->window)->magenta->update((int64_t)config.magenta);
- }
- if(slider != ((ColorBalanceWindow*)thread->window)->yellow)
- {
- config.yellow += difference;
- test_boundary(config.yellow);
- ((ColorBalanceWindow*)thread->window)->yellow->update((int64_t)config.yellow);
- }
- }
+ if(thread && config.lock_params) {
+ if(slider != ((ColorBalanceWindow*)thread->window)->cyan) {
+ config.cyan += difference;
+ test_boundary(config.cyan);
+ ((ColorBalanceWindow*)thread->window)->cyan->update((int64_t)config.cyan);
+ }
+ if(slider != ((ColorBalanceWindow*)thread->window)->magenta) {
+ config.magenta += difference;
+ test_boundary(config.magenta);
+ ((ColorBalanceWindow*)thread->window)->magenta->update((int64_t)config.magenta);
+ }
+ if(slider != ((ColorBalanceWindow*)thread->window)->yellow) {
+ config.yellow += difference;
+ test_boundary(config.yellow);
+ ((ColorBalanceWindow*)thread->window)->yellow->update((int64_t)config.yellow);
+ }
+ }
return 0;
}
get_aggregation(&aggregate_interpolate,
&aggregate_gamma);
- if(!EQUIV(config.cyan, 0) ||
- !EQUIV(config.magenta, 0) ||
+ if(!EQUIV(config.cyan, 0) ||
+ !EQUIV(config.magenta, 0) ||
!EQUIV(config.yellow, 0) ||
(get_use_opengl() &&
(aggregate_interpolate ||
if(next_effect_is(_("Histogram"))) return 0;
return run_opengl();
}
-
+
for(int i = 0; i < total_engines; i++)
{
- engine[i]->start_process_frame(frame,
- frame,
- frame->get_h() * i / total_engines,
+ engine[i]->start_process_frame(frame,
+ frame,
+ frame->get_h() * i / total_engines,
frame->get_h() * (i + 1) / total_engines);
}
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;
+ 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;
+
int aggregate_interpolate = 0;
int aggregate_gamma = 0;
//printf("ColorBalanceMain::handle_opengl %d %d\n", aggregate_interpolate, aggregate_gamma);
if(aggregate_interpolate)
- INTERPOLATE_COMPILE(shader_stack, current_shader)
+ 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)
- {
+ GAMMA_COMPILE(shader_stack, current_shader,
+ aggregate_interpolate);
+
+ COLORBALANCE_COMPILE(shader_stack, current_shader,
+ aggregate_gamma || aggregate_interpolate);
+
+ 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_gamma) GAMMA_UNIFORMS(shader);
COLORBALANCE_UNIFORMS(shader);
-
+ if( need_color_matrix ) BC_GL_COLORS(shader);
}
get_output()->init_screen();