dynamic keyframes, textbox rework, andrea ffmpeg.opts, perpetual chkpt undo, lv2...
[goodguy/history.git] / cinelerra-5.1 / plugins / timeavg / timeavg.C
index 548876f8fcde4d120ccac2b52db8b4c8dd607074..d32db7efe1eb80c849806a4ac5ab0214f567642c 100644 (file)
@@ -2,29 +2,30 @@
 /*
  * CINELERRA
  * Copyright (C) 1997-2011 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 "clip.h"
+#include "bccolors.h"
 #include "bchash.h"
+#include "clip.h"
 #include "filexml.h"
 #include "keyframe.h"
 #include "language.h"
-#include "cicolors.h"
+#include "bccolors.h"
 #include "timeavg.h"
 #include "timeavgwindow.h"
 #include "transportque.h"
@@ -90,7 +91,7 @@ int TimeAvgConfig::equivalent(TimeAvgConfig *src)
 TimeAvgMain::TimeAvgMain(PluginServer *server)
  : PluginVClient(server)
 {
-       
+
        accumulation = 0;
        history = 0;
        history_size = 0;
@@ -102,7 +103,7 @@ TimeAvgMain::TimeAvgMain(PluginServer *server)
 
 TimeAvgMain::~TimeAvgMain()
 {
-       
+
 
        if(accumulation) delete [] accumulation;
        if(history)
@@ -115,7 +116,7 @@ TimeAvgMain::~TimeAvgMain()
        if(history_valid) delete [] history_valid;
 }
 
-const char* TimeAvgMain::plugin_title() { return _("Time Average"); }
+const char* TimeAvgMain::plugin_title() { return N_("Time Average"); }
 int TimeAvgMain::is_realtime() { return 1; }
 
 
@@ -166,8 +167,8 @@ int TimeAvgMain::process_buffer(VFrame *frame,
 // Allocate accumulation
        if(!accumulation || reset)
        {
-               if(!accumulation) accumulation = new unsigned char[w * 
-                       h * 
+               if(!accumulation) accumulation = new unsigned char[w *
+                       h *
                        BC_CModels::components(color_model) *
                        MAX(sizeof(float), sizeof(int))];
                reset_accum(w, h, color_model);
@@ -214,7 +215,7 @@ int TimeAvgMain::process_buffer(VFrame *frame,
 // Create new frames
                                for( ; i < config.frames; i++)
                                {
-                                       history2[i] = new VFrame(w, h, color_model);
+                                       history2[i] = new VFrame(w, h, color_model, 0);
                                        history_frame2[i] = -0x7fffffff;
                                        history_valid2[i] = 0;
                                }
@@ -231,7 +232,7 @@ int TimeAvgMain::process_buffer(VFrame *frame,
                {
                        history = new VFrame*[config.frames];
                        for(int i = 0; i < config.frames; i++)
-                               history[i] = new VFrame(w, h, color_model);
+                               history[i] = new VFrame(w, h, color_model, 0);
                        history_size = config.frames;
                        history_frame = new int64_t[config.frames];
                        bzero(history_frame, sizeof(int64_t) * config.frames);
@@ -263,7 +264,7 @@ int TimeAvgMain::process_buffer(VFrame *frame,
                                for(int j = 0; j < history_size; j++)
                                {
 // Old frame is equal to a new frame
-                                       if(history_frame[i] == new_history_frames[j]) 
+                                       if(history_frame[i] == new_history_frames[j])
                                        {
                                                got_it = 1;
                                                break;
@@ -371,7 +372,7 @@ int TimeAvgMain::process_buffer(VFrame *frame,
                        reset_accum(w, h, color_model);
                }
 
-// printf("TimeAvgMain::process_buffer %d prev_frame=%jd start_position=%jd\n", 
+// printf("TimeAvgMain::process_buffer %d prev_frame=%jd start_position=%jd\n",
 //   __LINE__, prev_frame, start_position);
                for(int64_t i = prev_frame; i <= start_position; i++)
                {
@@ -381,7 +382,7 @@ int TimeAvgMain::process_buffer(VFrame *frame,
                                frame_rate,
                                0);
                        add_accum(frame);
-printf("TimeAvgMain::process_buffer %d prev_frame=%jd start_position=%jd i=%jd\n", 
+printf("TimeAvgMain::process_buffer %d prev_frame=%jd start_position=%jd i=%jd\n",
   __LINE__, prev_frame, start_position, i);
                }
 
@@ -498,8 +499,7 @@ void TimeAvgMain::reset_accum(int w, int h, int color_model)
        }
 }
 
-#define RGB_TO_VALUE(r, g, b) \
-((r) * R_TO_Y + (g) * G_TO_Y + (b) * B_TO_Y)
+#define RGB_TO_VALUE(r, g, b) YUV::yuv.rgb_to_y_f((r),(g),(b))
 
 // Only AVERAGE and ACCUMULATE use this
 #define SUBTRACT_ACCUM(type, \
@@ -1026,7 +1026,7 @@ void TimeAvgMain::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("TIME_AVERAGE");
        output.tag.set_property("FRAMES", config.frames);
        output.tag.set_property("MODE", config.mode);
@@ -1045,7 +1045,7 @@ void TimeAvgMain::read_data(KeyFrame *keyframe)
 {
        FileXML input;
 
-       input.set_shared_input(keyframe->get_data(), strlen(keyframe->get_data()));
+       input.set_shared_input(keyframe->xbuf);
 
        while(!input.read_tag())
        {
@@ -1064,7 +1064,7 @@ void TimeAvgMain::read_data(KeyFrame *keyframe)
 
 void TimeAvgMain::update_gui()
 {
-       if(thread) 
+       if(thread)
        {
                if(load_configuration())
                {