/*
* 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 "bcsignals.h"
#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"
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;
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);
this->plugin = plugin;
}
-
+
void GammaUnit::process_package(LoadPackage *package)
{
GammaPackage *pkg = (GammaPackage*)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:
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;
}
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;
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;
GammaEngine::GammaEngine(GammaMain *plugin)
- : LoadServer(plugin->get_project_smp() + 1,
+ : LoadServer(plugin->get_project_smp() + 1,
plugin->get_project_smp() + 1)
{
this->plugin = plugin;
: 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; }
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);
if(next_effect_is(_("Color Balance")))
return 0;
-
+
return run_opengl();
}
else
send_render_gui(this);
}
else
- if(config.plot)
+ if(config.plot)
{
send_render_gui(this);
}
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();
}
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();
FileXML output;
// cause data to be stored directly in text
- output.set_shared_output(keyframe->get_data(), MESSAGESIZE);
+ output.set_shared_output(keyframe->xbuf);
output.tag.set_title("GAMMA");
output.tag.set_property("MAX", config.max);
output.tag.set_property("GAMMA", config.gamma);
{
FileXML input;
- input.set_shared_input(keyframe->get_data(), strlen(keyframe->get_data()));
+ input.set_shared_input(keyframe->xbuf);
int result = 0;
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();