From: Good Guy Date: Sat, 19 Sep 2020 23:08:39 +0000 (-0600) Subject: add histogram frame averaging, lock renderengine during updates, fix ffmpeg btn booby X-Git-Tag: 2020-09~5 X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=0b751b07a28e84a721b2bb76083db6629aa26d73;p=goodguy%2Fcinelerra.git add histogram frame averaging, lock renderengine during updates, fix ffmpeg btn booby --- diff --git a/cinelerra-5.1/cinelerra/playbackengine.C b/cinelerra-5.1/cinelerra/playbackengine.C index 571afe2a..3b2b9ed4 100644 --- a/cinelerra-5.1/cinelerra/playbackengine.C +++ b/cinelerra-5.1/cinelerra/playbackengine.C @@ -84,8 +84,8 @@ PlaybackEngine::~PlaybackEngine() done = 1; output_lock->unlock(); Thread::join(); - delete preferences; delete_render_engine(); + delete preferences; if( audio_cache ) audio_cache->remove_user(); if( video_cache ) @@ -147,14 +147,18 @@ void PlaybackEngine::delete_render_engine() void PlaybackEngine::arm_render_engine() { + renderengine_lock->lock("PlaybackEngine::arm_render_engine"); if( render_engine ) render_engine->arm_command(command); + renderengine_lock->unlock(); } void PlaybackEngine::start_render_engine() { + renderengine_lock->lock("PlaybackEngine::start_render_engine"); if( render_engine ) render_engine->start_command(); + renderengine_lock->unlock(); } void PlaybackEngine::wait_render_engine() @@ -180,14 +184,21 @@ void PlaybackEngine::create_cache() void PlaybackEngine::perform_change() { switch( command->change_type ) { - case CHANGE_ALL: - create_cache(); - case CHANGE_EDL: - create_render_engine(); - break; - case CHANGE_PARAMS: - render_engine->get_edl()->synchronize_params(command->get_edl()); - case CHANGE_NONE: + case CHANGE_ALL: + create_cache(); + case CHANGE_EDL: + create_render_engine(); + break; + case CHANGE_PARAMS: { + renderengine_lock->lock("PlaybackEngine::perform_change"); + EDL *edl = render_engine ? render_engine->get_edl() : 0; + if( edl ) edl->add_user(); + renderengine_lock->unlock(); + if( !edl ) break; + edl->synchronize_params(command->get_edl()); + edl->remove_user(); + } + case CHANGE_NONE: break; } } diff --git a/cinelerra-5.1/cinelerra/preferencesthread.C b/cinelerra-5.1/cinelerra/preferencesthread.C index 47f16efd..75d8fe81 100644 --- a/cinelerra-5.1/cinelerra/preferencesthread.C +++ b/cinelerra-5.1/cinelerra/preferencesthread.C @@ -278,9 +278,11 @@ int PreferencesThread::apply_settings() mwindow->reset_android_remote(); int ffmpeg_early_probe = mwindow->preferences->get_file_probe_armed("FFMPEG_Early"); + mwindow->gui->lock_window("PreferencesThread::apply_settings 6"); mwindow->gui->ffmpeg_toggle->update(ffmpeg_early_probe); mwindow->gui->ffmpeg_toggle->set_tooltip(ffmpeg_early_probe ? FFMPEG_EARLY_TIP : FFMPEG_LATE_TIP); + mwindow->gui->unlock_window(); mwindow->gui->mainshbtns->load(mwindow->preferences); mwindow->init_brender(); diff --git a/cinelerra-5.1/plugins/histogram/histogram.C b/cinelerra-5.1/plugins/histogram/histogram.C index f16e3fd4..ef886305 100644 --- a/cinelerra-5.1/plugins/histogram/histogram.C +++ b/cinelerra-5.1/plugins/histogram/histogram.C @@ -25,9 +25,11 @@ #include #include "bcdisplayinfo.h" +#include "bchash.h" +#include "bcprogressbox.h" #include "bcsignals.h" #include "clip.h" -#include "bchash.h" +#include "edl.h" #include "filexml.h" #include "histogram.h" #include "histogramconfig.h" @@ -35,7 +37,11 @@ #include "keyframe.h" #include "language.h" #include "loadbalance.h" +#include "localsession.h" +#include "mainsession.h" +#include "mwindow.h" #include "playback3d.h" +#include "pluginserver.h" #include "bccolors.h" #include "vframe.h" #include "workarounds.h" @@ -68,6 +74,7 @@ HistogramMain::HistogramMain(PluginServer *server) { engine = 0; + stripe_engine = 0; for(int i = 0; i < HISTOGRAM_MODES; i++) { lookup[i] = 0; @@ -82,6 +89,9 @@ HistogramMain::HistogramMain(PluginServer *server) w = 440; h = 500; parade = 0; + fframe = 0; + last_frames = 0; + last_position = -1; } HistogramMain::~HistogramMain() @@ -94,6 +104,8 @@ HistogramMain::~HistogramMain() delete [] preview_lookup[i]; } delete engine; + delete stripe_engine; + delete fframe; } const char* HistogramMain::plugin_title() { return N_("Histogram"); } @@ -187,6 +199,8 @@ void HistogramMain::save_data(KeyFrame *keyframe) output.tag.set_property("THRESHOLD", config.threshold); output.tag.set_property("PLOT", config.plot); output.tag.set_property("SPLIT", config.split); + output.tag.set_property("FRAMES", config.frames); + output.tag.set_property("LOG_SLIDER", config.log_slider); output.tag.set_property("W", w); output.tag.set_property("H", h); output.tag.set_property("PARADE", parade); @@ -235,6 +249,8 @@ void HistogramMain::read_data(KeyFrame *keyframe) config.threshold = input.tag.get_property("THRESHOLD", config.threshold); config.plot = input.tag.get_property("PLOT", config.plot); config.split = input.tag.get_property("SPLIT", config.split); + config.frames = input.tag.get_property("FRAMES", config.frames); + config.log_slider = input.tag.get_property("LOG_SLIDER", config.log_slider); if(is_defaults()) { @@ -434,27 +450,84 @@ int HistogramMain::process_buffer(VFrame *frame, double frame_rate) { int need_reconfigure = load_configuration(); - - - int use_opengl = calculate_use_opengl(); -//printf("%d\n", use_opengl); - read_frame(frame, - 0, - start_position, - frame_rate, - use_opengl); - this->input = frame; this->output = frame; - if( !engine ) - { - int cpus = input->get_w() * input->get_h() / 0x80000 + 2; - int smps = get_project_smp(); - if( cpus > smps ) cpus = smps; + int cpus = input->get_w() * input->get_h() / 0x80000 + 2; + int smps = get_project_smp(); + if( cpus > smps ) cpus = smps; + if( !engine ) { engine = new HistogramEngine(this, cpus, cpus); } + int frames = config.frames; + MWindow *mwindow = server->mwindow; + if( frames > 1 && (!mwindow || // dont scan during SELECT_REGION + mwindow->session->current_operation != SELECT_REGION || + mwindow->edl->local_session->get_selectionstart() == + mwindow->edl->local_session->get_selectionend() ) ) { + if( !stripe_engine ) + stripe_engine = new HistStripeEngine(this, cpus, cpus); + int fw = frame->get_w(), fh =frame->get_h(); + new_temp(fw, fh, BC_RGB_FLOAT); + MWindow *mwindow = server->mwindow; + if( (mwindow && mwindow->session->current_operation == SELECT_REGION) || + ( last_frames == frames && last_position-1 == start_position && + fframe && fframe->get_w() == fw && fframe->get_h() == fh ) ) { + read_frame(temp, 0, start_position, frame_rate, use_opengl); + stripe_engine->process_packages(ADD_FFRM); + frame->transfer_from(temp); + } + else if( last_frames != frames || last_position != start_position || + !fframe || fframe->get_w() != fw || fframe->get_h() != fh ) { + last_frames = frames; + last_position = start_position; + VFrame::get_temp(fframe, fw, fh, BC_RGB_FLOAT); + read_frame(fframe, 0, start_position+1, frame_rate, use_opengl); + BC_ProgressBox *progress = 0; + const char *progress_title = _("Histogram: scanning\n"); + Timer timer; + for( int i=2; iprocess_packages(ADD_TEMP); + if( !progress && gui_open() && frames > 2*frame_rate ) { + progress = new BC_ProgressBox(-1, -1, progress_title, frames); + progress->start(); + } + if( progress && timer.get_difference() > 100 ) { + timer.update(); + progress->update(i, 1); + char string[BCTEXTLEN]; + sprintf(string, "%sframe: %d", progress_title, i); + progress->update_title(string, 1); + if( progress->is_cancelled() ) break; + } + if( progress && !gui_open() ) { + progress->stop_progress(); + delete progress; progress = 0; + } + } + read_frame(temp, 0, start_position, frame_rate, use_opengl); + stripe_engine->process_packages(ADD_FFRMS); + frame->transfer_from(temp); + if( progress ) { + progress->stop_progress(); + delete progress; + } + ++last_position; + } + else { + read_frame(temp, 0, start_position+frames-1, frame_rate, use_opengl); + stripe_engine->process_packages(ADD_TEMPS); + frame->transfer_from(fframe); + read_frame(temp, 0, start_position, frame_rate, use_opengl); + stripe_engine->process_packages(SUB_TEMPS); + ++last_position; + } + } + else + read_frame(frame, 0, start_position, frame_rate, use_opengl); + // if to plot histogram if(config.plot) send_render_gui(frame); @@ -814,13 +887,118 @@ int HistogramMain::handle_opengl() } +HistStripePackage::HistStripePackage() + : LoadPackage() +{ +} +HistStripeUnit::HistStripeUnit(HistStripeEngine *server, HistogramMain *plugin) + : LoadClient(server) +{ + this->plugin = plugin; + this->server = server; +} +void HistStripeUnit::process_package(LoadPackage *package) +{ + HistStripePackage *pkg = (HistStripePackage*)package; + int frames = plugin->config.frames; + float scale = 1. / frames; + int iy0 = pkg->y0, iy1 = pkg->y1; + int fw = plugin->fframe->get_w(); + uint8_t **frows = plugin->fframe->get_rows(); + uint8_t **trows = plugin->temp->get_rows(); + switch( server->operation ) { + case ADD_TEMP: // add temp to fframe + for( int iy=iy0; iyplugin = plugin; +} +void HistStripeEngine::init_packages() +{ + int ih = plugin->input->get_h(), iy0 = 0; + for( int i=0,n=get_total_packages(); iy0 = iy0; pkg->y1 = iy1; + iy0 = iy1; + } +} +LoadClient* HistStripeEngine::new_client() +{ + return new HistStripeUnit(this, plugin); +} +LoadPackage* HistStripeEngine::new_package() +{ + return new HistStripePackage(); +} - +void HistStripeEngine::process_packages(int operation) +{ + this->operation = operation; + LoadServer::process_packages(); +} @@ -829,9 +1007,6 @@ HistogramPackage::HistogramPackage() { } - - - HistogramUnit::HistogramUnit(HistogramEngine *server, HistogramMain *plugin) : LoadClient(server) diff --git a/cinelerra-5.1/plugins/histogram/histogram.h b/cinelerra-5.1/plugins/histogram/histogram.h index 6a5d527b..9aa4747a 100644 --- a/cinelerra-5.1/plugins/histogram/histogram.h +++ b/cinelerra-5.1/plugins/histogram/histogram.h @@ -67,6 +67,8 @@ public: VFrame *input, *output; HistogramEngine *engine; + HistStripeEngine *stripe_engine; + int *lookup[HISTOGRAM_MODES]; // No value applied to this int *preview_lookup[HISTOGRAM_MODES]; @@ -80,8 +82,42 @@ public: int point_y_offset; int w, h; int parade; + VFrame *fframe; + int64_t last_position; + int last_frames; +}; + +enum { ADD_TEMP, ADD_FFRM, ADD_FFRMS, ADD_TEMPS, SUB_TEMPS }; + +class HistStripePackage : public LoadPackage +{ +public: + HistStripePackage(); + int y0, y1; +}; + +class HistStripeUnit : public LoadClient +{ +public: + HistStripeUnit(HistStripeEngine *server, HistogramMain *plugin); + void process_package(LoadPackage *package); + HistStripeEngine *server; + HistogramMain *plugin; +}; + +class HistStripeEngine : public LoadServer +{ +public: + HistStripeEngine(HistogramMain *plugin, int total_clients, int total_packages); + void process_packages(int operation); + void init_packages(); + LoadClient *new_client(); + LoadPackage *new_package(); + HistogramMain *plugin; + int operation; }; + class HistogramPackage : public LoadPackage { public: diff --git a/cinelerra-5.1/plugins/histogram/histogram.inc b/cinelerra-5.1/plugins/histogram/histogram.inc index 581200ef..0608165d 100644 --- a/cinelerra-5.1/plugins/histogram/histogram.inc +++ b/cinelerra-5.1/plugins/histogram/histogram.inc @@ -54,8 +54,13 @@ #define BOX_SIZE 10 -class HistogramEngine; class HistogramMain; +class HistStripePackage; +class HistStripeUnit; +class HistStripeEngine; +class HistogramPackage; +class HistogramUnit; +class HistogramEngine; #endif diff --git a/cinelerra-5.1/plugins/histogram/histogramconfig.C b/cinelerra-5.1/plugins/histogram/histogramconfig.C index 7203063f..fc138ba7 100644 --- a/cinelerra-5.1/plugins/histogram/histogramconfig.C +++ b/cinelerra-5.1/plugins/histogram/histogramconfig.C @@ -52,6 +52,9 @@ void HistogramConfig::reset(int do_mode) automatic_v = 0; threshold = 1.0; } + + frames = 0; + log_slider = .5; } void HistogramConfig::reset_points(int colors_only) @@ -80,6 +83,8 @@ void HistogramConfig::boundaries() high_output[i] = Units::quantize(high_output[i], PRECISION); } CLAMP(threshold, 0, 1); + CLAMP(log_slider, 0, 1); + CLAMP(frames, 0, 65535); } int HistogramConfig::equivalent(HistogramConfig &that) @@ -104,7 +109,9 @@ int HistogramConfig::equivalent(HistogramConfig &that) threshold != that.threshold) return 0; if(plot != that.plot || - split != that.split) return 0; + split != that.split || + frames != that.frames || + log_slider != that.log_slider ) return 0; return 1; } @@ -125,6 +132,8 @@ void HistogramConfig::copy_from(HistogramConfig &that) threshold = that.threshold; plot = that.plot; split = that.split; + frames = that.frames; + log_slider = that.log_slider; } void HistogramConfig::interpolate(HistogramConfig &prev, @@ -150,8 +159,8 @@ void HistogramConfig::interpolate(HistogramConfig &prev, automatic_v = prev.automatic_v; plot = prev.plot; split = prev.split; - - + frames = prev.frames; + log_slider = prev.log_slider; } @@ -159,7 +168,7 @@ void HistogramConfig::dump() { for(int j = 0; j < HISTOGRAM_MODES; j++) { - printf("HistogramConfig::dump mode=%d plot=%d split=%d\n", j, plot, split); + printf("HistogramConfig::dump mode=%d plot=%d split=%d frames=%d\n", j, plot, split, frames); } } diff --git a/cinelerra-5.1/plugins/histogram/histogramconfig.h b/cinelerra-5.1/plugins/histogram/histogramconfig.h index ab9f55f5..38f9982f 100644 --- a/cinelerra-5.1/plugins/histogram/histogramconfig.h +++ b/cinelerra-5.1/plugins/histogram/histogramconfig.h @@ -61,6 +61,8 @@ public: float threshold; int plot; int split; + int frames; + float log_slider; }; diff --git a/cinelerra-5.1/plugins/histogram/histogramwindow.C b/cinelerra-5.1/plugins/histogram/histogramwindow.C index 3a2e6cf2..cb50652d 100644 --- a/cinelerra-5.1/plugins/histogram/histogramwindow.C +++ b/cinelerra-5.1/plugins/histogram/histogramwindow.C @@ -22,11 +22,15 @@ #include "bcdisplayinfo.h" #include "bcsignals.h" #include "cursors.h" +#include "edl.h" #include "histogram.h" #include "histogramconfig.h" #include "histogramwindow.h" #include "keys.h" #include "language.h" +#include "localsession.h" +#include "mwindow.h" +#include "pluginserver.h" #include "theme.h" #include @@ -199,10 +203,20 @@ void HistogramWindow::create_objects() low_output_carrot->get_w() / 2, y)); y += high_output_carrot->get_h() + margin; + // add_subwindow(title = new BC_Title(x, y, _("Output:"))); // x += title->get_w() + margin; low_output = new HistogramText(plugin, this, x, y); low_output->create_objects(); + + const char *linear_text = _("Linear"); + int xs = get_w()/2 - xS(50); + x = xs - BC_Title::calculate_w(this, linear_text) - margin; + add_subwindow(log_title1 = new BC_Title(x, y, linear_text)); + add_subwindow(log_slider = new HistogramLogSlider(plugin, this, xs, y)); + xs += log_slider->get_w() + margin; + add_subwindow(log_title2 = new BC_Title(xs, y, _("Log"))); + high_output = new HistogramText(plugin, this, get_w() - low_output->get_w() - margin, y); high_output->create_objects(); @@ -214,24 +228,25 @@ void HistogramWindow::create_objects() y += bar->get_h() + margin; add_subwindow(automatic = new HistogramAuto(plugin, x, y)); - - //int y1 = y; - x = xS(200); - add_subwindow(threshold_title = new BC_Title(x, y, _("Threshold:"))); - x += threshold_title->get_w() + margin; - threshold = new HistogramText(plugin, this, x, y); + int x2 = xS(190); + add_subwindow(threshold_title = new BC_Title(x2, y, _("Threshold:"))); + int x3 = xS(305); + threshold = new HistogramText(plugin, this, x3, y); threshold->create_objects(); + y += automatic->get_h() + margin; - x = get_w() / 2; - add_subwindow(reset = new HistogramReset(plugin, - x, y + threshold->get_h() + margin)); + add_subwindow(plot = new HistogramPlot(plugin, x1, y)); + add_subwindow(select = new HistogramSelect(plugin, this, x2, y)); + frames = new HistogramFrames(plugin, this, x3, y); + frames->create_objects(); + x = x3 + frames->get_w() + margin; + add_subwindow(clear_frames = new HistogramClearFrames(plugin, this, x, y)); + y += plot->get_h() + margin; x = x1; - y += automatic->get_h() + margin; - add_subwindow(plot = new HistogramPlot(plugin, x, y)); - - y += plot->get_h() + yS(5); add_subwindow(split = new HistogramSplit(plugin, x, y)); + x = xS(340); + add_subwindow(reset = new HistogramReset(plugin, x, y + yS(5))); update(1, 1, 1, 1); @@ -308,6 +323,14 @@ int HistogramWindow::resize_event(int w, int h) low_output->reposition_window(low_output->get_x(), low_output->get_y() + ydiff); + int xs = (get_w() - log_slider->get_w()) / 2; + int margin = plugin->get_theme()->widget_border; + log_title1->reposition_window(xs - log_title1->get_w() - margin, + log_title1->get_y() + ydiff); + log_slider->reposition_window(xs, + log_slider->get_y() + ydiff); + log_title2->reposition_window(xs + log_slider->get_w() + margin, + log_title2->get_y() + ydiff); high_output->reposition_window(high_output->get_x() + xdiff, high_output->get_y() + ydiff); @@ -321,13 +344,20 @@ int HistogramWindow::resize_event(int w, int h) threshold_title->get_y() + ydiff); threshold->reposition_window(threshold->get_x(), threshold->get_y() + ydiff); - reset->reposition_window(reset->get_x(), - reset->get_y() + ydiff); - plot->reposition_window(plot->get_x(), plot->get_y() + ydiff); + split->reposition_window(split->get_x(), split->get_y() + ydiff); + reset->reposition_window(reset->get_x(), + reset->get_y() + ydiff); + + frames->reposition_window(frames->get_x(), + frames->get_y() + ydiff); + select->reposition_window(select->get_x(), + select->get_y() + ydiff); + clear_frames->reposition_window(clear_frames->get_x(), + clear_frames->get_y() + ydiff); update(1, 1, 1, 1); @@ -388,8 +418,10 @@ void HistogramWindow::update(int do_canvases, mode_b->update(plugin->mode == HISTOGRAM_BLUE ? 1 : 0); plot->update(plugin->config.plot); split->update(plugin->config.split); + frames->update(plugin->config.frames); parade_on->update(plugin->parade ? 1 : 0); parade_off->update(plugin->parade ? 0 : 1); + log_slider->update(plugin->config.log_slider); output->update(); } @@ -423,43 +455,36 @@ void HistogramWindow::update(int do_canvases, void HistogramWindow::draw_canvas_mode(int mode, int color, int y, int h) { - int *accum = plugin->accum[mode]; - int accum_per_canvas_i = HISTOGRAM_SLOTS / canvas_w + 1; - float accum_per_canvas_f = (float)HISTOGRAM_SLOTS / canvas_w; - int normalize = 0; - int max = 0; - - // Draw histogram - for(int i = 0; i < HISTOGRAM_SLOTS; i++) - { - if(accum && accum[i] > normalize) normalize = accum[i]; + int max = 0, *accum = plugin->accum[mode]; + if( accum ) { + for( int i=0; i 0 ) { + double log_slider = plugin->config.log_slider; + double lin_slider = 1. - log_slider; + double lin_scale = (lin_slider * h) / max; + double log_scale = (log_slider * h) / log(max); + for( int i=0,x=0; xset_color(BLACK); - canvas->draw_line(i, y, i, y + h - max); + canvas->draw_line(x, y, x, y+h - m); canvas->set_color(color); - canvas->draw_line(i, y + h - max, i, y + h); + canvas->draw_line(x, y+h - m, x, y+h); } } - else - { + else { canvas->set_color(BLACK); canvas->draw_box(0, y, canvas_w, h); } @@ -470,26 +495,16 @@ void HistogramWindow::draw_canvas_mode(int mode, int color, int y, int h) int y1 = 0; // Draw output line - for(int i = 0; i < canvas_w; i++) - { - float input = (float)i / - canvas_w * - FLOAT_RANGE + - HIST_MIN_INPUT; - float output = plugin->calculate_level(input, - mode, - 0); - + for( int x=0; xcalculate_level(input, mode, 0); int y2 = h - (int)(output * h); - if(i > 0) - { - canvas->draw_line(i - 1, y + y1, i, y + y2); - } + if( x > 0 ) + canvas->draw_line(x-1, y+y1, x, y+y2); y1 = y2; } canvas->set_line_width(1); - } @@ -606,21 +621,7 @@ int HistogramCanvas::button_release_event() } - - - - - - - - - - - - -HistogramReset::HistogramReset(HistogramMain *plugin, - int x, - int y) +HistogramReset::HistogramReset(HistogramMain *plugin, int x, int y) : BC_GenericButton(x, y, _("Reset")) { this->plugin = plugin; @@ -634,19 +635,66 @@ int HistogramReset::handle_event() } +HistogramSelect::HistogramSelect(HistogramMain *plugin, HistogramWindow *gui, + int x, int y) + : BC_GenericButton(x, y, xS(100), _("Frames")) +{ + this->plugin = plugin; + this->gui = gui; + set_tooltip(_("Set frames to selection duration")); +} +int HistogramSelect::handle_event() +{ + MWindow *mwindow = plugin->server->mwindow; + if( mwindow ) { + EDL *edl = mwindow->edl; + double start = edl->local_session->get_selectionstart(); + int64_t start_pos = edl->get_frame_rate() * start; + double end = edl->local_session->get_selectionend(); + int64_t end_pos = edl->get_frame_rate() * end; + int64_t frames = end_pos - start_pos; + gui->frames->update(frames); + plugin->config.frames = frames; + plugin->send_configure_change(); + } + return 1; +} +HistogramClearFrames::HistogramClearFrames(HistogramMain *plugin, HistogramWindow *gui, + int x, int y) + : BC_Button(x, y, plugin->get_theme()->get_image_set("reset_button")) +{ + this->plugin = plugin; + this->gui = gui; + set_tooltip(_("Clear frames")); +} +int HistogramClearFrames::handle_event() +{ + plugin->config.frames = 0; + gui->frames->update(0); + plugin->send_configure_change(); + return 1; +} +HistogramLogSlider::HistogramLogSlider(HistogramMain *plugin, HistogramWindow *gui, + int x, int y) +: BC_FSlider(x, y, 0, xS(100), xS(100), 0., 1., plugin->config.log_slider) +{ + this->plugin = plugin; + this->gui = gui; +} -HistogramCarrot::HistogramCarrot(HistogramMain *plugin, - HistogramWindow *gui, - int x, - int y) - : BC_Toggle(x, - y, - plugin->get_theme()->get_image_set("histogram_carrot"), - 0) +int HistogramLogSlider::handle_event() +{ + plugin->config.log_slider = get_value(); + plugin->send_configure_change(); + return 1; +} + +HistogramCarrot::HistogramCarrot(HistogramMain *plugin, HistogramWindow *gui, int x, int y) + : BC_Toggle(x, y, plugin->get_theme()->get_image_set("histogram_carrot"), 0) { this->plugin = plugin; this->gui = gui; @@ -659,30 +707,16 @@ HistogramCarrot::~HistogramCarrot() float* HistogramCarrot::get_value() { - if(this == gui->low_input_carrot) - { + if( this == gui->low_input_carrot ) return &plugin->config.low_input[plugin->mode]; - } - else - if(this == gui->high_input_carrot) - { + if( this == gui->high_input_carrot ) return &plugin->config.high_input[plugin->mode]; - } - else - if(this == gui->gamma_carrot) - { + if( this == gui->gamma_carrot ) return &plugin->config.gamma[plugin->mode]; - } - else - if(this == gui->low_output_carrot) - { + if( this == gui->low_output_carrot ) return &plugin->config.low_output[plugin->mode]; - } - else - if(this == gui->high_output_carrot) - { + if( this == gui->high_output_carrot ) return &plugin->config.high_output[plugin->mode]; - } return 0; } @@ -935,7 +969,6 @@ int HistogramSplit::handle_event() } - HistogramMode::HistogramMode(HistogramMain *plugin, int x, int y, @@ -963,17 +996,30 @@ int HistogramMode::handle_event() } +HistogramFrames::HistogramFrames(HistogramMain *plugin, HistogramWindow *gui, + int x, int y) + : BC_TumbleTextBox(gui, 0, 0, 65535, x, y, xS(80)) +{ + this->plugin = plugin; + this->gui = gui; +} +int HistogramFrames::handle_event() +{ + plugin->config.frames = atoi(get_text()); + plugin->send_configure_change(); + return 1; +} - - - - +void HistogramFrames::update(int frames) +{ + BC_TumbleTextBox::update((int64_t)frames); +} HistogramText::HistogramText(HistogramMain *plugin, HistogramWindow *gui, int x, int y, float hist_min, float hist_max) - : BC_TumbleTextBox(gui, 0.0, hist_min, hist_max, x, y, xS(70)) + : BC_TumbleTextBox(gui, 0.0, hist_min, hist_max, x, y, xS(80)) { this->plugin = plugin; this->gui = gui; @@ -983,46 +1029,26 @@ HistogramText::HistogramText(HistogramMain *plugin, float* HistogramText::get_value() { - if(this == gui->low_input) - { + if( this == gui->low_input ) return &plugin->config.low_input[plugin->mode]; - } - else - if(this == gui->high_input) - { + if( this == gui->high_input ) return &plugin->config.high_input[plugin->mode]; - } - else - if(this == gui->gamma) - { + if( this == gui->gamma ) return &plugin->config.gamma[plugin->mode]; - } - else - if(this == gui->low_output) - { + if( this == gui->low_output ) return &plugin->config.low_output[plugin->mode]; - } - else - if(this == gui->high_output) - { + if( this == gui->high_output ) return &plugin->config.high_output[plugin->mode]; - } - else - if(this == gui->threshold) - { + if( this == gui->threshold ) return &plugin->config.threshold; - } - return 0; } int HistogramText::handle_event() { float *output = get_value(); - if(output) - { + if( output ) *output = atof(get_text()); - } gui->update(1, 1, 0, 0); plugin->send_configure_change(); @@ -1032,23 +1058,7 @@ int HistogramText::handle_event() void HistogramText::update() { float *output = get_value(); - if(output) - { + if( output ) BC_TumbleTextBox::update(*output); - } } - - - - - - - - - - - - - - diff --git a/cinelerra-5.1/plugins/histogram/histogramwindow.h b/cinelerra-5.1/plugins/histogram/histogramwindow.h index f21363e3..fb2b01e7 100644 --- a/cinelerra-5.1/plugins/histogram/histogramwindow.h +++ b/cinelerra-5.1/plugins/histogram/histogramwindow.h @@ -74,10 +74,7 @@ public: class HistogramCarrot : public BC_Toggle { public: - HistogramCarrot(HistogramMain *plugin, - HistogramWindow *gui, - int x, - int y); + HistogramCarrot(HistogramMain *plugin, HistogramWindow *gui, int x, int y); virtual ~HistogramCarrot(); void update(); @@ -98,9 +95,7 @@ public: class HistogramAuto : public BC_CheckBox { public: - HistogramAuto(HistogramMain *plugin, - int x, - int y); + HistogramAuto(HistogramMain *plugin, int x, int y); int handle_event(); HistogramMain *plugin; }; @@ -108,9 +103,7 @@ public: class HistogramPlot : public BC_CheckBox { public: - HistogramPlot(HistogramMain *plugin, - int x, - int y); + HistogramPlot(HistogramMain *plugin, int x, int y); int handle_event(); HistogramMain *plugin; }; @@ -118,9 +111,7 @@ public: class HistogramSplit : public BC_CheckBox { public: - HistogramSplit(HistogramMain *plugin, - int x, - int y); + HistogramSplit(HistogramMain *plugin, int x, int y); int handle_event(); HistogramMain *plugin; }; @@ -128,10 +119,7 @@ public: class HistogramMode : public BC_Radial { public: - HistogramMode(HistogramMain *plugin, - int x, - int y, - int value, + HistogramMode(HistogramMain *plugin, int x, int y, int value, char *text); int handle_event(); HistogramMain *plugin; @@ -141,11 +129,47 @@ public: class HistogramReset : public BC_GenericButton { public: - HistogramReset(HistogramMain *plugin, - int x, - int y); + HistogramReset(HistogramMain *plugin, int x, int y); + int handle_event(); + HistogramMain *plugin; +}; + +class HistogramSelect : public BC_GenericButton +{ +public: + HistogramSelect(HistogramMain *plugin, HistogramWindow *gui, int x, int y); + int handle_event(); + HistogramMain *plugin; + HistogramWindow *gui; +}; + +class HistogramClearFrames : public BC_Button +{ +public: + HistogramClearFrames(HistogramMain *plugin, HistogramWindow *gui, int x, int y); int handle_event(); HistogramMain *plugin; + HistogramWindow *gui; +}; + +class HistogramLogSlider : public BC_FSlider +{ +public: + HistogramLogSlider(HistogramMain *plugin, HistogramWindow *gui, int x, int y); + int handle_event(); + HistogramMain *plugin; + HistogramWindow *gui; +}; + +class HistogramFrames : public BC_TumbleTextBox +{ +public: + HistogramFrames(HistogramMain *plugin, HistogramWindow *gui, int x, int y); + int handle_event(); + void update(int frames); + + HistogramMain *plugin; + HistogramWindow *gui; }; class HistogramText : public BC_TumbleTextBox @@ -167,12 +191,8 @@ public: class HistogramCanvas : public BC_SubWindow { public: - HistogramCanvas(HistogramMain *plugin, - HistogramWindow *gui, - int x, - int y, - int w, - int h); + HistogramCanvas(HistogramMain *plugin, HistogramWindow *gui, + int x, int y, int w, int h); int button_press_event(); int cursor_motion_event(); int button_release_event(); @@ -187,22 +207,14 @@ public: ~HistogramWindow(); void create_objects(); - void update(int do_canvases, - int do_carrots, - int do_text, - int do_toggles); + void update(int do_canvases, int do_carrots, int do_text, int do_toggles); void draw_canvas_mode(int mode, int color, int y, int h); void update_canvas(); int keypress_event(); int resize_event(int w, int h); void get_point_extents(HistogramPoint *current, - int *x1, - int *y1, - int *x2, - int *y2, - int *x, - int *y); + int *x1, int *y1, int *x2, int *y2, int *x, int *y); HistogramSlider *output; HistogramAuto *automatic; @@ -214,6 +226,7 @@ public: HistogramText *low_input; HistogramText *high_input; HistogramText *gamma; + HistogramFrames *frames; HistogramCanvas *canvas; HistogramCarrot *low_input_carrot; HistogramCarrot *gamma_carrot; @@ -225,6 +238,11 @@ public: BC_Title *canvas_title2; BC_Title *threshold_title; BC_Bar *bar; + HistogramSelect *select; + HistogramClearFrames *clear_frames; + HistogramLogSlider *log_slider; + BC_Title *log_title1; + BC_Title *log_title2; // Value to change with keypresses float *active_value; @@ -239,10 +257,4 @@ public: HistogramSplit *split; }; - - - - - - #endif diff --git a/cinelerra-5.1/plugins/histogram/histogramwindow.inc b/cinelerra-5.1/plugins/histogram/histogramwindow.inc index 095b69aa..35cd2f97 100644 --- a/cinelerra-5.1/plugins/histogram/histogramwindow.inc +++ b/cinelerra-5.1/plugins/histogram/histogramwindow.inc @@ -22,7 +22,19 @@ #ifndef HISTOGRAMWINDOW_INC #define HISTOGRAMWINDOW_INC +class HistogramSlider; +class HistogramParade; +class HistogramCarrot; +class HistogramAuto; +class HistogramPlot; +class HistogramSplit; +class HistogramMode; +class HistogramReset; +class HistogramSelect; +class HistogramLogSlider; +class HistogramFrames; +class HistogramText; +class HistogramCanvas; class HistogramWindow; -class HistogramThread; #endif