1 #include "adeviceprefs.h"
2 #include "audioconfig.h"
3 #include "audiodevice.inc"
8 #include "edlsession.h"
11 #include "overlayframe.inc"
12 #include "playbackprefs.h"
13 #include "preferences.h"
15 #include "vdeviceprefs.h"
16 #include "videodevice.inc"
20 PlaybackPrefs::PlaybackPrefs(MWindow *mwindow, PreferencesWindow *pwindow)
21 : PreferencesDialog(mwindow, pwindow)
26 PlaybackPrefs::~PlaybackPrefs()
32 int PlaybackPrefs::create_objects()
35 char string[BCTEXTLEN];
36 BC_PopupTextBox *popup;
37 BC_WindowBase *window;
38 BC_Resources *resources = BC_WindowBase::get_resources();
40 playback_config = pwindow->thread->edl->session->playback_config;
42 x = mwindow->theme->preferencesoptions_x;
43 y = mwindow->theme->preferencesoptions_y;
46 add_subwindow(new BC_Title(x,
53 y += get_text_height(LARGEFONT) + 5;
56 BC_Title *title1, *title2;
57 add_subwindow(title2 = new BC_Title(x, y, _("Playback buffer size:"), MEDIUMFONT));
58 x2 = MAX(title2->get_w(), title2->get_w()) + 10;
61 sprintf(string, "%d", playback_config->aconfig->fragment_size);
62 PlaybackModuleFragment *menu;
63 add_subwindow(menu = new PlaybackModuleFragment(x2,
68 menu->add_item(new BC_MenuItem("2048"));
69 menu->add_item(new BC_MenuItem("4096"));
70 menu->add_item(new BC_MenuItem("8192"));
71 menu->add_item(new BC_MenuItem("16384"));
72 menu->add_item(new BC_MenuItem("32768"));
73 menu->add_item(new BC_MenuItem("65536"));
74 menu->add_item(new BC_MenuItem("131072"));
75 menu->add_item(new BC_MenuItem("262144"));
78 y += menu->get_h() + 5;
80 add_subwindow(title1 = new BC_Title(x2, y, _("Audio offset (sec):")));
81 x2 += title1->get_w() + 5;
82 PlaybackAudioOffset *audio_offset = new PlaybackAudioOffset(pwindow,
86 audio_offset->create_objects();
87 y += audio_offset->get_h() + 5;
90 add_subwindow(new PlaybackViewFollows(pwindow, pwindow->thread->edl->session->view_follows_playback, y));
92 add_subwindow(new PlaybackSoftwareTimer(pwindow, pwindow->thread->edl->session->playback_software_position, y));
94 add_subwindow(new PlaybackRealTime(pwindow, pwindow->thread->edl->session->real_time_playback, y));
96 add_subwindow(new BC_Title(x, y, _("Audio Driver:")));
97 audio_device = new ADevicePrefs(x + 100,
101 playback_config->aconfig,
104 audio_device->initialize();
111 y += audio_device->get_h();
114 add_subwindow(new BC_Bar(5, y, get_w() - 10));
118 add_subwindow(new BC_Title(x, y, _("Video Out"), LARGEFONT));
122 add_subwindow(window = new VideoEveryFrame(pwindow, this, x, y));
124 add_subwindow(new BC_Title(x + 200, y + 5, _("Framerate achieved:")));
125 add_subwindow(framerate_title = new BC_Title(x + 350, y + 5, _("--"), MEDIUMFONT, RED));
127 y += window->get_h() + 5;
129 add_subwindow(asynchronous = new VideoAsynchronous(pwindow, x, y));
130 y += asynchronous->get_h() + 10;
133 add_subwindow(new BC_Title(x, y, _("Scaling equation:")));
135 add_subwindow(nearest_neighbor = new PlaybackNearest(pwindow,
137 pwindow->thread->edl->session->interpolation_type == NEAREST_NEIGHBOR,
141 add_subwindow(cubic_linear = new PlaybackBicubicBilinear(pwindow,
143 pwindow->thread->edl->session->interpolation_type == CUBIC_LINEAR,
147 add_subwindow(linear_linear = new PlaybackBilinearBilinear(pwindow,
149 pwindow->thread->edl->session->interpolation_type == LINEAR_LINEAR,
155 add_subwindow(new BC_Title(x, y, _("Preload buffer for Quicktime:"), MEDIUMFONT));
156 sprintf(string, "%d", pwindow->thread->edl->session->playback_preload);
157 PlaybackPreload *preload;
158 add_subwindow(preload = new PlaybackPreload(x + 210, y, pwindow, this, string));
160 y += preload->get_h() + 5;
161 add_subwindow(title1 = new BC_Title(x, y, _("DVD Subtitle to display:")));
162 PlaybackSubtitleNumber *subtitle_number;
163 subtitle_number = new PlaybackSubtitleNumber(x + title1->get_w() + 10,
167 subtitle_number->create_objects();
169 PlaybackSubtitle *subtitle_toggle;
170 add_subwindow(subtitle_toggle = new PlaybackSubtitle(
171 x + title1->get_w() + 10 + subtitle_number->get_w() + 10,
175 y += subtitle_number->get_h();
178 add_subwindow(interpolate_raw = new PlaybackInterpolateRaw(
183 y += interpolate_raw->get_h();
185 add_subwindow(white_balance_raw = new PlaybackWhiteBalanceRaw(
190 y += white_balance_raw->get_h() + 10;
191 if(!pwindow->thread->edl->session->interpolate_raw)
192 white_balance_raw->disable();
197 // add_subwindow(new PlaybackDeblock(pwindow, 10, y));
199 add_subwindow(new BC_Title(x, y, _("Timecode offset:"), MEDIUMFONT, BLACK));
200 sprintf(string, "%d", pwindow->thread->edl->session->timecode_offset[3]);
201 add_subwindow(new TimecodeOffset(x + 120, y, pwindow, this, string, 3));
202 add_subwindow(new BC_Title(x + 152, y, _(":"), MEDIUMFONT, BLACK));
203 sprintf(string, "%d", pwindow->thread->edl->session->timecode_offset[2]);
204 add_subwindow(new TimecodeOffset(x + 160, y, pwindow, this, string, 2));
205 add_subwindow(new BC_Title(x + 192, y, _(":"), MEDIUMFONT, BLACK));
206 sprintf(string, "%d", pwindow->thread->edl->session->timecode_offset[1]);
207 add_subwindow(new TimecodeOffset(x + 200, y, pwindow, this, string, 1));
208 add_subwindow(new BC_Title(x + 232, y, _(":"), MEDIUMFONT, BLACK));
209 sprintf(string, "%d", pwindow->thread->edl->session->timecode_offset[0]);
210 add_subwindow(new TimecodeOffset(x + 240, y, pwindow, this, string, 0));
213 add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
214 video_device = new VDevicePrefs(x + vdevice_title->get_w() + 10,
218 playback_config->vconfig,
221 video_device->initialize();
229 void PlaybackPrefs::update(int interpolation)
231 pwindow->thread->edl->session->interpolation_type = interpolation;
232 nearest_neighbor->update(interpolation == NEAREST_NEIGHBOR);
233 // cubic_cubic->update(interpolation == CUBIC_CUBIC);
234 cubic_linear->update(interpolation == CUBIC_LINEAR);
235 linear_linear->update(interpolation == LINEAR_LINEAR);
239 int PlaybackPrefs::get_buffer_bytes()
241 // return pwindow->thread->edl->aconfig->oss_out_bits / 8 * pwindow->thread->preferences->aconfig->oss_out_channels * pwindow->thread->preferences->playback_buffer;
244 int PlaybackPrefs::draw_framerate()
246 //printf("PlaybackPrefs::draw_framerate 1 %f\n", pwindow->thread->edl->session->actual_frame_rate);
247 char string[BCTEXTLEN];
248 sprintf(string, "%.4f", pwindow->thread->edl->session->actual_frame_rate);
249 framerate_title->update(string);
255 PlaybackAudioOffset::PlaybackAudioOffset(PreferencesWindow *pwindow,
256 PlaybackPrefs *playback,
259 : BC_TumbleTextBox(playback,
260 playback->playback_config->aconfig->audio_offset,
267 this->pwindow = pwindow;
268 this->playback = playback;
273 int PlaybackAudioOffset::handle_event()
275 playback->playback_config->aconfig->audio_offset = atof(get_text());
282 PlaybackModuleFragment::PlaybackModuleFragment(int x,
284 PreferencesWindow *pwindow,
285 PlaybackPrefs *playback,
293 this->pwindow = pwindow;
294 this->playback = playback;
297 int PlaybackModuleFragment::handle_event()
299 playback->playback_config->aconfig->fragment_size = atol(get_text());
306 PlaybackViewFollows::PlaybackViewFollows(PreferencesWindow *pwindow, int value, int y)
307 : BC_CheckBox(10, y, value, _("View follows playback"))
309 this->pwindow = pwindow;
312 int PlaybackViewFollows::handle_event()
314 pwindow->thread->edl->session->view_follows_playback = get_value();
321 PlaybackSoftwareTimer::PlaybackSoftwareTimer(PreferencesWindow *pwindow, int value, int y)
322 : BC_CheckBox(10, y, value, _("Use software for positioning information"))
324 this->pwindow = pwindow;
327 int PlaybackSoftwareTimer::handle_event()
329 pwindow->thread->edl->session->playback_software_position = get_value();
336 PlaybackRealTime::PlaybackRealTime(PreferencesWindow *pwindow, int value, int y)
337 : BC_CheckBox(10, y, value, _("Audio playback in real time priority (root only)"))
339 this->pwindow = pwindow;
342 int PlaybackRealTime::handle_event()
344 pwindow->thread->edl->session->real_time_playback = get_value();
354 PlaybackNearest::PlaybackNearest(PreferencesWindow *pwindow, PlaybackPrefs *prefs, int value, int x, int y)
355 : BC_Radial(x, y, value, _("Nearest neighbor enlarge and reduce"))
357 this->pwindow = pwindow;
360 int PlaybackNearest::handle_event()
362 prefs->update(NEAREST_NEIGHBOR);
370 PlaybackBicubicBicubic::PlaybackBicubicBicubic(PreferencesWindow *pwindow, PlaybackPrefs *prefs, int value, int x, int y)
371 : BC_Radial(x, y, value, _("Bicubic enlarge and reduce"))
373 this->pwindow = pwindow;
376 int PlaybackBicubicBicubic::handle_event()
378 prefs->update(CUBIC_CUBIC);
385 PlaybackBicubicBilinear::PlaybackBicubicBilinear(PreferencesWindow *pwindow, PlaybackPrefs *prefs, int value, int x, int y)
386 : BC_Radial(x, y, value, _("Bicubic enlarge and bilinear reduce"))
388 this->pwindow = pwindow;
391 int PlaybackBicubicBilinear::handle_event()
393 prefs->update(CUBIC_LINEAR);
398 PlaybackBilinearBilinear::PlaybackBilinearBilinear(PreferencesWindow *pwindow,
399 PlaybackPrefs *prefs,
403 : BC_Radial(x, y, value, _("Bilinear enlarge and bilinear reduce"))
405 this->pwindow = pwindow;
408 int PlaybackBilinearBilinear::handle_event()
410 prefs->update(LINEAR_LINEAR);
415 PlaybackPreload::PlaybackPreload(int x,
417 PreferencesWindow *pwindow,
418 PlaybackPrefs *playback,
420 : BC_TextBox(x, y, 100, 1, text)
422 this->pwindow = pwindow;
423 this->playback = playback;
426 int PlaybackPreload::handle_event()
428 pwindow->thread->edl->session->playback_preload = atol(get_text());
433 PlaybackInterpolateRaw::PlaybackInterpolateRaw(
436 PreferencesWindow *pwindow,
437 PlaybackPrefs *playback)
440 pwindow->thread->edl->session->interpolate_raw,
441 _("Interpolate CR2 images"))
443 this->pwindow = pwindow;
444 this->playback = playback;
447 int PlaybackInterpolateRaw::handle_event()
449 pwindow->thread->edl->session->interpolate_raw = get_value();
450 if(!pwindow->thread->edl->session->interpolate_raw)
452 playback->white_balance_raw->update(0, 0);
453 playback->white_balance_raw->disable();
457 playback->white_balance_raw->update(pwindow->thread->edl->session->white_balance_raw, 0);
458 playback->white_balance_raw->enable();
466 PlaybackWhiteBalanceRaw::PlaybackWhiteBalanceRaw(
469 PreferencesWindow *pwindow,
470 PlaybackPrefs *playback)
473 pwindow->thread->edl->session->interpolate_raw &&
474 pwindow->thread->edl->session->white_balance_raw,
475 _("White balance CR2 images"))
477 this->pwindow = pwindow;
478 this->playback = playback;
479 if(!pwindow->thread->edl->session->interpolate_raw) disable();
482 int PlaybackWhiteBalanceRaw::handle_event()
484 pwindow->thread->edl->session->white_balance_raw = get_value();
493 VideoAsynchronous::VideoAsynchronous(PreferencesWindow *pwindow, int x, int y)
496 pwindow->thread->edl->session->video_every_frame &&
497 pwindow->thread->edl->session->video_asynchronous,
498 _("Decode frames asynchronously"))
500 this->pwindow = pwindow;
501 if(!pwindow->thread->edl->session->video_every_frame)
505 int VideoAsynchronous::handle_event()
507 pwindow->thread->edl->session->video_asynchronous = get_value();
514 VideoEveryFrame::VideoEveryFrame(PreferencesWindow *pwindow,
515 PlaybackPrefs *playback_prefs,
518 : BC_CheckBox(x, y, pwindow->thread->edl->session->video_every_frame, _("Play every frame"))
520 this->pwindow = pwindow;
521 this->playback_prefs = playback_prefs;
524 int VideoEveryFrame::handle_event()
526 pwindow->thread->edl->session->video_every_frame = get_value();
527 if(!pwindow->thread->edl->session->video_every_frame)
529 playback_prefs->asynchronous->update(0, 0);
530 playback_prefs->asynchronous->disable();
534 playback_prefs->asynchronous->update(pwindow->thread->edl->session->video_asynchronous, 0);
535 playback_prefs->asynchronous->enable();
546 PlaybackSubtitle::PlaybackSubtitle(int x,
548 PreferencesWindow *pwindow,
549 PlaybackPrefs *playback)
552 pwindow->thread->edl->session->decode_subtitles,
553 _("Enable subtitles"))
555 this->pwindow = pwindow;
556 this->playback = playback;
559 int PlaybackSubtitle::handle_event()
561 pwindow->thread->edl->session->decode_subtitles = get_value();
574 PlaybackSubtitleNumber::PlaybackSubtitleNumber(int x,
576 PreferencesWindow *pwindow,
577 PlaybackPrefs *playback)
578 : BC_TumbleTextBox(playback,
579 pwindow->thread->edl->session->subtitle_number,
586 this->pwindow = pwindow;
587 this->playback = playback;
590 int PlaybackSubtitleNumber::handle_event()
592 pwindow->thread->edl->session->subtitle_number = atoi(get_text());
599 TimecodeOffset::TimecodeOffset(int x, int y, PreferencesWindow *pwindow,
600 PlaybackPrefs *playback, char *text, int unit)
601 : BC_TextBox(x, y, 30, 1, text)
603 this->pwindow = pwindow;
604 this->playback = playback;
608 int TimecodeOffset::handle_event()
610 pwindow->thread->edl->session->timecode_offset[unit] = atol(get_text());