repair default keyframe load, tweak init default histogram threshold
[goodguy/history.git] / cinelerra-5.1 / plugins / histogram_bezier / bistogram.C
index 9e34e016ddca680cde72e400dab9bf5225f9a83a..1f786f957d287155156f4e26ca15037807846bfc 100644 (file)
@@ -2,21 +2,21 @@
 /*
  * 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 <math.h>
@@ -35,7 +35,7 @@
 #include "keyframe.h"
 #include "language.h"
 #include "loadbalance.h"
-#include "cicolors.h"
+#include "bccolors.h"
 #include "vframe.h"
 
 
@@ -49,7 +49,7 @@ REGISTER_PLUGIN(HistogramMain)
 HistogramMain::HistogramMain(PluginServer *server)
  : PluginVClient(server)
 {
-       
+
        engine = 0;
        for(int i = 0; i < HISTOGRAM_MODES; i++)
        {
@@ -67,7 +67,7 @@ HistogramMain::HistogramMain(PluginServer *server)
 
 HistogramMain::~HistogramMain()
 {
-       
+
        for(int i = 0; i < HISTOGRAM_MODES;i++)
        {
                delete [] lookup[i];
@@ -78,7 +78,7 @@ HistogramMain::~HistogramMain()
        delete engine;
 }
 
-const char* HistogramMain::plugin_title() { return _("Histogram Bezier"); }
+const char* HistogramMain::plugin_title() { return N_("Histogram Bezier"); }
 int HistogramMain::is_realtime() { return 1; }
 
 
@@ -109,21 +109,16 @@ void HistogramMain::render_gui(void *data)
 
 void HistogramMain::update_gui()
 {
-       if(thread)
-       {
-               thread->window->lock_window("HistogramMain::update_gui");
-               int reconfigure = load_configuration();
-               if(reconfigure) 
-               {
-                       HistogramWindow *window = (HistogramWindow *)thread->window;
-                       window->update(0);
-                       if(!config.automatic)
-                       {
-                               window->update_input();
-                       }
-               }
-               thread->window->unlock_window();
+       if( !thread ) return;
+       HistogramWindow *window = (HistogramWindow *)thread->window;
+// points delete in load_configuration,read_data
+       window->lock_window("HistogramMain::update_gui");
+       if( load_configuration() ) {
+               window->update(0);
+               if(!config.automatic)
+                       window->update_input();
        }
+       window->unlock_window();
 }
 
 
@@ -132,7 +127,7 @@ void HistogramMain::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("HISTOGRAM");
 
        char string[BCTEXTLEN];
@@ -201,7 +196,7 @@ void HistogramMain::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;
        int current_input_mode = 0;
@@ -235,7 +230,7 @@ void HistogramMain::read_data(KeyFrame *keyframe)
                                if(current_input_mode < HISTOGRAM_MODES)
                                {
                                        HistogramPoints *points = &config.points[current_input_mode];
-                                       while(points->last) 
+                                       while(points->last)
                                                delete points->last;
                                        while(!result)
                                        {
@@ -252,9 +247,9 @@ void HistogramMain::read_data(KeyFrame *keyframe)
                                                                points->insert(
                                                                        input.tag.get_property("X", 0.0),
                                                                        input.tag.get_property("Y", 0.0));
-                                                               points->last->gradient = 
+                                                               points->last->gradient =
                                                                        input.tag.get_property("GRADIENT", 1.0);
-                                                               points->last->xoffset_left = 
+                                                               points->last->xoffset_left =
                                                                        input.tag.get_property("XOFFSET_LEFT", -0.02);
                                                                points->last->xoffset_right =
                                                                        input.tag.get_property("XOFFSET_RIGHT", 0.02);
@@ -272,7 +267,7 @@ void HistogramMain::read_data(KeyFrame *keyframe)
 
 }
 
-float HistogramMain::calculate_linear(float input, 
+float HistogramMain::calculate_linear(float input,
        int subscript,
        int use_value)
 {
@@ -332,7 +327,7 @@ float HistogramMain::calculate_linear(float input,
 
 
                if(!EQUIV(x2 - x1, 0))
-               {       
+               {
                  if (config.smoothMode == HISTOGRAM_LINEAR)
                        output = (input - x1) * (y2 - y1) / (x2 - x1) + y1;
                  else if (config.smoothMode == HISTOGRAM_POLYNOMINAL)
@@ -554,13 +549,13 @@ void HistogramMain::tabulate_curve(int subscript, int use_value)
                        case BC_RGB888:
                        case BC_RGBA8888:
                                for(i = 0; i < 0x100; i++)
-                                       lookup[subscript][i] = 
+                                       lookup[subscript][i] =
                                                (int)(calculate_smooth((float)i / 0xff, subscript) * 0xff);
                                break;
 // All other integer colormodels are converted to 16 bit RGB
                        default:
                                for(i = 0; i < 0x10000; i++)
-                                       lookup[subscript][i] = 
+                                       lookup[subscript][i] =
                                                (int)(calculate_smooth((float)i / 0xffff, subscript) * 0xffff);
                                break;
                }
@@ -572,7 +567,7 @@ HistogramPackage::HistogramPackage()
 {
 }
 
-HistogramUnit::HistogramUnit(HistogramEngine *server, 
+HistogramUnit::HistogramUnit(HistogramEngine *server,
        HistogramMain *plugin)
  : LoadClient(server)
 {
@@ -654,7 +649,7 @@ void HistogramUnit::process_package(LoadPackage *package)
                                y = (row[0] << 8) | row[0];
                                u = (row[1] << 8) | row[1];
                                v = (row[2] << 8) | row[2];
-                               plugin->yuv.yuv_to_rgb_16(r, g, b, y, u, v);
+                               YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);
                                HISTOGRAM_TAIL(3)
                                break;
                        case BC_RGBA8888:
@@ -676,7 +671,7 @@ void HistogramUnit::process_package(LoadPackage *package)
                                y = (row[0] << 8) | row[0];
                                u = (row[1] << 8) | row[1];
                                v = (row[2] << 8) | row[2];
-                               plugin->yuv.yuv_to_rgb_16(r, g, b, y, u, v);
+                               YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);
                                HISTOGRAM_TAIL(4)
                                break;
                        case BC_RGB161616:
@@ -691,7 +686,7 @@ void HistogramUnit::process_package(LoadPackage *package)
                                y = row[0];
                                u = row[1];
                                v = row[2];
-                               plugin->yuv.yuv_to_rgb_16(r, g, b, y, u, v);
+                               YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);
                                HISTOGRAM_TAIL(3)
                                break;
                        case BC_RGBA16161616:
@@ -706,7 +701,7 @@ void HistogramUnit::process_package(LoadPackage *package)
                                y = row[0];
                                u = row[1];
                                v = row[2];
-                               plugin->yuv.yuv_to_rgb_16(r, g, b, y, u, v);
+                               YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);
                                HISTOGRAM_TAIL(4)
                                break;
                }
@@ -757,7 +752,7 @@ void HistogramUnit::process_package(LoadPackage *package)
                                v = row[2]; \
                        } \
  \
-                       plugin->yuv.yuv_to_rgb_16(r, g, b, y, u, v); \
+                       YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v); \
  \
 /* Look up in RGB domain */ \
                        r = lookup_r[r]; \
@@ -765,7 +760,7 @@ void HistogramUnit::process_package(LoadPackage *package)
                        b = lookup_b[b]; \
  \
 /* Convert to 16 bit YUV */ \
-                       plugin->yuv.rgb_to_yuv_16(r, g, b, y, u, v); \
+                       YUV::yuv.rgb_to_yuv_16(r, g, b, y, u, v); \
  \
                        if(max == 0xff) \
                        { \
@@ -859,8 +854,8 @@ void HistogramUnit::process_package(LoadPackage *package)
 
 
 
-HistogramEngine::HistogramEngine(HistogramMain *plugin, 
-       int total_clients, 
+HistogramEngine::HistogramEngine(HistogramMain *plugin,
+       int total_clients,
        int total_packages)
  : LoadServer(total_clients, total_packages)
 {