4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "bcsignals.h"
25 #include "edlsession.h"
26 #include "formattools.h"
29 #include "performanceprefs.h"
30 #include "preferences.h"
34 #define MASTER_NODE_FRAMERATE_TEXT "Master node framerate: %0.3f"
36 N_(MASTER_NODE_FRAMERATE_TEXT)
39 PerformancePrefs::PerformancePrefs(MWindow *mwindow, PreferencesWindow *pwindow)
40 : PreferencesDialog(mwindow, pwindow)
45 PerformancePrefs::~PerformancePrefs()
48 nodes[0].remove_all_objects();
49 nodes[1].remove_all_objects();
50 nodes[2].remove_all_objects();
51 nodes[3].remove_all_objects();
54 void PerformancePrefs::create_objects()
61 char string[BCTEXTLEN];
62 BC_Resources *resources = BC_WindowBase::get_resources();
67 xmargin1 = x = mwindow->theme->preferencesoptions_x;
68 y = mwindow->theme->preferencesoptions_y;
70 // add_subwindow(new BC_Title(x,
74 // resources->text_default));
76 // y += get_text_height(LARGEFONT) + 5;
78 add_subwindow(new BC_Title(x, y + 5, _("Cache size (MB):"), MEDIUMFONT, resources->text_default));
79 cache_size = new CICacheSize(x + 230,
83 cache_size->create_objects();
85 add_subwindow(new BC_Title(x, y + 5, _("Seconds to preroll renders:")));
86 PrefsRenderPreroll *preroll = new PrefsRenderPreroll(pwindow,
90 preroll->create_objects();
92 PrefsForceUniprocessor *force_1cpu = new PrefsForceUniprocessor(pwindow, x, y);
93 add_subwindow(force_1cpu);
95 int x1 = force_1cpu->get_x() + force_1cpu->get_w() + 50;
97 PrefsTrapSigSEGV *trap_segv = new PrefsTrapSigSEGV(this, x1, y);
98 add_subwindow(trap_segv);
99 int x2 = x1 + trap_segv->get_w() + 10;
100 add_subwindow(new BC_Title(x2, y, _("(must be root)"), MEDIUMFONT, RED));
103 PrefsTrapSigINTR *trap_intr = new PrefsTrapSigINTR(this, x1, y);
104 add_subwindow(trap_intr);
105 add_subwindow(new BC_Title(x2, y, _("(must be root)"), MEDIUMFONT, RED));
106 ffmpeg_marker_indecies = new PrefsFFMPEGMarkerIndecies(this, x, y);
107 add_subwindow(ffmpeg_marker_indecies);
110 ffmpeg_early_probe = new PrefsFFMPEGEarlyProbe(this, x, y);
111 add_subwindow(ffmpeg_early_probe);
117 // Background rendering
118 add_subwindow(new BC_Bar(5, y, get_w() - 10));
122 add_subwindow(new BC_Title(x, y, _("Background Rendering (Video only)"), LARGEFONT, resources->text_default));
125 add_subwindow(new PrefsUseBRender(pwindow,
130 add_subwindow(new BC_Title(x, y + 40, _("Frames per background rendering job:")));
131 PrefsBRenderFragment *brender_fragment = new PrefsBRenderFragment(pwindow,
135 brender_fragment->create_objects();
136 add_subwindow(new BC_Title(x, y + 95, _("Frames to preroll background:")));
137 PrefsBRenderPreroll *bpreroll = new PrefsBRenderPreroll(pwindow,
141 bpreroll->create_objects();
145 add_subwindow(new BC_Title(x, y, _("Output for background rendering:")));
148 new FormatTools(mwindow,
150 pwindow->thread->preferences->brender_asset);
151 brender_tools->create_objects(x,
153 0, // Include tools for audio
154 1, // Include tools for video
155 0, // Include checkbox for audio
156 0, // Include checkbox for video
159 0, // Select compressors to be offered
160 0, // Prompt for recording options
161 0, // If nonzero, prompt for insertion strategy
162 1); // Supply file formats for background rendering
167 add_subwindow(new BC_Bar(5, y, get_w() - 10));
169 add_subwindow(new BC_Title(x, y, _("Render Farm"), LARGEFONT, resources->text_default));
171 BC_Title *node_title = new BC_Title(x1, y, _("Nodes:"));
172 add_subwindow(node_title);
173 x1 += node_title->get_w() + 25;
174 sprintf(string, _(MASTER_NODE_FRAMERATE_TEXT),
175 pwindow->thread->preferences->local_rate);
176 add_subwindow(master_rate = new BC_Title(x1, y, string));
178 add_subwindow(node_list = new PrefsRenderFarmNodes(pwindow,
183 add_subwindow(new PrefsRenderFarm(pwindow, x, y));
185 add_subwindow(new BC_Title(x, y, _("Hostname:")));
186 add_subwindow(new BC_Title(x + xmargin3, y, _("Port:")));
189 add_subwindow(edit_node = new PrefsRenderFarmEditNode(pwindow,
193 edit_port = new PrefsRenderFarmPort(pwindow,
197 edit_port->create_objects();
202 add_subwindow(new PrefsRenderFarmReplaceNode(pwindow,
206 add_subwindow(new PrefsRenderFarmNewNode(pwindow,
211 add_subwindow(new PrefsRenderFarmDelNode(pwindow,
215 add_subwindow(new PrefsRenderFarmSortNodes(pwindow,
220 add_subwindow(new PrefsRenderFarmReset(pwindow,
225 add_subwindow(new BC_Title(x,
227 _("Total jobs to create:")));
228 add_subwindow(new BC_Title(x,
230 _("(overridden if new file at each label is checked)")));
231 PrefsRenderFarmJobs *jobs = new PrefsRenderFarmJobs(pwindow,
235 jobs->create_objects();
237 // add_subwindow(new PrefsRenderFarmVFS(pwindow,
241 // add_subwindow(new BC_Title(x,
243 // _("Filesystem prefix on remote nodes:")));
244 // add_subwindow(new PrefsRenderFarmMountpoint(pwindow,
251 void PerformancePrefs::generate_node_list()
253 int selected_row = node_list ? node_list->get_selection_number(0, 0) : -1;
255 for(int i = 0; i < TOTAL_COLUMNS; i++)
256 nodes[i].remove_all_objects();
259 i < pwindow->thread->preferences->renderfarm_nodes.size();
262 BC_ListBoxItem *item;
263 nodes[ENABLED_COLUMN].append(item = new BC_ListBoxItem(
264 (char*)(pwindow->thread->preferences->renderfarm_enabled.get(i) ? "X" : " ")));
265 if(i == selected_row) item->set_selected(1);
267 nodes[HOSTNAME_COLUMN].append(item = new BC_ListBoxItem(
268 pwindow->thread->preferences->renderfarm_nodes.get(i)));
269 if(i == selected_row) item->set_selected(1);
271 char string[BCTEXTLEN];
272 sprintf(string, "%d", pwindow->thread->preferences->renderfarm_ports.get(i));
273 nodes[PORT_COLUMN].append(item = new BC_ListBoxItem(string));
274 if(i == selected_row) item->set_selected(1);
276 sprintf(string, "%0.3f", pwindow->thread->preferences->renderfarm_rate.get(i));
277 nodes[RATE_COLUMN].append(item = new BC_ListBoxItem(string));
278 if(i == selected_row) item->set_selected(1);
282 static const char *titles[] =
290 static int widths[] =
299 void PerformancePrefs::update_node_list()
301 node_list->update(nodes,
305 node_list->get_xposition(),
306 node_list->get_yposition(),
307 node_list->get_selection_number(0, 0));
311 void PerformancePrefs::update_rates()
313 //printf("PerformancePrefs::update_rates %d\n", __LINE__);
314 char string[BCTEXTLEN];
316 i < mwindow->preferences->renderfarm_rate.size();
319 if(i < nodes[RATE_COLUMN].size())
321 sprintf(string, "%0.3f", mwindow->preferences->renderfarm_rate.get(i));
322 nodes[RATE_COLUMN].get(i)->set_text(string);
326 sprintf(string, _(MASTER_NODE_FRAMERATE_TEXT),
327 mwindow->preferences->local_rate);
328 master_rate->update(string);
334 PrefsUseBRender::PrefsUseBRender(PreferencesWindow *pwindow,
339 pwindow->thread->preferences->use_brender,
340 _("Use background rendering"))
342 this->pwindow = pwindow;
345 int PrefsUseBRender::handle_event()
347 pwindow->thread->redraw_overlays = 1;
348 pwindow->thread->redraw_times = 1;
349 pwindow->thread->preferences->use_brender = get_value();
358 PrefsBRenderFragment::PrefsBRenderFragment(PreferencesWindow *pwindow,
359 PerformancePrefs *subwindow,
362 : BC_TumbleTextBox(subwindow,
363 (int64_t)pwindow->thread->preferences->brender_fragment,
370 this->pwindow = pwindow;
372 int PrefsBRenderFragment::handle_event()
374 pwindow->thread->preferences->brender_fragment = atol(get_text());
388 CICacheSize::CICacheSize(int x,
390 PreferencesWindow *pwindow,
391 PerformancePrefs *subwindow)
392 : BC_TumbleTextBox(subwindow,
393 (int64_t)pwindow->thread->preferences->cache_size / 0x100000,
394 (int64_t)MIN_CACHE_SIZE / 0x100000,
395 (int64_t)MAX_CACHE_SIZE / 0x100000,
400 this->pwindow = pwindow;
404 int CICacheSize::handle_event()
407 result = (int64_t)atol(get_text()) * 0x100000;
408 CLAMP(result, MIN_CACHE_SIZE, MAX_CACHE_SIZE);
409 pwindow->thread->preferences->cache_size = result;
414 PrefsRenderPreroll::PrefsRenderPreroll(PreferencesWindow *pwindow,
415 PerformancePrefs *subwindow,
418 : BC_TumbleTextBox(subwindow,
419 (float)pwindow->thread->preferences->render_preroll,
426 this->pwindow = pwindow;
429 PrefsRenderPreroll::~PrefsRenderPreroll()
432 int PrefsRenderPreroll::handle_event()
434 pwindow->thread->preferences->render_preroll = atof(get_text());
439 PrefsBRenderPreroll::PrefsBRenderPreroll(PreferencesWindow *pwindow,
440 PerformancePrefs *subwindow,
443 : BC_TumbleTextBox(subwindow,
444 (int64_t)pwindow->thread->preferences->brender_preroll,
451 this->pwindow = pwindow;
453 int PrefsBRenderPreroll::handle_event()
455 pwindow->thread->preferences->brender_preroll = atol(get_text());
469 PrefsRenderFarm::PrefsRenderFarm(PreferencesWindow *pwindow, int x, int y)
472 pwindow->thread->preferences->use_renderfarm,
473 _("Use render farm"))
475 this->pwindow = pwindow;
477 PrefsRenderFarm::~PrefsRenderFarm()
480 int PrefsRenderFarm::handle_event()
482 pwindow->thread->preferences->use_renderfarm = get_value();
489 PrefsForceUniprocessor::PrefsForceUniprocessor(PreferencesWindow *pwindow, int x, int y)
492 pwindow->thread->preferences->force_uniprocessor,
493 _("Force single processor use"))
495 this->pwindow = pwindow;
497 PrefsForceUniprocessor::~PrefsForceUniprocessor()
500 int PrefsForceUniprocessor::handle_event()
502 pwindow->thread->preferences->force_uniprocessor = get_value();
506 PrefsTrapSigSEGV::PrefsTrapSigSEGV(PerformancePrefs *perf_prefs, int x, int y)
508 perf_prefs->pwindow->thread->preferences->trap_sigsegv,
511 this->perf_prefs = perf_prefs;
513 PrefsTrapSigSEGV::~PrefsTrapSigSEGV()
516 int PrefsTrapSigSEGV::handle_event()
518 perf_prefs->pwindow->thread->preferences->trap_sigsegv = get_value();
522 PrefsTrapSigINTR::PrefsTrapSigINTR(PerformancePrefs *perf_prefs, int x, int y)
524 perf_prefs->pwindow->thread->preferences->trap_sigintr,
527 this->perf_prefs = perf_prefs;
529 PrefsTrapSigINTR::~PrefsTrapSigINTR()
532 int PrefsTrapSigINTR::handle_event()
534 perf_prefs->pwindow->thread->preferences->trap_sigintr = get_value();
539 PrefsFFMPEGEarlyProbe::PrefsFFMPEGEarlyProbe(PerformancePrefs *perf_prefs, int x, int y)
541 perf_prefs->pwindow->thread->preferences->ffmpeg_early_probe,
542 _("On file open, ffmpeg probes early"))
544 this->perf_prefs = perf_prefs;
546 PrefsFFMPEGEarlyProbe::~PrefsFFMPEGEarlyProbe()
550 int PrefsFFMPEGEarlyProbe::handle_event()
552 perf_prefs->pwindow->thread->preferences->ffmpeg_early_probe = get_value();
557 PrefsFFMPEGMarkerIndecies::PrefsFFMPEGMarkerIndecies(PerformancePrefs *perf_prefs, int x, int y)
559 perf_prefs->pwindow->thread->preferences->ffmpeg_marker_indecies,
560 _("build ffmpeg marker indecies"))
562 this->perf_prefs = perf_prefs;
564 PrefsFFMPEGMarkerIndecies::~PrefsFFMPEGMarkerIndecies()
568 int PrefsFFMPEGMarkerIndecies::handle_event()
570 perf_prefs->pwindow->thread->preferences->ffmpeg_marker_indecies = get_value();
579 PrefsRenderFarmConsolidate::PrefsRenderFarmConsolidate(PreferencesWindow *pwindow, int x, int y)
582 pwindow->thread->preferences->renderfarm_consolidate,
583 _("Consolidate output files on completion"))
585 this->pwindow = pwindow;
587 PrefsRenderFarmConsolidate::~PrefsRenderFarmConsolidate()
590 int PrefsRenderFarmConsolidate::handle_event()
592 pwindow->thread->preferences->renderfarm_consolidate = get_value();
600 PrefsRenderFarmPort::PrefsRenderFarmPort(PreferencesWindow *pwindow,
601 PerformancePrefs *subwindow,
604 : BC_TumbleTextBox(subwindow,
605 (int64_t)pwindow->thread->preferences->renderfarm_port,
612 this->pwindow = pwindow;
615 PrefsRenderFarmPort::~PrefsRenderFarmPort()
619 int PrefsRenderFarmPort::handle_event()
621 pwindow->thread->preferences->renderfarm_port = atol(get_text());
627 PrefsRenderFarmNodes::PrefsRenderFarmNodes(PreferencesWindow *pwindow,
628 PerformancePrefs *subwindow,
635 LISTBOX_TEXT, // Display text list or icons
641 this->subwindow = subwindow;
642 this->pwindow = pwindow;
644 PrefsRenderFarmNodes::~PrefsRenderFarmNodes()
648 int PrefsRenderFarmNodes::column_resize_event()
650 for(int i = 0; i < 3; i++)
651 widths[i] = get_column_width(i);
655 int PrefsRenderFarmNodes::handle_event()
658 if(get_selection_number(0, 0) >= 0)
660 subwindow->hot_node = get_selection_number(1, 0);
661 subwindow->edit_node->update(get_selection(1, 0)->get_text());
662 subwindow->edit_port->update(get_selection(2, 0)->get_text());
663 if(get_cursor_x() < widths[0])
665 pwindow->thread->preferences->renderfarm_enabled.values[subwindow->hot_node] =
666 !pwindow->thread->preferences->renderfarm_enabled.values[subwindow->hot_node];
667 subwindow->generate_node_list();
668 subwindow->update_node_list();
673 subwindow->hot_node = -1;
674 subwindow->edit_node->update("");
679 int PrefsRenderFarmNodes::selection_changed()
691 PrefsRenderFarmEditNode::PrefsRenderFarmEditNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
692 : BC_TextBox(x, y, 240, 1, "")
694 this->pwindow = pwindow;
695 this->subwindow = subwindow;
698 PrefsRenderFarmEditNode::~PrefsRenderFarmEditNode()
702 int PrefsRenderFarmEditNode::handle_event()
712 PrefsRenderFarmNewNode::PrefsRenderFarmNewNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
713 : BC_GenericButton(x, y, _("Add Node"))
715 this->pwindow = pwindow;
716 this->subwindow = subwindow;
718 PrefsRenderFarmNewNode::~PrefsRenderFarmNewNode()
721 int PrefsRenderFarmNewNode::handle_event()
723 pwindow->thread->preferences->add_node(subwindow->edit_node->get_text(),
724 pwindow->thread->preferences->renderfarm_port,
727 pwindow->thread->preferences->reset_rates();
728 subwindow->generate_node_list();
729 subwindow->update_node_list();
730 subwindow->hot_node = -1;
740 PrefsRenderFarmReplaceNode::PrefsRenderFarmReplaceNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
741 : BC_GenericButton(x, y, _("Apply Changes"))
743 this->pwindow = pwindow;
744 this->subwindow = subwindow;
746 PrefsRenderFarmReplaceNode::~PrefsRenderFarmReplaceNode()
749 int PrefsRenderFarmReplaceNode::handle_event()
751 if(subwindow->hot_node >= 0)
753 pwindow->thread->preferences->edit_node(subwindow->hot_node,
754 subwindow->edit_node->get_text(),
755 pwindow->thread->preferences->renderfarm_port,
756 pwindow->thread->preferences->renderfarm_enabled.values[subwindow->hot_node]);
757 subwindow->generate_node_list();
758 subwindow->update_node_list();
767 PrefsRenderFarmDelNode::PrefsRenderFarmDelNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
768 : BC_GenericButton(x, y, _("Delete Node"))
770 this->pwindow = pwindow;
771 this->subwindow = subwindow;
773 PrefsRenderFarmDelNode::~PrefsRenderFarmDelNode()
776 int PrefsRenderFarmDelNode::handle_event()
778 if(strlen(subwindow->edit_node->get_text()) &&
779 subwindow->hot_node >= 0)
782 pwindow->thread->preferences->delete_node(subwindow->hot_node);
784 subwindow->generate_node_list();
785 subwindow->update_node_list();
786 subwindow->hot_node = -1;
795 PrefsRenderFarmSortNodes::PrefsRenderFarmSortNodes(PreferencesWindow *pwindow,
796 PerformancePrefs *subwindow,
799 : BC_GenericButton(x, y, _("Sort nodes"))
801 this->pwindow = pwindow;
802 this->subwindow = subwindow;
805 PrefsRenderFarmSortNodes::~PrefsRenderFarmSortNodes()
809 int PrefsRenderFarmSortNodes::handle_event()
811 pwindow->thread->preferences->sort_nodes();
812 subwindow->generate_node_list();
813 subwindow->update_node_list();
814 subwindow->hot_node = -1;
822 PrefsRenderFarmReset::PrefsRenderFarmReset(PreferencesWindow *pwindow,
823 PerformancePrefs *subwindow,
826 : BC_GenericButton(x, y, _("Reset rates"))
828 this->pwindow = pwindow;
829 this->subwindow = subwindow;
832 int PrefsRenderFarmReset::handle_event()
834 pwindow->thread->preferences->reset_rates();
835 subwindow->generate_node_list();
836 subwindow->update_node_list();
838 char string[BCTEXTLEN];
840 MASTER_NODE_FRAMERATE_TEXT,
841 pwindow->thread->preferences->local_rate);
842 subwindow->master_rate->update(string);
843 subwindow->hot_node = -1;
853 PrefsRenderFarmJobs::PrefsRenderFarmJobs(PreferencesWindow *pwindow,
854 PerformancePrefs *subwindow,
857 : BC_TumbleTextBox(subwindow,
858 (int64_t)pwindow->thread->preferences->renderfarm_job_count,
865 this->pwindow = pwindow;
867 PrefsRenderFarmJobs::~PrefsRenderFarmJobs()
870 int PrefsRenderFarmJobs::handle_event()
872 pwindow->thread->preferences->renderfarm_job_count = atol(get_text());
878 PrefsRenderFarmMountpoint::PrefsRenderFarmMountpoint(PreferencesWindow *pwindow,
879 PerformancePrefs *subwindow,
886 pwindow->thread->preferences->renderfarm_mountpoint)
888 this->pwindow = pwindow;
889 this->subwindow = subwindow;
891 PrefsRenderFarmMountpoint::~PrefsRenderFarmMountpoint()
894 int PrefsRenderFarmMountpoint::handle_event()
896 strcpy(pwindow->thread->preferences->renderfarm_mountpoint, get_text());
903 PrefsRenderFarmVFS::PrefsRenderFarmVFS(PreferencesWindow *pwindow,
904 PerformancePrefs *subwindow,
907 : BC_CheckBox(x, y, pwindow->thread->preferences->renderfarm_vfs, _("Use virtual filesystem"))
909 this->pwindow = pwindow;
910 this->subwindow = subwindow;
913 int PrefsRenderFarmVFS::handle_event()
915 pwindow->thread->preferences->renderfarm_vfs = get_value();