00001 #include "adeviceprefs.h"
00002 #include "audioconfig.h"
00003 #include "audiodevice.inc"
00004 #include "bcsignals.h"
00005 #include "clip.h"
00006 #include "bchash.h"
00007 #include "edl.h"
00008 #include "edlsession.h"
00009 #include "language.h"
00010 #include "mwindow.h"
00011 #include "overlayframe.inc"
00012 #include "playbackprefs.h"
00013 #include "preferences.h"
00014 #include "theme.h"
00015 #include "vdeviceprefs.h"
00016 #include "videodevice.inc"
00017
00018
00019
00020 PlaybackPrefs::PlaybackPrefs(MWindow *mwindow, PreferencesWindow *pwindow)
00021 : PreferencesDialog(mwindow, pwindow)
00022 {
00023 video_device = 0;
00024 }
00025
00026 PlaybackPrefs::~PlaybackPrefs()
00027 {
00028 delete audio_device;
00029 delete video_device;
00030 }
00031
00032 int PlaybackPrefs::create_objects()
00033 {
00034 int x, y, x2;
00035 char string[BCTEXTLEN];
00036 BC_PopupTextBox *popup;
00037 BC_WindowBase *window;
00038 BC_Resources *resources = BC_WindowBase::get_resources();
00039
00040 playback_config = pwindow->thread->edl->session->playback_config;
00041
00042 x = mwindow->theme->preferencesoptions_x;
00043 y = mwindow->theme->preferencesoptions_y;
00044
00045
00046 add_subwindow(new BC_Title(x,
00047 y,
00048 _("Audio Out"),
00049 LARGEFONT));
00050
00051 SET_TRACE
00052
00053 y += get_text_height(LARGEFONT) + 5;
00054
00055
00056 BC_Title *title1, *title2;
00057 add_subwindow(title2 = new BC_Title(x, y, _("Playback buffer size:"), MEDIUMFONT));
00058 x2 = MAX(title2->get_w(), title2->get_w()) + 10;
00059
00060 SET_TRACE
00061 sprintf(string, "%d", playback_config->aconfig->fragment_size);
00062 PlaybackModuleFragment *menu;
00063 add_subwindow(menu = new PlaybackModuleFragment(x2,
00064 y,
00065 pwindow,
00066 this,
00067 string));
00068 menu->add_item(new BC_MenuItem("2048"));
00069 menu->add_item(new BC_MenuItem("4096"));
00070 menu->add_item(new BC_MenuItem("8192"));
00071 menu->add_item(new BC_MenuItem("16384"));
00072 menu->add_item(new BC_MenuItem("32768"));
00073 menu->add_item(new BC_MenuItem("65536"));
00074 menu->add_item(new BC_MenuItem("131072"));
00075 menu->add_item(new BC_MenuItem("262144"));
00076
00077 SET_TRACE
00078 y += menu->get_h() + 5;
00079 x2 = x;
00080 add_subwindow(title1 = new BC_Title(x2, y, _("Audio offset (sec):")));
00081 x2 += title1->get_w() + 5;
00082 PlaybackAudioOffset *audio_offset = new PlaybackAudioOffset(pwindow,
00083 this,
00084 x2,
00085 y);
00086 audio_offset->create_objects();
00087 y += audio_offset->get_h() + 5;
00088
00089 SET_TRACE
00090 add_subwindow(new PlaybackViewFollows(pwindow, pwindow->thread->edl->session->view_follows_playback, y));
00091 y += 30;
00092 add_subwindow(new PlaybackSoftwareTimer(pwindow, pwindow->thread->edl->session->playback_software_position, y));
00093 y += 30;
00094 add_subwindow(new PlaybackRealTime(pwindow, pwindow->thread->edl->session->real_time_playback, y));
00095 y += 40;
00096 add_subwindow(new BC_Title(x, y, _("Audio Driver:")));
00097 audio_device = new ADevicePrefs(x + 100,
00098 y,
00099 pwindow,
00100 this,
00101 playback_config->aconfig,
00102 0,
00103 MODEPLAY);
00104 audio_device->initialize();
00105
00106 SET_TRACE
00107
00108
00109
00110
00111 y += audio_device->get_h();
00112
00113 SET_TRACE
00114 add_subwindow(new BC_Bar(5, y, get_w() - 10));
00115 y += 5;
00116
00117 SET_TRACE
00118 add_subwindow(new BC_Title(x, y, _("Video Out"), LARGEFONT));
00119 y += 30;
00120
00121 SET_TRACE
00122 add_subwindow(window = new VideoEveryFrame(pwindow, this, x, y));
00123
00124 add_subwindow(new BC_Title(x + 200, y + 5, _("Framerate achieved:")));
00125 add_subwindow(framerate_title = new BC_Title(x + 350, y + 5, _("--"), MEDIUMFONT, RED));
00126 draw_framerate();
00127 y += window->get_h() + 5;
00128
00129 add_subwindow(asynchronous = new VideoAsynchronous(pwindow, x, y));
00130 y += asynchronous->get_h() + 10;
00131
00132 SET_TRACE
00133 add_subwindow(new BC_Title(x, y, _("Scaling equation:")));
00134 y += 20;
00135 add_subwindow(nearest_neighbor = new PlaybackNearest(pwindow,
00136 this,
00137 pwindow->thread->edl->session->interpolation_type == NEAREST_NEIGHBOR,
00138 10,
00139 y));
00140 y += 20;
00141 add_subwindow(cubic_linear = new PlaybackBicubicBilinear(pwindow,
00142 this,
00143 pwindow->thread->edl->session->interpolation_type == CUBIC_LINEAR,
00144 10,
00145 y));
00146 y += 20;
00147 add_subwindow(linear_linear = new PlaybackBilinearBilinear(pwindow,
00148 this,
00149 pwindow->thread->edl->session->interpolation_type == LINEAR_LINEAR,
00150 10,
00151 y));
00152
00153 SET_TRACE
00154 y += 35;
00155 add_subwindow(new BC_Title(x, y, _("Preload buffer for Quicktime:"), MEDIUMFONT));
00156 sprintf(string, "%d", pwindow->thread->edl->session->playback_preload);
00157 PlaybackPreload *preload;
00158 add_subwindow(preload = new PlaybackPreload(x + 210, y, pwindow, this, string));
00159
00160 y += preload->get_h() + 5;
00161 add_subwindow(title1 = new BC_Title(x, y, _("DVD Subtitle to display:")));
00162 PlaybackSubtitleNumber *subtitle_number;
00163 subtitle_number = new PlaybackSubtitleNumber(x + title1->get_w() + 10,
00164 y,
00165 pwindow,
00166 this);
00167 subtitle_number->create_objects();
00168
00169 PlaybackSubtitle *subtitle_toggle;
00170 add_subwindow(subtitle_toggle = new PlaybackSubtitle(
00171 x + title1->get_w() + 10 + subtitle_number->get_w() + 10,
00172 y,
00173 pwindow,
00174 this));
00175 y += subtitle_number->get_h();
00176
00177
00178 add_subwindow(interpolate_raw = new PlaybackInterpolateRaw(
00179 x,
00180 y,
00181 pwindow,
00182 this));
00183 y += interpolate_raw->get_h();
00184
00185 add_subwindow(white_balance_raw = new PlaybackWhiteBalanceRaw(
00186 x,
00187 y,
00188 pwindow,
00189 this));
00190 y += white_balance_raw->get_h() + 10;
00191 if(!pwindow->thread->edl->session->interpolate_raw)
00192 white_balance_raw->disable();
00193
00194
00195 SET_TRACE
00196
00197
00198
00199 add_subwindow(new BC_Title(x, y, _("Timecode offset:"), MEDIUMFONT, BLACK));
00200 sprintf(string, "%d", pwindow->thread->edl->session->timecode_offset[3]);
00201 add_subwindow(new TimecodeOffset(x + 120, y, pwindow, this, string, 3));
00202 add_subwindow(new BC_Title(x + 152, y, _(":"), MEDIUMFONT, BLACK));
00203 sprintf(string, "%d", pwindow->thread->edl->session->timecode_offset[2]);
00204 add_subwindow(new TimecodeOffset(x + 160, y, pwindow, this, string, 2));
00205 add_subwindow(new BC_Title(x + 192, y, _(":"), MEDIUMFONT, BLACK));
00206 sprintf(string, "%d", pwindow->thread->edl->session->timecode_offset[1]);
00207 add_subwindow(new TimecodeOffset(x + 200, y, pwindow, this, string, 1));
00208 add_subwindow(new BC_Title(x + 232, y, _(":"), MEDIUMFONT, BLACK));
00209 sprintf(string, "%d", pwindow->thread->edl->session->timecode_offset[0]);
00210 add_subwindow(new TimecodeOffset(x + 240, y, pwindow, this, string, 0));
00211
00212 y += 35;
00213 add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
00214 video_device = new VDevicePrefs(x + vdevice_title->get_w() + 10,
00215 y,
00216 pwindow,
00217 this,
00218 playback_config->vconfig,
00219 0,
00220 MODEPLAY);
00221 video_device->initialize();
00222
00223 SET_TRACE
00224
00225 return 0;
00226 }
00227
00228
00229 void PlaybackPrefs::update(int interpolation)
00230 {
00231 pwindow->thread->edl->session->interpolation_type = interpolation;
00232 nearest_neighbor->update(interpolation == NEAREST_NEIGHBOR);
00233
00234 cubic_linear->update(interpolation == CUBIC_LINEAR);
00235 linear_linear->update(interpolation == LINEAR_LINEAR);
00236 }
00237
00238
00239 int PlaybackPrefs::get_buffer_bytes()
00240 {
00241
00242 }
00243
00244 int PlaybackPrefs::draw_framerate()
00245 {
00246
00247 char string[BCTEXTLEN];
00248 sprintf(string, "%.4f", pwindow->thread->edl->session->actual_frame_rate);
00249 framerate_title->update(string);
00250 return 0;
00251 }
00252
00253
00254
00255 PlaybackAudioOffset::PlaybackAudioOffset(PreferencesWindow *pwindow,
00256 PlaybackPrefs *playback,
00257 int x,
00258 int y)
00259 : BC_TumbleTextBox(playback,
00260 playback->playback_config->aconfig->audio_offset,
00261 -10.0,
00262 10.0,
00263 x,
00264 y,
00265 100)
00266 {
00267 this->pwindow = pwindow;
00268 this->playback = playback;
00269 set_precision(2);
00270 set_increment(0.1);
00271 }
00272
00273 int PlaybackAudioOffset::handle_event()
00274 {
00275 playback->playback_config->aconfig->audio_offset = atof(get_text());
00276 return 1;
00277 }
00278
00279
00280
00281
00282 PlaybackModuleFragment::PlaybackModuleFragment(int x,
00283 int y,
00284 PreferencesWindow *pwindow,
00285 PlaybackPrefs *playback,
00286 char *text)
00287 : BC_PopupMenu(x,
00288 y,
00289 100,
00290 text,
00291 1)
00292 {
00293 this->pwindow = pwindow;
00294 this->playback = playback;
00295 }
00296
00297 int PlaybackModuleFragment::handle_event()
00298 {
00299 playback->playback_config->aconfig->fragment_size = atol(get_text());
00300 return 1;
00301 }
00302
00303
00304
00305
00306 PlaybackViewFollows::PlaybackViewFollows(PreferencesWindow *pwindow, int value, int y)
00307 : BC_CheckBox(10, y, value, _("View follows playback"))
00308 {
00309 this->pwindow = pwindow;
00310 }
00311
00312 int PlaybackViewFollows::handle_event()
00313 {
00314 pwindow->thread->edl->session->view_follows_playback = get_value();
00315 return 1;
00316 }
00317
00318
00319
00320
00321 PlaybackSoftwareTimer::PlaybackSoftwareTimer(PreferencesWindow *pwindow, int value, int y)
00322 : BC_CheckBox(10, y, value, _("Use software for positioning information"))
00323 {
00324 this->pwindow = pwindow;
00325 }
00326
00327 int PlaybackSoftwareTimer::handle_event()
00328 {
00329 pwindow->thread->edl->session->playback_software_position = get_value();
00330 return 1;
00331 }
00332
00333
00334
00335
00336 PlaybackRealTime::PlaybackRealTime(PreferencesWindow *pwindow, int value, int y)
00337 : BC_CheckBox(10, y, value, _("Audio playback in real time priority (root only)"))
00338 {
00339 this->pwindow = pwindow;
00340 }
00341
00342 int PlaybackRealTime::handle_event()
00343 {
00344 pwindow->thread->edl->session->real_time_playback = get_value();
00345 return 1;
00346 }
00347
00348
00349
00350
00351
00352
00353
00354 PlaybackNearest::PlaybackNearest(PreferencesWindow *pwindow, PlaybackPrefs *prefs, int value, int x, int y)
00355 : BC_Radial(x, y, value, _("Nearest neighbor enlarge and reduce"))
00356 {
00357 this->pwindow = pwindow;
00358 this->prefs = prefs;
00359 }
00360 int PlaybackNearest::handle_event()
00361 {
00362 prefs->update(NEAREST_NEIGHBOR);
00363 return 1;
00364 }
00365
00366
00367
00368
00369
00370 PlaybackBicubicBicubic::PlaybackBicubicBicubic(PreferencesWindow *pwindow, PlaybackPrefs *prefs, int value, int x, int y)
00371 : BC_Radial(x, y, value, _("Bicubic enlarge and reduce"))
00372 {
00373 this->pwindow = pwindow;
00374 this->prefs = prefs;
00375 }
00376 int PlaybackBicubicBicubic::handle_event()
00377 {
00378 prefs->update(CUBIC_CUBIC);
00379 return 1;
00380 }
00381
00382
00383
00384
00385 PlaybackBicubicBilinear::PlaybackBicubicBilinear(PreferencesWindow *pwindow, PlaybackPrefs *prefs, int value, int x, int y)
00386 : BC_Radial(x, y, value, _("Bicubic enlarge and bilinear reduce"))
00387 {
00388 this->pwindow = pwindow;
00389 this->prefs = prefs;
00390 }
00391 int PlaybackBicubicBilinear::handle_event()
00392 {
00393 prefs->update(CUBIC_LINEAR);
00394 return 1;
00395 }
00396
00397
00398 PlaybackBilinearBilinear::PlaybackBilinearBilinear(PreferencesWindow *pwindow,
00399 PlaybackPrefs *prefs,
00400 int value,
00401 int x,
00402 int y)
00403 : BC_Radial(x, y, value, _("Bilinear enlarge and bilinear reduce"))
00404 {
00405 this->pwindow = pwindow;
00406 this->prefs = prefs;
00407 }
00408 int PlaybackBilinearBilinear::handle_event()
00409 {
00410 prefs->update(LINEAR_LINEAR);
00411 return 1;
00412 }
00413
00414
00415 PlaybackPreload::PlaybackPreload(int x,
00416 int y,
00417 PreferencesWindow *pwindow,
00418 PlaybackPrefs *playback,
00419 char *text)
00420 : BC_TextBox(x, y, 100, 1, text)
00421 {
00422 this->pwindow = pwindow;
00423 this->playback = playback;
00424 }
00425
00426 int PlaybackPreload::handle_event()
00427 {
00428 pwindow->thread->edl->session->playback_preload = atol(get_text());
00429 return 1;
00430 }
00431
00432
00433 PlaybackInterpolateRaw::PlaybackInterpolateRaw(
00434 int x,
00435 int y,
00436 PreferencesWindow *pwindow,
00437 PlaybackPrefs *playback)
00438 : BC_CheckBox(x,
00439 y,
00440 pwindow->thread->edl->session->interpolate_raw,
00441 _("Interpolate CR2 images"))
00442 {
00443 this->pwindow = pwindow;
00444 this->playback = playback;
00445 }
00446
00447 int PlaybackInterpolateRaw::handle_event()
00448 {
00449 pwindow->thread->edl->session->interpolate_raw = get_value();
00450 if(!pwindow->thread->edl->session->interpolate_raw)
00451 {
00452 playback->white_balance_raw->update(0, 0);
00453 playback->white_balance_raw->disable();
00454 }
00455 else
00456 {
00457 playback->white_balance_raw->update(pwindow->thread->edl->session->white_balance_raw, 0);
00458 playback->white_balance_raw->enable();
00459 }
00460 return 1;
00461 }
00462
00463
00464
00465
00466 PlaybackWhiteBalanceRaw::PlaybackWhiteBalanceRaw(
00467 int x,
00468 int y,
00469 PreferencesWindow *pwindow,
00470 PlaybackPrefs *playback)
00471 : BC_CheckBox(x,
00472 y,
00473 pwindow->thread->edl->session->interpolate_raw &&
00474 pwindow->thread->edl->session->white_balance_raw,
00475 _("White balance CR2 images"))
00476 {
00477 this->pwindow = pwindow;
00478 this->playback = playback;
00479 if(!pwindow->thread->edl->session->interpolate_raw) disable();
00480 }
00481
00482 int PlaybackWhiteBalanceRaw::handle_event()
00483 {
00484 pwindow->thread->edl->session->white_balance_raw = get_value();
00485 return 1;
00486 }
00487
00488
00489
00490
00491
00492
00493 VideoAsynchronous::VideoAsynchronous(PreferencesWindow *pwindow, int x, int y)
00494 : BC_CheckBox(x,
00495 y,
00496 pwindow->thread->edl->session->video_every_frame &&
00497 pwindow->thread->edl->session->video_asynchronous,
00498 _("Decode frames asynchronously"))
00499 {
00500 this->pwindow = pwindow;
00501 if(!pwindow->thread->edl->session->video_every_frame)
00502 disable();
00503 }
00504
00505 int VideoAsynchronous::handle_event()
00506 {
00507 pwindow->thread->edl->session->video_asynchronous = get_value();
00508 return 1;
00509 }
00510
00511
00512
00513
00514 VideoEveryFrame::VideoEveryFrame(PreferencesWindow *pwindow,
00515 PlaybackPrefs *playback_prefs,
00516 int x,
00517 int y)
00518 : BC_CheckBox(x, y, pwindow->thread->edl->session->video_every_frame, _("Play every frame"))
00519 {
00520 this->pwindow = pwindow;
00521 this->playback_prefs = playback_prefs;
00522 }
00523
00524 int VideoEveryFrame::handle_event()
00525 {
00526 pwindow->thread->edl->session->video_every_frame = get_value();
00527 if(!pwindow->thread->edl->session->video_every_frame)
00528 {
00529 playback_prefs->asynchronous->update(0, 0);
00530 playback_prefs->asynchronous->disable();
00531 }
00532 else
00533 {
00534 playback_prefs->asynchronous->update(pwindow->thread->edl->session->video_asynchronous, 0);
00535 playback_prefs->asynchronous->enable();
00536 }
00537 return 1;
00538 }
00539
00540
00541
00542
00543
00544
00545
00546 PlaybackSubtitle::PlaybackSubtitle(int x,
00547 int y,
00548 PreferencesWindow *pwindow,
00549 PlaybackPrefs *playback)
00550 : BC_CheckBox(x,
00551 y,
00552 pwindow->thread->edl->session->decode_subtitles,
00553 _("Enable subtitles"))
00554 {
00555 this->pwindow = pwindow;
00556 this->playback = playback;
00557 }
00558
00559 int PlaybackSubtitle::handle_event()
00560 {
00561 pwindow->thread->edl->session->decode_subtitles = get_value();
00562 return 1;
00563 }
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574 PlaybackSubtitleNumber::PlaybackSubtitleNumber(int x,
00575 int y,
00576 PreferencesWindow *pwindow,
00577 PlaybackPrefs *playback)
00578 : BC_TumbleTextBox(playback,
00579 pwindow->thread->edl->session->subtitle_number,
00580 0,
00581 31,
00582 x,
00583 y,
00584 50)
00585 {
00586 this->pwindow = pwindow;
00587 this->playback = playback;
00588 }
00589
00590 int PlaybackSubtitleNumber::handle_event()
00591 {
00592 pwindow->thread->edl->session->subtitle_number = atoi(get_text());
00593 return 1;
00594 }
00595
00596
00597
00598
00599 TimecodeOffset::TimecodeOffset(int x, int y, PreferencesWindow *pwindow,
00600 PlaybackPrefs *playback, char *text, int unit)
00601 : BC_TextBox(x, y, 30, 1, text)
00602 {
00603 this->pwindow = pwindow;
00604 this->playback = playback;
00605 this->unit = unit;
00606 }
00607
00608 int TimecodeOffset::handle_event()
00609 {
00610 pwindow->thread->edl->session->timecode_offset[unit] = atol(get_text());
00611 return 1;
00612 }
00613
00614
00615
00616