X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Finterpolate%2Finterpolate.C;h=9294d8fd6b4217047e68a2a648769966b2288991;hb=b2eb290b3f6e5c233393017aa152e67c76243130;hp=7cede4ab986766b1edbec7bd02425f3d3e76aaf7;hpb=30bdb85eb33a8ee7ba675038a86c6be59c43d7bd;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/plugins/interpolate/interpolate.C b/cinelerra-5.1/plugins/interpolate/interpolate.C index 7cede4ab..9294d8fd 100644 --- a/cinelerra-5.1/plugins/interpolate/interpolate.C +++ b/cinelerra-5.1/plugins/interpolate/interpolate.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 "bcdisplayinfo.h" @@ -38,9 +38,9 @@ REGISTER_PLUGIN(InterpolatePixelsMain) -InterpolatePixelsOffset::InterpolatePixelsOffset(InterpolatePixelsWindow *window, - int x, - int y, +InterpolatePixelsOffset::InterpolatePixelsOffset(InterpolatePixelsWindow *window, + int x, + int y, int *output) : BC_ISlider(x, y, @@ -74,13 +74,13 @@ int InterpolatePixelsOffset::handle_event() InterpolatePixelsWindow::InterpolatePixelsWindow(InterpolatePixelsMain *client) : PluginClientWindow(client, - 200, - 100, - 200, - 100, + 200, + 100, + 200, + 100, 0) -{ - this->client = client; +{ + this->client = client; } InterpolatePixelsWindow::~InterpolatePixelsWindow() @@ -90,18 +90,18 @@ InterpolatePixelsWindow::~InterpolatePixelsWindow() void InterpolatePixelsWindow::create_objects() { int x = 10, y = 10; - + BC_Title *title; add_tool(title = new BC_Title(x, y, _("X Offset:"))); - add_tool(x_offset = new InterpolatePixelsOffset(this, + add_tool(x_offset = new InterpolatePixelsOffset(this, x + title->get_w() + 5, - y, + y, &client->config.x)); y += MAX(x_offset->get_h(), title->get_h()) + 5; add_tool(title = new BC_Title(x, y, _("Y Offset:"))); - add_tool(y_offset = new InterpolatePixelsOffset(this, + add_tool(y_offset = new InterpolatePixelsOffset(this, x + title->get_w() + 5, - y, + y, &client->config.y)); y += MAX(y_offset->get_h(), title->get_h()) + 5; @@ -167,7 +167,7 @@ InterpolatePixelsMain::~InterpolatePixelsMain() delete engine; } -const char* InterpolatePixelsMain::plugin_title() { return _("Interpolate Pixels"); } +const char* InterpolatePixelsMain::plugin_title() { return N_("Interpolate Bayer"); } int InterpolatePixelsMain::is_realtime() { return 1; } @@ -198,7 +198,7 @@ void InterpolatePixelsMain::save_data(KeyFrame *keyframe) 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("INTERPOLATEPIXELS"); output.tag.set_property("X", config.x); output.tag.set_property("Y", config.y); @@ -213,7 +213,7 @@ void InterpolatePixelsMain::read_data(KeyFrame *keyframe) { FileXML input; - input.set_shared_input(keyframe->get_data(), strlen(keyframe->get_data())); + input.set_shared_input(keyframe->xbuf); int result = 0; @@ -242,9 +242,9 @@ int InterpolatePixelsMain::process_buffer(VFrame *frame, frame->get_params()->update("INTERPOLATEPIXELS_X", config.x); frame->get_params()->update("INTERPOLATEPIXELS_Y", config.y); - read_frame(frame, - 0, - start_position, + read_frame(frame, + 0, + start_position, frame_rate, get_use_opengl()); //frame->dump_params(); @@ -278,7 +278,7 @@ int InterpolatePixelsMain::process_buffer(VFrame *frame, delete out_temp; out_temp = 0; } if( !out_temp ) - out_temp = new VFrame(0, -1, w, h, active_model, -1); + out_temp = new VFrame(w, h, active_model, 0); out_frame = out_temp; } @@ -327,25 +327,25 @@ int InterpolatePixelsMain::handle_opengl() get_output()->to_texture(); get_output()->enable_opengl(); - const char *shader_stack[] = { 0, 0, 0 }; - int current_shader = 0; - INTERPOLATE_COMPILE(shader_stack, current_shader) - unsigned int frag = VFrame::make_shader(0, - shader_stack[0], - 0); - if(frag > 0) - { - glUseProgram(frag); - glUniform1i(glGetUniformLocation(frag, "tex"), 0); - INTERPOLATE_UNIFORMS(frag) - } + const char *shader_stack[16]; + memset(shader_stack,0, sizeof(shader_stack)); + int current_shader = 0; + INTERPOLATE_COMPILE(shader_stack, current_shader); + + shader_stack[current_shader] = 0; + unsigned int shader = VFrame::make_shader(shader_stack); + if( shader > 0 ) { + glUseProgram(shader); + glUniform1i(glGetUniformLocation(shader, "tex"), 0); + INTERPOLATE_UNIFORMS(shader); + } get_output()->init_screen(); get_output()->bind_texture(0); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - + get_output()->draw_texture(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -372,7 +372,7 @@ int InterpolatePixelsMain::handle_opengl() InterpolatePixelsPackage::InterpolatePixelsPackage() : LoadPackage() { - + } @@ -400,6 +400,13 @@ void InterpolatePixelsUnit::process_package(LoadPackage *package) float color_matrix[9]; memcpy(color_matrix, server->color_matrix, sizeof(color_matrix)); +// printf("InterpolatePixelsUnit::process_package %d color_matrix=", __LINE__); +// for(int i = 0; i < 9; i++) +// { +// printf("%f ", color_matrix[i]); +// } +// printf("\n"); + y1 = MAX(y1, 1); y2 = MIN(y2, h - 1); @@ -440,7 +447,7 @@ void InterpolatePixelsUnit::process_package(LoadPackage *package) else // Top right pixel { - r = (prev_row[-components + RED] + + r = (prev_row[-components + RED] + prev_row[components + RED] + next_row[-components + RED] + next_row[components + RED]) / 4; @@ -451,9 +458,14 @@ void InterpolatePixelsUnit::process_package(LoadPackage *package) b = current_row[BLUE]; } - out_row[0] = r * color_matrix[0] + g * color_matrix[1] + b * color_matrix[2]; - out_row[1] = r * color_matrix[3] + g * color_matrix[4] + b * color_matrix[5]; - out_row[2] = r * color_matrix[6] + g * color_matrix[7] + b * color_matrix[8]; +// out_row[0] = r * color_matrix[0] + g * color_matrix[1] + b * color_matrix[2]; +// out_row[1] = r * color_matrix[3] + g * color_matrix[4] + b * color_matrix[5]; +// out_row[2] = r * color_matrix[6] + g * color_matrix[7] + b * color_matrix[8]; + + out_row[0] = r; + out_row[1] = g; + out_row[2] = b; + prev_row += components; current_row += components; next_row += components; @@ -473,7 +485,7 @@ void InterpolatePixelsUnit::process_package(LoadPackage *package) prev_row[GREEN] + current_row[components + GREEN] + next_row[GREEN]) / 4; - b = (prev_row[-components + BLUE] + + b = (prev_row[-components + BLUE] + prev_row[components + BLUE] + next_row[-components + BLUE] + next_row[components + BLUE]) / 4; @@ -486,9 +498,14 @@ void InterpolatePixelsUnit::process_package(LoadPackage *package) b = (prev_row[BLUE] + next_row[BLUE]) / 2; } - out_row[0] = r * color_matrix[0] + g * color_matrix[1] + b * color_matrix[2]; - out_row[1] = r * color_matrix[3] + g * color_matrix[4] + b * color_matrix[5]; - out_row[2] = r * color_matrix[6] + g * color_matrix[7] + b * color_matrix[8]; +// out_row[0] = r * color_matrix[0] + g * color_matrix[1] + b * color_matrix[2]; +// out_row[1] = r * color_matrix[3] + g * color_matrix[4] + b * color_matrix[5]; +// out_row[2] = r * color_matrix[6] + g * color_matrix[7] + b * color_matrix[8]; + + out_row[0] = r; + out_row[1] = g; + out_row[2] = b; + prev_row += components; current_row += components; next_row += components; @@ -514,8 +531,12 @@ void InterpolatePixelsEngine::init_packages() char string[BCTEXTLEN]; string[0] = 0; plugin->get_output()->get_params()->get("DCRAW_MATRIX", string); - sscanf(string, - "%f %f %f %f %f %f %f %f %f", + +// printf("InterpolatePixelsEngine::init_packages %d\n", __LINE__); +// plugin->get_output()->dump_params(); + + sscanf(string, + "%f %f %f %f %f %f %f %f %f", &color_matrix[0], &color_matrix[1], &color_matrix[2],