6 #include "edlsession.h"
12 #include "mainerror.h"
15 #include "mwindowgui.h"
17 #include "pluginset.h"
25 #include <sys/statfs.h>
29 const int64_t CreateBD_Thread::BD_SIZE = 25000000000;
30 const int CreateBD_Thread::BD_STREAMS = 1;
31 const int CreateBD_Thread::BD_WIDTH = 1920;
32 const int CreateBD_Thread::BD_HEIGHT = 1080;
33 const double CreateBD_Thread::BD_ASPECT_WIDTH = 4.;
34 const double CreateBD_Thread::BD_ASPECT_HEIGHT = 3.;
35 const double CreateBD_Thread::BD_WIDE_ASPECT_WIDTH = 16.;
36 const double CreateBD_Thread::BD_WIDE_ASPECT_HEIGHT = 9.;
37 const double CreateBD_Thread::BD_FRAMERATE = 24000. / 1001.;
38 //const int CreateBD_Thread::BD_MAX_BITRATE = 40000000;
39 const int CreateBD_Thread::BD_MAX_BITRATE = 8000000;
40 const int CreateBD_Thread::BD_CHANNELS = 2;
41 const int CreateBD_Thread::BD_WIDE_CHANNELS = 6;
42 const double CreateBD_Thread::BD_SAMPLERATE = 48000;
43 const double CreateBD_Thread::BD_KAUDIO_RATE = 224;
46 CreateBD_MenuItem::CreateBD_MenuItem(MWindow *mwindow)
47 : BC_MenuItem(_("BD Render..."), _("Ctrl-d"), 'd')
50 this->mwindow = mwindow;
53 int CreateBD_MenuItem::handle_event()
55 mwindow->create_bd->start();
60 CreateBD_Thread::CreateBD_Thread(MWindow *mwindow)
63 this->mwindow = mwindow;
65 this->use_deinterlace = 0;
66 this->use_inverse_telecine = 0;
68 this->use_resize_tracks = 0;
69 this->use_histogram = 0;
70 this->use_wide_audio = 0;
71 this->use_wide_aspect = 0;
72 this->use_label_chapters = 0;
75 CreateBD_Thread::~CreateBD_Thread()
80 int CreateBD_Thread::create_bd_jobs(ArrayList<BatchRenderJob*> *jobs,
81 const char *tmp_path, const char *asset_title)
83 EDL *edl = mwindow->edl;
84 if( !edl || !edl->session ) {
86 sprintf(msg, _("No EDL/Session"));
87 MainError::show_error(msg);
90 EDLSession *session = edl->session;
92 double total_length = edl->tracks->total_length();
93 if( total_length <= 0 ) {
95 sprintf(msg, _("No content: %s"), asset_title);
96 MainError::show_error(msg);
100 char asset_dir[BCTEXTLEN];
101 sprintf(asset_dir, "%s/%s", tmp_path, asset_title);
103 if( mkdir(asset_dir, 0777) ) {
104 char err[BCTEXTLEN], msg[BCTEXTLEN];
105 strerror_r(errno, err, sizeof(err));
106 sprintf(msg, _("Unable to create directory: %s\n-- %s"), asset_dir, err);
107 MainError::show_error(msg);
111 double old_samplerate = session->sample_rate;
112 double old_framerate = session->frame_rate;
114 session->video_channels = BD_STREAMS;
115 session->video_tracks = BD_STREAMS;
116 // use session framerate
117 // session->frame_rate = BD_FRAMERATE;
118 session->output_w = BD_WIDTH;
119 session->output_h = BD_HEIGHT;
120 session->aspect_w = use_wide_aspect ? BD_WIDE_ASPECT_WIDTH : BD_ASPECT_WIDTH;
121 session->aspect_h = use_wide_aspect ? BD_WIDE_ASPECT_HEIGHT : BD_ASPECT_HEIGHT;
122 session->sample_rate = BD_SAMPLERATE;
123 session->audio_channels = session->audio_tracks =
124 use_wide_audio ? BD_WIDE_CHANNELS : BD_CHANNELS;
126 char script_filename[BCTEXTLEN];
127 sprintf(script_filename, "%s/bd.sh", asset_dir);
128 int fd = open(script_filename, O_WRONLY+O_CREAT+O_TRUNC, 0755);
129 FILE *fp = fdopen(fd, "w");
131 char err[BCTEXTLEN], msg[BCTEXTLEN];
132 strerror_r(errno, err, sizeof(err));
133 sprintf(msg, _("Unable to save: %s\n-- %s"), script_filename, err);
134 MainError::show_error(msg);
137 char exe_path[BCTEXTLEN];
138 get_exe_path(exe_path);
139 fprintf(fp,"#!/bin/bash -ex\n");
140 fprintf(fp,"PATH=$PATH:%s\n",exe_path);
141 fprintf(fp,"mkdir -p $1/udfs\n");
142 fprintf(fp,"sz=`du -sb $1/bd.m2ts | sed -e 's/[ \t].*//'`\n");
143 fprintf(fp,"blks=$((sz/2048 + 4096))\n");
144 fprintf(fp,"mkudffs $1/bd.udfs $blks\n");
145 fprintf(fp,"mount -o loop $1/bd.udfs $1/udfs\n");
146 fprintf(fp,"bdwrite $1/udfs $1/bd.m2ts\n");
147 fprintf(fp,"umount $1/udfs\n");
148 fprintf(fp,"echo To burn bluray, load writable media and run:\n");
149 fprintf(fp,"echo growisofs -dvd-compat -Z /dev/bd=$1/bd.udfs\n");
153 if( use_wide_audio ) {
154 session->audio_channels = session->audio_tracks = BD_WIDE_CHANNELS;
155 session->achannel_positions[0] = 90;
156 session->achannel_positions[1] = 150;
157 session->achannel_positions[2] = 30;
158 session->achannel_positions[3] = 210;
159 session->achannel_positions[4] = 330;
160 session->achannel_positions[5] = 270;
161 if( edl->tracks->recordable_audio_tracks() == BD_WIDE_CHANNELS )
162 mwindow->remap_audio(MWindow::AUDIO_1_TO_1);
165 session->audio_channels = session->audio_tracks = BD_CHANNELS;
166 session->achannel_positions[0] = 180;
167 session->achannel_positions[1] = 0;
168 if( edl->tracks->recordable_audio_tracks() == BD_WIDE_CHANNELS )
169 mwindow->remap_audio(MWindow::AUDIO_5_1_TO_2);
172 double new_samplerate = session->sample_rate;
173 double new_framerate = session->frame_rate;
175 edl->resample(old_samplerate, new_samplerate, TRACK_AUDIO);
176 edl->resample(old_framerate, new_framerate, TRACK_VIDEO);
178 int64_t aud_size = ((BD_KAUDIO_RATE * total_length)/8 + 1000-1) * 1000;
179 int64_t vid_size = BD_SIZE*0.96 - aud_size;
180 int64_t vid_bitrate = (vid_size * 8) / total_length;
181 vid_bitrate /= 1000; vid_bitrate *= 1000;
182 if( vid_bitrate > BD_MAX_BITRATE ) vid_bitrate = BD_MAX_BITRATE;
184 char xml_filename[BCTEXTLEN];
185 sprintf(xml_filename, "%s/bd.xml", asset_dir);
187 edl->save_xml(&xml_file, xml_filename, 0, 0);
188 xml_file.terminate_string();
189 if( xml_file.write_to_file(xml_filename) ) {
191 sprintf(msg, _("Unable to save: %s"), xml_filename);
192 MainError::show_error(msg);
196 BatchRenderJob *job = new BatchRenderJob(mwindow->preferences);
198 strcpy(&job->edl_path[0], xml_filename);
199 Asset *asset = job->asset;
201 asset->layers = BD_STREAMS;
202 asset->frame_rate = session->frame_rate;
203 asset->width = session->output_w;
204 asset->height = session->output_h;
205 asset->aspect_ratio = session->aspect_w / session->aspect_h;
207 char option_path[BCTEXTLEN];
208 sprintf(&asset->path[0],"%s/bd.m2ts", asset_dir);
209 asset->format = FILE_FFMPEG;
210 strcpy(asset->fformat, "m2ts");
212 asset->audio_data = 1;
213 strcpy(asset->acodec, "bluray.m2ts");
214 FFMPEG::set_option_path(option_path, "audio/%s", asset->acodec);
215 FFMPEG::load_options(option_path, asset->ff_audio_options,
216 sizeof(asset->ff_audio_options));
217 asset->ff_audio_bitrate = BD_KAUDIO_RATE * 1000;
219 asset->video_data = 1;
220 strcpy(asset->vcodec, "bluray.m2ts");
221 FFMPEG::set_option_path(option_path, "video/%s", asset->vcodec);
222 FFMPEG::load_options(option_path, asset->ff_video_options,
223 sizeof(asset->ff_video_options));
224 asset->ff_video_bitrate = vid_bitrate;
225 asset->ff_video_quality = 0;
227 int len = strlen(asset->ff_video_options);
228 char *cp = asset->ff_video_options + len;
229 snprintf(cp, sizeof(asset->ff_video_options)-len-1,
230 "aspect %.5f\n", asset->aspect_ratio);
232 job = new BatchRenderJob(mwindow->preferences);
234 job->edl_path[0] = '@';
235 strcpy(&job->edl_path[1], script_filename);
236 strcpy(&job->asset->path[0], asset_dir);
241 void CreateBD_Thread::handle_close_event(int result)
244 mwindow->batch_render->load_defaults(mwindow->defaults);
245 mwindow->undo->update_undo_before();
246 KeyFrame keyframe; char data[BCTEXTLEN];
247 if( use_deinterlace ) {
248 sprintf(data,"<DEINTERLACE MODE=1>");
249 keyframe.set_data(data);
250 insert_video_plugin("Deinterlace", &keyframe);
252 if( use_inverse_telecine ) {
253 sprintf(data,"<IVTC FRAME_OFFSET=0 FIRST_FIELD=0 "
254 "AUTOMATIC=1 AUTO_THRESHOLD=2.0e+00 PATTERN=2>");
255 keyframe.set_data(data);
256 insert_video_plugin("Inverse Telecine", &keyframe);
259 sprintf(data,"<PHOTOSCALE WIDTH=%d HEIGHT=%d USE_FILE=1>", BD_WIDTH, BD_HEIGHT);
260 keyframe.set_data(data);
261 insert_video_plugin("Auto Scale", &keyframe);
263 if( use_resize_tracks )
265 if( use_histogram ) {
267 sprintf(data, "<HISTOGRAM OUTPUT_MIN_0=0 OUTPUT_MAX_0=1 "
268 "OUTPUT_MIN_1=0 OUTPUT_MAX_1=1 "
269 "OUTPUT_MIN_2=0 OUTPUT_MAX_2=1 "
270 "OUTPUT_MIN_3=0 OUTPUT_MAX_3=1 "
271 "AUTOMATIC=0 THRESHOLD=9.0-01 PLOT=0 SPLIT=0>"
272 "<POINTS></POINTS><POINTS></POINTS><POINTS></POINTS>"
273 "<POINTS><POINT X=6.0e-02 Y=0>"
274 "<POINT X=9.4e-01 Y=1></POINTS>");
276 sprintf(data, "<HISTOGRAM AUTOMATIC=0 THRESHOLD=1.0e-01 "
277 "PLOT=0 SPLIT=0 W=440 H=500 PARADE=0 MODE=3 "
278 "LOW_OUTPUT_0=0 HIGH_OUTPUT_0=1 LOW_INPUT_0=0 HIGH_INPUT_0=1 GAMMA_0=1 "
279 "LOW_OUTPUT_1=0 HIGH_OUTPUT_1=1 LOW_INPUT_1=0 HIGH_INPUT_1=1 GAMMA_1=1 "
280 "LOW_OUTPUT_2=0 HIGH_OUTPUT_2=1 LOW_INPUT_2=0 HIGH_INPUT_2=1 GAMMA_2=1 "
281 "LOW_OUTPUT_3=0 HIGH_OUTPUT_3=1 LOW_INPUT_3=0.044 HIGH_INPUT_3=0.956 "
284 keyframe.set_data(data);
285 insert_video_plugin("Histogram", &keyframe);
287 create_bd_jobs(&mwindow->batch_render->jobs, tmp_path, asset_title);
288 mwindow->save_backup();
289 mwindow->undo->update_undo_after(_("create bd"), LOAD_ALL);
290 mwindow->resync_guis();
291 mwindow->batch_render->handle_close_event(0);
292 mwindow->batch_render->start();
295 BC_Window* CreateBD_Thread::new_gui()
297 memset(tmp_path,0,sizeof(tmp_path));
298 strcpy(tmp_path,"/tmp");
299 memset(asset_title,0,sizeof(asset_title));
300 time_t dt; time(&dt);
301 struct tm dtm; localtime_r(&dt, &dtm);
302 sprintf(asset_title, "bd_%02d%02d%02d-%02d%02d%02d",
303 dtm.tm_year+1900, dtm.tm_mon+1, dtm.tm_mday,
304 dtm.tm_hour, dtm.tm_min, dtm.tm_sec);
306 use_inverse_telecine = 0;
308 use_resize_tracks = 0;
312 use_label_chapters = 0;
314 int scr_x = mwindow->gui->get_screen_x(0, -1);
315 int scr_w = mwindow->gui->get_screen_w(0, -1);
316 int scr_h = mwindow->gui->get_screen_h(0, -1);
317 int w = 500, h = 250;
318 int x = scr_x + scr_w/2 - w/2, y = scr_h/2 - h/2;
320 gui = new CreateBD_GUI(this, x, y, w, h);
321 gui->create_objects();
326 CreateBD_OK::CreateBD_OK(CreateBD_GUI *gui, int x, int y)
330 set_tooltip(_("end setup, start batch render"));
333 CreateBD_OK::~CreateBD_OK()
337 int CreateBD_OK::button_press_event()
339 if(get_buttonpress() == 1 && is_event_win() && cursor_inside()) {
346 int CreateBD_OK::keypress_event()
352 CreateBD_Cancel::CreateBD_Cancel(CreateBD_GUI *gui, int x, int y)
353 : BC_CancelButton(x, y)
358 CreateBD_Cancel::~CreateBD_Cancel()
362 int CreateBD_Cancel::button_press_event()
364 if(get_buttonpress() == 1 && is_event_win() && cursor_inside()) {
372 CreateBD_DiskSpace::CreateBD_DiskSpace(CreateBD_GUI *gui, int x, int y)
373 : BC_Title(x, y, "", MEDIUMFONT, GREEN)
378 CreateBD_DiskSpace::~CreateBD_DiskSpace()
382 int64_t CreateBD_DiskSpace::tmp_path_space()
384 const char *path = gui->tmp_path->get_text();
385 if( access(path,R_OK+W_OK) ) return 0;
387 if( statfs(path, &sfs) ) return 0;
388 return (int64_t)sfs.f_bsize * sfs.f_bfree;
391 void CreateBD_DiskSpace::update()
393 // gui->disk_space->set_color(get_bg_color());
394 int64_t disk_space = tmp_path_space();
395 int color = disk_space<gui->needed_disk_space ? RED : GREEN;
396 static const char *suffix[] = { "", "KB", "MB", "GB", "TB", "PB" };
398 for( int64_t space=disk_space; i<5 && (space/=1000)>0; disk_space=space, ++i );
399 char text[BCTEXTLEN];
400 sprintf(text, "%s" _LDv(3) "%s", _("disk space: "), disk_space, suffix[i]);
401 gui->disk_space->BC_Title::update(text);
402 gui->disk_space->set_color(color);
405 CreateBD_TmpPath::CreateBD_TmpPath(CreateBD_GUI *gui, int x, int y, int w)
406 : BC_TextBox(x, y, w, 1, -(int)sizeof(gui->thread->tmp_path),
407 gui->thread->tmp_path, 1, MEDIUMFONT)
412 CreateBD_TmpPath::~CreateBD_TmpPath()
416 int CreateBD_TmpPath::handle_event()
418 gui->disk_space->update();
423 CreateBD_AssetTitle::CreateBD_AssetTitle(CreateBD_GUI *gui, int x, int y, int w)
424 : BC_TextBox(x, y, w, 1, 0, gui->thread->asset_title, 1, MEDIUMFONT)
429 CreateBD_AssetTitle::~CreateBD_AssetTitle()
434 CreateBD_Deinterlace::CreateBD_Deinterlace(CreateBD_GUI *gui, int x, int y)
435 : BC_CheckBox(x, y, &gui->thread->use_deinterlace, _("Deinterlace"))
440 CreateBD_Deinterlace::~CreateBD_Deinterlace()
444 int CreateBD_Deinterlace::handle_event()
447 gui->need_inverse_telecine->set_value(0);
448 gui->thread->use_inverse_telecine = 0;
450 return BC_CheckBox::handle_event();
454 CreateBD_InverseTelecine::CreateBD_InverseTelecine(CreateBD_GUI *gui, int x, int y)
455 : BC_CheckBox(x, y, &gui->thread->use_inverse_telecine, _("Inverse Telecine"))
460 CreateBD_InverseTelecine::~CreateBD_InverseTelecine()
464 int CreateBD_InverseTelecine::handle_event()
467 gui->need_deinterlace->set_value(0);
468 gui->thread->use_deinterlace = 0;
470 return BC_CheckBox::handle_event();
474 CreateBD_Scale::CreateBD_Scale(CreateBD_GUI *gui, int x, int y)
475 : BC_CheckBox(x, y, &gui->thread->use_scale, _("Scale"))
480 CreateBD_Scale::~CreateBD_Scale()
485 CreateBD_ResizeTracks::CreateBD_ResizeTracks(CreateBD_GUI *gui, int x, int y)
486 : BC_CheckBox(x, y, &gui->thread->use_resize_tracks, _("Resize Tracks"))
491 CreateBD_ResizeTracks::~CreateBD_ResizeTracks()
496 CreateBD_Histogram::CreateBD_Histogram(CreateBD_GUI *gui, int x, int y)
497 : BC_CheckBox(x, y, &gui->thread->use_histogram, _("Histogram"))
502 CreateBD_Histogram::~CreateBD_Histogram()
506 CreateBD_LabelChapters::CreateBD_LabelChapters(CreateBD_GUI *gui, int x, int y)
507 : BC_CheckBox(x, y, &gui->thread->use_label_chapters, _("Chapters at Labels"))
512 CreateBD_LabelChapters::~CreateBD_LabelChapters()
516 CreateBD_WideAudio::CreateBD_WideAudio(CreateBD_GUI *gui, int x, int y)
517 : BC_CheckBox(x, y, &gui->thread->use_wide_audio, _("Audio 5.1"))
522 CreateBD_WideAudio::~CreateBD_WideAudio()
526 CreateBD_WideAspect::CreateBD_WideAspect(CreateBD_GUI *gui, int x, int y)
527 : BC_CheckBox(x, y, &gui->thread->use_wide_aspect, _("Aspect 16x9"))
532 CreateBD_WideAspect::~CreateBD_WideAspect()
538 CreateBD_GUI::CreateBD_GUI(CreateBD_Thread *thread, int x, int y, int w, int h)
539 : BC_Window(_(PROGRAM_NAME ": Create BD"), x, y, w, h, 50, 50, 1, 0, 1)
541 this->thread = thread;
542 at_x = at_y = tmp_x = tmp_y = 0;
543 ok_x = ok_y = ok_w = ok_h = 0;
544 cancel_x = cancel_y = cancel_w = cancel_h = 0;
548 needed_disk_space = 100e9;
549 need_deinterlace = 0;
550 need_inverse_telecine = 0;
552 need_resize_tracks = 0;
555 need_wide_aspect = 0;
556 need_label_chapters = 0;
561 CreateBD_GUI::~CreateBD_GUI()
565 void CreateBD_GUI::create_objects()
567 lock_window("CreateBD_GUI::create_objects");
568 int pady = BC_TextBox::calculate_h(this, MEDIUMFONT, 0, 1) + 5;
569 int padx = BC_Title::calculate_w(this, (char*)"X", MEDIUMFONT);
570 int x = padx/2, y = pady/2;
571 BC_Title *title = new BC_Title(x, y, _("Title:"), MEDIUMFONT, YELLOW);
572 add_subwindow(title);
573 at_x = x + title->get_w(); at_y = y;
574 asset_title = new CreateBD_AssetTitle(this, at_x, at_y, get_w()-at_x-10);
575 add_subwindow(asset_title);
576 y += title->get_h() + pady/2;
577 title = new BC_Title(x, y, _("tmp path:"), MEDIUMFONT, YELLOW);
578 add_subwindow(title);
579 tmp_x = x + title->get_w(); tmp_y = y;
580 tmp_path = new CreateBD_TmpPath(this, tmp_x, tmp_y, get_w()-tmp_x-10);
581 add_subwindow(tmp_path);
582 y += title->get_h() + pady/2;
583 disk_space = new CreateBD_DiskSpace(this, x, y);
584 add_subwindow(disk_space);
585 disk_space->update();
586 y += disk_space->get_h() + pady/2;
587 need_deinterlace = new CreateBD_Deinterlace(this, x, y);
588 add_subwindow(need_deinterlace);
589 int x1 = x + 150, x2 = x1 + 150;
590 need_inverse_telecine = new CreateBD_InverseTelecine(this, x1, y);
591 add_subwindow(need_inverse_telecine);
592 y += need_deinterlace->get_h() + pady/2;
593 need_scale = new CreateBD_Scale(this, x, y);
594 add_subwindow(need_scale);
595 need_wide_audio = new CreateBD_WideAudio(this, x1, y);
596 add_subwindow(need_wide_audio);
597 need_resize_tracks = new CreateBD_ResizeTracks(this, x2, y);
598 add_subwindow(need_resize_tracks);
599 y += need_scale->get_h() + pady/2;
600 need_histogram = new CreateBD_Histogram(this, x, y);
601 add_subwindow(need_histogram);
602 need_wide_aspect = new CreateBD_WideAspect(this, x1, y);
603 add_subwindow(need_wide_aspect);
604 // need_label_chapters = new CreateBD_LabelChapters(this, x2, y);
605 // add_subwindow(need_label_chapters);
606 ok_w = BC_OKButton::calculate_w();
607 ok_h = BC_OKButton::calculate_h();
609 ok_y = get_h() - ok_h - 10;
610 ok = new CreateBD_OK(this, ok_x, ok_y);
612 cancel_w = BC_CancelButton::calculate_w();
613 cancel_h = BC_CancelButton::calculate_h();
614 cancel_x = get_w() - cancel_w - 10,
615 cancel_y = get_h() - cancel_h - 10;
616 cancel = new CreateBD_Cancel(this, cancel_x, cancel_y);
617 add_subwindow(cancel);
622 int CreateBD_GUI::resize_event(int w, int h)
624 asset_title->reposition_window(at_x, at_y, get_w()-at_x-10);
625 tmp_path->reposition_window(tmp_x, tmp_y, get_w()-tmp_x-10);
626 ok_y = h - ok_h - 10;
627 ok->reposition_window(ok_x, ok_y);
628 cancel_x = w - cancel_w - 10,
629 cancel_y = h - cancel_h - 10;
630 cancel->reposition_window(cancel_x, cancel_y);
634 int CreateBD_GUI::translation_event()
639 int CreateBD_GUI::close_event()
645 int CreateBD_Thread::
646 insert_video_plugin(const char *title, KeyFrame *default_keyframe)
648 Tracks *tracks = mwindow->edl->tracks;
649 for( Track *vtrk=tracks->first; vtrk; vtrk=vtrk->next ) {
650 if( vtrk->data_type != TRACK_VIDEO ) continue;
651 if( !vtrk->record ) continue;
652 vtrk->expand_view = 1;
653 PluginSet *plugin_set = new PluginSet(mwindow->edl, vtrk);
654 vtrk->plugin_set.append(plugin_set);
655 Edits *edits = vtrk->edits;
656 for( Edit *edit=edits->first; edit; edit=edit->next ) {
657 plugin_set->insert_plugin(title,
658 edit->startproject, edit->length,
659 PLUGIN_STANDALONE, 0, default_keyframe, 0);
666 int CreateBD_Thread::
669 Tracks *tracks = mwindow->edl->tracks;
671 int max_w = 0, max_h = 0;
672 for( Track *vtrk=tracks->first; vtrk; vtrk=vtrk->next ) {
673 if( vtrk->data_type != TRACK_VIDEO ) continue;
674 if( !vtrk->record ) continue;
675 Edits *edits = vtrk->edits;
676 for( Edit *edit=edits->first; edit; edit=edit->next ) {
677 Indexable *indexable = edit->get_source();
678 int w = indexable->get_w();
679 if( w > max_w ) max_w = w;
680 int h = indexable->get_h();
681 if( h > max_h ) max_h = h;
685 for( Track *vtrk=tracks->first; vtrk; vtrk=vtrk->next ) {
686 if( vtrk->data_type != TRACK_VIDEO ) continue;
687 if( !vtrk->record ) continue;
688 vtrk->track_w = BD_WIDTH; // max_w;
689 vtrk->track_h = BD_HEIGHT; // max_h;
694 int CreateBD_Thread::
697 if( !mwindow->edl ) return 1;
698 Tracks *tracks = mwindow->edl->tracks;
699 int max_w = 0, max_h = 0;
700 int has_deinterlace = 0, has_scale = 0;
701 for( Track *trk=tracks->first; trk; trk=trk->next ) {
702 if( !trk->record ) continue;
703 Edits *edits = trk->edits;
704 switch( trk->data_type ) {
706 for( Edit *edit=edits->first; edit; edit=edit->next ) {
707 Indexable *indexable = edit->get_source();
708 int w = indexable->get_w();
709 if( w > max_w ) max_w = w;
710 if( w != BD_WIDTH ) use_scale = 1;
711 int h = indexable->get_h();
712 if( h > max_h ) max_h = h;
713 if( h != BD_HEIGHT ) use_scale = 1;
715 for( int i=0; i<trk->plugin_set.size(); ++i ) {
716 for(Plugin *plugin = (Plugin*)trk->plugin_set[i]->first;
718 plugin = (Plugin*)plugin->next) {
719 if( !strcmp(plugin->title, "Deinterlace") )
721 if( !strcmp(plugin->title, "Auto Scale") ||
722 !strcmp(plugin->title, "Scale") )
732 if( max_w != BD_WIDTH ) use_resize_tracks = 1;
733 if( max_h != BD_HEIGHT ) use_resize_tracks = 1;
735 for( Track *trk=tracks->first; trk && !use_resize_tracks; trk=trk->next ) {
736 if( !trk->record ) continue;
737 switch( trk->data_type ) {
739 if( trk->track_w != max_w ) use_resize_tracks = 1;
740 if( trk->track_h != max_h ) use_resize_tracks = 1;
744 if( !has_deinterlace && max_h > 2*BD_HEIGHT ) use_deinterlace = 1;
745 // Labels *labels = mwindow->edl->labels;
746 // use_label_chapters = labels && labels->first ? 1 : 0;
748 MWindow::create_aspect_ratio(w, h, max_w, max_h);
749 if( w == BD_WIDE_ASPECT_WIDTH && h == BD_WIDE_ASPECT_HEIGHT )
751 if( tracks->recordable_audio_tracks() == BD_WIDE_CHANNELS )