6 #include "edlsession.h"
11 #include "mainerror.h"
14 #include "mwindowgui.h"
16 #include "pluginset.h"
24 #include <sys/statfs.h>
29 const int64_t CreateDVD_Thread::DVD_SIZE = 4700000000;
30 const int CreateDVD_Thread::DVD_STREAMS = 1;
31 const int CreateDVD_Thread::DVD_WIDTH = 720;
32 const int CreateDVD_Thread::DVD_HEIGHT = 480;
33 const double CreateDVD_Thread::DVD_ASPECT_WIDTH = 4.;
34 const double CreateDVD_Thread::DVD_ASPECT_HEIGHT = 3.;
35 const double CreateDVD_Thread::DVD_WIDE_ASPECT_WIDTH = 16.;
36 const double CreateDVD_Thread::DVD_WIDE_ASPECT_HEIGHT = 9.;
37 const double CreateDVD_Thread::DVD_FRAMERATE = 30000. / 1001.;
38 const int CreateDVD_Thread::DVD_MAX_BITRATE = 8000000;
39 const int CreateDVD_Thread::DVD_CHANNELS = 2;
40 const int CreateDVD_Thread::DVD_WIDE_CHANNELS = 6;
41 const double CreateDVD_Thread::DVD_SAMPLERATE = 48000;
42 const double CreateDVD_Thread::DVD_KAUDIO_RATE = 224;
45 CreateDVD_MenuItem::CreateDVD_MenuItem(MWindow *mwindow)
46 : BC_MenuItem(_("DVD Render..."), _("Shift-D"), 'D')
49 this->mwindow = mwindow;
52 int CreateDVD_MenuItem::handle_event()
54 mwindow->create_dvd->start();
59 CreateDVD_Thread::CreateDVD_Thread(MWindow *mwindow)
62 this->mwindow = mwindow;
64 this->use_deinterlace = 0;
65 this->use_inverse_telecine = 0;
67 this->use_resize_tracks = 0;
68 this->use_histogram = 0;
69 this->use_wide_audio = 0;
70 this->use_wide_aspect = 0;
71 this->use_label_chapters = 0;
75 CreateDVD_Thread::~CreateDVD_Thread()
80 int CreateDVD_Thread::create_dvd_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 = DVD_STREAMS;
115 session->video_tracks = DVD_STREAMS;
116 session->frame_rate = DVD_FRAMERATE;
117 session->output_w = DVD_WIDTH;
118 session->output_h = DVD_HEIGHT;
119 session->aspect_w = use_wide_aspect ? DVD_WIDE_ASPECT_WIDTH : DVD_ASPECT_WIDTH;
120 session->aspect_h = use_wide_aspect ? DVD_WIDE_ASPECT_HEIGHT : DVD_ASPECT_HEIGHT;
121 session->sample_rate = DVD_SAMPLERATE;
122 session->audio_channels = session->audio_tracks =
123 use_wide_audio ? DVD_WIDE_CHANNELS : DVD_CHANNELS;
125 char script_filename[BCTEXTLEN];
126 sprintf(script_filename, "%s/dvd.sh", asset_dir);
127 int fd = open(script_filename, O_WRONLY+O_CREAT+O_TRUNC, 0755);
128 FILE *fp = fdopen(fd, "w");
130 char err[BCTEXTLEN], msg[BCTEXTLEN];
131 strerror_r(errno, err, sizeof(err));
132 sprintf(msg, _("Unable to save: %s\n-- %s"), script_filename, err);
133 MainError::show_error(msg);
136 fprintf(fp,"#!/bin/bash\n");
137 fprintf(fp,"echo \"running %s\" $# $*\n", script_filename);
140 fprintf(fp,"mplex -f 8 -o $1/dvd.mpg $1/dvd.m2v $1/dvd.ac3\n");
143 fprintf(fp,"rm -rf $1/iso\n");
144 fprintf(fp,"mkdir -p $1/iso\n");
146 fprintf(fp,"dvdauthor -x - <<eof\n");
147 fprintf(fp,"<dvdauthor dest=\"$1/iso\">\n");
148 fprintf(fp," <vmgm>\n");
149 fprintf(fp," <fpc> jump title 1; </fpc>\n");
150 fprintf(fp," </vmgm>\n");
151 fprintf(fp," <titleset>\n");
152 fprintf(fp," <titles>\n");
153 fprintf(fp," <video format=\"ntsc\" aspect=\"%d:%d\" resolution=\"%dx%d\"/>\n",
154 (int)session->aspect_w, (int)session->aspect_h,
155 session->output_w, session->output_h);
156 fprintf(fp," <audio format=\"ac3\" lang=\"en\"/>\n");
157 fprintf(fp," <pgc>\n");
158 fprintf(fp," <vob file=\"$1/dvd.mpg\" chapters=\"");
159 if( use_label_chapters && edl->labels ) {
160 Label *label = edl->labels->first;
162 int secs = label->position;
163 int mins = secs / 60;
164 int frms = (label->position-secs) * session->frame_rate;
165 fprintf(fp,"%d:%02d:%02d.%d", mins/60, mins%60, secs%60, frms);
166 if( (label=label->next) != 0 ) fprintf(fp, ",");
171 for( int secs=0 ; secs<total_length; secs+=10*60 ) {
173 fprintf(fp,"%d:%02d:00,", mins/60, mins%60);
175 fprintf(fp,"%d:%02d:00", mins/60, mins%60);
177 fprintf(fp,"\"/>\n");
178 fprintf(fp," </pgc>\n");
179 fprintf(fp," </titles>\n");
180 fprintf(fp," </titleset>\n");
181 fprintf(fp,"</dvdauthor>\n");
184 fprintf(fp,"echo To burn dvd, load blank media and run:\n");
185 fprintf(fp,"echo growisofs -dvd-compat -Z /dev/dvd -dvd-video $1/iso\n");
189 if( use_wide_audio ) {
190 session->audio_channels = session->audio_tracks = DVD_WIDE_CHANNELS;
191 session->achannel_positions[0] = 90;
192 session->achannel_positions[1] = 150;
193 session->achannel_positions[2] = 30;
194 session->achannel_positions[3] = 210;
195 session->achannel_positions[4] = 330;
196 session->achannel_positions[5] = 270;
197 if( edl->tracks->recordable_audio_tracks() == DVD_WIDE_CHANNELS )
198 mwindow->remap_audio(MWindow::AUDIO_1_TO_1);
201 session->audio_channels = session->audio_tracks = DVD_CHANNELS;
202 session->achannel_positions[0] = 180;
203 session->achannel_positions[1] = 0;
204 if( edl->tracks->recordable_audio_tracks() == DVD_WIDE_CHANNELS )
205 mwindow->remap_audio(MWindow::AUDIO_5_1_TO_2);
208 double new_samplerate = session->sample_rate;
209 double new_framerate = session->frame_rate;
211 edl->resample(old_samplerate, new_samplerate, TRACK_AUDIO);
212 edl->resample(old_framerate, new_framerate, TRACK_VIDEO);
214 int64_t aud_size = ((DVD_KAUDIO_RATE * total_length)/8 + 1000-1) * 1000;
215 int64_t vid_size = DVD_SIZE*0.96 - aud_size;
216 int64_t vid_bitrate = (vid_size * 8) / total_length;
217 vid_bitrate /= 1000; vid_bitrate *= 1000;
218 if( vid_bitrate > DVD_MAX_BITRATE ) vid_bitrate = DVD_MAX_BITRATE;
220 char xml_filename[BCTEXTLEN];
221 sprintf(xml_filename, "%s/dvd.xml", asset_dir);
223 edl->save_xml(&xml_file, xml_filename, 0, 0);
224 xml_file.terminate_string();
225 if( xml_file.write_to_file(xml_filename) ) {
227 sprintf(msg, _("Unable to save: %s"), xml_filename);
228 MainError::show_error(msg);
232 BatchRenderJob *job = new BatchRenderJob(mwindow->preferences);
234 strcpy(&job->edl_path[0], xml_filename);
235 Asset *asset = job->asset;
237 asset->layers = DVD_STREAMS;
238 asset->frame_rate = session->frame_rate;
239 asset->width = session->output_w;
240 asset->height = session->output_h;
241 asset->aspect_ratio = session->aspect_w / session->aspect_h;
244 char option_path[BCTEXTLEN];
245 sprintf(&asset->path[0],"%s/dvd.mpg", asset_dir);
246 asset->format = FILE_FFMPEG;
247 strcpy(asset->fformat, "dvd");
249 asset->audio_data = 1;
250 strcpy(asset->acodec, "dvd.dvd");
251 FFMPEG::set_option_path(option_path, "audio/%s", asset->acodec);
252 FFMPEG::load_options(option_path, asset->ff_audio_options,
253 sizeof(asset->ff_audio_options));
254 asset->ff_audio_bitrate = DVD_KAUDIO_RATE * 1000;
256 asset->video_data = 1;
257 strcpy(asset->vcodec, "dvd.dvd");
258 FFMPEG::set_option_path(option_path, "video/%s", asset->vcodec);
259 FFMPEG::load_options(option_path, asset->ff_video_options,
260 sizeof(asset->ff_video_options));
261 asset->ff_video_bitrate = vid_bitrate;
262 asset->ff_video_quality = 0;
264 int len = strlen(asset->ff_video_options);
265 char *cp = asset->ff_video_options + len;
266 snprintf(cp, sizeof(asset->ff_video_options)-len-1,
267 "aspect %.5f\n", asset->aspect_ratio);
270 sprintf(&asset->path[0],"%s/dvd.m2v", asset_dir);
271 asset->video_data = 1;
272 asset->format = FILE_VMPEG;
273 asset->vmpeg_cmodel = BC_YUV420P;
274 asset->vmpeg_fix_bitrate = 1;
275 asset->vmpeg_bitrate = vid_bitrate;
276 asset->vmpeg_quantization = 15;
277 asset->vmpeg_iframe_distance = 15;
278 asset->vmpeg_progressive = 0;
279 asset->vmpeg_denoise = 0;
280 asset->vmpeg_seq_codes = 0;
281 asset->vmpeg_derivative = 2;
282 asset->vmpeg_preset = 8;
283 asset->vmpeg_field_order = 0;
284 asset->vmpeg_pframe_distance = 0;
285 job = new BatchRenderJob(mwindow->preferences);
287 strcpy(&job->edl_path[0], xml_filename);
290 sprintf(&asset->path[0],"%s/dvd.ac3", asset_dir);
291 asset->audio_data = 1;
292 asset->format = FILE_AC3;
293 asset->channels = session->audio_channels;
294 asset->sample_rate = session->sample_rate;
296 asset->byte_order = 0;
300 asset->ac3_bitrate = DVD_KAUDIO_RATE;
303 job = new BatchRenderJob(mwindow->preferences);
305 job->edl_path[0] = '@';
306 strcpy(&job->edl_path[1], script_filename);
307 strcpy(&job->asset->path[0], asset_dir);
312 void CreateDVD_Thread::handle_close_event(int result)
315 mwindow->batch_render->load_defaults(mwindow->defaults);
316 mwindow->undo->update_undo_before();
317 KeyFrame keyframe; char data[BCTEXTLEN];
318 if( use_deinterlace ) {
319 sprintf(data,"<DEINTERLACE MODE=1>");
320 keyframe.set_data(data);
321 insert_video_plugin("Deinterlace", &keyframe);
323 if( use_inverse_telecine ) {
324 sprintf(data,"<IVTC FRAME_OFFSET=0 FIRST_FIELD=0 "
325 "AUTOMATIC=1 AUTO_THRESHOLD=2.0e+00 PATTERN=2>");
326 keyframe.set_data(data);
327 insert_video_plugin("Inverse Telecine", &keyframe);
330 sprintf(data,"<PHOTOSCALE WIDTH=%d HEIGHT=%d USE_FILE=1>", DVD_WIDTH, DVD_HEIGHT);
331 keyframe.set_data(data);
332 insert_video_plugin("Auto Scale", &keyframe);
334 if( use_resize_tracks )
336 if( use_histogram ) {
338 sprintf(data, "<HISTOGRAM OUTPUT_MIN_0=0 OUTPUT_MAX_0=1 "
339 "OUTPUT_MIN_1=0 OUTPUT_MAX_1=1 "
340 "OUTPUT_MIN_2=0 OUTPUT_MAX_2=1 "
341 "OUTPUT_MIN_3=0 OUTPUT_MAX_3=1 "
342 "AUTOMATIC=0 THRESHOLD=9.0-01 PLOT=0 SPLIT=0>"
343 "<POINTS></POINTS><POINTS></POINTS><POINTS></POINTS>"
344 "<POINTS><POINT X=6.0e-02 Y=0>"
345 "<POINT X=9.4e-01 Y=1></POINTS>");
347 sprintf(data, "<HISTOGRAM AUTOMATIC=0 THRESHOLD=1.0e-01 "
348 "PLOT=0 SPLIT=0 W=440 H=500 PARADE=0 MODE=3 "
349 "LOW_OUTPUT_0=0 HIGH_OUTPUT_0=1 LOW_INPUT_0=0 HIGH_INPUT_0=1 GAMMA_0=1 "
350 "LOW_OUTPUT_1=0 HIGH_OUTPUT_1=1 LOW_INPUT_1=0 HIGH_INPUT_1=1 GAMMA_1=1 "
351 "LOW_OUTPUT_2=0 HIGH_OUTPUT_2=1 LOW_INPUT_2=0 HIGH_INPUT_2=1 GAMMA_2=1 "
352 "LOW_OUTPUT_3=0 HIGH_OUTPUT_3=1 LOW_INPUT_3=0.044 HIGH_INPUT_3=0.956 "
355 keyframe.set_data(data);
356 insert_video_plugin("Histogram", &keyframe);
358 create_dvd_jobs(&mwindow->batch_render->jobs, tmp_path, asset_title);
359 mwindow->save_backup();
360 mwindow->undo->update_undo_after(_("create dvd"), LOAD_ALL);
361 mwindow->resync_guis();
362 mwindow->batch_render->handle_close_event(0);
363 mwindow->batch_render->start();
366 BC_Window* CreateDVD_Thread::new_gui()
368 memset(tmp_path,0,sizeof(tmp_path));
369 strcpy(tmp_path,"/tmp");
370 memset(asset_title,0,sizeof(asset_title));
371 time_t dt; time(&dt);
372 struct tm dtm; localtime_r(&dt, &dtm);
373 sprintf(asset_title, "dvd_%02d%02d%02d-%02d%02d%02d",
374 dtm.tm_year+1900, dtm.tm_mon+1, dtm.tm_mday,
375 dtm.tm_hour, dtm.tm_min, dtm.tm_sec);
377 use_inverse_telecine = 0;
379 use_resize_tracks = 0;
383 use_label_chapters = 0;
386 int scr_x = mwindow->gui->get_screen_x(0, -1);
387 int scr_w = mwindow->gui->get_screen_w(0, -1);
388 int scr_h = mwindow->gui->get_screen_h(0, -1);
389 int w = 500, h = 250;
390 int x = scr_x + scr_w/2 - w/2, y = scr_h/2 - h/2;
392 gui = new CreateDVD_GUI(this, x, y, w, h);
393 gui->create_objects();
398 CreateDVD_OK::CreateDVD_OK(CreateDVD_GUI *gui, int x, int y)
402 set_tooltip(_("end setup, start batch render"));
405 CreateDVD_OK::~CreateDVD_OK()
409 int CreateDVD_OK::button_press_event()
411 if(get_buttonpress() == 1 && is_event_win() && cursor_inside()) {
418 int CreateDVD_OK::keypress_event()
424 CreateDVD_Cancel::CreateDVD_Cancel(CreateDVD_GUI *gui, int x, int y)
425 : BC_CancelButton(x, y)
430 CreateDVD_Cancel::~CreateDVD_Cancel()
434 int CreateDVD_Cancel::button_press_event()
436 if(get_buttonpress() == 1 && is_event_win() && cursor_inside()) {
444 CreateDVD_DiskSpace::CreateDVD_DiskSpace(CreateDVD_GUI *gui, int x, int y)
445 : BC_Title(x, y, "", MEDIUMFONT, GREEN)
450 CreateDVD_DiskSpace::~CreateDVD_DiskSpace()
454 int64_t CreateDVD_DiskSpace::tmp_path_space()
456 const char *path = gui->tmp_path->get_text();
457 if( access(path,R_OK+W_OK) ) return 0;
459 if( statfs(path, &sfs) ) return 0;
460 return (int64_t)sfs.f_bsize * sfs.f_bfree;
463 void CreateDVD_DiskSpace::update()
465 // gui->disk_space->set_color(get_bg_color());
466 int64_t disk_space = tmp_path_space();
467 int color = disk_space<gui->needed_disk_space ? RED : GREEN;
468 static const char *suffix[] = { "", "KB", "MB", "GB", "TB", "PB" };
470 for( int64_t space=disk_space; i<5 && (space/=1000)>0; disk_space=space, ++i );
471 char text[BCTEXTLEN];
472 sprintf(text, "%s" _LDv(3) "%s", _("disk space: "), disk_space, suffix[i]);
473 gui->disk_space->BC_Title::update(text);
474 gui->disk_space->set_color(color);
477 CreateDVD_TmpPath::CreateDVD_TmpPath(CreateDVD_GUI *gui, int x, int y, int w)
478 : BC_TextBox(x, y, w, 1, -sizeof(gui->thread->tmp_path),
479 gui->thread->tmp_path, 1, MEDIUMFONT)
484 CreateDVD_TmpPath::~CreateDVD_TmpPath()
488 int CreateDVD_TmpPath::handle_event()
490 gui->disk_space->update();
495 CreateDVD_AssetTitle::CreateDVD_AssetTitle(CreateDVD_GUI *gui, int x, int y, int w)
496 : BC_TextBox(x, y, w, 1, 0, gui->thread->asset_title, 1, MEDIUMFONT)
501 CreateDVD_AssetTitle::~CreateDVD_AssetTitle()
506 CreateDVD_Deinterlace::CreateDVD_Deinterlace(CreateDVD_GUI *gui, int x, int y)
507 : BC_CheckBox(x, y, &gui->thread->use_deinterlace, _("Deinterlace"))
512 CreateDVD_Deinterlace::~CreateDVD_Deinterlace()
516 int CreateDVD_Deinterlace::handle_event()
519 gui->need_inverse_telecine->set_value(0);
520 gui->thread->use_inverse_telecine = 0;
522 return BC_CheckBox::handle_event();
526 CreateDVD_InverseTelecine::CreateDVD_InverseTelecine(CreateDVD_GUI *gui, int x, int y)
527 : BC_CheckBox(x, y, &gui->thread->use_inverse_telecine, _("Inverse Telecine"))
532 CreateDVD_InverseTelecine::~CreateDVD_InverseTelecine()
536 int CreateDVD_InverseTelecine::handle_event()
539 gui->need_deinterlace->set_value(0);
540 gui->thread->use_deinterlace = 0;
542 return BC_CheckBox::handle_event();
546 CreateDVD_Scale::CreateDVD_Scale(CreateDVD_GUI *gui, int x, int y)
547 : BC_CheckBox(x, y, &gui->thread->use_scale, _("Scale"))
552 CreateDVD_Scale::~CreateDVD_Scale()
557 CreateDVD_ResizeTracks::CreateDVD_ResizeTracks(CreateDVD_GUI *gui, int x, int y)
558 : BC_CheckBox(x, y, &gui->thread->use_resize_tracks, _("Resize Tracks"))
563 CreateDVD_ResizeTracks::~CreateDVD_ResizeTracks()
568 CreateDVD_Histogram::CreateDVD_Histogram(CreateDVD_GUI *gui, int x, int y)
569 : BC_CheckBox(x, y, &gui->thread->use_histogram, _("Histogram"))
574 CreateDVD_Histogram::~CreateDVD_Histogram()
578 CreateDVD_LabelChapters::CreateDVD_LabelChapters(CreateDVD_GUI *gui, int x, int y)
579 : BC_CheckBox(x, y, &gui->thread->use_label_chapters, _("Chapters at Labels"))
584 CreateDVD_LabelChapters::~CreateDVD_LabelChapters()
588 CreateDVD_WideAudio::CreateDVD_WideAudio(CreateDVD_GUI *gui, int x, int y)
589 : BC_CheckBox(x, y, &gui->thread->use_wide_audio, _("Audio 5.1"))
594 CreateDVD_WideAudio::~CreateDVD_WideAudio()
598 CreateDVD_WideAspect::CreateDVD_WideAspect(CreateDVD_GUI *gui, int x, int y)
599 : BC_CheckBox(x, y, &gui->thread->use_wide_aspect, _("Aspect 16x9"))
604 CreateDVD_WideAspect::~CreateDVD_WideAspect()
608 CreateDVD_UseFFMpeg::CreateDVD_UseFFMpeg(CreateDVD_GUI *gui, int x, int y)
609 : BC_CheckBox(x, y, &gui->thread->use_ffmpeg, _("Use FFMPEG"))
614 CreateDVD_UseFFMpeg::~CreateDVD_UseFFMpeg()
621 CreateDVD_GUI::CreateDVD_GUI(CreateDVD_Thread *thread, int x, int y, int w, int h)
622 : BC_Window(_(PROGRAM_NAME ": Create DVD"), x, y, w, h, 50, 50, 1, 0, 1)
624 this->thread = thread;
625 at_x = at_y = tmp_x = tmp_y = 0;
626 ok_x = ok_y = ok_w = ok_h = 0;
627 cancel_x = cancel_y = cancel_w = cancel_h = 0;
631 needed_disk_space = 15e9;
632 need_deinterlace = 0;
633 need_inverse_telecine = 0;
635 need_resize_tracks = 0;
638 need_wide_aspect = 0;
639 need_label_chapters = 0;
644 CreateDVD_GUI::~CreateDVD_GUI()
648 void CreateDVD_GUI::create_objects()
650 lock_window("CreateDVD_GUI::create_objects");
651 int pady = BC_TextBox::calculate_h(this, MEDIUMFONT, 0, 1) + 5;
652 int padx = BC_Title::calculate_w(this, (char*)"X", MEDIUMFONT);
653 int x = padx/2, y = pady/2;
654 BC_Title *title = new BC_Title(x, y, _("Title:"), MEDIUMFONT, YELLOW);
655 add_subwindow(title);
656 at_x = x + title->get_w(); at_y = y;
657 asset_title = new CreateDVD_AssetTitle(this, at_x, at_y, get_w()-at_x-10);
658 add_subwindow(asset_title);
659 y += title->get_h() + pady/2;
660 title = new BC_Title(x, y, _("tmp path:"), MEDIUMFONT, YELLOW);
661 add_subwindow(title);
662 tmp_x = x + title->get_w(); tmp_y = y;
663 tmp_path = new CreateDVD_TmpPath(this, tmp_x, tmp_y, get_w()-tmp_x-10);
664 add_subwindow(tmp_path);
665 y += title->get_h() + pady/2;
666 disk_space = new CreateDVD_DiskSpace(this, x, y);
667 add_subwindow(disk_space);
668 disk_space->update();
669 y += disk_space->get_h() + pady/2;
670 need_deinterlace = new CreateDVD_Deinterlace(this, x, y);
671 add_subwindow(need_deinterlace);
672 int x1 = x + 150, x2 = x1 + 150;
673 need_inverse_telecine = new CreateDVD_InverseTelecine(this, x1, y);
674 add_subwindow(need_inverse_telecine);
675 need_use_ffmpeg = new CreateDVD_UseFFMpeg(this, x2, y);
676 add_subwindow(need_use_ffmpeg);
677 y += need_deinterlace->get_h() + pady/2;
678 need_scale = new CreateDVD_Scale(this, x, y);
679 add_subwindow(need_scale);
680 need_wide_audio = new CreateDVD_WideAudio(this, x1, y);
681 add_subwindow(need_wide_audio);
682 need_resize_tracks = new CreateDVD_ResizeTracks(this, x2, y);
683 add_subwindow(need_resize_tracks);
684 y += need_scale->get_h() + pady/2;
685 need_histogram = new CreateDVD_Histogram(this, x, y);
686 add_subwindow(need_histogram);
687 need_wide_aspect = new CreateDVD_WideAspect(this, x1, y);
688 add_subwindow(need_wide_aspect);
689 need_label_chapters = new CreateDVD_LabelChapters(this, x2, y);
690 add_subwindow(need_label_chapters);
691 ok_w = BC_OKButton::calculate_w();
692 ok_h = BC_OKButton::calculate_h();
694 ok_y = get_h() - ok_h - 10;
695 ok = new CreateDVD_OK(this, ok_x, ok_y);
697 cancel_w = BC_CancelButton::calculate_w();
698 cancel_h = BC_CancelButton::calculate_h();
699 cancel_x = get_w() - cancel_w - 10,
700 cancel_y = get_h() - cancel_h - 10;
701 cancel = new CreateDVD_Cancel(this, cancel_x, cancel_y);
702 add_subwindow(cancel);
707 int CreateDVD_GUI::resize_event(int w, int h)
709 asset_title->reposition_window(at_x, at_y, get_w()-at_x-10);
710 tmp_path->reposition_window(tmp_x, tmp_y, get_w()-tmp_x-10);
711 ok_y = h - ok_h - 10;
712 ok->reposition_window(ok_x, ok_y);
713 cancel_x = w - cancel_w - 10,
714 cancel_y = h - cancel_h - 10;
715 cancel->reposition_window(cancel_x, cancel_y);
719 int CreateDVD_GUI::translation_event()
724 int CreateDVD_GUI::close_event()
730 int CreateDVD_Thread::
731 insert_video_plugin(const char *title, KeyFrame *default_keyframe)
733 Tracks *tracks = mwindow->edl->tracks;
734 for( Track *vtrk=tracks->first; vtrk; vtrk=vtrk->next ) {
735 if( vtrk->data_type != TRACK_VIDEO ) continue;
736 if( !vtrk->record ) continue;
737 vtrk->expand_view = 1;
738 PluginSet *plugin_set = new PluginSet(mwindow->edl, vtrk);
739 vtrk->plugin_set.append(plugin_set);
740 Edits *edits = vtrk->edits;
741 for( Edit *edit=edits->first; edit; edit=edit->next ) {
742 plugin_set->insert_plugin(title,
743 edit->startproject, edit->length,
744 PLUGIN_STANDALONE, 0, default_keyframe, 0);
751 int CreateDVD_Thread::
754 Tracks *tracks = mwindow->edl->tracks;
756 int max_w = 0, max_h = 0;
757 for( Track *vtrk=tracks->first; vtrk; vtrk=vtrk->next ) {
758 if( vtrk->data_type != TRACK_VIDEO ) continue;
759 if( !vtrk->record ) continue;
760 Edits *edits = vtrk->edits;
761 for( Edit *edit=edits->first; edit; edit=edit->next ) {
762 Indexable *indexable = edit->get_source();
763 int w = indexable->get_w();
764 if( w > max_w ) max_w = w;
765 int h = indexable->get_h();
766 if( h > max_h ) max_h = h;
770 for( Track *vtrk=tracks->first; vtrk; vtrk=vtrk->next ) {
771 if( vtrk->data_type != TRACK_VIDEO ) continue;
772 if( !vtrk->record ) continue;
773 vtrk->track_w = DVD_WIDTH; // max_w;
774 vtrk->track_h = DVD_HEIGHT; // max_h;
779 int CreateDVD_Thread::
782 if( !mwindow->edl ) return 1;
783 Tracks *tracks = mwindow->edl->tracks;
784 int max_w = 0, max_h = 0;
785 int has_deinterlace = 0, has_scale = 0;
786 for( Track *trk=tracks->first; trk; trk=trk->next ) {
787 if( !trk->record ) continue;
788 Edits *edits = trk->edits;
789 switch( trk->data_type ) {
791 for( Edit *edit=edits->first; edit; edit=edit->next ) {
792 Indexable *indexable = edit->get_source();
793 int w = indexable->get_w();
794 if( w > max_w ) max_w = w;
795 if( w != DVD_WIDTH ) use_scale = 1;
796 int h = indexable->get_h();
797 if( h > max_h ) max_h = h;
798 if( h != DVD_HEIGHT ) use_scale = 1;
800 for( int i=0; i<trk->plugin_set.size(); ++i ) {
801 for(Plugin *plugin = (Plugin*)trk->plugin_set[i]->first;
803 plugin = (Plugin*)plugin->next) {
804 if( !strcmp(plugin->title, "Deinterlace") )
806 if( !strcmp(plugin->title, "Auto Scale") ||
807 !strcmp(plugin->title, "Scale") )
817 if( max_w != DVD_WIDTH ) use_resize_tracks = 1;
818 if( max_h != DVD_HEIGHT ) use_resize_tracks = 1;
820 for( Track *trk=tracks->first; trk && !use_resize_tracks; trk=trk->next ) {
821 if( !trk->record ) continue;
822 switch( trk->data_type ) {
824 if( trk->track_w != max_w ) use_resize_tracks = 1;
825 if( trk->track_h != max_h ) use_resize_tracks = 1;
829 if( !has_deinterlace && max_h > 2*DVD_HEIGHT ) use_deinterlace = 1;
830 Labels *labels = mwindow->edl->labels;
831 use_label_chapters = labels && labels->first ? 1 : 0;
833 MWindow::create_aspect_ratio(w, h, max_w, max_h);
834 if( w == DVD_WIDE_ASPECT_WIDTH && h == DVD_WIDE_ASPECT_HEIGHT )
836 if( tracks->recordable_audio_tracks() == DVD_WIDE_CHANNELS )