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
25 #include "awindowgui.h"
26 #include "bccmodels.h"
30 #include "edlsession.h"
32 #include "interlacemodes.h"
33 #include "overlayframe.inc"
34 #include "playbackconfig.h"
35 #include "recordconfig.h"
37 #include "workarounds.h"
39 int EDLSession::current_id = 0;
41 EDLSession::EDLSession(EDL *edl)
44 for(int i = 0; i < MAXCHANNELS; i++)
45 achannel_positions[i] = 0;
46 assetlist_format = ASSETS_ICONS;
47 for(int i = 0; i < ASSET_COLUMNS; i++)
48 asset_columns[i] = 100;
49 auto_conf = new AutoConf;
50 awindow_folder = AW_MEDIA_FOLDER;
51 aspect_w = 4; aspect_h = 3;
54 autos_follow_edits = 1; // this is needed for predictability
56 brender_start = brender_end = 0.0;
57 clipboard_length = 0; // unused
58 color_model = BC_RGBA8888;
59 interlace_mode = ILACE_MODE_UNDETECTED;
60 crop_x1 = 0; crop_x2 = 320;
61 crop_y1 = 0; crop_y2 = 240;
63 ruler_x1 = ruler_y1 = 0.0;
64 ruler_x2 = ruler_y2 = 0.0;
66 typeless_keyframes = 0;
70 cwindow_operation = 0;
71 cwindow_scrollbars = 0;
72 cwindow_xscroll = cwindow_yscroll = 0;
74 cwindow_click2play = 0;
75 strcpy(default_atransition, INIT_ATRANSITION);
76 strcpy(default_vtransition, INIT_VTRANSITION);
77 default_transition_length = 1.0;
78 edit_handle_mode[0] = MOVE_ALL_EDITS;
79 edit_handle_mode[1] = MOVE_ONE_EDIT;
80 edit_handle_mode[2] = MOVE_NO_EDITS;
81 editing_mode = EDITING_IBEAM;
83 folderlist_format = FOLDERS_ICONS;
84 frame_rate = 30000./1001;
86 highlighted_track = 0;
87 interpolation_type = CUBIC_CUBIC;
89 white_balance_raw = 1;
90 labels_follow_edits = 1;
91 plugins_follow_edits = 1;
92 single_standalone = 1;
93 meter_format = METER_DB;
98 playback_buffer = 4096;
99 playback_cursor_visible = 0;
100 playback_preload = 0;
102 proxy_disabled_scale = 1;
103 proxy_use_scaler = 0;
104 proxy_auto_scale = 1;
107 decode_subtitles = 0;
111 playback_software_position = 0;
113 real_time_playback = 0;
114 real_time_record = 0;
115 record_positioning = 1;
116 record_raw_stream = 0;
117 record_sync_drives = 0;
118 record_speed = frame_rate;
119 record_fragment_size = 2048;
120 record_write_length = 131072;
121 record_realtime_toc = 1;
130 test_playback_edits = 1;
131 time_format = TIME_HMSF;
134 for(int i = 0; i < MAXCHANNELS; i++) {
135 vchannel_x[i] = 64*i;
139 aconfig_in = new AudioInConfig;
140 vconfig_in = new VideoInConfig;
141 recording_format = new Asset;
142 video_every_frame = 0;
143 // video_asynchronous = 0;
145 video_write_length = 30;
146 view_follows_playback = 1;
149 vwindow_click2play = 0;
151 playback_config = new PlaybackConfig;
154 EDLSession::~EDLSession()
159 delete playback_config;
160 recording_format->Garbage::remove_user();
164 int EDLSession::need_rerender(EDLSession *ptr)
166 return ((playback_preload != ptr->playback_preload) ||
167 (interpolation_type != ptr->interpolation_type) ||
168 (video_every_frame != ptr->video_every_frame) ||
169 // (video_asynchronous != ptr->video_asynchronous) ||
170 (real_time_playback != ptr->real_time_playback) ||
171 (playback_software_position != ptr->playback_software_position) ||
172 (test_playback_edits != ptr->test_playback_edits) ||
173 (playback_buffer != ptr->playback_buffer) ||
174 (decode_subtitles != ptr->decode_subtitles) ||
175 (subtitle_number != ptr->subtitle_number) ||
176 (interpolate_raw != ptr->interpolate_raw) ||
177 (white_balance_raw != ptr->white_balance_raw) ||
178 (proxy_disabled_scale != ptr->proxy_disabled_scale) ||
179 (proxy_scale != ptr->proxy_scale) ||
180 (proxy_use_scaler != ptr->proxy_use_scaler));
183 void EDLSession::equivalent_output(EDLSession *session, double *result)
185 if( session->output_w != output_w ||
186 session->output_h != output_h ||
187 !EQUIV(session->frame_rate, frame_rate) ||
188 session->color_model != color_model ||
189 session->interpolation_type != interpolation_type ||
190 session->interpolate_raw != interpolate_raw ||
191 session->white_balance_raw != white_balance_raw ||
192 session->decode_subtitles != decode_subtitles ||
193 session->subtitle_number != subtitle_number ||
194 session->proxy_disabled_scale != proxy_disabled_scale ||
195 session->proxy_scale != proxy_scale ||
196 session->proxy_use_scaler != proxy_use_scaler )
199 // If it's before the current brender_start, render extra data.
200 // If it's after brender_start, check brender map.
201 if(brender_start != session->brender_start &&
202 (*result < 0 || *result > brender_start))
203 *result = brender_start;
206 int EDLSession::load_defaults(BC_Hash *defaults)
208 char string[BCTEXTLEN];
209 audio_channels = defaults->get("ACHANNELS", audio_channels);
210 audio_tracks = defaults->get("ATRACKS", audio_tracks);
211 // Default channel positions
212 for( int i=0; i<MAXCHANNELS; ++i ) {
213 sprintf(string, "ACHANNEL_ANGLE_%d", i);
214 achannel_positions[i] = defaults->get(string,
215 default_audio_channel_position(i, audio_channels));
217 aconfig_in->load_defaults(defaults);
218 assetlist_format = defaults->get("ASSETLIST_FORMAT", ASSETS_ICONS);
219 aspect_w = defaults->get("ASPECTW", aspect_w);
220 aspect_h = defaults->get("ASPECTH", aspect_h);
221 for(int i = 0; i < ASSET_COLUMNS; i++)
223 sprintf(string, "ASSET_COLUMN%d", i);
224 asset_columns[i] = defaults->get(string, 100);
226 auto_conf->load_defaults(defaults);
227 autos_follow_edits = defaults->get("AUTOS_FOLLOW_EDITS", 1);
228 brender_start = defaults->get("BRENDER_START", brender_start);
229 brender_end = defaults->get("BRENDER_END", brender_end);
230 BC_CModels::to_text(string, BC_RGBA8888);
231 color_model = BC_CModels::from_text(defaults->get("COLOR_MODEL", string));
232 eyedrop_radius = defaults->get("EYEDROP_RADIUS", 0);
233 ilacemode_to_xmltext(string, interlace_mode);
234 const char *ilace_mode = defaults->get("INTERLACE_MODE",string);
235 interlace_mode = ilacemode_from_xmltext(ilace_mode, ILACE_MODE_NOTINTERLACED);
236 crop_x1 = defaults->get("CROP_X1", 0);
237 crop_x2 = defaults->get("CROP_X2", 320);
238 crop_y1 = defaults->get("CROP_Y1", 0);
239 crop_y2 = defaults->get("CROP_Y2", 240);
240 ruler_x1 = defaults->get("RULER_X1", 0.0);
241 ruler_x2 = defaults->get("RULER_X2", 0.0);
242 ruler_y1 = defaults->get("RULER_Y1", 0.0);
243 ruler_y2 = defaults->get("RULER_Y2", 0.0);
244 awindow_folder = defaults->get("AWINDOW_FOLDER", AW_MEDIA_FOLDER);
245 cursor_on_frames = defaults->get("CURSOR_ON_FRAMES", 1);
246 typeless_keyframes = defaults->get("TYPELESS_KEYFRAMES", 0);
247 cwindow_dest = defaults->get("CWINDOW_DEST", 0);
248 cwindow_mask = defaults->get("CWINDOW_MASK", 0);
249 cwindow_meter = defaults->get("CWINDOW_METER", 0);
250 cwindow_operation = defaults->get("CWINDOW_OPERATION", 0);
251 cwindow_scrollbars = defaults->get("CWINDOW_SCROLLBARS", 0);
252 cwindow_xscroll = defaults->get("CWINDOW_XSCROLL", 0);
253 cwindow_yscroll = defaults->get("CWINDOW_YSCROLL", 0);
254 cwindow_zoom = defaults->get("CWINDOW_ZOOM", (float)1);
255 cwindow_click2play = defaults->get("CWINDOW_CLICK2PLAY", 0);
256 sprintf(default_atransition, INIT_ATRANSITION);
257 defaults->get("DEFAULT_ATRANSITION", default_atransition);
258 sprintf(default_vtransition, INIT_VTRANSITION);
259 defaults->get("DEFAULT_VTRANSITION", default_vtransition);
260 default_transition_length = defaults->get("DEFAULT_TRANSITION_LENGTH", (double)1);
261 edit_handle_mode[0] = defaults->get("EDIT_HANDLE_MODE0", MOVE_ALL_EDITS);
262 edit_handle_mode[1] = defaults->get("EDIT_HANDLE_MODE1", MOVE_ONE_EDIT);
263 edit_handle_mode[2] = defaults->get("EDIT_HANDLE_MODE2", MOVE_NO_EDITS);
264 editing_mode = defaults->get("EDITING_MODE", EDITING_IBEAM);
265 enable_duplex = defaults->get("ENABLE_DUPLEX", 1);
266 folderlist_format = defaults->get("FOLDERLIST_FORMAT", FOLDERS_TEXT);
267 frame_rate = defaults->get("FRAMERATE", frame_rate);
268 frames_per_foot = defaults->get("FRAMES_PER_FOOT", (float)16);
269 interpolation_type = defaults->get("INTERPOLATION_TYPE", interpolation_type);
270 interpolate_raw = defaults->get("INTERPOLATE_RAW", interpolate_raw);
271 white_balance_raw = defaults->get("WHITE_BALANCE_RAW", white_balance_raw);
272 labels_follow_edits = defaults->get("LABELS_FOLLOW_EDITS", 1);
273 plugins_follow_edits = defaults->get("PLUGINS_FOLLOW_EDITS", 1);
274 single_standalone = defaults->get("SINGLE_STANDALONE", 1);
275 playback_preload = defaults->get("PLAYBACK_PRELOAD", 0);
276 auto_keyframes = defaults->get("AUTO_KEYFRAMES", 0);
277 meter_format = defaults->get("METER_FORMAT", METER_DB);
278 min_meter_db = defaults->get("MIN_METER_DB", -85);
279 max_meter_db = defaults->get("MAX_METER_DB", 6);
280 output_w = defaults->get("OUTPUTW", output_w);
281 output_h = defaults->get("OUTPUTH", output_h);
282 playback_buffer = defaults->get("PLAYBACK_BUFFER", 4096);
283 playback_software_position = defaults->get("PLAYBACK_SOFTWARE_POSITION", 0);
284 delete playback_config;
285 playback_config = new PlaybackConfig;
286 playback_config->load_defaults(defaults);
287 real_time_playback = defaults->get("PLAYBACK_REALTIME", 0);
288 real_time_record = defaults->get("REALTIME_RECORD", 0);
289 record_positioning = defaults->get("RECORD_POSITIONING", 1);
290 record_raw_stream = defaults->get("RECORD_RAW_STREAM", 0);
291 record_sync_drives = defaults->get("RECORD_SYNC_DRIVES", 0);
292 // record_speed = defaults->get("RECORD_SPEED", 24);
293 record_fragment_size = defaults->get("RECORD_FRAGMENT_SIZE", 2048);
294 record_write_length = defaults->get("RECORD_WRITE_LENGTH", 131072);
296 // set some defaults that work
297 recording_format->video_data = 1;
298 recording_format->audio_data = 1;
299 recording_format->format = FILE_FFMPEG;
300 strcpy(recording_format->acodec, "mp4.qt");
301 strcpy(recording_format->vcodec, "mp4.qt");
302 recording_format->channels = 2;
303 recording_format->sample_rate = 48000;
304 recording_format->bits = 16;
305 recording_format->dither = 0;
307 record_realtime_toc = defaults->get("RECORD_REALTIME_TOC", 1);
308 recording_format->load_defaults(defaults, "RECORD_", 1, 1, 1, 1, 1);
310 safe_regions = defaults->get("SAFE_REGIONS", 0);
311 sample_rate = defaults->get("SAMPLERATE", sample_rate);
312 scrub_speed = defaults->get("SCRUB_SPEED", (float)2);
313 si_useduration = defaults->get("SI_USEDURATION",1);
314 si_duration = defaults->get("SI_DURATION",3);
316 show_assets = defaults->get("SHOW_ASSETS", 1);
317 show_titles = defaults->get("SHOW_TITLES", 1);
318 // test_playback_edits = defaults->get("TEST_PLAYBACK_EDITS", 1);
319 time_format = defaults->get("TIME_FORMAT", TIME_HMSF);
320 nudge_format = defaults->get("NUDGE_FORMAT", 1);
321 tool_window = defaults->get("TOOL_WINDOW", 0);
322 vconfig_in->load_defaults(defaults);
323 for(int i = 0; i < MAXCHANNELS; i++) {
324 int default_position = i * output_w;
325 sprintf(string, "VCHANNEL_X_%d", i);
326 vchannel_x[i] = defaults->get(string, default_position);
327 sprintf(string, "VCHANNEL_Y_%d", i);
328 vchannel_y[i] = defaults->get(string, 0);
330 video_channels = defaults->get("VCHANNELS", video_channels);
331 video_every_frame = defaults->get("VIDEO_EVERY_FRAME", 0);
332 // video_asynchronous = defaults->get("VIDEO_ASYNCHRONOUS", 0);
333 video_tracks = defaults->get("VTRACKS", video_tracks);
334 video_write_length = defaults->get("VIDEO_WRITE_LENGTH", 30);
335 view_follows_playback = defaults->get("VIEW_FOLLOWS_PLAYBACK", 1);
336 vwindow_meter = defaults->get("VWINDOW_METER", 0);
337 vwindow_zoom = defaults->get("VWINDOW_ZOOM", (float)1);
338 vwindow_click2play = defaults->get("VWINDOW_CLICK2PLAY", 0);
340 decode_subtitles = defaults->get("DECODE_SUBTITLES", decode_subtitles);
341 subtitle_number = defaults->get("SUBTITLE_NUMBER", subtitle_number);
342 label_cells = defaults->get("LABEL_CELLS", label_cells);
343 program_no = defaults->get("PROGRAM_NO", program_no);
344 proxy_beep = defaults->get("PROXY_BEEP", proxy_beep);
345 render_beep = defaults->get("RENDER_BEEP", render_beep);
352 int EDLSession::save_defaults(BC_Hash *defaults)
354 char string[BCTEXTLEN];
357 for(int i = 0; i < MAXCHANNELS; i++)
359 sprintf(string, "ACHANNEL_ANGLE_%d", i);
360 defaults->update(string, achannel_positions[i]);
362 defaults->update("ACHANNELS", audio_channels);
363 aconfig_in->save_defaults(defaults);
364 for(int i = 0; i < ASSET_COLUMNS; i++)
366 sprintf(string, "ASSET_COLUMN%d", i);
367 defaults->update(string, asset_columns[i]);
369 auto_conf->save_defaults(defaults);
370 defaults->update("ASSETLIST_FORMAT", assetlist_format);
371 defaults->update("ASPECTW", aspect_w);
372 defaults->update("ASPECTH", aspect_h);
373 defaults->update("ATRACKS", audio_tracks);
374 defaults->update("AUTOS_FOLLOW_EDITS", autos_follow_edits);
375 defaults->update("BRENDER_START", brender_start);
376 defaults->update("BRENDER_END", brender_end);
377 BC_CModels::to_text(string, color_model);
378 defaults->update("COLOR_MODEL", string);
379 ilacemode_to_xmltext(string, interlace_mode);
380 defaults->update("INTERLACE_MODE", string);
381 defaults->update("EYEDROP_RADIUS", eyedrop_radius);
382 defaults->update("CROP_X1", crop_x1);
383 defaults->update("CROP_X2", crop_x2);
384 defaults->update("CROP_Y1", crop_y1);
385 defaults->update("CROP_Y2", crop_y2);
386 defaults->update("RULER_X1", ruler_x1);
387 defaults->update("RULER_X2", ruler_x2);
388 defaults->update("RULER_Y1", ruler_y1);
389 defaults->update("RULER_Y2", ruler_y2);
390 defaults->update("AWINDOW_FOLDER", awindow_folder);
391 defaults->update("CURSOR_ON_FRAMES", cursor_on_frames);
392 defaults->update("TYPELESS_KEYFRAMES", typeless_keyframes);
393 defaults->update("CWINDOW_DEST", cwindow_dest);
394 defaults->update("CWINDOW_MASK", cwindow_mask);
395 defaults->update("CWINDOW_METER", cwindow_meter);
396 defaults->update("CWINDOW_OPERATION", cwindow_operation);
397 defaults->update("CWINDOW_SCROLLBARS", cwindow_scrollbars);
398 defaults->update("CWINDOW_XSCROLL", cwindow_xscroll);
399 defaults->update("CWINDOW_YSCROLL", cwindow_yscroll);
400 defaults->update("CWINDOW_ZOOM", cwindow_zoom);
401 defaults->update("CWINDOW_CLICK2PLAY", cwindow_click2play);
402 defaults->update("DEFAULT_ATRANSITION", default_atransition);
403 defaults->update("DEFAULT_VTRANSITION", default_vtransition);
404 defaults->update("DEFAULT_TRANSITION_LENGTH", default_transition_length);
405 defaults->update("EDIT_HANDLE_MODE0", edit_handle_mode[0]);
406 defaults->update("EDIT_HANDLE_MODE1", edit_handle_mode[1]);
407 defaults->update("EDIT_HANDLE_MODE2", edit_handle_mode[2]);
408 defaults->update("EDITING_MODE", editing_mode);
409 defaults->update("ENABLE_DUPLEX", enable_duplex);
410 defaults->update("FOLDERLIST_FORMAT", folderlist_format);
411 defaults->update("FRAMERATE", frame_rate);
412 defaults->update("FRAMES_PER_FOOT", frames_per_foot);
413 defaults->update("HIGHLIGHTED_TRACK", highlighted_track);
414 defaults->update("INTERPOLATION_TYPE", interpolation_type);
415 defaults->update("INTERPOLATE_RAW", interpolate_raw);
416 defaults->update("WHITE_BALANCE_RAW", white_balance_raw);
417 defaults->update("LABELS_FOLLOW_EDITS", labels_follow_edits);
418 defaults->update("PLUGINS_FOLLOW_EDITS", plugins_follow_edits);
419 defaults->update("SINGLE_STANDALONE", single_standalone);
420 defaults->update("PLAYBACK_PRELOAD", playback_preload);
421 defaults->update("AUTO_KEYFRAMES", auto_keyframes);
422 defaults->update("METER_FORMAT", meter_format);
423 defaults->update("MIN_METER_DB", min_meter_db);
424 defaults->update("MAX_METER_DB", max_meter_db);
425 defaults->update("OUTPUTW", output_w);
426 defaults->update("OUTPUTH", output_h);
427 defaults->update("PLAYBACK_BUFFER", playback_buffer);
428 defaults->update("PLAYBACK_SOFTWARE_POSITION", playback_software_position);
429 playback_config->save_defaults(defaults);
430 defaults->update("PLAYBACK_REALTIME", real_time_playback);
431 defaults->update("REALTIME_RECORD", real_time_record);
432 defaults->update("RECORD_POSITIONING", record_positioning);
433 defaults->update("RECORD_RAW_STREAM", record_raw_stream);
434 defaults->update("RECORD_SYNC_DRIVES", record_sync_drives);
435 // defaults->update("RECORD_SPEED", record_speed);
436 defaults->update("RECORD_FRAGMENT_SIZE", record_fragment_size);
437 defaults->update("RECORD_WRITE_LENGTH", record_write_length); // Heroine kernel 2.2 scheduling sucks.
438 defaults->update("RECORD_REALTIME_TOC", record_realtime_toc);
439 recording_format->save_defaults(defaults,
446 defaults->update("SAFE_REGIONS", safe_regions);
447 defaults->update("SAMPLERATE", sample_rate);
448 defaults->update("SCRUB_SPEED", scrub_speed);
449 defaults->update("SI_USEDURATION",si_useduration);
450 defaults->update("SI_DURATION",si_duration);
451 defaults->update("SHOW_ASSETS", show_assets);
452 defaults->update("SHOW_TITLES", show_titles);
453 // defaults->update("TEST_PLAYBACK_EDITS", test_playback_edits);
454 defaults->update("TIME_FORMAT", time_format);
455 defaults->update("NUDGE_FORMAT", nudge_format);
456 defaults->update("TOOL_WINDOW", tool_window);
457 vconfig_in->save_defaults(defaults);
458 for(int i = 0; i < MAXCHANNELS; i++) {
459 sprintf(string, "VCHANNEL_X_%d", i);
460 defaults->update(string, vchannel_x[i]);
461 sprintf(string, "VCHANNEL_Y_%d", i);
462 defaults->update(string, vchannel_y[i]);
464 defaults->update("VCHANNELS", video_channels);
465 defaults->update("VIDEO_EVERY_FRAME", video_every_frame);
466 // defaults->update("VIDEO_ASYNCHRONOUS", video_asynchronous);
467 defaults->update("VTRACKS", video_tracks);
468 defaults->update("VIDEO_WRITE_LENGTH", video_write_length);
469 defaults->update("VIEW_FOLLOWS_PLAYBACK", view_follows_playback);
470 defaults->update("VWINDOW_METER", vwindow_meter);
471 defaults->update("VWINDOW_ZOOM", vwindow_zoom);
472 defaults->update("VWINDOW_CLICK2PLAY", vwindow_click2play);
474 defaults->update("DECODE_SUBTITLES", decode_subtitles);
475 defaults->update("SUBTITLE_NUMBER", subtitle_number);
476 defaults->update("LABEL_CELLS", label_cells);
477 defaults->update("PROGRAM_NO", program_no);
478 defaults->update("PROXY_BEEP", proxy_beep);
479 defaults->update("RENDER_BEEP", render_beep);
485 // GCC 3.0 fails to compile
486 #define BC_INFINITY 65536
489 void EDLSession::boundaries()
491 Workarounds::clamp(audio_tracks, 0, (int)BC_INFINITY);
492 Workarounds::clamp(audio_channels, 1, MAXCHANNELS - 1);
493 Workarounds::clamp(sample_rate, 1, 1000000);
494 Workarounds::clamp(video_tracks, 0, (int)BC_INFINITY);
495 Workarounds::clamp(video_channels, 1, MAXCHANNELS - 1);
496 Workarounds::clamp(frame_rate, 1.0, (double)BC_INFINITY);
497 Workarounds::clamp(min_meter_db, -80, -20);
498 Workarounds::clamp(max_meter_db, 0, 10);
499 Workarounds::clamp(frames_per_foot, 1, 32);
500 Workarounds::clamp(proxy_scale, 1, 32);
501 Workarounds::clamp(output_w, 16, (int)BC_INFINITY);
502 Workarounds::clamp(output_h, 16, (int)BC_INFINITY);
503 Workarounds::clamp(video_write_length, 1, 1000);
504 //printf("EDLSession::boundaries 1\n");
510 Workarounds::clamp(eyedrop_radius, 0, 255);
511 Workarounds::clamp(crop_x1, 0, output_w);
512 Workarounds::clamp(crop_x2, 0, output_w);
513 Workarounds::clamp(crop_y1, 0, output_h);
514 Workarounds::clamp(crop_y2, 0, output_h);
515 Workarounds::clamp(ruler_x1, 0.0, output_w);
516 Workarounds::clamp(ruler_x2, 0.0, output_w);
517 Workarounds::clamp(ruler_y1, 0.0, output_h);
518 Workarounds::clamp(ruler_y2, 0.0, output_h);
519 if(brender_start < 0) brender_start = 0.0;
520 if(brender_end < 0) brender_end = 0.0;
522 Workarounds::clamp(subtitle_number, 0, 31);
523 Workarounds::clamp(awindow_folder, 0, AWINDOW_FOLDERS - 1);
525 // Correct framerates
526 frame_rate = Units::fix_framerate(frame_rate);
531 int EDLSession::load_video_config(FileXML *file, int append_mode, uint32_t load_flags)
533 char string[BCTEXTLEN];
534 if(append_mode) return 0;
535 interpolation_type = file->tag.get_property("INTERPOLATION_TYPE", interpolation_type);
536 interpolate_raw = file->tag.get_property("INTERPOLATE_RAW", interpolate_raw);
537 white_balance_raw = file->tag.get_property("WHITE_BALANCE_RAW", white_balance_raw);
538 BC_CModels::to_text(string, color_model);
539 color_model = BC_CModels::from_text(file->tag.get_property("COLORMODEL", string));
540 const char *ilace_mode = file->tag.get_property("INTERLACE_MODE");
541 interlace_mode = ilacemode_from_xmltext(ilace_mode, ILACE_MODE_NOTINTERLACED);
542 video_channels = file->tag.get_property("CHANNELS", video_channels);
543 for(int i = 0; i < video_channels; i++)
545 int default_position = i * output_w;
546 sprintf(string, "VCHANNEL_X_%d", i);
547 vchannel_x[i] = file->tag.get_property(string, default_position);
548 sprintf(string, "VCHANNEL_Y_%d", i);
549 vchannel_y[i] = file->tag.get_property(string, 0);
552 frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
553 frames_per_foot = file->tag.get_property("FRAMES_PER_FOOT", frames_per_foot);
554 output_w = file->tag.get_property("OUTPUTW", output_w);
555 output_h = file->tag.get_property("OUTPUTH", output_h);
556 aspect_w = file->tag.get_property("ASPECTW", aspect_w);
557 aspect_h = file->tag.get_property("ASPECTH", aspect_h);
558 proxy_scale = file->tag.get_property("PROXY_SCALE", proxy_scale);
559 proxy_disabled_scale = file->tag.get_property("PROXY_DISABLED_SCALE", proxy_disabled_scale);
560 proxy_use_scaler = file->tag.get_property("PROXY_USE_SCALER", proxy_use_scaler);
561 proxy_auto_scale = file->tag.get_property("PROXY_AUTO_SCALE", proxy_auto_scale);
565 int EDLSession::load_audio_config(FileXML *file, int append_mode, uint32_t load_flags)
568 // load channels setting
569 if(append_mode) return 0;
570 audio_channels = file->tag.get_property("CHANNELS", (int64_t)audio_channels);
571 for(int i = 0; i < audio_channels; i++)
573 sprintf(string, "ACHANNEL_ANGLE_%d", i);
574 achannel_positions[i] = file->tag.get_property(string, achannel_positions[i]);
575 //printf("EDLSession::load_audio_config 1 %d %d\n", i, achannel_positions[i]);
578 sample_rate = file->tag.get_property("SAMPLERATE", (int64_t)sample_rate);
582 int EDLSession::load_xml(FileXML *file,
586 char string[BCTEXTLEN];
593 assetlist_format = file->tag.get_property("ASSETLIST_FORMAT", assetlist_format);
594 for(int i = 0; i < ASSET_COLUMNS; i++) {
595 sprintf(string, "ASSET_COLUMN%d", i);
596 asset_columns[i] = file->tag.get_property(string, asset_columns[i]);
598 auto_conf->load_xml(file);
599 auto_keyframes = file->tag.get_property("AUTO_KEYFRAMES", auto_keyframes);
600 autos_follow_edits = file->tag.get_property("AUTOS_FOLLOW_EDITS", autos_follow_edits);
601 brender_start = file->tag.get_property("BRENDER_START", brender_start);
602 brender_end = file->tag.get_property("BRENDER_END", brender_end);
603 eyedrop_radius = file->tag.get_property("EYEDROP_RADIUS", eyedrop_radius);
604 crop_x1 = file->tag.get_property("CROP_X1", crop_x1);
605 crop_y1 = file->tag.get_property("CROP_Y1", crop_y1);
606 crop_x2 = file->tag.get_property("CROP_X2", crop_x2);
607 crop_y2 = file->tag.get_property("CROP_Y2", crop_y2);
608 ruler_x1 = file->tag.get_property("RULER_X1", ruler_x1);
609 ruler_y1 = file->tag.get_property("RULER_Y1", ruler_y1);
610 ruler_x2 = file->tag.get_property("RULER_X2", ruler_x2);
611 ruler_y2 = file->tag.get_property("RULER_Y2", ruler_y2);
612 awindow_folder = file->tag.get_property("AWINDOW_FOLDER", AW_MEDIA_FOLDER);
613 cursor_on_frames = file->tag.get_property("CURSOR_ON_FRAMES", cursor_on_frames);
614 typeless_keyframes = file->tag.get_property("TYPELESS_KEYFRAMES", typeless_keyframes);
615 cwindow_dest = file->tag.get_property("CWINDOW_DEST", cwindow_dest);
616 cwindow_mask = file->tag.get_property("CWINDOW_MASK", cwindow_mask);
617 cwindow_meter = file->tag.get_property("CWINDOW_METER", cwindow_meter);
618 cwindow_operation = file->tag.get_property("CWINDOW_OPERATION", cwindow_operation);
619 cwindow_scrollbars = file->tag.get_property("CWINDOW_SCROLLBARS", cwindow_scrollbars);
620 cwindow_xscroll = file->tag.get_property("CWINDOW_XSCROLL", cwindow_xscroll);
621 cwindow_yscroll = file->tag.get_property("CWINDOW_YSCROLL", cwindow_yscroll);
622 cwindow_zoom = file->tag.get_property("CWINDOW_ZOOM", cwindow_zoom);
623 cwindow_click2play = file->tag.get_property("CWINDOW_CLICK2PLAY", cwindow_click2play);
624 editing_mode = file->tag.get_property("EDITING_MODE", editing_mode);
625 folderlist_format = file->tag.get_property("FOLDERLIST_FORMAT", folderlist_format);
626 highlighted_track = file->tag.get_property("HIGHLIGHTED_TRACK", 0);
627 labels_follow_edits = file->tag.get_property("LABELS_FOLLOW_EDITS", labels_follow_edits);
628 plugins_follow_edits = file->tag.get_property("PLUGINS_FOLLOW_EDITS", plugins_follow_edits);
629 single_standalone = file->tag.get_property("SINGLE_STANDALONE", single_standalone);
630 playback_preload = file->tag.get_property("PLAYBACK_PRELOAD", playback_preload);
631 safe_regions = file->tag.get_property("SAFE_REGIONS", safe_regions);
632 show_assets = file->tag.get_property("SHOW_ASSETS", 1);
633 show_titles = file->tag.get_property("SHOW_TITLES", 1);
634 // test_playback_edits = file->tag.get_property("TEST_PLAYBACK_EDITS", test_playback_edits);
635 time_format = file->tag.get_property("TIME_FORMAT", time_format);
636 nudge_format = file->tag.get_property("NUDGE_FORMAT", nudge_format);
637 tool_window = file->tag.get_property("TOOL_WINDOW", tool_window);
638 vwindow_meter = file->tag.get_property("VWINDOW_METER", vwindow_meter);
639 vwindow_zoom = file->tag.get_property("VWINDOW_ZOOM", vwindow_zoom);
640 vwindow_click2play = file->tag.get_property("VWINDOW_CLICK2PLAY", vwindow_click2play);
642 decode_subtitles = file->tag.get_property("DECODE_SUBTITLES", decode_subtitles);
643 subtitle_number = file->tag.get_property("SUBTITLE_NUMBER", subtitle_number);
644 label_cells = file->tag.get_property("LABEL_CELLS", label_cells);
645 program_no = file->tag.get_property("PROGRAM_NO", program_no);
646 proxy_beep = file->tag.get_property("PROXY_BEEP", proxy_beep);
647 render_beep = file->tag.get_property("RENDER_BEEP", render_beep);
654 int EDLSession::save_xml(FileXML *file)
656 //printf("EDLSession::save_session 1\n");
657 char string[BCTEXTLEN];
658 file->tag.set_title("SESSION");
659 file->tag.set_property("ASSETLIST_FORMAT", assetlist_format);
660 for(int i = 0; i < ASSET_COLUMNS; i++) {
661 sprintf(string, "ASSET_COLUMN%d", i);
662 file->tag.set_property(string, asset_columns[i]);
664 auto_conf->save_xml(file);
665 file->tag.set_property("AUTO_KEYFRAMES", auto_keyframes);
666 file->tag.set_property("AUTOS_FOLLOW_EDITS", autos_follow_edits);
667 file->tag.set_property("BRENDER_START", brender_start);
668 file->tag.set_property("BRENDER_END", brender_end);
669 file->tag.set_property("EYEDROP_RADIUS", eyedrop_radius);
670 file->tag.set_property("CROP_X1", crop_x1);
671 file->tag.set_property("CROP_Y1", crop_y1);
672 file->tag.set_property("CROP_X2", crop_x2);
673 file->tag.set_property("CROP_Y2", crop_y2);
674 file->tag.set_property("RULER_X1", ruler_x1);
675 file->tag.set_property("RULER_Y1", ruler_y1);
676 file->tag.set_property("RULER_X2", ruler_x2);
677 file->tag.set_property("RULER_Y2", ruler_y2);
678 file->tag.set_property("AWINDOW_FOLDER", awindow_folder);
679 file->tag.set_property("CURSOR_ON_FRAMES", cursor_on_frames);
680 file->tag.set_property("TYPELESS_KEYFRAMES", typeless_keyframes);
681 file->tag.set_property("CWINDOW_DEST", cwindow_dest);
682 file->tag.set_property("CWINDOW_MASK", cwindow_mask);
683 file->tag.set_property("CWINDOW_METER", cwindow_meter);
684 file->tag.set_property("CWINDOW_OPERATION", cwindow_operation);
685 file->tag.set_property("CWINDOW_SCROLLBARS", cwindow_scrollbars);
686 file->tag.set_property("CWINDOW_XSCROLL", cwindow_xscroll);
687 file->tag.set_property("CWINDOW_YSCROLL", cwindow_yscroll);
688 file->tag.set_property("CWINDOW_ZOOM", cwindow_zoom);
689 file->tag.set_property("CWINDOW_CLICK2PLAY", cwindow_click2play);
690 file->tag.set_property("EDITING_MODE", editing_mode);
691 file->tag.set_property("FOLDERLIST_FORMAT", folderlist_format);
692 file->tag.set_property("HIGHLIGHTED_TRACK", highlighted_track);
693 file->tag.set_property("LABELS_FOLLOW_EDITS", labels_follow_edits);
694 file->tag.set_property("PLUGINS_FOLLOW_EDITS", plugins_follow_edits);
695 file->tag.set_property("SINGLE_STANDALONE", single_standalone);
696 file->tag.set_property("PLAYBACK_PRELOAD", playback_preload);
697 file->tag.set_property("SAFE_REGIONS", safe_regions);
698 file->tag.set_property("SHOW_ASSETS", show_assets);
699 file->tag.set_property("SHOW_TITLES", show_titles);
700 file->tag.set_property("TEST_PLAYBACK_EDITS", test_playback_edits);
701 file->tag.set_property("TIME_FORMAT", time_format);
702 file->tag.set_property("NUDGE_FORMAT", nudge_format);
703 file->tag.set_property("TOOL_WINDOW", tool_window);
704 file->tag.set_property("VWINDOW_METER", vwindow_meter);
705 file->tag.set_property("VWINDOW_ZOOM", vwindow_zoom);
706 file->tag.set_property("VWINDOW_CLICK2PLAY", vwindow_click2play);
708 file->tag.set_property("DECODE_SUBTITLES", decode_subtitles);
709 file->tag.set_property("SUBTITLE_NUMBER", subtitle_number);
710 file->tag.set_property("PROXY_BEEP", proxy_beep);
711 file->tag.set_property("RENDER_BEEP", render_beep);
714 file->tag.set_title("/SESSION");
716 file->append_newline();
717 file->append_newline();
718 //printf("EDLSession::save_session 3\n");
722 int EDLSession::save_video_config(FileXML *file)
724 char string[BCTEXTLEN];
725 file->tag.set_title("VIDEO");
726 file->tag.set_property("INTERPOLATION_TYPE", interpolation_type);
727 file->tag.set_property("INTERPOLATE_RAW", interpolate_raw);
728 file->tag.set_property("WHITE_BALANCE_RAW", white_balance_raw);
729 BC_CModels::to_text(string, color_model);
730 file->tag.set_property("COLORMODEL", string);
731 ilacemode_to_xmltext(string, interlace_mode);
732 file->tag.set_property("INTERLACE_MODE",string);
733 file->tag.set_property("CHANNELS", video_channels);
734 for(int i = 0; i < video_channels; i++)
736 sprintf(string, "VCHANNEL_X_%d", i);
737 file->tag.set_property(string, vchannel_x[i]);
738 sprintf(string, "VCHANNEL_Y_%d", i);
739 file->tag.set_property(string, vchannel_y[i]);
742 file->tag.set_property("FRAMERATE", frame_rate);
743 file->tag.set_property("FRAMES_PER_FOOT", frames_per_foot);
744 file->tag.set_property("OUTPUTW", output_w);
745 file->tag.set_property("OUTPUTH", output_h);
746 file->tag.set_property("ASPECTW", aspect_w);
747 file->tag.set_property("ASPECTH", aspect_h);
748 file->tag.set_property("PROXY_SCALE", proxy_scale);
749 file->tag.set_property("PROXY_DISABLED_SCALE", proxy_disabled_scale);
750 file->tag.set_property("PROXY_USE_SCALER", proxy_use_scaler);
751 file->tag.set_property("PROXY_AUTO_SCALE", proxy_auto_scale);
753 file->tag.set_title("/VIDEO");
755 file->append_newline();
756 file->append_newline();
760 int EDLSession::save_audio_config(FileXML *file)
763 file->tag.set_title("AUDIO");
764 file->tag.set_property("SAMPLERATE", (int64_t)sample_rate);
765 file->tag.set_property("CHANNELS", (int64_t)audio_channels);
767 for(int i = 0; i < audio_channels; i++)
769 sprintf(string, "ACHANNEL_ANGLE_%d", i);
770 file->tag.set_property(string, achannel_positions[i]);
774 file->tag.set_title("/AUDIO");
776 file->append_newline();
777 file->append_newline();
781 int EDLSession::copy(EDLSession *session)
783 // Audio channel positions
784 for(int i = 0; i < MAXCHANNELS; i++)
786 achannel_positions[i] = session->achannel_positions[i];
788 aconfig_in->copy_from(session->aconfig_in);
789 for(int i = 0; i < ASSET_COLUMNS; i++)
791 asset_columns[i] = session->asset_columns[i];
793 assetlist_format = session->assetlist_format;
794 auto_conf->copy_from(session->auto_conf);
795 aspect_w = session->aspect_w;
796 aspect_h = session->aspect_h;
797 audio_channels = session->audio_channels;
798 audio_tracks = session->audio_tracks;
799 autos_follow_edits = session->autos_follow_edits;
800 brender_start = session->brender_start;
801 brender_end = session->brender_end;
802 color_model = session->color_model;
803 interlace_mode = session->interlace_mode;
804 eyedrop_radius = session->eyedrop_radius;
805 crop_x1 = session->crop_x1;
806 crop_y1 = session->crop_y1;
807 crop_x2 = session->crop_x2;
808 crop_y2 = session->crop_y2;
809 ruler_x1 = session->ruler_x1;
810 ruler_y1 = session->ruler_y1;
811 ruler_x2 = session->ruler_x2;
812 ruler_y2 = session->ruler_y2;
813 awindow_folder = session->awindow_folder;
814 cursor_on_frames = session->cursor_on_frames;
815 typeless_keyframes = session->typeless_keyframes;
816 cwindow_dest = session->cwindow_dest;
817 cwindow_mask = session->cwindow_mask;
818 cwindow_meter = session->cwindow_meter;
819 cwindow_operation = session->cwindow_operation;
820 cwindow_scrollbars = session->cwindow_scrollbars;
821 cwindow_xscroll = session->cwindow_xscroll;
822 cwindow_yscroll = session->cwindow_yscroll;
823 cwindow_zoom = session->cwindow_zoom;
824 cwindow_click2play = session->cwindow_click2play;
825 strcpy(default_atransition, session->default_atransition);
826 strcpy(default_vtransition, session->default_vtransition);
827 default_transition_length = session->default_transition_length;
828 edit_handle_mode[0] = session->edit_handle_mode[0];
829 edit_handle_mode[1] = session->edit_handle_mode[1];
830 edit_handle_mode[2] = session->edit_handle_mode[2];
831 editing_mode = session->editing_mode;
832 enable_duplex = session->enable_duplex;
833 folderlist_format = session->folderlist_format;
834 frame_rate = session->frame_rate;
835 frames_per_foot = session->frames_per_foot;
836 highlighted_track = session->highlighted_track;
837 interpolation_type = session->interpolation_type;
838 interpolate_raw = session->interpolate_raw;
839 white_balance_raw = session->white_balance_raw;
840 labels_follow_edits = session->labels_follow_edits;
841 plugins_follow_edits = session->plugins_follow_edits;
842 single_standalone = session->single_standalone;
843 auto_keyframes = session->auto_keyframes;
844 // last_playback_position = session->last_playback_position;
845 meter_format = session->meter_format;
846 min_meter_db = session->min_meter_db;
847 max_meter_db = session->max_meter_db;
848 output_w = session->output_w;
849 output_h = session->output_h;
850 playback_buffer = session->playback_buffer;
851 delete playback_config;
852 playback_config = new PlaybackConfig;
853 playback_config->copy_from(session->playback_config);
854 playback_cursor_visible = session->playback_cursor_visible;
855 playback_software_position = session->playback_software_position;
856 real_time_playback = session->real_time_playback;
857 real_time_record = session->real_time_record;
858 record_positioning = session->record_positioning;
859 record_raw_stream = session->record_raw_stream;
860 record_speed = session->record_speed;
861 record_sync_drives = session->record_sync_drives;
862 record_fragment_size = session->record_fragment_size;
863 record_write_length = session->record_write_length;
864 record_realtime_toc = session->record_realtime_toc;
865 recording_format->copy_from(session->recording_format, 0);
866 safe_regions = session->safe_regions;
867 sample_rate = session->sample_rate;
868 scrub_speed = session->scrub_speed;
869 si_useduration = session->si_useduration;
870 si_duration = session->si_duration;
871 show_assets = session->show_assets;
872 show_titles = session->show_titles;
873 test_playback_edits = session->test_playback_edits;
874 time_format = session->time_format;
875 nudge_format = session->nudge_format;
876 tool_window = session->tool_window;
877 for(int i = 0; i < MAXCHANNELS; i++) {
878 vchannel_x[i] = session->vchannel_x[i];
879 vchannel_y[i] = session->vchannel_y[i];
881 video_channels = session->video_channels;
882 *vconfig_in = *session->vconfig_in;
883 video_every_frame = session->video_every_frame;
884 // video_asynchronous = session->video_asynchronous;
885 video_tracks = session->video_tracks;
886 video_write_length = session->video_write_length;
887 view_follows_playback = session->view_follows_playback;
888 vwindow_meter = session->vwindow_meter;
889 vwindow_zoom = session->vwindow_zoom;
890 vwindow_click2play = session->vwindow_click2play;
891 proxy_scale = session->proxy_scale;
892 proxy_disabled_scale = session->proxy_disabled_scale;
893 proxy_use_scaler = session->proxy_use_scaler;
894 proxy_auto_scale = session->proxy_auto_scale;
895 proxy_beep = session->proxy_beep;
896 render_beep = session->render_beep;
898 subtitle_number = session->subtitle_number;
899 decode_subtitles = session->decode_subtitles;
900 label_cells = session->label_cells;
901 program_no = session->program_no;
906 void EDLSession::dump()
908 printf("EDLSession::dump\n");
909 printf(" audio_tracks=%d audio_channels=%d sample_rate=%jd\n"
910 " video_tracks=%d frame_rate=%f output_w=%d output_h=%d aspect_w=%f aspect_h=%f\n"
911 " decode subtitles=%d subtitle_number=%d label_cells=%d program_no=%d\n"
912 " proxy scale=%d\n disabled_scale=%d, use_scaler=%d, auto_scale=%d\n"
913 " proxy_beep=%d render_beep=%d\n",
914 audio_tracks, audio_channels, sample_rate, video_tracks,
915 frame_rate, output_w, output_h, aspect_w, aspect_h,
916 decode_subtitles, subtitle_number, label_cells, program_no,
917 proxy_scale, proxy_disabled_scale, proxy_use_scaler, proxy_auto_scale,
918 proxy_beep, render_beep);