00001 #include "asset.h"
00002 #include "assets.h"
00003 #include "autoconf.h"
00004 #include "colormodels.h"
00005 #include "bchash.h"
00006 #include "edl.h"
00007 #include "edlsession.h"
00008 #include "filexml.h"
00009 #include "interlacemodes.h"
00010 #include "overlayframe.inc"
00011 #include "playbackconfig.h"
00012 #include "recordconfig.h"
00013 #include "tracks.h"
00014 #include "workarounds.h"
00015
00016 int EDLSession::current_id = 0;
00017
00018 EDLSession::EDLSession(EDL *edl)
00019 {
00020 highlighted_track = 0;
00021 playback_cursor_visible = 0;
00022 aconfig_in = new AudioInConfig;
00023 aconfig_duplex = new AudioOutConfig(1);
00024 vconfig_in = new VideoInConfig;
00025 recording_format = new Asset;
00026 interpolation_type = CUBIC_LINEAR;
00027 interpolate_raw = 1;
00028 white_balance_raw = 1;
00029 test_playback_edits = 1;
00030 brender_start = 0.0;
00031 mpeg4_deblock = 1;
00032
00033 playback_config = new PlaybackConfig;
00034 auto_conf = new AutoConf;
00035 strcpy(vwindow_folder, "");
00036 strcpy(current_folder, "");
00037 strcpy(default_atransition, "");
00038 strcpy(default_vtransition, "");
00039 default_transition_length = 1.0;
00040 folderlist_format = ASSETS_ICONS;
00041 frame_rate = 25;
00042 autos_follow_edits = 1;
00043 labels_follow_edits = 1;
00044 plugins_follow_edits = 1;
00045 audio_tracks = -10;
00046 audio_channels = -10;
00047 video_tracks = -10;
00048 video_channels = -10;
00049 sample_rate = -10;
00050 frame_rate = -10;
00051 frames_per_foot = -10;
00052 min_meter_db = -1000;
00053 max_meter_db = -1000;
00054 output_w = -1000;
00055 output_h = -1000;
00056 video_write_length = -1000;
00057 color_model = -100;
00058 interlace_mode = BC_ILACE_MODE_UNDETECTED;
00059 record_speed = 24;
00060 decode_subtitles = 0;
00061 subtitle_number = 0;
00062 }
00063
00064 EDLSession::~EDLSession()
00065 {
00066 delete aconfig_in;
00067 delete aconfig_duplex;
00068 delete auto_conf;
00069 delete vconfig_in;
00070 delete playback_config;
00071 Garbage::delete_object(recording_format);
00072 }
00073
00074
00075 char* EDLSession::get_cwindow_display()
00076 {
00077 if(playback_config->vconfig->x11_host[0])
00078 return playback_config->vconfig->x11_host;
00079 else
00080 return 0;
00081 }
00082
00083 int EDLSession::need_rerender(EDLSession *ptr)
00084 {
00085 return (playback_preload != ptr->playback_preload) ||
00086 (interpolation_type != ptr->interpolation_type) ||
00087 (video_every_frame != ptr->video_every_frame) ||
00088 (video_asynchronous != ptr->video_asynchronous) ||
00089 (real_time_playback != ptr->real_time_playback) ||
00090 (playback_software_position != ptr->playback_software_position) ||
00091 (test_playback_edits != ptr->test_playback_edits) ||
00092 (playback_buffer != ptr->playback_buffer) ||
00093 (decode_subtitles != ptr->decode_subtitles) ||
00094 (subtitle_number != ptr->subtitle_number) ||
00095 (interpolate_raw != ptr->interpolate_raw) ||
00096 (white_balance_raw != ptr->white_balance_raw);
00097 }
00098
00099 void EDLSession::equivalent_output(EDLSession *session, double *result)
00100 {
00101 if(session->output_w != output_w ||
00102 session->output_h != output_h ||
00103 session->frame_rate != frame_rate ||
00104 session->color_model != color_model ||
00105 session->interpolation_type != interpolation_type ||
00106 session->interpolate_raw != interpolate_raw ||
00107 session->white_balance_raw != white_balance_raw ||
00108 session->mpeg4_deblock != mpeg4_deblock ||
00109 session->decode_subtitles != decode_subtitles ||
00110 session->subtitle_number != subtitle_number)
00111 *result = 0;
00112
00113
00114
00115 if(brender_start != session->brender_start &&
00116 (*result < 0 || *result > brender_start))
00117 *result = brender_start;
00118 }
00119
00120
00121 int EDLSession::load_defaults(BC_Hash *defaults)
00122 {
00123 char string[BCTEXTLEN];
00124
00125
00126 for(int i = 0; i < MAXCHANNELS; i++)
00127 {
00128 sprintf(string, "ACHANNEL_ANGLE_%d", i);
00129 int default_position = i * 30;
00130
00131 if(i == 0) default_position = 180;
00132 else
00133 if(i == 1) default_position = 0;
00134 else
00135 if(default_position == 90) default_position = 300;
00136 else
00137 if(default_position == 0) default_position = 330;
00138
00139 achannel_positions[i] = defaults->get(string, default_position);
00140 }
00141 aconfig_duplex->load_defaults(defaults);
00142 aconfig_in->load_defaults(defaults);
00143 actual_frame_rate = defaults->get("ACTUAL_FRAME_RATE", (float)-1);
00144 assetlist_format = defaults->get("ASSETLIST_FORMAT", ASSETS_ICONS);
00145 aspect_w = defaults->get("ASPECTW", (float)4);
00146 aspect_h = defaults->get("ASPECTH", (float)3);
00147 for(int i = 0; i < ASSET_COLUMNS; i++)
00148 {
00149 sprintf(string, "ASSET_COLUMN%d", i);
00150 asset_columns[i] = defaults->get(string, 100);
00151 }
00152 audio_channels = defaults->get("ACHANNELS", 2);
00153 audio_tracks = defaults->get("ATRACKS", 2);
00154 auto_conf->load_defaults(defaults);
00155 autos_follow_edits = defaults->get("AUTOS_FOLLOW_EDITS", 1);
00156 brender_start = defaults->get("BRENDER_START", brender_start);
00157 cmodel_to_text(string, BC_RGBA8888);
00158 color_model = cmodel_from_text(defaults->get("COLOR_MODEL", string));
00159 ilacemode_to_xmltext(string, BC_ILACE_MODE_NOTINTERLACED);
00160 interlace_mode = ilacemode_from_xmltext(defaults->get("INTERLACE_MODE",string), BC_ILACE_MODE_NOTINTERLACED);
00161 crop_x1 = defaults->get("CROP_X1", 0);
00162 crop_x2 = defaults->get("CROP_X2", 320);
00163 crop_y1 = defaults->get("CROP_Y1", 0);
00164 crop_y2 = defaults->get("CROP_Y2", 240);
00165 sprintf(current_folder, MEDIA_FOLDER);
00166 defaults->get("CURRENT_FOLDER", current_folder);
00167 cursor_on_frames = defaults->get("CURSOR_ON_FRAMES", 1);
00168 cwindow_dest = defaults->get("CWINDOW_DEST", 0);
00169 cwindow_mask = defaults->get("CWINDOW_MASK", 0);
00170 cwindow_meter = defaults->get("CWINDOW_METER", 1);
00171 cwindow_operation = defaults->get("CWINDOW_OPERATION", 0);
00172 cwindow_scrollbars = defaults->get("CWINDOW_SCROLLBARS", 1);
00173 cwindow_xscroll = defaults->get("CWINDOW_XSCROLL", 0);
00174 cwindow_yscroll = defaults->get("CWINDOW_YSCROLL", 0);
00175 cwindow_zoom = defaults->get("CWINDOW_ZOOM", (float)1);
00176 sprintf(default_atransition, "Crossfade");
00177 defaults->get("DEFAULT_ATRANSITION", default_atransition);
00178 sprintf(default_vtransition, "Dissolve");
00179 defaults->get("DEFAULT_VTRANSITION", default_vtransition);
00180 default_transition_length = defaults->get("DEFAULT_TRANSITION_LENGTH", (double)1);
00181 edit_handle_mode[0] = defaults->get("EDIT_HANDLE_MODE0", MOVE_ALL_EDITS);
00182 edit_handle_mode[1] = defaults->get("EDIT_HANDLE_MODE1", MOVE_ONE_EDIT);
00183 edit_handle_mode[2] = defaults->get("EDIT_HANDLE_MODE2", MOVE_NO_EDITS);
00184 editing_mode = defaults->get("EDITING_MODE", EDITING_IBEAM);
00185 enable_duplex = defaults->get("ENABLE_DUPLEX", 1);
00186 folderlist_format = defaults->get("FOLDERLIST_FORMAT", FOLDERS_ICONS);
00187 frame_rate = defaults->get("FRAMERATE", (double)30000.0/1001);
00188 frames_per_foot = defaults->get("FRAMES_PER_FOOT", (float)16);
00189 interpolation_type = defaults->get("INTERPOLATION_TYPE", interpolation_type);
00190 interpolate_raw = defaults->get("INTERPOLATE_RAW", interpolate_raw);
00191 white_balance_raw = defaults->get("WHITE_BALANCE_RAW", white_balance_raw);
00192 labels_follow_edits = defaults->get("LABELS_FOLLOW_EDITS", 1);
00193 plugins_follow_edits = defaults->get("PLUGINS_FOLLOW_EDITS", 1);
00194 auto_keyframes = defaults->get("AUTO_KEYFRAMES", 0);
00195 meter_format = defaults->get("METER_FORMAT", METER_DB);
00196 min_meter_db = defaults->get("MIN_METER_DB", -85);
00197 max_meter_db = defaults->get("MAX_METER_DB", 6);
00198 mpeg4_deblock = defaults->get("MPEG4_DEBLOCK", mpeg4_deblock);
00199 output_w = defaults->get("OUTPUTW", 720);
00200 output_h = defaults->get("OUTPUTH", 480);
00201 playback_buffer = defaults->get("PLAYBACK_BUFFER", 4096);
00202 playback_preload = defaults->get("PLAYBACK_PRELOAD", 0);
00203 playback_software_position = defaults->get("PLAYBACK_SOFTWARE_POSITION", 0);
00204 delete playback_config;
00205 playback_config = new PlaybackConfig;
00206 playback_config->load_defaults(defaults);
00207 real_time_playback = defaults->get("PLAYBACK_REALTIME", 0);
00208 real_time_record = defaults->get("REALTIME_RECORD", 0);
00209 record_software_position = defaults->get("RECORD_SOFTWARE_POSITION", 1);
00210 record_sync_drives = defaults->get("RECORD_SYNC_DRIVES", 0);
00211
00212 record_write_length = defaults->get("RECORD_WRITE_LENGTH", 131072);
00213 recording_format->load_defaults(defaults,
00214 "RECORD_",
00215 1,
00216 1,
00217 1,
00218 1,
00219 1);
00220 safe_regions = defaults->get("SAFE_REGIONS", 1);
00221 sample_rate = defaults->get("SAMPLERATE", 48000);
00222 scrub_speed = defaults->get("SCRUB_SPEED", (float)2);
00223 si_useduration = defaults->get("SI_USEDURATION",0);
00224 si_duration = defaults->get("SI_DURATION",5);
00225
00226 show_assets = defaults->get("SHOW_ASSETS", 1);
00227 show_titles = defaults->get("SHOW_TITLES", 1);
00228
00229 time_format = defaults->get("TIME_FORMAT", TIME_HMS);
00230 for(int i = 0; i < 4; i++)
00231 {
00232 sprintf(string, "TIMECODE_OFFSET_%d", i);
00233 timecode_offset[i] = defaults->get(string, 0);
00234 }
00235 nudge_seconds = defaults->get("NUDGE_FORMAT", 1);
00236 tool_window = defaults->get("TOOL_WINDOW", 0);
00237 vconfig_in->load_defaults(defaults);
00238 for(int i = 0; i < MAXCHANNELS; i++)
00239 {
00240 int default_position = i * output_w;
00241 sprintf(string, "VCHANNEL_X_%d", i);
00242 vchannel_x[i] = defaults->get(string, default_position);
00243 sprintf(string, "VCHANNEL_Y_%d", i);
00244 vchannel_y[i] = defaults->get(string, 0);
00245 }
00246 video_channels = defaults->get("VCHANNELS", 1);
00247 video_every_frame = defaults->get("VIDEO_EVERY_FRAME", 1);
00248 video_asynchronous = defaults->get("VIDEO_ASYNCHRONOUS", 0);
00249 video_tracks = defaults->get("VTRACKS", 1);
00250 video_write_length = defaults->get("VIDEO_WRITE_LENGTH", 30);
00251 view_follows_playback = defaults->get("VIEW_FOLLOWS_PLAYBACK", 1);
00252 vwindow_meter = defaults->get("VWINDOW_METER", 1);
00253
00254
00255 decode_subtitles = defaults->get("DECODE_SUBTITLES", decode_subtitles);
00256 subtitle_number = defaults->get("SUBTITLE_NUMBER", subtitle_number);
00257
00258 vwindow_folder[0] = 0;
00259 vwindow_source = -1;
00260 vwindow_zoom = defaults->get("VWINDOW_ZOOM", (float)1);
00261 boundaries();
00262
00263 return 0;
00264 }
00265
00266 int EDLSession::save_defaults(BC_Hash *defaults)
00267 {
00268 char string[BCTEXTLEN];
00269
00270
00271 for(int i = 0; i < MAXCHANNELS; i++)
00272 {
00273 sprintf(string, "ACHANNEL_ANGLE_%d", i);
00274 defaults->update(string, achannel_positions[i]);
00275 }
00276 defaults->update("ACHANNELS", audio_channels);
00277 aconfig_duplex->save_defaults(defaults);
00278 aconfig_in->save_defaults(defaults);
00279 for(int i = 0; i < ASSET_COLUMNS; i++)
00280 {
00281 sprintf(string, "ASSET_COLUMN%d", i);
00282 defaults->update(string, asset_columns[i]);
00283 }
00284 auto_conf->save_defaults(defaults);
00285 defaults->update("ACTUAL_FRAME_RATE", actual_frame_rate);
00286 defaults->update("ASSETLIST_FORMAT", assetlist_format);
00287 defaults->update("ASPECTW", aspect_w);
00288 defaults->update("ASPECTH", aspect_h);
00289 defaults->update("ATRACKS", audio_tracks);
00290 defaults->update("AUTOS_FOLLOW_EDITS", autos_follow_edits);
00291 defaults->update("BRENDER_START", brender_start);
00292 cmodel_to_text(string, color_model);
00293 defaults->update("COLOR_MODEL", string);
00294 ilacemode_to_xmltext(string, interlace_mode);
00295 defaults->update("INTERLACE_MODE", string);
00296 defaults->update("CROP_X1", crop_x1);
00297 defaults->update("CROP_X2", crop_x2);
00298 defaults->update("CROP_Y1", crop_y1);
00299 defaults->update("CROP_Y2", crop_y2);
00300 defaults->update("CURRENT_FOLDER", current_folder);
00301 defaults->update("CURSOR_ON_FRAMES", cursor_on_frames);
00302 defaults->update("CWINDOW_DEST", cwindow_dest);
00303 defaults->update("CWINDOW_MASK", cwindow_mask);
00304 defaults->update("CWINDOW_METER", cwindow_meter);
00305 defaults->update("CWINDOW_OPERATION", cwindow_operation);
00306 defaults->update("CWINDOW_SCROLLBARS", cwindow_scrollbars);
00307 defaults->update("CWINDOW_XSCROLL", cwindow_xscroll);
00308 defaults->update("CWINDOW_YSCROLL", cwindow_yscroll);
00309 defaults->update("CWINDOW_ZOOM", cwindow_zoom);
00310 defaults->update("DEFAULT_ATRANSITION", default_atransition);
00311 defaults->update("DEFAULT_VTRANSITION", default_vtransition);
00312 defaults->update("DEFAULT_TRANSITION_LENGTH", default_transition_length);
00313 defaults->update("EDIT_HANDLE_MODE0", edit_handle_mode[0]);
00314 defaults->update("EDIT_HANDLE_MODE1", edit_handle_mode[1]);
00315 defaults->update("EDIT_HANDLE_MODE2", edit_handle_mode[2]);
00316 defaults->update("EDITING_MODE", editing_mode);
00317 defaults->update("ENABLE_DUPLEX", enable_duplex);
00318 defaults->update("FOLDERLIST_FORMAT", folderlist_format);
00319 defaults->update("FRAMERATE", frame_rate);
00320 defaults->update("FRAMES_PER_FOOT", frames_per_foot);
00321 defaults->update("HIGHLIGHTED_TRACK", highlighted_track);
00322 defaults->update("INTERPOLATION_TYPE", interpolation_type);
00323 defaults->update("INTERPOLATE_RAW", interpolate_raw);
00324 defaults->update("WHITE_BALANCE_RAW", white_balance_raw);
00325 defaults->update("LABELS_FOLLOW_EDITS", labels_follow_edits);
00326 defaults->update("PLUGINS_FOLLOW_EDITS", plugins_follow_edits);
00327 defaults->update("AUTO_KEYFRAMES", auto_keyframes);
00328 defaults->update("METER_FORMAT", meter_format);
00329 defaults->update("MIN_METER_DB", min_meter_db);
00330 defaults->update("MAX_METER_DB", max_meter_db);
00331 defaults->update("MPEG4_DEBLOCK", mpeg4_deblock);
00332 defaults->update("OUTPUTW", output_w);
00333 defaults->update("OUTPUTH", output_h);
00334 defaults->update("PLAYBACK_BUFFER", playback_buffer);
00335 defaults->update("PLAYBACK_PRELOAD", playback_preload);
00336 defaults->update("PLAYBACK_SOFTWARE_POSITION", playback_software_position);
00337 playback_config->save_defaults(defaults);
00338 defaults->update("PLAYBACK_REALTIME", real_time_playback);
00339 defaults->update("REALTIME_RECORD", real_time_record);
00340 defaults->update("RECORD_SOFTWARE_POSITION", record_software_position);
00341 defaults->update("RECORD_SYNC_DRIVES", record_sync_drives);
00342
00343 defaults->update("RECORD_WRITE_LENGTH", record_write_length);
00344 recording_format->save_defaults(defaults,
00345 "RECORD_",
00346 1,
00347 1,
00348 1,
00349 1,
00350 1);
00351 defaults->update("SAFE_REGIONS", safe_regions);
00352 defaults->update("SAMPLERATE", sample_rate);
00353 defaults->update("SCRUB_SPEED", scrub_speed);
00354 defaults->update("SI_USEDURATION",si_useduration);
00355 defaults->update("SI_DURATION",si_duration);
00356 defaults->update("SHOW_ASSETS", show_assets);
00357 defaults->update("SHOW_TITLES", show_titles);
00358
00359 defaults->update("TIME_FORMAT", time_format);
00360 for(int i = 0; i < 4; i++)
00361 {
00362 sprintf(string, "TIMECODE_OFFSET_%d", i);
00363 defaults->update(string, timecode_offset[i]);
00364 }
00365 defaults->update("NUDGE_FORMAT", nudge_seconds);
00366 defaults->update("TOOL_WINDOW", tool_window);
00367 vconfig_in->save_defaults(defaults);
00368 for(int i = 0; i < MAXCHANNELS; i++)
00369 {
00370 sprintf(string, "VCHANNEL_X_%d", i);
00371 defaults->update(string, vchannel_x[i]);
00372 sprintf(string, "VCHANNEL_Y_%d", i);
00373 defaults->update(string, vchannel_y[i]);
00374 }
00375 defaults->update("VCHANNELS", video_channels);
00376 defaults->update("VIDEO_EVERY_FRAME", video_every_frame);
00377 defaults->update("VIDEO_ASYNCHRONOUS", video_asynchronous);
00378 defaults->update("VTRACKS", video_tracks);
00379 defaults->update("VIDEO_WRITE_LENGTH", video_write_length);
00380 defaults->update("VIEW_FOLLOWS_PLAYBACK", view_follows_playback);
00381 defaults->update("VWINDOW_METER", vwindow_meter);
00382 defaults->update("VWINDOW_ZOOM", vwindow_zoom);
00383
00384 defaults->update("DECODE_SUBTITLES", decode_subtitles);
00385 defaults->update("SUBTITLE_NUMBER", subtitle_number);
00386
00387
00388 return 0;
00389 }
00390
00391
00392
00393
00394 #define BC_INFINITY 65536
00395
00396
00397 void EDLSession::boundaries()
00398 {
00399 Workarounds::clamp(audio_tracks, 0, (int)BC_INFINITY);
00400 Workarounds::clamp(audio_channels, 1, MAXCHANNELS - 1);
00401 Workarounds::clamp(sample_rate, 1, 1000000);
00402 Workarounds::clamp(video_tracks, 0, (int)BC_INFINITY);
00403 Workarounds::clamp(video_channels, 1, MAXCHANNELS - 1);
00404 Workarounds::clamp(frame_rate, 1.0, (double)BC_INFINITY);
00405 Workarounds::clamp(min_meter_db, -80, -20);
00406 Workarounds::clamp(max_meter_db, 0, 10);
00407 Workarounds::clamp(frames_per_foot, 1, 32);
00408 Workarounds::clamp(output_w, 16, (int)BC_INFINITY);
00409 Workarounds::clamp(output_h, 16, (int)BC_INFINITY);
00410 Workarounds::clamp(video_write_length, 1, 1000);
00411
00412 output_w /= 2;
00413 output_w *= 2;
00414 output_h /= 2;
00415 output_h *= 2;
00416
00417 Workarounds::clamp(crop_x1, 0, output_w);
00418 Workarounds::clamp(crop_x2, 0, output_w);
00419 Workarounds::clamp(crop_y1, 0, output_h);
00420 Workarounds::clamp(crop_y2, 0, output_h);
00421 if(brender_start < 0) brender_start = 0.0;
00422
00423 Workarounds::clamp(subtitle_number, 0, 31);
00424
00425
00426 frame_rate = Units::fix_framerate(frame_rate);
00427
00428
00429
00430
00431 }
00432
00433
00434
00435 int EDLSession::load_video_config(FileXML *file, int append_mode, uint32_t load_flags)
00436 {
00437 char string[1024];
00438 if(append_mode) return 0;
00439 interpolation_type = file->tag.get_property("INTERPOLATION_TYPE", interpolation_type);
00440 interpolate_raw = file->tag.get_property("INTERPOLATE_RAW", interpolate_raw);
00441 white_balance_raw = file->tag.get_property("WHITE_BALANCE_RAW", white_balance_raw);
00442 cmodel_to_text(string, color_model);
00443 color_model = cmodel_from_text(file->tag.get_property("COLORMODEL", string));
00444 interlace_mode = ilacemode_from_xmltext(file->tag.get_property("INTERLACE_MODE"), BC_ILACE_MODE_NOTINTERLACED);
00445 video_channels = file->tag.get_property("CHANNELS", video_channels);
00446 for(int i = 0; i < video_channels; i++)
00447 {
00448 int default_position = i * output_w;
00449 sprintf(string, "VCHANNEL_X_%d", i);
00450 vchannel_x[i] = file->tag.get_property(string, default_position);
00451 sprintf(string, "VCHANNEL_Y_%d", i);
00452 vchannel_y[i] = file->tag.get_property(string, 0);
00453 }
00454
00455 frame_rate = file->tag.get_property("FRAMERATE", frame_rate);
00456 frames_per_foot = file->tag.get_property("FRAMES_PER_FOOT", frames_per_foot);
00457 output_w = file->tag.get_property("OUTPUTW", output_w);
00458 output_h = file->tag.get_property("OUTPUTH", output_h);
00459 aspect_w = file->tag.get_property("ASPECTW", aspect_w);
00460 aspect_h = file->tag.get_property("ASPECTH", aspect_h);
00461 return 0;
00462 }
00463
00464 int EDLSession::load_audio_config(FileXML *file, int append_mode, uint32_t load_flags)
00465 {
00466 char string[32];
00467
00468 if(append_mode) return 0;
00469 audio_channels = file->tag.get_property("CHANNELS", (int64_t)audio_channels);
00470
00471
00472 for(int i = 0; i < audio_channels; i++)
00473 {
00474 sprintf(string, "ACHANNEL_ANGLE_%d", i);
00475 achannel_positions[i] = file->tag.get_property(string, achannel_positions[i]);
00476
00477 }
00478
00479 sample_rate = file->tag.get_property("SAMPLERATE", (int64_t)sample_rate);
00480 return 0;
00481 }
00482
00483 int EDLSession::load_xml(FileXML *file,
00484 int append_mode,
00485 uint32_t load_flags)
00486 {
00487 char string[BCTEXTLEN];
00488
00489 if(append_mode)
00490 {
00491 }
00492 else
00493 {
00494 assetlist_format = file->tag.get_property("ASSETLIST_FORMAT", assetlist_format);
00495 for(int i = 0; i < ASSET_COLUMNS; i++)
00496 {
00497 sprintf(string, "ASSET_COLUMN%d", i);
00498 asset_columns[i] = file->tag.get_property(string, asset_columns[i]);
00499 }
00500 auto_conf->load_xml(file);
00501 auto_keyframes = file->tag.get_property("AUTO_KEYFRAMES", auto_keyframes);
00502 autos_follow_edits = file->tag.get_property("AUTOS_FOLLOW_EDITS", autos_follow_edits);
00503 brender_start = file->tag.get_property("BRENDER_START", brender_start);
00504 crop_x1 = file->tag.get_property("CROP_X1", crop_x1);
00505 crop_y1 = file->tag.get_property("CROP_Y1", crop_y1);
00506 crop_x2 = file->tag.get_property("CROP_X2", crop_x2);
00507 crop_y2 = file->tag.get_property("CROP_Y2", crop_y2);
00508 file->tag.get_property("CURRENT_FOLDER", current_folder);
00509 cursor_on_frames = file->tag.get_property("CURSOR_ON_FRAMES", cursor_on_frames);
00510 cwindow_dest = file->tag.get_property("CWINDOW_DEST", cwindow_dest);
00511 cwindow_mask = file->tag.get_property("CWINDOW_MASK", cwindow_mask);
00512 cwindow_meter = file->tag.get_property("CWINDOW_METER", cwindow_meter);
00513 cwindow_operation = file->tag.get_property("CWINDOW_OPERATION", cwindow_operation);
00514 cwindow_scrollbars = file->tag.get_property("CWINDOW_SCROLLBARS", cwindow_scrollbars);
00515 cwindow_xscroll = file->tag.get_property("CWINDOW_XSCROLL", cwindow_xscroll);
00516 cwindow_yscroll = file->tag.get_property("CWINDOW_YSCROLL", cwindow_yscroll);
00517 cwindow_zoom = file->tag.get_property("CWINDOW_ZOOM", cwindow_zoom);
00518 file->tag.get_property("DEFAULT_ATRANSITION", default_atransition);
00519 file->tag.get_property("DEFAULT_VTRANSITION", default_vtransition);
00520 default_transition_length = file->tag.get_property("DEFAULT_TRANSITION_LENGTH", default_transition_length);
00521 editing_mode = file->tag.get_property("EDITING_MODE", editing_mode);
00522 folderlist_format = file->tag.get_property("FOLDERLIST_FORMAT", folderlist_format);
00523 highlighted_track = file->tag.get_property("HIGHLIGHTED_TRACK", 0);
00524 labels_follow_edits = file->tag.get_property("LABELS_FOLLOW_EDITS", labels_follow_edits);
00525 mpeg4_deblock = file->tag.get_property("MPEG4_DEBLOCK", mpeg4_deblock);
00526 plugins_follow_edits = file->tag.get_property("PLUGINS_FOLLOW_EDITS", plugins_follow_edits);
00527 playback_preload = file->tag.get_property("PLAYBACK_PRELOAD", playback_preload);
00528 safe_regions = file->tag.get_property("SAFE_REGIONS", safe_regions);
00529 show_assets = file->tag.get_property("SHOW_ASSETS", 1);
00530 show_titles = file->tag.get_property("SHOW_TITLES", 1);
00531
00532 time_format = file->tag.get_property("TIME_FORMAT", time_format);
00533 for(int i = 0; i < 4; i++)
00534 {
00535 sprintf(string, "TIMECODE_OFFSET_%d", i);
00536 timecode_offset[i] = file->tag.get_property(string, timecode_offset[i]);
00537 }
00538 nudge_seconds = file->tag.get_property("NUDGE_FORMAT", nudge_seconds);
00539 tool_window = file->tag.get_property("TOOL_WINDOW", tool_window);
00540 vwindow_meter = file->tag.get_property("VWINDOW_METER", vwindow_meter);
00541 file->tag.get_property("VWINDOW_FOLDER", vwindow_folder);
00542 vwindow_source = file->tag.get_property("VWINDOW_SOURCE", vwindow_source);
00543 vwindow_zoom = file->tag.get_property("VWINDOW_ZOOM", vwindow_zoom);
00544
00545 decode_subtitles = file->tag.get_property("DECODE_SUBTITLES", decode_subtitles);
00546 subtitle_number = file->tag.get_property("subtitle_number", subtitle_number);
00547 boundaries();
00548 }
00549
00550 return 0;
00551 }
00552
00553 int EDLSession::save_xml(FileXML *file)
00554 {
00555
00556 char string[BCTEXTLEN];
00557 file->tag.set_title("SESSION");
00558 file->tag.set_property("ASSETLIST_FORMAT", assetlist_format);
00559 for(int i = 0; i < ASSET_COLUMNS; i++)
00560 {
00561 sprintf(string, "ASSET_COLUMN%d", i);
00562 file->tag.set_property(string, asset_columns[i]);
00563 }
00564 auto_conf->save_xml(file);
00565 file->tag.set_property("AUTO_KEYFRAMES", auto_keyframes);
00566 file->tag.set_property("AUTOS_FOLLOW_EDITS", autos_follow_edits);
00567 file->tag.set_property("BRENDER_START", brender_start);
00568 file->tag.set_property("CROP_X1", crop_x1);
00569 file->tag.set_property("CROP_Y1", crop_y1);
00570 file->tag.set_property("CROP_X2", crop_x2);
00571 file->tag.set_property("CROP_Y2", crop_y2);
00572 file->tag.set_property("CURRENT_FOLDER", current_folder);
00573 file->tag.set_property("CURSOR_ON_FRAMES", cursor_on_frames);
00574 file->tag.set_property("CWINDOW_DEST", cwindow_dest);
00575 file->tag.set_property("CWINDOW_MASK", cwindow_mask);
00576 file->tag.set_property("CWINDOW_METER", cwindow_meter);
00577 file->tag.set_property("CWINDOW_OPERATION", cwindow_operation);
00578 file->tag.set_property("CWINDOW_SCROLLBARS", cwindow_scrollbars);
00579 file->tag.set_property("CWINDOW_XSCROLL", cwindow_xscroll);
00580 file->tag.set_property("CWINDOW_YSCROLL", cwindow_yscroll);
00581 file->tag.set_property("CWINDOW_ZOOM", cwindow_zoom);
00582 file->tag.set_property("DEFAULT_ATRANSITION", default_atransition);
00583 file->tag.set_property("DEFAULT_VTRANSITION", default_vtransition);
00584 file->tag.set_property("DEFAULT_TRANSITION_LENGTH", default_transition_length);
00585 file->tag.set_property("EDITING_MODE", editing_mode);
00586 file->tag.set_property("FOLDERLIST_FORMAT", folderlist_format);
00587 file->tag.set_property("HIGHLIGHTED_TRACK", highlighted_track);
00588 file->tag.set_property("LABELS_FOLLOW_EDITS", labels_follow_edits);
00589 file->tag.set_property("MPEG4_DEBLOCK", mpeg4_deblock);
00590 file->tag.set_property("PLUGINS_FOLLOW_EDITS", plugins_follow_edits);
00591 file->tag.set_property("PLAYBACK_PRELOAD", playback_preload);
00592 file->tag.set_property("SAFE_REGIONS", safe_regions);
00593 file->tag.set_property("SHOW_ASSETS", show_assets);
00594 file->tag.set_property("SHOW_TITLES", show_titles);
00595 file->tag.set_property("TEST_PLAYBACK_EDITS", test_playback_edits);
00596 file->tag.set_property("TIME_FORMAT", time_format);
00597 for(int i = 0; i < 4; i++)
00598 {
00599 sprintf(string, "TIMECODE_OFFSET_%d", i);
00600 file->tag.set_property(string, timecode_offset[i]);
00601 }
00602 file->tag.set_property("NUDGE_SECONDS", nudge_seconds);
00603 file->tag.set_property("TOOL_WINDOW", tool_window);
00604 file->tag.set_property("VWINDOW_METER", vwindow_meter);
00605 file->tag.set_property("VWINDOW_FOLDER", vwindow_folder);
00606 file->tag.set_property("VWINDOW_SOURCE", vwindow_source);
00607 file->tag.set_property("VWINDOW_ZOOM", vwindow_zoom);
00608
00609
00610 file->tag.set_property("DECODE_SUBTITLES", decode_subtitles);
00611 file->tag.set_property("subtitle_number", subtitle_number);
00612
00613
00614
00615 file->append_tag();
00616 file->tag.set_title("/SESSION");
00617 file->append_tag();
00618 file->append_newline();
00619 file->append_newline();
00620
00621 return 0;
00622 }
00623
00624 int EDLSession::save_video_config(FileXML *file)
00625 {
00626 char string[1024];
00627 file->tag.set_title("VIDEO");
00628 file->tag.set_property("INTERPOLATION_TYPE", interpolation_type);
00629 file->tag.set_property("INTERPOLATE_RAW", interpolate_raw);
00630 file->tag.set_property("WHITE_BALANCE_RAW", white_balance_raw);
00631 cmodel_to_text(string, color_model);
00632 file->tag.set_property("COLORMODEL", string);
00633 ilacemode_to_xmltext(string, interlace_mode);
00634 file->tag.set_property("INTERLACE_MODE",string);
00635 file->tag.set_property("CHANNELS", video_channels);
00636 for(int i = 0; i < video_channels; i++)
00637 {
00638 sprintf(string, "VCHANNEL_X_%d", i);
00639 file->tag.set_property(string, vchannel_x[i]);
00640 sprintf(string, "VCHANNEL_Y_%d", i);
00641 file->tag.set_property(string, vchannel_y[i]);
00642 }
00643
00644 file->tag.set_property("FRAMERATE", frame_rate);
00645 file->tag.set_property("FRAMES_PER_FOOT", frames_per_foot);
00646 file->tag.set_property("OUTPUTW", output_w);
00647 file->tag.set_property("OUTPUTH", output_h);
00648 file->tag.set_property("ASPECTW", aspect_w);
00649 file->tag.set_property("ASPECTH", aspect_h);
00650 file->append_tag();
00651 file->tag.set_title("/VIDEO");
00652 file->append_tag();
00653 file->append_newline();
00654 file->append_newline();
00655 return 0;
00656 }
00657
00658 int EDLSession::save_audio_config(FileXML *file)
00659 {
00660 char string[1024];
00661 file->tag.set_title("AUDIO");
00662 file->tag.set_property("SAMPLERATE", (int64_t)sample_rate);
00663 file->tag.set_property("CHANNELS", (int64_t)audio_channels);
00664
00665 for(int i = 0; i < audio_channels; i++)
00666 {
00667 sprintf(string, "ACHANNEL_ANGLE_%d", i);
00668 file->tag.set_property(string, achannel_positions[i]);
00669 }
00670
00671 file->append_tag();
00672 file->tag.set_title("/AUDIO");
00673 file->append_tag();
00674 file->append_newline();
00675 file->append_newline();
00676 return 0;
00677 }
00678
00679 int EDLSession::copy(EDLSession *session)
00680 {
00681
00682 for(int i = 0; i < MAXCHANNELS; i++)
00683 {
00684 achannel_positions[i] = session->achannel_positions[i];
00685 }
00686 aconfig_duplex->copy_from(session->aconfig_duplex);
00687 aconfig_in->copy_from(session->aconfig_in);
00688 actual_frame_rate = session->actual_frame_rate;
00689 for(int i = 0; i < ASSET_COLUMNS; i++)
00690 {
00691 asset_columns[i] = session->asset_columns[i];
00692 }
00693 assetlist_format = session->assetlist_format;
00694 auto_conf->copy_from(session->auto_conf);
00695 aspect_w = session->aspect_w;
00696 aspect_h = session->aspect_h;
00697 audio_channels = session->audio_channels;
00698 audio_tracks = session->audio_tracks;
00699 autos_follow_edits = session->autos_follow_edits;
00700 brender_start = session->brender_start;
00701 color_model = session->color_model;
00702 interlace_mode = session->interlace_mode;
00703 crop_x1 = session->crop_x1;
00704 crop_y1 = session->crop_y1;
00705 crop_x2 = session->crop_x2;
00706 crop_y2 = session->crop_y2;
00707 strcpy(current_folder, session->current_folder);
00708 cursor_on_frames = session->cursor_on_frames;
00709 cwindow_dest = session->cwindow_dest;
00710 cwindow_mask = session->cwindow_mask;
00711 cwindow_meter = session->cwindow_meter;
00712 cwindow_operation = session->cwindow_operation;
00713 cwindow_scrollbars = session->cwindow_scrollbars;
00714 cwindow_xscroll = session->cwindow_xscroll;
00715 cwindow_yscroll = session->cwindow_yscroll;
00716 cwindow_zoom = session->cwindow_zoom;
00717 strcpy(default_atransition, session->default_atransition);
00718 strcpy(default_vtransition, session->default_vtransition);
00719 default_transition_length = session->default_transition_length;
00720 edit_handle_mode[0] = session->edit_handle_mode[0];
00721 edit_handle_mode[1] = session->edit_handle_mode[1];
00722 edit_handle_mode[2] = session->edit_handle_mode[2];
00723 editing_mode = session->editing_mode;
00724 enable_duplex = session->enable_duplex;
00725 folderlist_format = session->folderlist_format;
00726 frame_rate = session->frame_rate;
00727 frames_per_foot = session->frames_per_foot;
00728 highlighted_track = session->highlighted_track;
00729 interpolation_type = session->interpolation_type;
00730 interpolate_raw = session->interpolate_raw;
00731 white_balance_raw = session->white_balance_raw;
00732 labels_follow_edits = session->labels_follow_edits;
00733 plugins_follow_edits = session->plugins_follow_edits;
00734 auto_keyframes = session->auto_keyframes;
00735
00736 meter_format = session->meter_format;
00737 min_meter_db = session->min_meter_db;
00738 max_meter_db = session->max_meter_db;
00739 mpeg4_deblock = session->mpeg4_deblock;
00740 output_w = session->output_w;
00741 output_h = session->output_h;
00742 playback_buffer = session->playback_buffer;
00743 delete playback_config;
00744 playback_config = new PlaybackConfig;
00745 playback_config->copy_from(session->playback_config);
00746 playback_cursor_visible = session->playback_cursor_visible;
00747 playback_preload = session->playback_preload;
00748 playback_software_position = session->playback_software_position;
00749 real_time_playback = session->real_time_playback;
00750 real_time_record = session->real_time_record;
00751 record_software_position = session->record_software_position;
00752
00753 record_sync_drives = session->record_sync_drives;
00754 record_write_length = session->record_write_length;
00755 recording_format->copy_from(session->recording_format, 0);
00756 safe_regions = session->safe_regions;
00757 sample_rate = session->sample_rate;
00758 scrub_speed = session->scrub_speed;
00759 si_useduration = session->si_useduration;
00760 si_duration = session->si_duration;
00761 show_assets = session->show_assets;
00762 show_titles = session->show_titles;
00763 test_playback_edits = session->test_playback_edits;
00764 time_format = session->time_format;
00765 for(int i = 0; i < 4; i++)
00766 {
00767 timecode_offset[i] = session->timecode_offset[i];
00768 }
00769 nudge_seconds = session->nudge_seconds;
00770 tool_window = session->tool_window;
00771 for(int i = 0; i < MAXCHANNELS; i++)
00772 {
00773 vchannel_x[i] = session->vchannel_x[i];
00774 vchannel_y[i] = session->vchannel_y[i];
00775 }
00776 video_channels = session->video_channels;
00777 *vconfig_in = *session->vconfig_in;
00778 video_every_frame = session->video_every_frame;
00779 video_asynchronous = session->video_asynchronous;
00780 video_tracks = session->video_tracks;
00781 video_write_length = session->video_write_length;
00782 view_follows_playback = session->view_follows_playback;
00783 vwindow_meter = session->vwindow_meter;
00784 strcpy(vwindow_folder, session->vwindow_folder);
00785 vwindow_source = session->vwindow_source;
00786 vwindow_zoom = session->vwindow_zoom;
00787
00788 subtitle_number = session->subtitle_number;
00789 decode_subtitles = session->decode_subtitles;
00790
00791 return 0;
00792 }
00793
00794 int64_t EDLSession::get_frame_offset()
00795 {
00796 return int64_t((timecode_offset[3] * 3600 +
00797 timecode_offset[2] * 60 +
00798 timecode_offset[1]) *
00799 frame_rate +
00800 timecode_offset[0]);
00801 }
00802
00803 void EDLSession::dump()
00804 {
00805 printf("EDLSession::dump\n");
00806 printf(" audio_tracks=%d audio_channels=%d sample_rate=%lld\n"
00807 "video_tracks=%d frame_rate=%f output_w=%d output_h=%d aspect_w=%f aspect_h=%f decode subtitles=%d subtitle_number=%d\n",
00808 audio_tracks,
00809 audio_channels,
00810 sample_rate,
00811 video_tracks,
00812 frame_rate,
00813 output_w,
00814 output_h,
00815 aspect_w,
00816 aspect_h,
00817 decode_subtitles,
00818 subtitle_number);
00819 }