4 * Copyright (C) 1997-2011 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
26 #include "awindowgui.h"
27 #include "batchrender.h"
28 #include "bcprogressbox.h"
29 #include "bcsignals.h"
32 #include "compresspopup.h"
33 #include "condition.h"
34 #include "confirmsave.h"
35 #include "cwindowgui.h"
40 #include "edlsession.h"
43 #include "filesystem.h"
45 #include "formatcheck.h"
46 #include "formatpopup.h"
47 #include "formattools.h"
48 #include "indexable.h"
52 #include "localsession.h"
53 #include "mainprogress.h"
54 #include "mainsession.h"
58 #include "mwindowgui.h"
60 #include "packagedispatcher.h"
61 #include "packagerenderer.h"
63 #include "playabletracks.h"
64 #include "preferences.h"
65 #include "preferencesthread.h"
66 #include "renderfarm.h"
68 #include "renderprofiles.h"
69 #include "statusbar.h"
73 #include "transportque.h"
76 #include "videoconfig.h"
84 RenderItem::RenderItem(MWindow *mwindow)
85 : BC_MenuItem(_("Render..."), _("Shift-R"), 'R')
87 this->mwindow = mwindow;
91 int RenderItem::handle_event()
93 mwindow->gui->unlock_window();
94 mwindow->render->start_interactive();
95 mwindow->gui->lock_window("RenderItem::handle_event");
108 RenderProgress::RenderProgress(MWindow *mwindow, Render *render)
111 this->mwindow = mwindow;
112 this->render = render;
114 Thread::set_synchronous(1);
117 RenderProgress::~RenderProgress()
124 void RenderProgress::run()
126 Thread::disable_cancel();
129 if(render->total_rendered != last_value)
131 render->progress->update(render->total_rendered);
132 last_value = render->total_rendered;
134 if(mwindow) mwindow->preferences_thread->update_rates();
137 Thread::enable_cancel();
139 Thread::disable_cancel();
145 MainPackageRenderer::MainPackageRenderer(Render *render)
148 this->render = render;
153 MainPackageRenderer::~MainPackageRenderer()
158 int MainPackageRenderer::get_master()
163 int MainPackageRenderer::get_result()
165 return render->result;
168 void MainPackageRenderer::set_result(int value)
171 render->result = value;
177 void MainPackageRenderer::set_progress(int64_t value)
179 render->counter_lock->lock("MainPackageRenderer::set_progress");
180 // Increase total rendered for all nodes
181 render->total_rendered += value;
183 // Update frames per second for master node
184 render->preferences->set_rate(frames_per_second, -1);
186 //printf("MainPackageRenderer::set_progress %d %ld %f\n", __LINE__, (long)value, frames_per_second);
188 // If non interactive, print progress out
189 if(!render->progress)
191 int64_t current_eta = render->progress_timer->get_scaled_difference(1000);
192 if(current_eta - render->last_eta > 1000)
197 if(render->total_rendered)
201 render->progress_max /
202 render->total_rendered -
207 char string[BCTEXTLEN];
208 Units::totext(string,
212 printf("\r%d%% %s: %s ",
213 (int)(100 * (float)render->total_rendered / render->progress_max),
216 render->last_eta = current_eta;
220 render->counter_lock->unlock();
223 mwindow->preferences->copy_rates_from(preferences);
226 int MainPackageRenderer::progress_cancelled()
228 return (render->progress && render->progress->is_cancelled()) ||
229 render->batch_cancelled;
233 Render::Render(MWindow *mwindow)
236 this->mwindow = mwindow;
240 package_lock = new Mutex("Render::package_lock");
241 counter_lock = new Mutex("Render::counter_lock");
242 completion = new Condition(0, "Render::completion");
243 progress_timer = new Timer;
244 range_type = RANGE_BACKCOMPAT;
245 preferences = new Preferences();
246 thread = new RenderThread(mwindow, this);
259 delete progress_timer;
260 if( asset ) asset->Garbage::remove_user();
264 void Render::start_interactive()
266 if( !thread->running() ) {
267 mode = Render::INTERACTIVE;
268 BC_DialogThread::start();
270 else if( in_progress ) {
272 mwindow->gui->get_abs_cursor(cx, cy, 1);
273 ErrorBox error_box(_(PROGRAM_NAME ": Error"), cx, cy);
274 error_box.create_objects(_("Already rendering"));
275 error_box.raise_window();
276 error_box.run_window();
278 else if( render_window ) {
279 render_window->raise_window();
284 void Render::start_batches(ArrayList<BatchRenderJob*> *jobs)
286 if(!thread->running())
288 mode = Render::BATCH;
294 else if( in_progress ) {
296 mwindow->gui->get_abs_cursor(cx, cy, 1);
297 ErrorBox error_box(_(PROGRAM_NAME ": Error"), cx, cy);
298 error_box.create_objects("Already rendering");
299 error_box.raise_window();
300 error_box.run_window();
302 // raise the window if rendering hasn't started yet
303 else if( render_window ) {
304 render_window->raise_window();
308 void Render::start_batches(ArrayList<BatchRenderJob*> *jobs,
309 BC_Hash *boot_defaults, Preferences *batch_prefs)
311 mode = Render::BATCH;
313 preferences->copy_from(batch_prefs);
321 BC_Window* Render::new_gui()
327 if(mode == Render::INTERACTIVE) {
328 // Fix the asset for rendering
329 if(!asset) asset = new Asset;
330 load_defaults(asset);
331 check_asset(mwindow->edl, *asset);
332 int px = mwindow->gui->get_pop_cursor_x(1);
333 int py = mwindow->gui->get_pop_cursor_y(1);
334 // Get format from user
335 render_window = new RenderWindow(mwindow, this, asset, px, py);
336 render_window->create_objects();
339 return render_window;
342 void Render::handle_done_event(int result)
345 // add to recentlist only on OK
346 render_window->render_format->path_recent->
347 add_item(File::formattostr(asset->format), asset->path);
352 void Render::handle_close_event(int result)
355 double render_range = get_render_range();
356 const char *err_msg = 0;
358 if( !result && !render_range ) {
359 err_msg = _("zero render range");
362 if( !result && asset->video_data ) {
363 double frame_rate = mwindow->edl->session->frame_rate;
364 if( frame_rate > 0 && render_range+1e-3 < 1./frame_rate ) {
365 err_msg = _("Video data and range less than 1 frame");
369 if( !result && asset->audio_data ) {
370 double sample_rate = mwindow->edl->session->sample_rate;
371 if( sample_rate > 0 && render_range+1e-6 < 1./sample_rate ) {
372 err_msg = _("Audio data and range less than 1 sample");
376 if( !result && File::is_image_render(asset->format) ) {
377 if( asset->video_data ) {
378 double frames = render_range * mwindow->edl->session->frame_rate;
379 if( !EQUIV(frames, 1.) ) {
380 err_msg = _("Image format and not 1 frame");
385 err_msg = _("Image format and no video data");
391 mwindow->gui->get_abs_cursor(cx, cy, 1);
392 ErrorBox error_box(_(PROGRAM_NAME ": Error"),cx, cy);
393 error_box.create_objects(err_msg);
394 error_box.raise_window();
395 error_box.run_window();
399 // Check the asset format for errors.
400 FormatCheck format_check(asset);
401 if( format_check.check_format() )
407 save_defaults(asset);
409 mwindow->save_defaults();
413 if(debug) printf("Render::handle_close_event %d\n", __LINE__);
414 if(!result) start_render();
415 if(debug) printf("Render::handle_close_event %d\n", __LINE__);
422 void Render::stop_operation()
424 if(thread->Thread::running())
427 // Wait for completion
428 completion->lock("Render::stop_operation");
435 int Render::check_asset(EDL *edl, Asset &asset)
437 if(asset.video_data &&
438 edl->tracks->playable_video_tracks() &&
439 File::renders_video(&asset))
441 asset.video_data = 1;
443 asset.width = edl->session->output_w;
444 asset.height = edl->session->output_h;
445 asset.interlace_mode = edl->session->interlace_mode;
449 asset.video_data = 0;
453 if(asset.audio_data &&
454 edl->tracks->playable_audio_tracks() &&
455 File::renders_audio(&asset))
457 asset.audio_data = 1;
458 asset.channels = edl->session->audio_channels;
462 asset.audio_data = 0;
466 if(!asset.audio_data &&
474 int Render::get_strategy(int use_renderfarm, int file_per_label)
476 return use_renderfarm ?
477 (file_per_label ? FILE_PER_LABEL_FARM : SINGLE_PASS_FARM) :
478 (file_per_label ? FILE_PER_LABEL : SINGLE_PASS ) ;
480 int Render::get_strategy()
482 return get_strategy(preferences->use_renderfarm, file_per_label);
485 void Render::start_progress()
487 char filename[BCTEXTLEN];
488 char string[BCTEXTLEN];
491 progress_max = packages->get_progress_max();
493 progress_timer->update();
497 // Generate the progress box
498 fs.extract_name(filename, default_asset->path);
499 sprintf(string, _("Rendering %s..."), filename);
501 // Don't bother with the filename since renderfarm defeats the meaning
502 progress = mwindow->mainprogress->start_progress(_("Rendering..."),
504 render_progress = new RenderProgress(mwindow, this);
505 render_progress->start();
509 void Render::stop_progress()
513 char string[BCTEXTLEN], string2[BCTEXTLEN];
514 delete render_progress;
515 progress->get_time(string);
516 elapsed_time = progress->get_time();
517 progress->stop_progress();
520 sprintf(string2, _("Rendering took %s"), string);
521 mwindow->gui->lock_window("");
522 mwindow->gui->show_message(string2);
523 mwindow->gui->update_default_message();
524 mwindow->gui->stop_hourglass();
525 mwindow->gui->unlock_window();
532 void Render::start_render()
542 void Render::create_filename(char *path,
549 int len = strlen(default_path);
550 char printf_string[BCTEXTLEN];
552 for(i = 0, j = 0; i < number_start; i++, j++)
554 printf_string[j] = default_path[i];
558 sprintf(&printf_string[j], "%%0%dd", total_digits);
559 j = strlen(printf_string);
562 // Copy remainder of string
563 for( ; i < len; i++, j++)
565 printf_string[j] = default_path[i];
567 printf_string[j] = 0;
568 // Print the printf argument to the path
569 sprintf(path, printf_string, current_number);
572 void Render::get_starting_number(char *path,
578 int len = strlen(path);
579 char number_text[BCTEXTLEN];
587 ptr2 = strrchr(path, '/');
589 // Search for first 0 after last /.
591 ptr = strchr(ptr2, '0');
593 if(ptr && isdigit(*ptr))
595 number_start = ptr - path;
597 // Store the first number
598 char *ptr2 = number_text;
602 current_number = atol(number_text);
603 total_digits = strlen(number_text);
607 // No number found or number not long enough
608 if(total_digits < min_digits)
612 total_digits = min_digits;
617 int Render::load_defaults(Asset *asset)
619 file_per_label = mwindow->defaults->get("RENDER_FILE_PER_LABEL", 0);
620 load_mode = mwindow->defaults->get("RENDER_LOADMODE", LOADMODE_NEW_TRACKS);
621 range_type = mwindow->defaults->get("RENDER_RANGE_TYPE", RANGE_PROJECT);
623 // some defaults which work
624 asset->video_data = 1;
625 asset->audio_data = 1;
626 asset->format = FILE_FFMPEG;
627 strcpy(asset->acodec, "mp4.qt");
628 strcpy(asset->vcodec, "mp4.qt");
630 asset->load_defaults(mwindow->defaults,
631 "RENDER_", 1, 1, 1, 1, 1);
635 int Render::load_profile(int profile_slot, Asset *asset)
637 char string_name[100];
638 sprintf(string_name, "RENDER_%i_FILE_PER_LABEL", profile_slot);
639 file_per_label = mwindow->defaults->get(string_name, 0);
640 // Load mode is not part of the profile
641 // printf(string_name, "RENDER_%i_LOADMODE", profile_slot);
642 // load_mode = mwindow->defaults->get(string_name, LOADMODE_NEW_TRACKS);
643 sprintf(string_name, "RENDER_%i_RANGE_TYPE", profile_slot);
644 range_type = mwindow->defaults->get(string_name, RANGE_PROJECT);
646 sprintf(string_name, "RENDER_%i_", profile_slot);
647 asset->load_defaults(mwindow->defaults,
648 string_name, 1, 1, 1, 1, 1);
653 int Render::save_defaults(Asset *asset)
655 mwindow->defaults->update("RENDER_FILE_PER_LABEL", file_per_label);
656 mwindow->defaults->update("RENDER_LOADMODE", load_mode);
657 mwindow->defaults->update("RENDER_RANGE_TYPE", range_type);
659 asset->save_defaults(mwindow->defaults,
660 "RENDER_", 1, 1, 1, 1, 1);
665 static void run_script(const char *script, const char *arg)
667 char *const argv[] = { (char*)script, (char*)arg, 0 };
668 execvp(script ,&argv[0]);
669 perror("execvp script failed");
673 RenderThread::RenderThread(MWindow *mwindow, Render *render)
676 this->mwindow = mwindow;
677 this->render = render;
680 RenderThread::~RenderThread()
685 void RenderThread::render_single(int test_overwrite, Asset *asset, EDL *edl,
686 int strategy, int range_type)
688 // Total length in seconds
690 RenderFarmServer *farm_server = 0;
695 render->in_progress = 1;
698 render->default_asset = asset;
699 render->progress = 0;
702 // Create rendering command
703 TransportCommand *command = new TransportCommand;
704 command->command = NORMAL_FWD;
705 command->get_edl()->copy_all(edl);
706 command->change_type = CHANGE_ALL;
708 switch( range_type ) {
709 case RANGE_BACKCOMPAT:
710 // Get highlighted playback range
711 command->set_playback_range();
712 // Adjust playback range with in/out points
713 command->playback_range_adjust_inout();
716 command->playback_range_project();
718 case RANGE_SELECTION:
719 command->set_playback_range();
722 command->playback_range_inout();
725 command->playback_range_1frame();
729 render->packages = new PackageDispatcher;
732 CICache *audio_cache = new CICache(render->preferences);
733 CICache *video_cache = new CICache(render->preferences);
735 render->default_asset->frame_rate = command->get_edl()->session->frame_rate;
736 render->default_asset->sample_rate = command->get_edl()->session->sample_rate;
738 // Conform asset to EDL. Find out if any tracks are playable.
739 render->result = render->check_asset(command->get_edl(),
740 *render->default_asset);
744 // Get total range to render
745 render->total_start = command->start_position;
746 render->total_end = command->end_position;
747 total_length = render->total_end - render->total_start;
750 if(EQUIV(total_length, 0))
759 // Stop background rendering
760 if(mwindow) mwindow->stop_brender();
762 fs.complete_path(render->default_asset->path);
764 render->result = render->packages->create_packages(mwindow,
768 render->default_asset,
775 render->total_rendered = 0;
779 // Start dispatching external jobs
782 mwindow->gui->lock_window("Render::render 1");
783 mwindow->gui->show_message(_("Starting render farm"));
784 mwindow->gui->start_hourglass();
785 mwindow->gui->unlock_window();
789 printf("Render::render: starting render farm\n");
792 if(strategy == SINGLE_PASS_FARM || strategy == FILE_PER_LABEL_FARM)
794 farm_server = new RenderFarmServer(mwindow,
799 &render->total_rendered,
800 render->counter_lock,
801 render->default_asset,
804 render->result = farm_server->start_clients();
810 mwindow->gui->lock_window("Render::render 2");
811 mwindow->gui->show_message(_("Failed to start render farm"),
812 mwindow->theme->message_error);
813 mwindow->gui->stop_hourglass();
814 mwindow->gui->unlock_window();
818 printf("Render::render: Failed to start render farm\n");
824 // Perform local rendering
829 render->start_progress();
834 MainPackageRenderer package_renderer(render);
835 render->result = package_renderer.initialize(mwindow,
836 command->get_edl(), // Copy of master EDL
838 render->default_asset);
846 while(!render->result)
848 // Get unfinished job
849 RenderPackage *package;
851 if(strategy == SINGLE_PASS_FARM)
853 package = render->packages->get_package(
854 package_renderer.frames_per_second,
860 package = render->packages->get_package(0, -1, 1);
875 if(package_renderer.render_package(package))
883 printf("Render::render_single: Session finished.\n");
889 if(strategy == SINGLE_PASS_FARM || strategy == FILE_PER_LABEL_FARM)
891 farm_server->wait_clients();
892 render->result |= render->packages->packages_are_done();
895 if(debug) printf("Render::render %d\n", __LINE__);
899 (!render->progress || !render->progress->is_cancelled()) &&
900 !render->batch_cancelled)
902 if(debug) printf("Render::render %d\n", __LINE__);
905 if(debug) printf("Render::render %d\n", __LINE__);
907 mwindow->gui->get_abs_cursor(cx, cy, 1);
908 ErrorBox error_box(_(PROGRAM_NAME ": Error"), cx, cy);
909 error_box.create_objects(_("Error rendering data."));
910 error_box.raise_window();
911 error_box.run_window();
912 if(debug) printf("Render::render %d\n", __LINE__);
916 printf("Render::render: Error rendering data\n");
919 if(debug) printf("Render::render %d\n", __LINE__);
921 // Delete the progress box
922 render->stop_progress();
924 if(debug) printf("Render::render %d\n", __LINE__);
928 // Paste all packages into timeline if desired
930 if(!render->result &&
931 render->load_mode != LOADMODE_NOTHING &&
933 render->mode != Render::BATCH)
935 if(debug) printf("Render::render %d\n", __LINE__);
936 mwindow->gui->lock_window("Render::render 3");
937 if(debug) printf("Render::render %d\n", __LINE__);
939 mwindow->undo->update_undo_before();
941 if(debug) printf("Render::render %d\n", __LINE__);
944 ArrayList<Indexable*> *assets = render->packages->get_asset_list();
945 if(debug) printf("Render::render %d\n", __LINE__);
946 if(render->load_mode == LOADMODE_PASTE)
948 if(debug) printf("Render::render %d\n", __LINE__);
949 mwindow->load_assets(assets, -1, render->load_mode, 0, 0,
950 mwindow->edl->session->labels_follow_edits,
951 mwindow->edl->session->plugins_follow_edits,
952 mwindow->edl->session->autos_follow_edits,
954 if(debug) printf("Render::render %d\n", __LINE__);
955 for(int i = 0; i < assets->size(); i++)
956 assets->get(i)->Garbage::remove_user();
958 if(debug) printf("Render::render %d\n", __LINE__);
961 mwindow->save_backup();
962 if(debug) printf("Render::render %d\n", __LINE__);
963 mwindow->undo->update_undo_after(_("render"), LOAD_ALL);
964 if(debug) printf("Render::render %d\n", __LINE__);
965 mwindow->update_plugin_guis();
966 if(debug) printf("Render::render %d\n", __LINE__);
967 mwindow->gui->update(1,
974 if(debug) printf("Render::render %d\n", __LINE__);
975 mwindow->sync_parameters(CHANGE_ALL);
976 if(debug) printf("Render::render %d\n", __LINE__);
977 mwindow->gui->unlock_window();
980 mwindow->awindow->gui->async_update_assets();
982 if(debug) printf("Render::render %d\n", __LINE__);
985 if(debug) printf("Render::render %d\n", __LINE__);
990 mwindow->gui->lock_window("Render::render 3");
991 mwindow->gui->stop_hourglass();
992 mwindow->gui->unlock_window();
995 //printf("Render::render 110\n");
996 // Need to restart because brender always stops before render.
998 mwindow->restart_brender();
999 if(farm_server) delete farm_server;
1003 // Must delete packages after server
1004 delete render->packages;
1006 render->packages = 0;
1007 render->in_progress = 0;
1008 if(debug) printf("Render::render %d\n", __LINE__);
1011 void RenderThread::run()
1014 render->preferences->copy_from(mwindow->preferences);
1016 if(render->mode == Render::INTERACTIVE)
1018 render_single(1, render->asset, mwindow->edl,
1019 render->get_strategy(), render->range_type);
1022 if(render->mode == Render::BATCH)
1025 // printf("RenderThread::run %d %d %d\n",
1027 // render->jobs->total,
1029 for(int i = 0; i < render->jobs->total && !render->result; i++)
1032 BatchRenderJob *job = render->jobs->values[i];
1036 if( *job->edl_path == '@' )
1038 run_script(job->edl_path+1, job->asset->path);
1043 mwindow->batch_render->update_active(i);
1047 printf("Render::run: %s\n", job->edl_path);
1052 FileXML *file = new FileXML;
1054 edl->create_objects();
1055 file->read_from_file(job->edl_path);
1056 edl->load_xml(file, LOAD_ALL);
1058 render_single(0, job->asset, edl, job->get_strategy(), RANGE_BACKCOMPAT);
1061 edl->Garbage::remove_user();
1066 mwindow->batch_render->update_done(i, 1, render->elapsed_time);
1069 char string[BCTEXTLEN];
1070 render->elapsed_time =
1071 (double)render->progress_timer->get_scaled_difference(1);
1072 Units::totext(string,
1073 render->elapsed_time,
1075 printf("Render::run: done in %s\n", string);
1081 mwindow->batch_render->update_active(-1);
1083 printf("Render::run: failed\n");
1091 mwindow->batch_render->update_active(-1);
1092 mwindow->batch_render->update_done(-1, 0, 0);
1095 render->completion->unlock();
1103 RenderWindow::RenderWindow(MWindow *mwindow,
1108 : BC_Window(_(PROGRAM_NAME ": Render"), x, y,
1109 WIDTH, HEIGHT, WIDTH, HEIGHT, 0, 0, 1)
1111 this->mwindow = mwindow;
1112 this->render = render;
1113 this->asset = asset;
1123 RenderWindow::~RenderWindow()
1125 lock_window("RenderWindow::~RenderWindow");
1126 delete render_format;
1128 delete renderprofile;
1133 void RenderWindow::load_profile(int profile_slot)
1135 render->load_profile(profile_slot, asset);
1136 update_range_type(render->range_type);
1137 render_format->update(asset, &render->file_per_label);
1141 void RenderWindow::create_objects()
1144 lock_window("RenderWindow::create_objects");
1145 add_subwindow(new BC_Title(x, y,
1146 (char*)(render->file_per_label ?
1147 _("Select the first file to render to:") :
1148 _("Select a file to render to:"))));
1151 render_format = new RenderFormat(mwindow, this, asset);
1152 render_format->create_objects(x, y,
1153 1, 1, 1, 1, 0, 1, 0, 0, &render->file_per_label, 0);
1156 add_subwindow(title = new BC_Title(x, y, _("Render range:")));
1158 int is_image = File::is_image_render(asset->format);
1160 render->range_type = RANGE_1FRAME;
1162 int x1 = x + title->get_w() + 20;
1163 add_subwindow(rangeproject = new RenderRangeProject(this,
1164 render->range_type == RANGE_PROJECT, x1, y));
1166 add_subwindow(rangeselection = new RenderRangeSelection(this,
1167 render->range_type == RANGE_SELECTION, x1, y));
1169 add_subwindow(rangeinout = new RenderRangeInOut(this,
1170 render->range_type == RANGE_INOUT, x1, y));
1172 add_subwindow(range1frame = new RenderRange1Frame(this,
1173 render->range_type == RANGE_1FRAME, x1, y));
1177 enable_render_range(0);
1179 renderprofile = new RenderProfile(mwindow, this, x, y, 1);
1180 renderprofile->create_objects();
1183 loadmode = new LoadMode(mwindow, this, x, y, &render->load_mode, 1);
1184 loadmode->create_objects();
1186 add_subwindow(new BC_OKButton(this));
1187 add_subwindow(new BC_CancelButton(this));
1193 void RenderWindow::update_range_type(int range_type)
1195 if( render->range_type == range_type ) return;
1196 render->range_type = range_type;
1197 rangeproject->update(range_type == RANGE_PROJECT);
1198 rangeselection->update(range_type == RANGE_SELECTION);
1199 rangeinout->update(range_type == RANGE_INOUT);
1200 range1frame->update(range_type == RANGE_1FRAME);
1203 void RenderWindow::enable_render_range(int v)
1206 rangeproject->enable();
1207 rangeselection->enable();
1208 rangeinout->enable();
1209 range1frame->enable();
1212 rangeproject->disable();
1213 rangeselection->disable();
1214 rangeinout->disable();
1215 range1frame->disable();
1220 RenderRangeProject::RenderRangeProject(RenderWindow *rwindow, int value, int x, int y)
1221 : BC_Radial(x, y, value, _("Project"))
1223 this->rwindow = rwindow;
1225 int RenderRangeProject::handle_event()
1227 rwindow->update_range_type(RANGE_PROJECT);
1231 RenderRangeSelection::RenderRangeSelection(RenderWindow *rwindow, int value, int x, int y)
1232 : BC_Radial(x, y, value, _("Selection"))
1234 this->rwindow = rwindow;
1236 int RenderRangeSelection::handle_event()
1238 rwindow->update_range_type(RANGE_SELECTION);
1243 RenderRangeInOut::RenderRangeInOut(RenderWindow *rwindow, int value, int x, int y)
1244 : BC_Radial(x, y, value, _("In/Out Points"))
1246 this->rwindow = rwindow;
1248 int RenderRangeInOut::handle_event()
1250 rwindow->update_range_type(RANGE_INOUT);
1254 RenderRange1Frame::RenderRange1Frame(RenderWindow *rwindow, int value, int x, int y)
1255 : BC_Radial(x, y, value, _("One Frame"))
1257 this->rwindow = rwindow;
1259 int RenderRange1Frame::handle_event()
1261 rwindow->update_range_type(RANGE_1FRAME);
1265 double Render::get_render_range()
1267 EDL *edl = mwindow->edl;
1268 double last = edl->tracks->total_playable_length();
1269 double framerate = edl->session->frame_rate;
1270 if( framerate <= 0 ) framerate = 1;
1271 double start = 0, end = last;
1272 switch( range_type ) {
1274 case RANGE_BACKCOMPAT:
1275 start = edl->local_session->get_selectionstart(1);
1276 end = edl->local_session->get_selectionend(1);
1277 if( EQUIV(start, end) ) end = last;
1281 case RANGE_SELECTION:
1282 start = edl->local_session->get_selectionstart(1);
1283 end = edl->local_session->get_selectionend(1);
1286 start = edl->local_session->inpoint_valid() ?
1287 edl->local_session->get_inpoint() : 0;
1288 end = edl->local_session->outpoint_valid() ?
1289 edl->local_session->get_outpoint() : last;
1292 start = end = edl->local_session->get_selectionstart(1);
1293 if( edl->session->frame_rate > 0 ) end += 1./edl->session->frame_rate;
1296 if( start < 0 ) start = 0;
1297 if( end > last ) end = last;
1301 RenderFormat::RenderFormat(MWindow *mwindow, BC_WindowBase *window, Asset *asset)
1302 : FormatTools(mwindow, window, asset)
1305 RenderFormat::~RenderFormat()
1309 void RenderFormat::update_format()
1311 FormatTools::update_format();
1312 RenderWindow *render_window = (RenderWindow *)window;
1313 if( render_window->is_hidden() ) return;
1315 int is_image = File::is_image_render(asset->format);
1317 render_window->update_range_type(RANGE_1FRAME);
1318 render_window->enable_render_range(0);
1321 render_window->enable_render_range(1);