4 * Copyright (C) 2010 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 "adeviceprefs.h"
23 #include "audioconfig.h"
24 #include "audiodevice.inc"
25 #include "bcsignals.h"
29 #include "edlsession.h"
32 #include "mainsession.h"
34 #include "overlayframe.inc"
35 #include "playbackprefs.h"
36 #include "preferences.h"
38 #include "vdeviceprefs.h"
39 #include "videodevice.inc"
43 PlaybackPrefs::PlaybackPrefs(MWindow *mwindow, PreferencesWindow *pwindow, int config_number)
44 : PreferencesDialog(mwindow, pwindow)
46 this->config_number = config_number;
53 PlaybackPrefs::~PlaybackPrefs()
61 void PlaybackPrefs::create_objects()
64 char string[BCTEXTLEN];
65 BC_WindowBase *window;
68 playback_config = pwindow->thread->edl->session->playback_config;
70 x = mwindow->theme->preferencesoptions_x;
71 y = mwindow->theme->preferencesoptions_y;
72 //int margin = mwindow->theme->widget_border;
75 add_subwindow(new BC_Title(x,
81 y += get_text_height(LARGEFONT) + 5;
84 BC_Title *title1, *title2;
85 add_subwindow(title2 = new BC_Title(x, y, _("Playback buffer samples:"), MEDIUMFONT));
86 x2 = MAX(title2->get_w(), title2->get_w()) + 10;
89 sprintf(string, "%d", playback_config->aconfig->fragment_size);
90 PlaybackModuleFragment *menu;
91 add_subwindow(menu = new PlaybackModuleFragment(x2,
96 menu->add_item(new BC_MenuItem("1024"));
97 menu->add_item(new BC_MenuItem("2048"));
98 menu->add_item(new BC_MenuItem("4096"));
99 menu->add_item(new BC_MenuItem("8192"));
100 menu->add_item(new BC_MenuItem("16384"));
101 menu->add_item(new BC_MenuItem("32768"));
102 menu->add_item(new BC_MenuItem("65536"));
103 menu->add_item(new BC_MenuItem("131072"));
104 menu->add_item(new BC_MenuItem("262144"));
106 y += menu->get_h() + 5;
108 add_subwindow(title1 = new BC_Title(x2, y, _("Audio offset (sec):")));
109 x2 += title1->get_w() + 5;
110 audio_offset = new PlaybackAudioOffset(pwindow, this, x2, y);
111 audio_offset->create_objects();
112 y += audio_offset->get_h() + 5;
115 add_subwindow(new PlaybackViewFollows(pwindow,
116 pwindow->thread->edl->session->view_follows_playback, y));
118 add_subwindow(new PlaybackSoftwareTimer(pwindow,
119 pwindow->thread->edl->session->playback_software_position, y));
121 add_subwindow(new PlaybackRealTime(pwindow,
122 pwindow->thread->edl->session->real_time_playback, y));
124 PlaybackMap51_2 *map51_2 = new PlaybackMap51_2(pwindow, this,
125 playback_config->aconfig->map51_2, y);
126 add_subwindow(map51_2);
127 x2 = map51_2->get_x() + map51_2->get_w() + 15;
128 y2 = y + BC_TextBox::calculate_h(this,MEDIUMFONT,1,1) - get_text_height(MEDIUMFONT);
130 add_subwindow(title2 = new BC_Title(x2, y2, _("Gain:")));
131 x2 += title2->get_w() + 8;
132 play_gain = new PlaybackGain(x2, y, pwindow, this);
133 play_gain->create_objects();
135 add_subwindow(new BC_Title(x, y, _("Audio Driver:")));
136 audio_device = new ADevicePrefs(x + 100, y, pwindow,
137 this, playback_config->aconfig, 0, MODEPLAY);
138 audio_device->initialize(0);
145 y += audio_device->get_h();
148 add_subwindow(new BC_Bar(5, y, get_w() - 10));
152 add_subwindow(new BC_Title(x, y, _("Video Out"), LARGEFONT));
156 add_subwindow(window = new VideoEveryFrame(pwindow, this, x, y));
158 add_subwindow(new BC_Title(x + 200, y + 5, _("Framerate achieved:")));
159 add_subwindow(framerate_title = new BC_Title(x + 350, y + 5, "--", MEDIUMFONT, RED));
161 y += window->get_h() + 5;
163 add_subwindow(asynchronous = new VideoAsynchronous(pwindow, x, y));
164 y += asynchronous->get_h() + 10;
167 add_subwindow(title1 = new BC_Title(x, y, _("Scaling equation: Enlarge / Reduce ")));
168 VScalingEquation *vscaling_equation =
169 new VScalingEquation(x + title1->get_w() + 10, y,
170 &pwindow->thread->edl->session->interpolation_type);
171 add_subwindow(vscaling_equation);
172 vscaling_equation->create_objects();
175 add_subwindow(new BC_Title(x, y, _("Preload buffer for Quicktime:"), MEDIUMFONT));
176 sprintf(string, "" _LD "", pwindow->thread->edl->session->playback_preload);
177 PlaybackPreload *preload;
178 add_subwindow(preload = new PlaybackPreload(x + 210, y, pwindow, this, string));
180 y += preload->get_h() + 5;
181 add_subwindow(title1 = new BC_Title(x, y, _("DVD Subtitle to display:")));
182 PlaybackSubtitleNumber *subtitle_number;
183 subtitle_number = new PlaybackSubtitleNumber(x + title1->get_w() + 10,
187 subtitle_number->create_objects();
189 x2 = x + title1->get_w() + 10 + subtitle_number->get_w() + 30;
190 PlaybackSubtitle *subtitle_toggle;
191 add_subwindow(subtitle_toggle = new PlaybackSubtitle(x2, y, pwindow, this));
192 y += subtitle_toggle->get_h();
194 PlaybackLabelCells *label_cells_toggle;
195 add_subwindow(label_cells_toggle = new PlaybackLabelCells(x2, y, pwindow, this));
196 y2 = y + label_cells_toggle->get_h();
198 add_subwindow(title1=new BC_Title(x2, y2, _("TOC Program No:"), MEDIUMFONT));
199 PlaybackProgramNumber *program_number;
200 program_number = new PlaybackProgramNumber(
201 x2 + title1->get_w() + 10, y2, pwindow, this);
202 program_number->create_objects();
204 add_subwindow(interpolate_raw = new PlaybackInterpolateRaw( x, y,
206 y += interpolate_raw->get_h();
208 add_subwindow(white_balance_raw = new PlaybackWhiteBalanceRaw( x, y,
210 y += white_balance_raw->get_h() + 10;
211 if(!pwindow->thread->edl->session->interpolate_raw)
212 white_balance_raw->disable();
217 // add_subwindow(new PlaybackDeblock(pwindow, 10, y));
219 add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
220 video_device = new VDevicePrefs(x + vdevice_title->get_w() + 10, y,
221 pwindow, this, playback_config->vconfig, 0, MODEPLAY);
222 video_device->initialize(0);
228 int PlaybackPrefs::draw_framerate(int flush)
230 //printf("PlaybackPrefs::draw_framerate 1 %f\n", mwindow->session->actual_frame_rate);
231 char string[BCTEXTLEN];
232 sprintf(string, "%.4f", mwindow->session->actual_frame_rate);
233 framerate_title->update(string, flush);
239 PlaybackAudioOffset::PlaybackAudioOffset(PreferencesWindow *pwindow,
240 PlaybackPrefs *playback, int x, int y)
241 : BC_TumbleTextBox(playback, playback->playback_config->aconfig->audio_offset,
242 -10.0, 10.0, x, y, 100)
244 this->pwindow = pwindow;
245 this->playback = playback;
250 int PlaybackAudioOffset::handle_event()
252 playback->playback_config->aconfig->audio_offset = atof(get_text());
259 PlaybackModuleFragment::PlaybackModuleFragment(int x, int y,
260 PreferencesWindow *pwindow, PlaybackPrefs *playback, char *text)
261 : BC_PopupMenu(x, y, 100, text, 1)
263 this->pwindow = pwindow;
264 this->playback = playback;
267 int PlaybackModuleFragment::handle_event()
269 playback->playback_config->aconfig->fragment_size = atol(get_text());
274 PlaybackViewFollows::PlaybackViewFollows(PreferencesWindow *pwindow, int value, int y)
275 : BC_CheckBox(10, y, value, _("View follows playback"))
277 this->pwindow = pwindow;
280 int PlaybackViewFollows::handle_event()
282 pwindow->thread->edl->session->view_follows_playback = get_value();
287 PlaybackSoftwareTimer::PlaybackSoftwareTimer(PreferencesWindow *pwindow, int value, int y)
288 : BC_CheckBox(10, y, value, _("Use software for positioning information"))
290 this->pwindow = pwindow;
293 int PlaybackSoftwareTimer::handle_event()
295 pwindow->thread->edl->session->playback_software_position = get_value();
300 PlaybackRealTime::PlaybackRealTime(PreferencesWindow *pwindow, int value, int y)
301 : BC_CheckBox(10, y, value, _("Audio playback in real time priority (root only)"))
303 this->pwindow = pwindow;
306 int PlaybackRealTime::handle_event()
308 pwindow->thread->edl->session->real_time_playback = get_value();
313 PlaybackMap51_2::PlaybackMap51_2(PreferencesWindow *pwindow,
314 PlaybackPrefs *playback_prefs, int value, int y)
315 : BC_CheckBox(10, y, value, _("Map 5.1->2"))
317 this->pwindow = pwindow;
318 this->playback_prefs = playback_prefs;
321 int PlaybackMap51_2::handle_event()
323 playback_prefs->playback_config->aconfig->map51_2 = get_value();
328 PlaybackPreload::PlaybackPreload(int x, int y,
329 PreferencesWindow *pwindow, PlaybackPrefs *playback, char *text)
330 : BC_TextBox(x, y, 100, 1, text)
332 this->pwindow = pwindow;
333 this->playback = playback;
336 int PlaybackPreload::handle_event()
338 pwindow->thread->edl->session->playback_preload = atol(get_text());
343 PlaybackInterpolateRaw::PlaybackInterpolateRaw( int x, int y,
344 PreferencesWindow *pwindow, PlaybackPrefs *playback)
347 pwindow->thread->edl->session->interpolate_raw,
348 _("Interpolate CR2 images"))
350 this->pwindow = pwindow;
351 this->playback = playback;
354 int PlaybackInterpolateRaw::handle_event()
356 pwindow->thread->edl->session->interpolate_raw = get_value();
357 if(!pwindow->thread->edl->session->interpolate_raw) {
358 playback->white_balance_raw->update(0, 0);
359 playback->white_balance_raw->disable();
362 playback->white_balance_raw->update(pwindow->thread->edl->session->white_balance_raw, 0);
363 playback->white_balance_raw->enable();
369 PlaybackWhiteBalanceRaw::PlaybackWhiteBalanceRaw( int x, int y,
370 PreferencesWindow *pwindow, PlaybackPrefs *playback)
373 pwindow->thread->edl->session->interpolate_raw &&
374 pwindow->thread->edl->session->white_balance_raw,
375 _("White balance CR2 images"))
377 this->pwindow = pwindow;
378 this->playback = playback;
379 if(!pwindow->thread->edl->session->interpolate_raw) disable();
382 int PlaybackWhiteBalanceRaw::handle_event()
384 pwindow->thread->edl->session->white_balance_raw = get_value();
389 VideoAsynchronous::VideoAsynchronous(PreferencesWindow *pwindow, int x, int y)
391 pwindow->thread->edl->session->video_every_frame &&
392 pwindow->thread->edl->session->video_asynchronous,
393 _("Decode frames asynchronously"))
395 this->pwindow = pwindow;
396 if(!pwindow->thread->edl->session->video_every_frame)
400 int VideoAsynchronous::handle_event()
402 pwindow->thread->edl->session->video_asynchronous = get_value();
407 VideoEveryFrame::VideoEveryFrame(PreferencesWindow *pwindow,
408 PlaybackPrefs *playback_prefs, int x, int y)
409 : BC_CheckBox(x, y, pwindow->thread->edl->session->video_every_frame, _("Play every frame"))
411 this->pwindow = pwindow;
412 this->playback_prefs = playback_prefs;
415 int VideoEveryFrame::handle_event()
417 pwindow->thread->edl->session->video_every_frame = get_value();
418 if(!pwindow->thread->edl->session->video_every_frame) {
419 playback_prefs->asynchronous->update(0, 0);
420 playback_prefs->asynchronous->disable();
423 playback_prefs->asynchronous->update(pwindow->thread->edl->session->video_asynchronous, 0);
424 playback_prefs->asynchronous->enable();
430 PlaybackSubtitle::PlaybackSubtitle(int x, int y,
431 PreferencesWindow *pwindow, PlaybackPrefs *playback)
433 pwindow->thread->edl->session->decode_subtitles,
434 _("Enable subtitles/captioning"))
436 this->pwindow = pwindow;
437 this->playback = playback;
440 int PlaybackSubtitle::handle_event()
442 pwindow->thread->edl->session->decode_subtitles = get_value();
447 PlaybackSubtitleNumber::PlaybackSubtitleNumber(int x, int y,
448 PreferencesWindow *pwindow, PlaybackPrefs *playback)
449 : BC_TumbleTextBox(playback, pwindow->thread->edl->session->subtitle_number,
452 this->pwindow = pwindow;
453 this->playback = playback;
456 int PlaybackSubtitleNumber::handle_event()
458 pwindow->thread->edl->session->subtitle_number = atoi(get_text());
463 PlaybackLabelCells::PlaybackLabelCells(int x, int y,
464 PreferencesWindow *pwindow, PlaybackPrefs *playback)
466 pwindow->thread->edl->session->label_cells,
469 this->pwindow = pwindow;
470 this->playback = playback;
473 int PlaybackLabelCells::handle_event()
475 pwindow->thread->edl->session->label_cells = get_value();
480 PlaybackProgramNumber::PlaybackProgramNumber(int x, int y,
481 PreferencesWindow *pwindow, PlaybackPrefs *playback)
482 : BC_TumbleTextBox(playback,
483 pwindow->thread->edl->session->program_no,
486 this->pwindow = pwindow;
487 this->playback = playback;
490 int PlaybackProgramNumber::handle_event()
492 pwindow->thread->edl->session->program_no = atoi(get_text());
496 PlaybackGain::PlaybackGain(int x, int y,
497 PreferencesWindow *pwindow, PlaybackPrefs *playback)
498 : BC_TumbleTextBox(playback,
499 pwindow->thread->edl->session->playback_config->aconfig->play_gain,
500 0.0001f, 10000.0f, x, y, 72)
502 this->pwindow = pwindow;
503 this->set_increment(0.1);
506 int PlaybackGain::handle_event()
508 pwindow->thread->edl->session->playback_config->
509 aconfig->play_gain = atof(get_text());