1 #include "bcdisplayinfo.h"
6 #include "mainprogress.h"
8 #include "pluginvclient.h"
14 #define _(String) gettext(String)
15 #define gettext_noop(String) String
16 #define N_(String) gettext_noop (String)
18 #define TOP_FIELD_FIRST 0
19 #define BOTTOM_FIELD_FIRST 1
22 class FieldFrameWindow;
25 class FieldFrameConfig
35 class FieldFrameTop : public BC_Radial
38 FieldFrameTop(FieldFrame *plugin, FieldFrameWindow *gui, int x, int y);
41 FieldFrameWindow *gui;
45 class FieldFrameBottom : public BC_Radial
48 FieldFrameBottom(FieldFrame *plugin, FieldFrameWindow *gui, int x, int y);
51 FieldFrameWindow *gui;
54 class FieldFrameAvg : public BC_CheckBox
57 FieldFrameAvg(FieldFrame *plugin, FieldFrameWindow *gui, int x, int y);
60 FieldFrameWindow *gui;
63 class FieldFrameWindow : public BC_Window
66 FieldFrameWindow(FieldFrame *plugin, int x, int y);
67 void create_objects();
71 FieldFrameBottom *bottom;
77 class FieldFrame : public PluginVClient
80 FieldFrame(PluginServer *server);
90 int process_loop(VFrame *output);
91 double get_framerate();
95 VFrame *prev_frame, *next_frame;
96 FieldFrameConfig config;
98 MainProgressBar *progress;
112 FieldFrameConfig::FieldFrameConfig()
114 field_dominance = TOP_FIELD_FIRST;
125 FieldFrameWindow::FieldFrameWindow(FieldFrame *plugin, int x, int y)
126 : BC_Window(plugin->gui_string,
137 this->plugin = plugin;
140 void FieldFrameWindow::create_objects()
143 add_subwindow(top = new FieldFrameTop(plugin, this, x, y));
145 add_subwindow(bottom = new FieldFrameBottom(plugin, this, x, y));
147 add_subwindow(new BC_OKButton(this));
148 add_subwindow(new BC_CancelButton(this));
154 int FieldFrameWindow::close_event()
171 FieldFrameTop::FieldFrameTop(FieldFrame *plugin,
172 FieldFrameWindow *gui,
177 plugin->config.field_dominance == TOP_FIELD_FIRST,
178 _("Top field first"))
180 this->plugin = plugin;
184 int FieldFrameTop::handle_event()
186 plugin->config.field_dominance = TOP_FIELD_FIRST;
187 gui->bottom->update(0);
195 FieldFrameBottom::FieldFrameBottom(FieldFrame *plugin,
196 FieldFrameWindow *gui,
201 plugin->config.field_dominance == BOTTOM_FIELD_FIRST,
202 _("Bottom field first"))
204 this->plugin = plugin;
208 int FieldFrameBottom::handle_event()
210 plugin->config.field_dominance = BOTTOM_FIELD_FIRST;
234 REGISTER_PLUGIN(FieldFrame)
237 FieldFrame::FieldFrame(PluginServer *server)
238 : PluginVClient(server)
247 FieldFrame::~FieldFrame()
252 if(prev_frame) delete prev_frame;
253 if(next_frame) delete next_frame;
256 char* FieldFrame::plugin_title()
258 return _("Fields to frames");
261 NEW_PICON_MACRO(FieldFrame)
263 double FieldFrame::get_framerate()
265 return project_frame_rate / 2;
268 int FieldFrame::load_defaults()
270 char directory[BCTEXTLEN];
271 // set the default directory
272 sprintf(directory, "%sfieldframe.rc", BCASTDIR);
275 defaults = new Defaults(directory);
278 config.field_dominance = defaults->get("DOMINANCE", config.field_dominance);
282 int FieldFrame::save_defaults()
284 defaults->update("DOMINANCE", config.field_dominance);
289 int FieldFrame::get_parameters()
292 FieldFrameWindow window(this, info.get_abs_cursor_x(), info.get_abs_cursor_y());
293 window.create_objects();
294 int result = window.run_window();
299 int FieldFrame::start_loop()
301 if(PluginClient::interactive)
303 char string[BCTEXTLEN];
304 sprintf(string, "%s...", plugin_title());
305 progress = start_progress(string,
306 PluginClient::end - PluginClient::start);
309 input_position = PluginClient::start;
313 int FieldFrame::stop_loop()
315 if(PluginClient::interactive)
317 progress->stop_progress();
323 int FieldFrame::process_loop(VFrame *output)
329 prev_frame = new VFrame(0, output->get_w(), output->get_h(), output->get_color_model());
333 next_frame = new VFrame(0, output->get_w(), output->get_h(), output->get_color_model());
336 read_frame(prev_frame, input_position);
338 read_frame(next_frame, input_position);
341 unsigned char **input_rows1;
342 unsigned char **input_rows2;
343 if(config.field_dominance == TOP_FIELD_FIRST)
345 input_rows1 = prev_frame->get_rows();
346 input_rows2 = next_frame->get_rows();
350 input_rows1 = next_frame->get_rows();
351 input_rows2 = prev_frame->get_rows();
354 unsigned char **output_rows = output->get_rows();
355 int row_size = VFrame::calculate_bytes_per_pixel(output->get_color_model()) * output->get_w();
356 for(int i = 0; i < output->get_h() - 1; i += 2)
358 memcpy(output_rows[i], input_rows1[i], row_size);
359 memcpy(output_rows[i + 1], input_rows2[i + 1], row_size);
363 if(PluginClient::interactive)
364 result = progress->update(input_position - PluginClient::start);
366 if(input_position >= PluginClient::end) result = 1;