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();
69 xmargin1 = x = mwindow->theme->preferencesoptions_x;
70 y = mwindow->theme->preferencesoptions_y;
72 // add_subwindow(new BC_Title(x,
76 // resources->text_default));
78 // y += get_text_height(LARGEFONT) + 5;
83 win = add_subwindow(new BC_Title(x, y + 5, _("Cache size (MB):"), MEDIUMFONT, resources->text_default));
87 win = add_subwindow(new BC_Title(x, y + 5, _("Seconds to preroll renders:")));
88 if((curw = win->get_w()) > maxw)
92 cache_size = new CICacheSize(maxw,
96 cache_size->create_objects();
97 add_subwindow(new BC_Title(x, y + 5, _("Seconds to preroll renders:")));
98 PrefsRenderPreroll *preroll = new PrefsRenderPreroll(pwindow,
102 preroll->create_objects();
103 int x1 = preroll->get_x() + preroll->get_w() + 20;
104 BC_Title *smp_title = new BC_Title(x1, y + 5, _("Project SMP cpus:"));
105 add_subwindow(smp_title);
106 int x2 = x1 + smp_title->get_w() + 5;
107 PrefsProjectSMP *proj_smp = new PrefsProjectSMP(pwindow, this, x2, y);
108 proj_smp->create_objects();
111 PrefsForceUniprocessor *force_1cpu = new PrefsForceUniprocessor(pwindow, x, y);
112 add_subwindow(force_1cpu);
114 x1 = force_1cpu->get_x() + force_1cpu->get_w() + 120;
116 PrefsTrapSigSEGV *trap_segv = new PrefsTrapSigSEGV(this, x1, y);
117 add_subwindow(trap_segv);
118 x2 = x1 + trap_segv->get_w() + 10;
119 add_subwindow(new BC_Title(x2, y, _("(must be root)"), MEDIUMFONT, RED));
122 PrefsTrapSigINTR *trap_intr = new PrefsTrapSigINTR(this, x1, y);
123 add_subwindow(trap_intr);
124 add_subwindow(new BC_Title(x2, y, _("(must be root)"), MEDIUMFONT, RED));
125 ffmpeg_marker_indexes = new PrefsFFMPEGMarkerIndecies(this, x, y);
126 add_subwindow(ffmpeg_marker_indexes);
129 ffmpeg_early_probe = new PrefsFFMPEGEarlyProbe(this, x, y);
130 add_subwindow(ffmpeg_early_probe);
132 yuv420p_dvdlace = new PrefsYUV420P_DVDlace(pwindow, this, x1, y);
133 add_subwindow(yuv420p_dvdlace);
136 // Background rendering
137 add_subwindow(new BC_Bar(5, y, get_w() - 10));
141 add_subwindow(new BC_Title(x, y, _("Background Rendering (Video only)"), LARGEFONT, resources->text_default));
144 win = add_subwindow(new PrefsUseBRender(pwindow,
148 y += win->get_h() + 10;
149 win = add_subwindow(new BC_Title(x, y, _("Frames per background rendering job:")));
150 y += win->get_h() + 5;
151 PrefsBRenderFragment *brender_fragment = new PrefsBRenderFragment(pwindow,
155 brender_fragment->create_objects();
156 y += brender_fragment->get_h() + 5;
157 win = add_subwindow(new BC_Title(x, y, _("Frames to preroll background:")));
158 y += win->get_h() + 5;
159 PrefsBRenderPreroll *bpreroll = new PrefsBRenderPreroll(pwindow,
163 bpreroll->create_objects();
164 y += bpreroll->get_h() + 20;
168 add_subwindow(new BC_Title(x, y1, _("Output for background rendering:")));
171 new FormatTools(mwindow,
173 pwindow->thread->preferences->brender_asset);
174 brender_tools->create_objects(x,
176 0, // Include tools for audio
177 1, // Include tools for video
178 0, // Include checkbox for audio
179 0, // Include checkbox for video
182 0, // Select compressors to be offered
183 0, // Prompt for recording options
184 0, // If nonzero, prompt for insertion strategy
185 1); // Supply file formats for background rendering
190 add_subwindow(new BC_Bar(5, y, get_w() - 10));
192 add_subwindow(new BC_Title(x, y, _("Render Farm"), LARGEFONT, resources->text_default));
194 BC_Title *node_title = new BC_Title(x1, y, _("Nodes:"));
195 add_subwindow(node_title);
196 x1 += node_title->get_w() + 25;
197 sprintf(string, _(MASTER_NODE_FRAMERATE_TEXT),
198 pwindow->thread->preferences->local_rate);
199 add_subwindow(master_rate = new BC_Title(x1, y, string));
201 add_subwindow(node_list = new PrefsRenderFarmNodes(pwindow,
206 add_subwindow(new PrefsRenderFarm(pwindow, x, y));
208 add_subwindow(new BC_Title(x, y, _("Hostname:")));
209 add_subwindow(new BC_Title(x + xmargin3, y, _("Port:")));
212 add_subwindow(edit_node = new PrefsRenderFarmEditNode(pwindow,
216 edit_port = new PrefsRenderFarmPort(pwindow,
220 edit_port->create_objects();
225 add_subwindow(new PrefsRenderFarmReplaceNode(pwindow,
229 add_subwindow(new PrefsRenderFarmNewNode(pwindow,
234 add_subwindow(new PrefsRenderFarmDelNode(pwindow,
238 add_subwindow(new PrefsRenderFarmSortNodes(pwindow,
243 add_subwindow(new PrefsRenderFarmReset(pwindow,
248 add_subwindow(new BC_Title(x,
250 _("Total jobs to create:")));
251 add_subwindow(new BC_Title(x,
253 _("(overridden if new file at each label is checked)")));
254 PrefsRenderFarmJobs *jobs = new PrefsRenderFarmJobs(pwindow,
258 jobs->create_objects();
260 // add_subwindow(new PrefsRenderFarmVFS(pwindow,
264 // add_subwindow(new BC_Title(x,
266 // _("Filesystem prefix on remote nodes:")));
267 // add_subwindow(new PrefsRenderFarmMountpoint(pwindow,
274 void PerformancePrefs::generate_node_list()
276 int selected_row = node_list ? node_list->get_selection_number(0, 0) : -1;
278 for(int i = 0; i < TOTAL_COLUMNS; i++)
279 nodes[i].remove_all_objects();
282 i < pwindow->thread->preferences->renderfarm_nodes.size();
285 BC_ListBoxItem *item;
286 nodes[ENABLED_COLUMN].append(item = new BC_ListBoxItem(
287 (char*)(pwindow->thread->preferences->renderfarm_enabled.get(i) ? "X" : " ")));
288 if(i == selected_row) item->set_selected(1);
290 nodes[HOSTNAME_COLUMN].append(item = new BC_ListBoxItem(
291 pwindow->thread->preferences->renderfarm_nodes.get(i)));
292 if(i == selected_row) item->set_selected(1);
294 char string[BCTEXTLEN];
295 sprintf(string, "%d", pwindow->thread->preferences->renderfarm_ports.get(i));
296 nodes[PORT_COLUMN].append(item = new BC_ListBoxItem(string));
297 if(i == selected_row) item->set_selected(1);
299 sprintf(string, "%0.3f", pwindow->thread->preferences->renderfarm_rate.get(i));
300 nodes[RATE_COLUMN].append(item = new BC_ListBoxItem(string));
301 if(i == selected_row) item->set_selected(1);
305 static const char *titles[] =
313 static int widths[] =
322 void PerformancePrefs::update_node_list()
324 node_list->update(nodes,
328 node_list->get_xposition(),
329 node_list->get_yposition(),
330 node_list->get_selection_number(0, 0));
334 void PerformancePrefs::update_rates()
336 //printf("PerformancePrefs::update_rates %d\n", __LINE__);
337 char string[BCTEXTLEN];
339 i < mwindow->preferences->renderfarm_rate.size();
342 if(i < nodes[RATE_COLUMN].size())
344 sprintf(string, "%0.3f", mwindow->preferences->renderfarm_rate.get(i));
345 nodes[RATE_COLUMN].get(i)->set_text(string);
349 sprintf(string, _(MASTER_NODE_FRAMERATE_TEXT),
350 mwindow->preferences->local_rate);
351 master_rate->update(string);
357 PrefsUseBRender::PrefsUseBRender(PreferencesWindow *pwindow,
362 pwindow->thread->preferences->use_brender,
363 _("Use background rendering"))
365 this->pwindow = pwindow;
368 int PrefsUseBRender::handle_event()
370 pwindow->thread->redraw_overlays = 1;
371 pwindow->thread->redraw_times = 1;
372 pwindow->thread->preferences->use_brender = get_value();
381 PrefsBRenderFragment::PrefsBRenderFragment(PreferencesWindow *pwindow,
382 PerformancePrefs *subwindow,
385 : BC_TumbleTextBox(subwindow,
386 (int64_t)pwindow->thread->preferences->brender_fragment,
393 this->pwindow = pwindow;
395 int PrefsBRenderFragment::handle_event()
397 pwindow->thread->preferences->brender_fragment = atol(get_text());
411 CICacheSize::CICacheSize(int x,
413 PreferencesWindow *pwindow,
414 PerformancePrefs *subwindow)
415 : BC_TumbleTextBox(subwindow,
416 (int64_t)pwindow->thread->preferences->cache_size / 0x100000,
417 (int64_t)MIN_CACHE_SIZE / 0x100000,
418 (int64_t)MAX_CACHE_SIZE / 0x100000,
423 this->pwindow = pwindow;
427 int CICacheSize::handle_event()
430 result = (int64_t)atol(get_text()) * 0x100000;
431 CLAMP(result, MIN_CACHE_SIZE, MAX_CACHE_SIZE);
432 pwindow->thread->preferences->cache_size = result;
437 PrefsRenderPreroll::PrefsRenderPreroll(PreferencesWindow *pwindow,
438 PerformancePrefs *subwindow,
441 : BC_TumbleTextBox(subwindow,
442 (float)pwindow->thread->preferences->render_preroll,
449 this->pwindow = pwindow;
452 PrefsRenderPreroll::~PrefsRenderPreroll()
455 int PrefsRenderPreroll::handle_event()
457 pwindow->thread->preferences->render_preroll = atof(get_text());
462 PrefsBRenderPreroll::PrefsBRenderPreroll(PreferencesWindow *pwindow,
463 PerformancePrefs *subwindow,
466 : BC_TumbleTextBox(subwindow,
467 (int64_t)pwindow->thread->preferences->brender_preroll,
474 this->pwindow = pwindow;
476 int PrefsBRenderPreroll::handle_event()
478 pwindow->thread->preferences->brender_preroll = atol(get_text());
492 PrefsRenderFarm::PrefsRenderFarm(PreferencesWindow *pwindow, int x, int y)
495 pwindow->thread->preferences->use_renderfarm,
496 _("Use render farm"))
498 this->pwindow = pwindow;
500 PrefsRenderFarm::~PrefsRenderFarm()
503 int PrefsRenderFarm::handle_event()
505 pwindow->thread->preferences->use_renderfarm = get_value();
512 PrefsForceUniprocessor::PrefsForceUniprocessor(PreferencesWindow *pwindow, int x, int y)
515 pwindow->thread->preferences->force_uniprocessor,
516 _("Force single processor use"))
518 this->pwindow = pwindow;
520 PrefsForceUniprocessor::~PrefsForceUniprocessor()
523 int PrefsForceUniprocessor::handle_event()
525 pwindow->thread->preferences->force_uniprocessor = get_value();
529 PrefsTrapSigSEGV::PrefsTrapSigSEGV(PerformancePrefs *perf_prefs, int x, int y)
531 perf_prefs->pwindow->thread->preferences->trap_sigsegv,
534 this->perf_prefs = perf_prefs;
536 PrefsTrapSigSEGV::~PrefsTrapSigSEGV()
539 int PrefsTrapSigSEGV::handle_event()
541 perf_prefs->pwindow->thread->preferences->trap_sigsegv = get_value();
545 PrefsTrapSigINTR::PrefsTrapSigINTR(PerformancePrefs *perf_prefs, int x, int y)
547 perf_prefs->pwindow->thread->preferences->trap_sigintr,
550 this->perf_prefs = perf_prefs;
552 PrefsTrapSigINTR::~PrefsTrapSigINTR()
555 int PrefsTrapSigINTR::handle_event()
557 perf_prefs->pwindow->thread->preferences->trap_sigintr = get_value();
562 PrefsFFMPEGEarlyProbe::PrefsFFMPEGEarlyProbe(PerformancePrefs *perf_prefs, int x, int y)
564 perf_prefs->pwindow->thread->preferences->ffmpeg_early_probe,
565 _("On file open, ffmpeg probes early"))
567 this->perf_prefs = perf_prefs;
569 PrefsFFMPEGEarlyProbe::~PrefsFFMPEGEarlyProbe()
573 int PrefsFFMPEGEarlyProbe::handle_event()
575 perf_prefs->pwindow->thread->preferences->ffmpeg_early_probe = get_value();
580 PrefsFFMPEGMarkerIndecies::PrefsFFMPEGMarkerIndecies(PerformancePrefs *perf_prefs, int x, int y)
582 perf_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes,
583 _("build ffmpeg marker indexes"))
585 this->perf_prefs = perf_prefs;
587 PrefsFFMPEGMarkerIndecies::~PrefsFFMPEGMarkerIndecies()
591 int PrefsFFMPEGMarkerIndecies::handle_event()
593 perf_prefs->pwindow->thread->preferences->ffmpeg_marker_indexes = get_value();
602 PrefsRenderFarmConsolidate::PrefsRenderFarmConsolidate(PreferencesWindow *pwindow, int x, int y)
605 pwindow->thread->preferences->renderfarm_consolidate,
606 _("Consolidate output files on completion"))
608 this->pwindow = pwindow;
610 PrefsRenderFarmConsolidate::~PrefsRenderFarmConsolidate()
613 int PrefsRenderFarmConsolidate::handle_event()
615 pwindow->thread->preferences->renderfarm_consolidate = get_value();
623 PrefsRenderFarmPort::PrefsRenderFarmPort(PreferencesWindow *pwindow,
624 PerformancePrefs *subwindow,
627 : BC_TumbleTextBox(subwindow,
628 (int64_t)pwindow->thread->preferences->renderfarm_port,
635 this->pwindow = pwindow;
638 PrefsRenderFarmPort::~PrefsRenderFarmPort()
642 int PrefsRenderFarmPort::handle_event()
644 pwindow->thread->preferences->renderfarm_port = atol(get_text());
650 PrefsRenderFarmNodes::PrefsRenderFarmNodes(PreferencesWindow *pwindow,
651 PerformancePrefs *subwindow,
658 LISTBOX_TEXT, // Display text list or icons
664 this->subwindow = subwindow;
665 this->pwindow = pwindow;
667 PrefsRenderFarmNodes::~PrefsRenderFarmNodes()
671 int PrefsRenderFarmNodes::column_resize_event()
673 for(int i = 0; i < 3; i++)
674 widths[i] = get_column_width(i);
678 int PrefsRenderFarmNodes::handle_event()
681 if(get_selection_number(0, 0) >= 0)
683 subwindow->hot_node = get_selection_number(1, 0);
684 subwindow->edit_node->update(get_selection(1, 0)->get_text());
685 subwindow->edit_port->update(get_selection(2, 0)->get_text());
686 if(get_cursor_x() < widths[0])
688 pwindow->thread->preferences->renderfarm_enabled.values[subwindow->hot_node] =
689 !pwindow->thread->preferences->renderfarm_enabled.values[subwindow->hot_node];
690 subwindow->generate_node_list();
691 subwindow->update_node_list();
696 subwindow->hot_node = -1;
697 subwindow->edit_node->update("");
702 int PrefsRenderFarmNodes::selection_changed()
714 PrefsRenderFarmEditNode::PrefsRenderFarmEditNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
715 : BC_TextBox(x, y, 240, 1, "")
717 this->pwindow = pwindow;
718 this->subwindow = subwindow;
721 PrefsRenderFarmEditNode::~PrefsRenderFarmEditNode()
725 int PrefsRenderFarmEditNode::handle_event()
735 PrefsRenderFarmNewNode::PrefsRenderFarmNewNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
736 : BC_GenericButton(x, y, _("Add Node"))
738 this->pwindow = pwindow;
739 this->subwindow = subwindow;
741 PrefsRenderFarmNewNode::~PrefsRenderFarmNewNode()
744 int PrefsRenderFarmNewNode::handle_event()
746 pwindow->thread->preferences->add_node(subwindow->edit_node->get_text(),
747 pwindow->thread->preferences->renderfarm_port,
750 pwindow->thread->preferences->reset_rates();
751 subwindow->generate_node_list();
752 subwindow->update_node_list();
753 subwindow->hot_node = -1;
763 PrefsRenderFarmReplaceNode::PrefsRenderFarmReplaceNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
764 : BC_GenericButton(x, y, _("Apply Changes"))
766 this->pwindow = pwindow;
767 this->subwindow = subwindow;
769 PrefsRenderFarmReplaceNode::~PrefsRenderFarmReplaceNode()
772 int PrefsRenderFarmReplaceNode::handle_event()
774 if(subwindow->hot_node >= 0)
776 pwindow->thread->preferences->edit_node(subwindow->hot_node,
777 subwindow->edit_node->get_text(),
778 pwindow->thread->preferences->renderfarm_port,
779 pwindow->thread->preferences->renderfarm_enabled.values[subwindow->hot_node]);
780 subwindow->generate_node_list();
781 subwindow->update_node_list();
790 PrefsRenderFarmDelNode::PrefsRenderFarmDelNode(PreferencesWindow *pwindow, PerformancePrefs *subwindow, int x, int y)
791 : BC_GenericButton(x, y, _("Delete Node"))
793 this->pwindow = pwindow;
794 this->subwindow = subwindow;
796 PrefsRenderFarmDelNode::~PrefsRenderFarmDelNode()
799 int PrefsRenderFarmDelNode::handle_event()
801 if( subwindow->hot_node >= 0 ) {
802 pwindow->thread->preferences->delete_node(subwindow->hot_node);
804 subwindow->generate_node_list();
805 subwindow->update_node_list();
806 subwindow->hot_node = -1;
815 PrefsRenderFarmSortNodes::PrefsRenderFarmSortNodes(PreferencesWindow *pwindow,
816 PerformancePrefs *subwindow,
819 : BC_GenericButton(x, y, _("Sort nodes"))
821 this->pwindow = pwindow;
822 this->subwindow = subwindow;
825 PrefsRenderFarmSortNodes::~PrefsRenderFarmSortNodes()
829 int PrefsRenderFarmSortNodes::handle_event()
831 pwindow->thread->preferences->sort_nodes();
832 subwindow->generate_node_list();
833 subwindow->update_node_list();
834 subwindow->hot_node = -1;
842 PrefsRenderFarmReset::PrefsRenderFarmReset(PreferencesWindow *pwindow,
843 PerformancePrefs *subwindow,
846 : BC_GenericButton(x, y, _("Reset rates"))
848 this->pwindow = pwindow;
849 this->subwindow = subwindow;
852 int PrefsRenderFarmReset::handle_event()
854 pwindow->thread->preferences->reset_rates();
855 subwindow->generate_node_list();
856 subwindow->update_node_list();
858 char string[BCTEXTLEN];
860 MASTER_NODE_FRAMERATE_TEXT,
861 pwindow->thread->preferences->local_rate);
862 subwindow->master_rate->update(string);
863 subwindow->hot_node = -1;
871 PrefsProjectSMP::PrefsProjectSMP(PreferencesWindow *pwindow,
872 PerformancePrefs *subwindow, int x, int y)
873 : BC_TumbleTextBox(subwindow,
874 (int64_t)pwindow->thread->preferences->project_smp,
875 (int64_t)1, (int64_t)100, x, y, 100)
877 this->pwindow = pwindow;
879 PrefsProjectSMP::~PrefsProjectSMP()
882 int PrefsProjectSMP::handle_event()
884 pwindow->thread->preferences->project_smp = atol(get_text());
892 PrefsRenderFarmJobs::PrefsRenderFarmJobs(PreferencesWindow *pwindow,
893 PerformancePrefs *subwindow,
896 : BC_TumbleTextBox(subwindow,
897 (int64_t)pwindow->thread->preferences->renderfarm_job_count,
904 this->pwindow = pwindow;
906 PrefsRenderFarmJobs::~PrefsRenderFarmJobs()
909 int PrefsRenderFarmJobs::handle_event()
911 pwindow->thread->preferences->renderfarm_job_count = atol(get_text());
917 PrefsRenderFarmMountpoint::PrefsRenderFarmMountpoint(PreferencesWindow *pwindow,
918 PerformancePrefs *subwindow,
925 pwindow->thread->preferences->renderfarm_mountpoint)
927 this->pwindow = pwindow;
928 this->subwindow = subwindow;
930 PrefsRenderFarmMountpoint::~PrefsRenderFarmMountpoint()
933 int PrefsRenderFarmMountpoint::handle_event()
935 strcpy(pwindow->thread->preferences->renderfarm_mountpoint, get_text());
942 PrefsRenderFarmVFS::PrefsRenderFarmVFS(PreferencesWindow *pwindow,
943 PerformancePrefs *subwindow, int x, int y)
944 : BC_CheckBox(x, y, pwindow->thread->preferences->renderfarm_vfs,
945 _("Use virtual filesystem"))
947 this->pwindow = pwindow;
948 this->subwindow = subwindow;
951 int PrefsRenderFarmVFS::handle_event()
953 pwindow->thread->preferences->renderfarm_vfs = get_value();
958 PrefsYUV420P_DVDlace::PrefsYUV420P_DVDlace(PreferencesWindow *pwindow,
959 PerformancePrefs *subwindow, int x, int y)
960 : BC_CheckBox(x, y, pwindow->thread->preferences->dvd_yuv420p_interlace,
961 _("Use yuv420p dvd interlace format"))
963 this->pwindow = pwindow;
964 this->subwindow = subwindow;
967 int PrefsYUV420P_DVDlace::handle_event()
969 pwindow->thread->preferences->dvd_yuv420p_interlace = get_value();