X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fhistogram%2Fhistogram.C;h=523c863f3e0bc142c8b372dbde030f44c147a737;hb=6ca0a7892ec6459a54fcb3ba3a223d1ddc5ce402;hp=33091111dbbb05aa5217effc5d425784796c064c;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/plugins/histogram/histogram.C b/cinelerra-5.1/plugins/histogram/histogram.C index 33091111..523c863f 100644 --- a/cinelerra-5.1/plugins/histogram/histogram.C +++ b/cinelerra-5.1/plugins/histogram/histogram.C @@ -280,7 +280,8 @@ float HistogramMain::calculate_level(float input, // Scale to input range if(!EQUIV(config.high_input[mode], config.low_input[mode])) { - output = (input - config.low_input[mode]) / + output = input < config.low_input[mode] ? 0 : + (input - config.low_input[mode]) / (config.high_input[mode] - config.low_input[mode]); } else @@ -321,11 +322,13 @@ float HistogramMain::calculate_level(float input, void HistogramMain::calculate_histogram(VFrame *data, int do_value) { - - if(!engine) engine = new HistogramEngine(this, - get_project_smp() + 1, - get_project_smp() + 1); - + if( !engine ) + { + int cpus = data->get_w() * data->get_h() / 0x80000 + 2; + int smps = get_project_smp(); + if( cpus > smps ) cpus = smps; + engine = new HistogramEngine(this, cpus, cpus); + } if(!accum[0]) { for(int i = 0; i < HISTOGRAM_MODES; i++) @@ -446,13 +449,17 @@ int HistogramMain::process_buffer(VFrame *frame, // Apply histogram in hardware if(use_opengl) return run_opengl(); - if(!engine) engine = new HistogramEngine(this, - get_project_smp() + 1, - get_project_smp() + 1); this->input = frame; this->output = frame; -// Always plot to set the curves if automatic - if(config.plot || config.automatic) send_render_gui(frame); + if( !engine ) + { + int cpus = input->get_w() * input->get_h() / 0x80000 + 2; + int smps = get_project_smp(); + if( cpus > smps ) cpus = smps; + engine = new HistogramEngine(this, cpus, cpus); + } +// if to plot histogram + if(config.plot) send_render_gui(frame); // Generate tables here. The same table is used by many packages to render // each horizontal stripe. Need to cover the entire output range in each