From: Good Guy Date: Sat, 22 Aug 2015 00:34:25 +0000 (-0600) Subject: fixups for plugins interpolate, c41 X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=e5013d46af178d2557a656a777d747e23cc3ae7f;p=goodguy%2Fhistory.git fixups for plugins interpolate, c41 --- diff --git a/cinelerra-5.0/plugins/C41/c41.C b/cinelerra-5.0/plugins/C41/c41.C index 89607d70..ee59aec5 100644 --- a/cinelerra-5.0/plugins/C41/c41.C +++ b/cinelerra-5.0/plugins/C41/c41.C @@ -504,14 +504,9 @@ int C41Effect::process_buffer(VFrame *vframe, int components = active_model == BC_RGBA_FLOAT ? 4 : 3; if( color_model != active_model ) { - frame = new VFrame(frame_w, frame_h, active_model); - BC_CModels::transfer(frame->get_rows(), vframe->get_rows(), - 0, 0, 0, 0, 0, 0, - 0, 0, vframe->get_w(), vframe->get_h(), - 0, 0, frame->get_w(), frame->get_h(), - vframe->get_color_model(), frame->get_color_model(), - 0, vframe->get_bytes_per_line(), - frame->get_bytes_per_line()); + new_temp(frame_w, frame_h, active_model); + frame = get_temp(); + frame->transfer_from(vframe); } if(config.compute_magic) { @@ -612,17 +607,8 @@ for(int i = 0; i < frame_h; i++) } } - if( vframe != frame ) { - BC_CModels::transfer(vframe->get_rows(), frame->get_rows(), - vframe->get_y(), vframe->get_u(), vframe->get_v(), - 0, 0, 0, - 0, 0, frame->get_w(), frame->get_h(), - 0, 0, vframe->get_w(), vframe->get_h(), - frame->get_color_model(), vframe->get_color_model(), - 0, frame->get_bytes_per_line(), - vframe->get_bytes_per_line()); - delete frame; - } + if( vframe != frame ) + vframe->transfer_from(frame); return 0; } diff --git a/cinelerra-5.0/plugins/interpolate/aggregated.h b/cinelerra-5.0/plugins/interpolate/aggregated.h index 385abe1a..42eb6c4c 100644 --- a/cinelerra-5.0/plugins/interpolate/aggregated.h +++ b/cinelerra-5.0/plugins/interpolate/aggregated.h @@ -146,6 +146,8 @@ static const char *interpolate_shader = int x_offset = get_output()->get_params()->get("INTERPOLATEPIXELS_X", (int)0); \ int y_offset = get_output()->get_params()->get("INTERPOLATEPIXELS_Y", (int)0); \ float color_matrix[9]; \ + for( int i=0; i<9; ++i ) color_matrix[i] = 0; \ + for( int i=0; i<3; ++i ) color_matrix[i*3 + i] = 1; \ char string[BCTEXTLEN]; \ string[0] = 0; \ get_output()->get_params()->get("DCRAW_MATRIX", string); \ diff --git a/cinelerra-5.0/plugins/interpolate/interpolate.C b/cinelerra-5.0/plugins/interpolate/interpolate.C index 0b1bce1f..85c43201 100644 --- a/cinelerra-5.0/plugins/interpolate/interpolate.C +++ b/cinelerra-5.0/plugins/interpolate/interpolate.C @@ -157,13 +157,13 @@ void InterpolatePixelsConfig::interpolate(InterpolatePixelsConfig &prev, InterpolatePixelsMain::InterpolatePixelsMain(PluginServer *server) : PluginVClient(server) { - + out_temp = out_frame = 0; engine = 0; } InterpolatePixelsMain::~InterpolatePixelsMain() { - + delete out_temp; delete engine; } @@ -229,8 +229,6 @@ void InterpolatePixelsMain::read_data(KeyFrame *keyframe) } } - - int InterpolatePixelsMain::process_buffer(VFrame *frame, int64_t start_position, double frame_rate) @@ -260,20 +258,53 @@ int InterpolatePixelsMain::process_buffer(VFrame *frame, return run_opengl(); } - - if(get_output()->get_color_model() != BC_RGB_FLOAT && - get_output()->get_color_model() != BC_RGBA_FLOAT) - { - printf("InterpolatePixelsMain::process_buffer: only supports float colormodels\n"); - return 1; + int color_model = frame->get_color_model(); + int active_model = BC_CModels::has_alpha(color_model) ? + BC_RGBA_FLOAT : BC_RGB_FLOAT; + new_temp(frame->get_w(), frame->get_h(), active_model); + get_temp()->transfer_from(frame); + + out_frame = get_output(); + color_model = out_frame->get_color_model(); + active_model = BC_CModels::has_alpha(color_model) ? + BC_RGBA_FLOAT : BC_RGB_FLOAT; + if( active_model != color_model ) { + int w = out_frame->get_w(), h = out_frame->get_h(); + if( out_temp && ( out_temp->get_color_model() != active_model || + out_temp->get_w() != w || out_temp->get_w() != h ) ) { + delete out_temp; out_temp = 0; + } + if( !out_temp ) + out_temp = new VFrame(0, -1, w, h, active_model, -1); + out_frame = out_temp; } - new_temp(frame->get_w(), frame->get_h(), frame->get_color_model()); - get_temp()->copy_from(frame); if(!engine) engine = new InterpolatePixelsEngine(this); engine->process_packages(); + if( out_frame != get_output() ) { + if( BC_CModels::has_alpha(out_frame->get_color_model()) ) { + unsigned char **out_rows = out_frame->get_rows(); + int w = out_frame->get_w(), h = out_frame->get_h(); + if( BC_CModels::has_alpha(get_temp()->get_color_model()) ) { + unsigned char **in_rows = get_temp()->get_rows(); + for( int y=0; ytransfer_from(out_frame); + } + return 0; } @@ -362,7 +393,7 @@ void InterpolatePixelsUnit::process_package(LoadPackage *package) int pattern_offset_y = plugin->config.y; int y1 = pkg->y1; int y2 = pkg->y2; - int components = cmodel_components(plugin->get_output()->get_color_model()); + int components = cmodel_components(plugin->out_frame->get_color_model()); float color_matrix[9]; memcpy(color_matrix, server->color_matrix, sizeof(color_matrix)); @@ -376,7 +407,7 @@ void InterpolatePixelsUnit::process_package(LoadPackage *package) float *prev_row = (float*)plugin->get_temp()->get_rows()[i - 1]; float *current_row = (float*)plugin->get_temp()->get_rows()[i]; float *next_row = (float*)plugin->get_temp()->get_rows()[i + 1]; - float *out_row = (float*)plugin->get_output()->get_rows()[i]; + float *out_row = (float*)plugin->out_frame->get_rows()[i]; prev_row += components; current_row += components; @@ -475,6 +506,8 @@ InterpolatePixelsEngine::InterpolatePixelsEngine(InterpolatePixelsMain *plugin) void InterpolatePixelsEngine::init_packages() { + for( int i=0; i<9; ++i ) color_matrix[i] = 0; + for( int i=0; i<3; ++i ) color_matrix[i*3 + i] = 1; char string[BCTEXTLEN]; string[0] = 0; plugin->get_output()->get_params()->get("DCRAW_MATRIX", string); diff --git a/cinelerra-5.0/plugins/interpolate/interpolate.h b/cinelerra-5.0/plugins/interpolate/interpolate.h index b6d02d5a..7671de48 100644 --- a/cinelerra-5.0/plugins/interpolate/interpolate.h +++ b/cinelerra-5.0/plugins/interpolate/interpolate.h @@ -97,6 +97,7 @@ public: int handle_opengl(); InterpolatePixelsEngine *engine; + VFrame *out_temp, *out_frame; };