1 #include "bcdisplayinfo.h"
4 #include "freezeframe.h"
12 #define _(String) gettext(String)
13 #define gettext_noop(String) String
14 #define N_(String) gettext_noop (String)
16 REGISTER_PLUGIN(FreezeFrameMain)
22 FreezeFrameConfig::FreezeFrameConfig()
28 void FreezeFrameConfig::copy_from(FreezeFrameConfig &that)
30 enabled = that.enabled;
31 line_double = that.line_double;
34 int FreezeFrameConfig::equivalent(FreezeFrameConfig &that)
36 return enabled == that.enabled &&
37 line_double == that.line_double;
40 void FreezeFrameConfig::interpolate(FreezeFrameConfig &prev,
41 FreezeFrameConfig &next,
46 this->enabled = prev.enabled;
47 this->line_double = prev.line_double;
59 FreezeFrameWindow::FreezeFrameWindow(FreezeFrameMain *client, int x, int y)
60 : BC_Window(client->get_gui_string(),
71 this->client = client;
74 FreezeFrameWindow::~FreezeFrameWindow()
78 int FreezeFrameWindow::create_objects()
81 add_tool(enabled = new FreezeFrameToggle(client,
82 &client->config.enabled,
87 add_tool(line_double = new FreezeFrameToggle(client,
88 &client->config.line_double,
97 WINDOW_CLOSE_EVENT(FreezeFrameWindow)
102 PLUGIN_THREAD_OBJECT(FreezeFrameMain, FreezeFrameThread, FreezeFrameWindow)
108 FreezeFrameToggle::FreezeFrameToggle(FreezeFrameMain *client,
113 : BC_CheckBox(x, y, *value, text)
115 this->client = client;
118 FreezeFrameToggle::~FreezeFrameToggle()
121 int FreezeFrameToggle::handle_event()
123 *value = get_value();
124 client->send_configure_change();
139 FreezeFrameMain::FreezeFrameMain(PluginServer *server)
140 : PluginVClient(server)
142 PLUGIN_CONSTRUCTOR_MACRO
146 FreezeFrameMain::~FreezeFrameMain()
148 PLUGIN_DESTRUCTOR_MACRO
149 if(first_frame) delete first_frame;
152 char* FreezeFrameMain::plugin_title() { return _("Freeze Frame"); }
154 int FreezeFrameMain::is_synthesis()
159 int FreezeFrameMain::is_realtime() { return 1; }
161 SHOW_GUI_MACRO(FreezeFrameMain, FreezeFrameThread)
163 RAISE_WINDOW_MACRO(FreezeFrameMain)
165 SET_STRING_MACRO(FreezeFrameMain)
167 NEW_PICON_MACRO(FreezeFrameMain)
169 LOAD_CONFIGURATION_MACRO(FreezeFrameMain, FreezeFrameConfig)
171 void FreezeFrameMain::update_gui()
175 load_configuration();
176 thread->window->lock_window();
177 thread->window->enabled->update(config.enabled);
178 thread->window->line_double->update(config.line_double);
179 thread->window->unlock_window();
183 void FreezeFrameMain::save_data(KeyFrame *keyframe)
187 // cause data to be stored directly in text
188 output.set_shared_string(keyframe->data, MESSAGESIZE);
189 output.tag.set_title("FREEZEFRAME");
193 output.tag.set_title("ENABLED");
196 if(config.line_double)
198 output.tag.set_title("LINE_DOUBLE");
201 output.terminate_string();
202 // data is now in *text
205 void FreezeFrameMain::read_data(KeyFrame *keyframe)
209 input.set_shared_string(keyframe->data, strlen(keyframe->data));
213 config.line_double = 0;
217 result = input.read_tag();
221 if(input.tag.title_is("ENABLED"))
225 if(input.tag.title_is("LINE_DOUBLE"))
227 config.line_double = 1;
233 int FreezeFrameMain::load_defaults()
235 char directory[BCTEXTLEN], string[BCTEXTLEN];
236 // set the default directory
237 sprintf(directory, "%sfreezeframe.rc", BCASTDIR);
240 defaults = new Defaults(directory);
243 config.enabled = defaults->get("ENABLED", config.enabled);
244 config.line_double = defaults->get("LINE_DOUBLE", config.line_double);
248 int FreezeFrameMain::save_defaults()
250 defaults->update("ENABLED", config.enabled);
251 defaults->update("LINE_DOUBLE", config.line_double);
261 int FreezeFrameMain::process_realtime(VFrame *input_ptr, VFrame *output_ptr)
263 load_configuration();
264 KeyFrame *prev_keyframe;
266 prev_keyframe = get_prev_keyframe(get_source_position());
267 new_keyframe = (prev_keyframe->position == get_source_position());
269 if(!first_frame && config.enabled || new_keyframe)
272 first_frame = new VFrame(0,
275 input_ptr->get_color_model());
276 first_frame->copy_from(input_ptr);
277 output_ptr->copy_from(input_ptr);
280 if(!first_frame && !config.enabled)
282 output_ptr->copy_from(input_ptr);
285 if(first_frame && !config.enabled)
289 output_ptr->copy_from(input_ptr);
292 if(first_frame && config.enabled)
294 output_ptr->copy_from(first_frame);
298 if(config.line_double && config.enabled)
300 for(int i = 0; i < output_ptr->get_h() - 1; i += 2)
302 memcpy(output_ptr->get_rows()[i + 1],
303 output_ptr->get_rows()[i],
304 output_ptr->get_bytes_per_line());