confirm prefs update, fix bg_pixmap sz, plugin layout tweaks
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / bdcreate.C
1 #include "asset.h"
2 #include "bchash.h"
3 #include "bdcreate.h"
4 #include "clip.h"
5 #include "edl.h"
6 #include "edit.h"
7 #include "edits.h"
8 #include "edlsession.h"
9 #include "file.h"
10 #include "filexml.h"
11 #include "interlacemodes.h"
12 #include "keyframe.h"
13 #include "mainerror.h"
14 #include "mainundo.h"
15 #include "mwindow.h"
16 #include "mwindowgui.h"
17 #include "plugin.h"
18 #include "pluginset.h"
19 #include "preferences.h"
20 #include "rescale.h"
21 #include "track.h"
22 #include "tracks.h"
23
24 #include <unistd.h>
25 #include <fcntl.h>
26 #include <errno.h>
27 #include <sys/stat.h>
28 #include <sys/statfs.h>
29
30 // BD Creation
31
32 // selected by timezone
33 #define BD_1920x1080_2997i      0
34 #define BD_1920x1080_25i        3
35
36 static struct bd_format {
37         const char *name;
38         int w, h;
39         double framerate;
40         int wide, interlaced;
41 } bd_formats[] = {
42 // framerates are frames, not fields, per second, *=not standard
43         { "1920x1080 29.97i",   1920,1080, 29.97,  1, ILACE_MODE_TOP_FIRST },
44         { "1920x1080 29.97p*",  1920,1080, 29.97,  1, ILACE_MODE_NOTINTERLACED },
45         { "1920x1080 24p",      1920,1080, 24.,    1, ILACE_MODE_NOTINTERLACED },
46         { "1920x1080 25i",      1920,1080, 25.,    1, ILACE_MODE_TOP_FIRST },
47         { "1920x1080 23.976p",  1920,1080, 23.976, 1, ILACE_MODE_NOTINTERLACED },
48         { "1440x1080 29.97i",   1440,1080, 29.97, -1, ILACE_MODE_TOP_FIRST },
49         { "1440x1080 25i",      1440,1080, 25.,   -1, ILACE_MODE_TOP_FIRST },
50         { "1440x1080 24p",      1440,1080, 24.,   -1, ILACE_MODE_NOTINTERLACED },
51         { "1440x1080 23.976p",  1440,1080, 23.976,-1, ILACE_MODE_NOTINTERLACED },
52         { "1280x720  59.94p",   1280,720,  59.94,  1, ILACE_MODE_NOTINTERLACED },
53         { "1280x720  50p",      1280,720,  50.,    1, ILACE_MODE_NOTINTERLACED },
54         { "1280x720  24p",      1280,720,  24.,    1, ILACE_MODE_NOTINTERLACED },
55         { "1280x720  23.976p",  1280,720,  23.976, 1, ILACE_MODE_NOTINTERLACED },
56         { "720x576   25i",       720,576,  25.,    0, ILACE_MODE_BOTTOM_FIRST },
57         { "720x576   25p*",      720,576,  25.,    0, ILACE_MODE_NOTINTERLACED },
58         { "720x480   29.97i",    720,480,  29.97,  0, ILACE_MODE_BOTTOM_FIRST },
59         { "720x480   29.97p*",   720,480,  29.97,  0, ILACE_MODE_NOTINTERLACED },
60 };
61
62 const int64_t CreateBD_Thread::BD_SIZE = 25000000000;
63 const int CreateBD_Thread::BD_STREAMS = 1;
64 const int CreateBD_Thread::BD_WIDTH = 1920;
65 const int CreateBD_Thread::BD_HEIGHT = 1080;
66 const double CreateBD_Thread::BD_WIDE_ASPECT_WIDTH = 16.;
67 const double CreateBD_Thread::BD_WIDE_ASPECT_HEIGHT = 9.;
68 const double CreateBD_Thread::BD_ASPECT_WIDTH = 4.;
69 const double CreateBD_Thread::BD_ASPECT_HEIGHT = 3.;
70 const double CreateBD_Thread::BD_FRAMERATE = 24000. / 1001.;
71 //const int CreateBD_Thread::BD_MAX_BITRATE = 40000000;
72 const int CreateBD_Thread::BD_MAX_BITRATE = 10000000;
73 const int CreateBD_Thread::BD_CHANNELS = 2;
74 const int CreateBD_Thread::BD_WIDE_CHANNELS = 6;
75 const double CreateBD_Thread::BD_SAMPLERATE = 48000;
76 const double CreateBD_Thread::BD_KAUDIO_RATE = 192;
77 const int CreateBD_Thread::BD_INTERLACE_MODE = ILACE_MODE_NOTINTERLACED;
78
79 CreateBD_MenuItem::CreateBD_MenuItem(MWindow *mwindow)
80  : BC_MenuItem(_("BD Render..."), _("Ctrl-d"), 'd')
81 {
82         set_ctrl(1);
83         this->mwindow = mwindow;
84 }
85
86 int CreateBD_MenuItem::handle_event()
87 {
88         mwindow->create_bd->start();
89         return 1;
90 }
91
92 BD_BatchRenderJob::BD_BatchRenderJob(Preferences *preferences, int labeled, int farmed)
93  : BatchRenderJob("BD_JOB", preferences, labeled, farmed)
94 {
95 }
96
97 int BD_BatchRenderJob::get_udfs_mount(char *udfs, char *mopts, char *mntpt)
98 {
99         int ret = 0;
100 // default: mount -t udf -o loop $dir/bd.udfs $dir/udfs
101         strcpy(udfs,"$dir/bd.udfs");
102         strcpy(mopts,"-t udf -o loop $dir/bd.udfs ");
103         strcpy(mntpt,"$dir/udfs");
104         const char *home = getenv("HOME");
105         if( !home ) return ret;
106         FILE *fp = fopen("/etc/fstab","r");
107         if( !fp ) return ret;
108         int len = strlen(home);
109         char line[BCTEXTLEN], typ[BCTEXTLEN], file[BCTEXTLEN];
110         char mpnt[BCTEXTLEN], opts[BCTEXTLEN];
111         while( fgets(line,sizeof(line),fp) ) {
112 // search "/etc/fstab" for: $HOME/img_file $HOME/bluray udf noauto,loop,rw,user
113                 if( line[0] == '#' || line[0] == ';' ) continue;
114                 if( sscanf(line,"%s %s %s %s ", &file[0], &mpnt[0], &typ[0], &opts[0]) != 4 )
115                         continue;
116                 if( strcmp("udf", typ) ) continue;
117                 if( strncmp(home, file, len) || file[len] != '/' ) continue;
118                 if( strncmp(home, mpnt, len) ) continue;
119                 if( strcmp(&mpnt[len], "/bluray") ) continue;
120                 int loop = 0, user = 0, rw = 0, noauto = 0;
121                 char *op = opts, *ep = op + sizeof(opts)-1;
122                 while( op < ep && *op ) {
123                         char opt[BCTEXTLEN], *cp = opt;
124                         while( op < ep && *op && (*cp=*op++)!=',' ) ++cp;
125                         *cp = 0;
126                         if( !strcmp("loop", opt) ) loop = 1;
127                         else if( !strcmp("user", opt) ) user = 1;
128                         else if( !strcmp("noauto", opt) ) noauto = 1;
129                         else if( !strcmp("rw", opt) ) rw = 1;
130                 }
131                 if( loop && user && rw && noauto ) {
132                         strcpy(udfs, file);
133                         strcpy(mopts, "");
134                         strcpy(mntpt, mpnt);
135                         ret = 1;
136                         break;
137                 }
138         }
139         fclose(fp);
140         return ret;
141 }
142
143 char *BD_BatchRenderJob::create_script(EDL *edl, ArrayList<Indexable *> *idxbls)
144 {
145         char script[BCTEXTLEN];
146         strcpy(script, edl_path);
147         FILE *fp = 0;
148         char *bp = strrchr(script,'/');
149         int fd = -1;
150         if( bp ) {
151                 strcpy(bp, "/bd.sh");
152                 fd = open(script, O_WRONLY+O_CREAT+O_TRUNC, 0755);
153         }
154         if( fd >= 0 )
155                 fp = fdopen(fd, "w");
156         if( !fp ) {
157                 char err[BCTEXTLEN], msg[BCTEXTLEN];
158                 strerror_r(errno, err, sizeof(err));
159                 sprintf(msg, _("Unable to save: %s\n-- %s"), script, err);
160                 MainError::show_error(msg);
161                 return 0;
162         }
163         char udfs[BCTEXTLEN], mopts[BCTEXTLEN], mntpt[BCTEXTLEN];
164         int is_usr_mnt = get_udfs_mount(udfs, mopts, mntpt);
165         const char *exec_path = File::get_cinlib_path();
166         fprintf(fp,"#!/bin/bash -ex\n");
167         fprintf(fp,"sdir=`dirname $0`\n");
168         fprintf(fp,"dir=`cd \"$sdir\"; pwd`\n");
169         fprintf(fp,"PATH=$PATH:%s\n",exec_path);
170         fprintf(fp,"mkdir -p $dir/udfs\n");
171         fprintf(fp,"sz=`du -cb $dir/bd.m2ts* | tail -1 | sed -e 's/[ \t].*//'`\n");
172         fprintf(fp,"blks=$((sz/2048 + 4096))\n");
173         fprintf(fp,"rm -f %s\n", udfs);
174         fprintf(fp,"mkudffs -b 2048 %s $blks\n", udfs);
175         fprintf(fp,"mount %s%s\n", mopts, mntpt);
176         fprintf(fp,"bdwrite %s $dir/bd.m2ts*\n",mntpt);
177         fprintf(fp,"umount %s\n",mntpt);
178         if( is_usr_mnt )
179                 fprintf(fp,"mv -f %s $dir/bd.udfs\n", udfs);
180         fprintf(fp,"echo To burn bluray, load writable media and run:\n");
181         fprintf(fp,"echo for WORM: growisofs -dvd-compat -Z /dev/bd=$dir/bd.udfs\n");
182         fprintf(fp,"echo for RW:   dd if=$dir/bd.udfs of=/dev/bd bs=2048000\n");
183         fprintf(fp,"kill $$\n");
184         fprintf(fp,"\n");
185         fclose(fp);
186         return cstrdup(script);
187 }
188
189
190 CreateBD_Thread::CreateBD_Thread(MWindow *mwindow)
191  : BC_DialogThread()
192 {
193         this->mwindow = mwindow;
194         this->gui = 0;
195         this->use_deinterlace = 0;
196         this->use_scale = Rescale::none;
197         this->use_histogram = 0;
198         this->use_inverse_telecine = 0;
199         this->use_wide_audio = 0;
200         this->use_resize_tracks = 0;
201         this->use_labeled = 0;
202         this->use_farmed = 0;
203
204         this->bd_size = BD_SIZE;
205         this->bd_width = BD_WIDTH;
206         this->bd_height = BD_HEIGHT;
207         this->bd_aspect_width = BD_WIDE_ASPECT_WIDTH;
208         this->bd_aspect_height = BD_WIDE_ASPECT_HEIGHT;
209         this->bd_framerate = BD_FRAMERATE;
210         this->bd_samplerate = BD_SAMPLERATE;
211         this->bd_max_bitrate = BD_MAX_BITRATE;
212         this->bd_kaudio_rate = BD_KAUDIO_RATE;
213         this->max_w = this->max_h = 0;
214 }
215
216 CreateBD_Thread::~CreateBD_Thread()
217 {
218         close_window();
219 }
220
221 int CreateBD_Thread::create_bd_jobs(ArrayList<BatchRenderJob*> *jobs, const char *asset_dir)
222 {
223         EDL *edl = mwindow->edl;
224         if( !edl || !edl->session ) {
225                 char msg[BCTEXTLEN];
226                 sprintf(msg, _("No EDL/Session"));
227                 MainError::show_error(msg);
228                 return 1;
229         }
230         EDLSession *session = edl->session;
231
232         double total_length = edl->tracks->total_length();
233         if( total_length <= 0 ) {
234                 char msg[BCTEXTLEN];
235                 sprintf(msg, _("No content: %s"), asset_title);
236                 MainError::show_error(msg);
237                 return 1;
238         }
239
240         if( mkdir(asset_dir, 0777) ) {
241                 char err[BCTEXTLEN], msg[BCTEXTLEN];
242                 strerror_r(errno, err, sizeof(err));
243                 sprintf(msg, _("Unable to create directory: %s\n-- %s"), asset_dir, err);
244                 MainError::show_error(msg);
245                 return 1;
246         }
247
248         double old_samplerate = session->sample_rate;
249         double old_framerate = session->frame_rate;
250
251         session->video_channels = BD_STREAMS;
252         session->video_tracks = BD_STREAMS;
253         session->frame_rate = bd_framerate;
254         session->output_w = bd_width;
255         session->output_h = bd_height;
256         session->aspect_w = bd_aspect_width;
257         session->aspect_h = bd_aspect_height;
258         session->sample_rate = bd_samplerate;
259         session->audio_channels = session->audio_tracks =
260                 use_wide_audio ? BD_WIDE_CHANNELS : BD_CHANNELS;
261         session->interlace_mode = bd_interlace_mode;
262
263         session->audio_channels = session->audio_tracks =
264                 !use_wide_audio ? BD_CHANNELS : BD_WIDE_CHANNELS;
265         for( int i=0; i<MAX_CHANNELS; ++i )
266                 session->achannel_positions[i] = default_audio_channel_position(i, session->audio_channels);
267         int audio_mapping = edl->tracks->recordable_audio_tracks() == BD_WIDE_CHANNELS &&
268                 !use_wide_audio ? MWindow::AUDIO_5_1_TO_2 : MWindow::AUDIO_1_TO_1;
269         mwindow->remap_audio(audio_mapping);
270
271         double new_samplerate = session->sample_rate;
272         double new_framerate = session->frame_rate;
273         edl->retrack();
274         edl->rechannel();
275         edl->resample(old_samplerate, new_samplerate, TRACK_AUDIO);
276         edl->resample(old_framerate, new_framerate, TRACK_VIDEO);
277
278         int64_t aud_size = ((bd_kaudio_rate * total_length)/8 + 1000-1) * 1000;
279         int64_t vid_size = bd_size*0.96 - aud_size;
280         int64_t vid_bitrate = (vid_size * 8) / total_length;
281         vid_bitrate /= 1000;  vid_bitrate *= 1000;
282         if( vid_bitrate > bd_max_bitrate ) vid_bitrate = bd_max_bitrate;
283
284         char xml_filename[BCTEXTLEN];
285         sprintf(xml_filename, "%s/bd.xml", asset_dir);
286         FileXML xml_file;
287         edl->save_xml(&xml_file, xml_filename);
288         xml_file.terminate_string();
289         if( xml_file.write_to_file(xml_filename) ) {
290                 char msg[BCTEXTLEN];
291                 sprintf(msg, _("Unable to save: %s"), xml_filename);
292                 MainError::show_error(msg);
293                 return 1;
294         }
295
296         BatchRenderJob *job = new BD_BatchRenderJob(mwindow->preferences,
297                 use_labeled, use_farmed);
298         jobs->append(job);
299         strcpy(&job->edl_path[0], xml_filename);
300         Asset *asset = job->asset;
301
302         asset->layers = BD_STREAMS;
303         asset->frame_rate = session->frame_rate;
304         asset->width = session->output_w;
305         asset->height = session->output_h;
306         asset->aspect_ratio = session->aspect_w / session->aspect_h;
307         asset->interlace_mode = session->interlace_mode;
308
309         char option_path[BCTEXTLEN];
310         sprintf(&asset->path[0],"%s/bd.m2ts", asset_dir);
311         asset->format = FILE_FFMPEG;
312         strcpy(asset->fformat, "m2ts");
313
314         asset->audio_data = 1;
315         strcpy(asset->acodec, "bluray.m2ts");
316         //mwindow->defaults->get("DEFAULT_BLURAY_ACODEC", asset->acodec);
317         FFMPEG::set_option_path(option_path, "audio/%s", asset->acodec);
318         FFMPEG::load_options(option_path, asset->ff_audio_options,
319                          sizeof(asset->ff_audio_options));
320         asset->ff_audio_bitrate = bd_kaudio_rate * 1000;
321
322         asset->video_data = 1;
323         strcpy(asset->vcodec, "bluray.m2ts");
324         //mwindow->defaults->get("DEFAULT_BLURAY_VCODEC", asset->vcodec);
325         FFMPEG::set_option_path(option_path, "video/%s", asset->vcodec);
326         FFMPEG::load_options(option_path, asset->ff_video_options,
327                  sizeof(asset->ff_video_options));
328         const char *opts = 0;
329         switch( asset->interlace_mode ) {
330         case ILACE_MODE_TOP_FIRST:    opts = ":tff\n";  break;
331         case ILACE_MODE_BOTTOM_FIRST: opts = ":bff\n";  break;
332         }
333         if( opts ) {
334                 int len = strlen(asset->ff_video_options);
335                 char *cp = asset->ff_video_options + len-1;
336                 strncpy(cp, opts, sizeof(asset->ff_video_options)-len);
337         }
338         asset->ff_video_bitrate = vid_bitrate;
339         asset->ff_video_quality = -1;
340         return 0;
341 }
342
343 void CreateBD_Thread::handle_close_event(int result)
344 {
345         if( result ) return;
346         mwindow->defaults->update("WORK_DIRECTORY", tmp_path);
347         mwindow->batch_render->load_defaults(mwindow->defaults);
348         mwindow->undo->update_undo_before();
349         KeyFrame keyframe;  char data[BCTEXTLEN];
350         if( use_deinterlace ) {
351                 sprintf(data,"<DEINTERLACE MODE=1>");
352                 keyframe.set_data(data);
353                 insert_video_plugin("Deinterlace", &keyframe);
354         }
355         if( use_inverse_telecine ) {
356                 sprintf(data,"<IVTC FRAME_OFFSET=0 FIRST_FIELD=0 "
357                         "AUTOMATIC=1 AUTO_THRESHOLD=2.0e+00 PATTERN=2>");
358                 keyframe.set_data(data);
359                 insert_video_plugin("Inverse Telecine", &keyframe);
360         }
361         if( use_scale != Rescale::none ) {
362                 double bd_aspect = bd_aspect_height > 0 ? bd_aspect_width / bd_aspect_height : 1;
363
364                 Tracks *tracks = mwindow->edl->tracks;
365                 for( Track *vtrk=tracks->first; vtrk; vtrk=vtrk->next ) {
366                         if( vtrk->data_type != TRACK_VIDEO ) continue;
367                         if( !vtrk->record ) continue;
368                         vtrk->expand_view = 1;
369                         PluginSet *plugin_set = new PluginSet(mwindow->edl, vtrk);
370                         vtrk->plugin_set.append(plugin_set);
371                         Edits *edits = vtrk->edits;
372                         for( Edit *edit=edits->first; edit; edit=edit->next ) {
373                                 Indexable *indexable = edit->get_source();
374                                 if( !indexable ) continue;
375                                 Rescale in(indexable);
376                                 Rescale out(bd_width, bd_height, bd_aspect);
377                                 float src_w, src_h, dst_w, dst_h;
378                                 in.rescale(out,use_scale, src_w,src_h, dst_w,dst_h);
379                                 sprintf(data,"<SCALERATIO TYPE=%d"
380                                         " IN_W=%d IN_H=%d IN_ASPECT_RATIO=%f"
381                                         " OUT_W=%d OUT_H=%d OUT_ASPECT_RATIO=%f"
382                                         " SRC_X=%f SRC_Y=%f SRC_W=%f SRC_H=%f"
383                                         " DST_X=%f DST_Y=%f DST_W=%f DST_H=%f>", use_scale,
384                                         in.w, in.h, in.aspect, out.w, out.h, out.aspect,
385                                         0., 0., src_w, src_h, 0., 0., dst_w, dst_h);
386                                 keyframe.set_data(data);
387                                 plugin_set->insert_plugin(_("Scale Ratio"),
388                                         edit->startproject, edit->length,
389                                         PLUGIN_STANDALONE, 0, &keyframe, 0);
390                         }
391                         vtrk->optimize();
392                 }
393         }
394         if( use_resize_tracks )
395                 resize_tracks();
396         if( use_histogram ) {
397 #if 0
398                 sprintf(data, "<HISTOGRAM OUTPUT_MIN_0=0 OUTPUT_MAX_0=1 "
399                         "OUTPUT_MIN_1=0 OUTPUT_MAX_1=1 "
400                         "OUTPUT_MIN_2=0 OUTPUT_MAX_2=1 "
401                         "OUTPUT_MIN_3=0 OUTPUT_MAX_3=1 "
402                         "AUTOMATIC=0 THRESHOLD=9.0-01 PLOT=0 SPLIT=0>"
403                         "<POINTS></POINTS><POINTS></POINTS><POINTS></POINTS>"
404                         "<POINTS><POINT X=6.0e-02 Y=0>"
405                                 "<POINT X=9.4e-01 Y=1></POINTS>");
406 #else
407                 sprintf(data, "<HISTOGRAM AUTOMATIC=0 THRESHOLD=1.0e-01 "
408                         "PLOT=0 SPLIT=0 W=440 H=500 PARADE=0 MODE=3 "
409                         "LOW_OUTPUT_0=0 HIGH_OUTPUT_0=1 LOW_INPUT_0=0 HIGH_INPUT_0=1 GAMMA_0=1 "
410                         "LOW_OUTPUT_1=0 HIGH_OUTPUT_1=1 LOW_INPUT_1=0 HIGH_INPUT_1=1 GAMMA_1=1 "
411                         "LOW_OUTPUT_2=0 HIGH_OUTPUT_2=1 LOW_INPUT_2=0 HIGH_INPUT_2=1 GAMMA_2=1 "
412                         "LOW_OUTPUT_3=0 HIGH_OUTPUT_3=1 LOW_INPUT_3=0.044 HIGH_INPUT_3=0.956 "
413                         "GAMMA_3=1>");
414 #endif
415                 keyframe.set_data(data);
416                 insert_video_plugin("Histogram", &keyframe);
417         }
418
419         char asset_dir[BCTEXTLEN], jobs_path[BCTEXTLEN];
420         snprintf(asset_dir, sizeof(asset_dir), "%s/%s", tmp_path, asset_title);
421         snprintf(jobs_path, sizeof(jobs_path), "%s/bd.jobs", asset_dir);
422         mwindow->batch_render->reset(jobs_path);
423         int ret = create_bd_jobs(&mwindow->batch_render->jobs, asset_dir);
424         mwindow->undo->update_undo_after(_("create bd"), LOAD_ALL);
425         mwindow->resync_guis();
426         if( ret ) return;
427         mwindow->batch_render->save_jobs();
428         mwindow->batch_render->start(-use_farmed, -use_labeled);
429 }
430
431 BC_Window* CreateBD_Thread::new_gui()
432 {
433         strcpy(tmp_path, "/tmp");
434         mwindow->defaults->get("WORK_DIRECTORY", tmp_path);
435         memset(asset_title,0,sizeof(asset_title));
436         time_t dt;      time(&dt);
437         struct tm dtm;  localtime_r(&dt, &dtm);
438         sprintf(asset_title, "bd_%02d%02d%02d-%02d%02d%02d",
439                 dtm.tm_year+1900, dtm.tm_mon+1, dtm.tm_mday,
440                 dtm.tm_hour, dtm.tm_min, dtm.tm_sec);
441         use_deinterlace = 0;
442         use_scale = Rescale::none;
443         use_histogram = 0;
444         use_inverse_telecine = 0;
445         use_wide_audio = 0;
446         use_resize_tracks = 0;
447         use_labeled = 0;
448         use_farmed = 0;
449         use_standard = !strcmp(mwindow->default_std(),"NTSC") ?
450                  BD_1920x1080_2997i : BD_1920x1080_25i;
451         bd_size = BD_SIZE;
452         bd_width = BD_WIDTH;
453         bd_height = BD_HEIGHT;
454         bd_aspect_width = BD_WIDE_ASPECT_WIDTH;
455         bd_aspect_height = BD_WIDE_ASPECT_HEIGHT;
456         bd_framerate = BD_FRAMERATE;
457         bd_samplerate = BD_SAMPLERATE;
458         bd_max_bitrate = BD_MAX_BITRATE;
459         bd_kaudio_rate = BD_KAUDIO_RATE;
460         bd_interlace_mode = BD_INTERLACE_MODE;
461         max_w = 0; max_h = 0;
462
463         int has_standard = -1;
464         if( mwindow->edl ) {
465                 EDLSession *session = mwindow->edl->session;
466 // match the session to any known standard
467                 for( int i=0; i<(int)(sizeof(bd_formats)/sizeof(bd_formats[0])); ++i ) {
468                         if( !EQUIV(session->frame_rate, bd_formats[i].framerate) ) continue;
469                         if( session->output_w != bd_formats[i].w ) continue;
470                         if( session->output_h != bd_formats[i].h ) continue;
471                         has_standard = i;  break;
472                 }
473         }
474         if( has_standard >= 0 )
475                 use_standard = has_standard;
476
477         option_presets();
478         int scr_x = mwindow->gui->get_screen_x(0, -1);
479         int scr_w = mwindow->gui->get_screen_w(0, -1);
480         int scr_h = mwindow->gui->get_screen_h(0, -1);
481         int w = xS(500), h = yS(290);
482         int x = scr_x + scr_w/2 - w/2, y = scr_h/2 - h/2;
483
484         gui = new CreateBD_GUI(this, x, y, w, h);
485         gui->create_objects();
486
487         if( getuid() != 0 ) {
488                 mwindow->show_warning(
489                         &mwindow->preferences->bd_warn_root,
490                         _("Must be root to mount UDFS images\n"));
491         }
492         return gui;
493 }
494
495
496 CreateBD_OK::CreateBD_OK(CreateBD_GUI *gui, int x, int y)
497  : BC_OKButton(x, y)
498 {
499         this->gui = gui;
500         set_tooltip(_("end setup, start batch render"));
501 }
502
503 CreateBD_OK::~CreateBD_OK()
504 {
505 }
506
507 int CreateBD_OK::button_press_event()
508 {
509         if(get_buttonpress() == 1 && is_event_win() && cursor_inside()) {
510                 gui->set_done(0);
511                 return 1;
512         }
513         return 0;
514 }
515
516 int CreateBD_OK::keypress_event()
517 {
518         return 0;
519 }
520
521
522 CreateBD_Cancel::CreateBD_Cancel(CreateBD_GUI *gui, int x, int y)
523  : BC_CancelButton(x, y)
524 {
525         this->gui = gui;
526 }
527
528 CreateBD_Cancel::~CreateBD_Cancel()
529 {
530 }
531
532 int CreateBD_Cancel::button_press_event()
533 {
534         if(get_buttonpress() == 1 && is_event_win() && cursor_inside()) {
535                 gui->set_done(1);
536                 return 1;
537         }
538         return 0;
539 }
540
541
542 CreateBD_DiskSpace::CreateBD_DiskSpace(CreateBD_GUI *gui, int x, int y)
543  : BC_Title(x, y, "", MEDIUMFONT, GREEN)
544 {
545         this->gui = gui;
546 }
547
548 CreateBD_DiskSpace::~CreateBD_DiskSpace()
549 {
550 }
551
552 int64_t CreateBD_DiskSpace::tmp_path_space()
553 {
554         const char *path = gui->thread->tmp_path;
555         if( access(path,R_OK+W_OK) ) return 0;
556         struct statfs sfs;
557         if( statfs(path, &sfs) ) return 0;
558         return (int64_t)sfs.f_bsize * sfs.f_bfree;
559 }
560
561 void CreateBD_DiskSpace::update()
562 {
563         static const char *suffix[] = { "", "KB", "MB", "GB", "TB", "PB" };
564         int64_t disk_space = tmp_path_space();
565         double media_size = 100e9, msz = 0, m = 1;
566         char sfx[BCSTRLEN];
567         if( sscanf(gui->media_size->get_text(), "%lf%s", &msz, sfx) == 2 ) {
568                 int i = sizeof(suffix)/sizeof(suffix[0]);
569                 while( --i >= 0 && strcmp(sfx, suffix[i]) );
570                 while( --i >= 0 ) m *= 1000;
571                 media_size = msz * m;
572         }
573         int color = disk_space < media_size*2 ? RED : GREEN;
574         int i = 0;
575         for( int64_t space=disk_space; i<5 && (space/=1000)>0; disk_space=space, ++i );
576         char text[BCTEXTLEN];
577         sprintf(text, "%s%3jd%s", _("disk space: "), disk_space, suffix[i]);
578         gui->disk_space->BC_Title::update(text);
579         gui->disk_space->set_color(color);
580 }
581
582 CreateBD_TmpPath::CreateBD_TmpPath(CreateBD_GUI *gui, int x, int y, int w)
583  : BC_TextBox(x, y, w, 1, -(int)sizeof(gui->thread->tmp_path),
584                 gui->thread->tmp_path, 1, MEDIUMFONT)
585 {
586         this->gui = gui;
587 }
588
589 CreateBD_TmpPath::~CreateBD_TmpPath()
590 {
591 }
592
593 int CreateBD_TmpPath::handle_event()
594 {
595         get_text();
596         gui->disk_space->update();
597         return 1;
598 }
599
600
601 CreateBD_AssetTitle::CreateBD_AssetTitle(CreateBD_GUI *gui, int x, int y, int w)
602  : BC_TextBox(x, y, w, 1, -(int)sizeof(gui->thread->asset_title),
603                 gui->thread->asset_title, 1, MEDIUMFONT)
604 {
605         this->gui = gui;
606 }
607
608 CreateBD_AssetTitle::~CreateBD_AssetTitle()
609 {
610 }
611
612 int CreateBD_AssetTitle::handle_event()
613 {
614         get_text();
615         return 1;
616 }
617
618 CreateBD_Deinterlace::CreateBD_Deinterlace(CreateBD_GUI *gui, int x, int y)
619  : BC_CheckBox(x, y, &gui->thread->use_deinterlace, _("Deinterlace"))
620 {
621         this->gui = gui;
622 }
623
624 CreateBD_Deinterlace::~CreateBD_Deinterlace()
625 {
626 }
627
628 int CreateBD_Deinterlace::handle_event()
629 {
630         if( get_value() ) {
631                 gui->need_inverse_telecine->set_value(0);
632                 gui->thread->use_inverse_telecine = 0;
633         }
634         return BC_CheckBox::handle_event();
635 }
636
637
638 CreateBD_InverseTelecine::CreateBD_InverseTelecine(CreateBD_GUI *gui, int x, int y)
639  : BC_CheckBox(x, y, &gui->thread->use_inverse_telecine, _("Inverse Telecine"))
640 {
641         this->gui = gui;
642 }
643
644 CreateBD_InverseTelecine::~CreateBD_InverseTelecine()
645 {
646 }
647
648 int CreateBD_InverseTelecine::handle_event()
649 {
650         if( get_value() ) {
651                 gui->need_deinterlace->set_value(0);
652                 gui->thread->use_deinterlace = 0;
653         }
654         return BC_CheckBox::handle_event();
655 }
656
657
658 CreateBD_ResizeTracks::CreateBD_ResizeTracks(CreateBD_GUI *gui, int x, int y)
659  : BC_CheckBox(x, y, &gui->thread->use_resize_tracks, _("Resize Tracks"))
660 {
661         this->gui = gui;
662 }
663
664 CreateBD_ResizeTracks::~CreateBD_ResizeTracks()
665 {
666 }
667
668
669 CreateBD_Histogram::CreateBD_Histogram(CreateBD_GUI *gui, int x, int y)
670  : BC_CheckBox(x, y, &gui->thread->use_histogram, _("Histogram"))
671 {
672         this->gui = gui;
673 }
674
675 CreateBD_Histogram::~CreateBD_Histogram()
676 {
677 }
678
679 CreateBD_LabelChapters::CreateBD_LabelChapters(CreateBD_GUI *gui, int x, int y)
680  : BC_CheckBox(x, y, &gui->thread->use_labeled, _("Chapters at Labels"))
681 {
682         this->gui = gui;
683 }
684
685 CreateBD_LabelChapters::~CreateBD_LabelChapters()
686 {
687 }
688
689 CreateBD_UseRenderFarm::CreateBD_UseRenderFarm(CreateBD_GUI *gui, int x, int y)
690  : BC_CheckBox(x, y, &gui->thread->use_farmed, _("Use render farm"))
691 {
692         this->gui = gui;
693 }
694
695 CreateBD_UseRenderFarm::~CreateBD_UseRenderFarm()
696 {
697 }
698
699
700 CreateBD_WideAudio::CreateBD_WideAudio(CreateBD_GUI *gui, int x, int y)
701  : BC_CheckBox(x, y, &gui->thread->use_wide_audio, _("Audio 5.1"))
702 {
703         this->gui = gui;
704 }
705
706 CreateBD_WideAudio::~CreateBD_WideAudio()
707 {
708 }
709
710
711 CreateBD_GUI::CreateBD_GUI(CreateBD_Thread *thread, int x, int y, int w, int h)
712  : BC_Window(_(PROGRAM_NAME ": Create BD"), x, y, w, h, xS(50), yS(50), 1, 0, 1)
713 {
714         this->thread = thread;
715         at_x = at_y = tmp_x = tmp_y = 0;
716         ok_x = ok_y = ok_w = ok_h = 0;
717         cancel_x = cancel_y = cancel_w = cancel_h = 0;
718         asset_title = 0;
719         tmp_path = 0;
720         btmp_path = 0;
721         disk_space = 0;
722         standard = 0;
723         scale = 0;
724         need_deinterlace = 0;
725         need_inverse_telecine = 0;
726         need_resize_tracks = 0;
727         need_histogram = 0;
728         non_standard = 0;
729         need_wide_audio = 0;
730         need_labeled = 0;
731         need_farmed = 0;
732         ok = 0;
733         cancel = 0;
734 }
735
736 CreateBD_GUI::~CreateBD_GUI()
737 {
738 }
739
740 void CreateBD_GUI::create_objects()
741 {
742         int xs10 = xS(10), xs30 = xS(30), xs35 = xS(35);
743         int xs160 = xS(160), xs170 = xS(170);
744         int ys5 = yS(5), ys10 = yS(10);
745         lock_window("CreateBD_GUI::create_objects");
746         int pady = BC_TextBox::calculate_h(this, MEDIUMFONT, 0, 1) + ys5;
747         int padx = BC_Title::calculate_w(this, (char*)"X", MEDIUMFONT);
748         int x = padx/2, y = pady/2;
749         BC_Title *title = new BC_Title(x, y, _("Title:"), MEDIUMFONT, YELLOW);
750         add_subwindow(title);
751         at_x = x + title->get_w();  at_y = y;
752         asset_title = new CreateBD_AssetTitle(this, at_x, at_y, get_w()-at_x-xs10);
753         add_subwindow(asset_title);
754         y += title->get_h() + pady/2;
755         title = new BC_Title(x, y, _("Work path:"), MEDIUMFONT, YELLOW);
756         add_subwindow(title);
757         tmp_x = x + title->get_w();  tmp_y = y;
758         tmp_path = new CreateBD_TmpPath(this, tmp_x, tmp_y,  get_w()-tmp_x-xs35);
759         add_subwindow(tmp_path);
760         btmp_path = new BrowseButton(thread->mwindow->theme, this, tmp_path,
761                 tmp_x+tmp_path->get_w(), tmp_y, "/tmp",
762                 _("Work path"), _("Select a Work directory:"), 1);
763         add_subwindow(btmp_path);
764         y += title->get_h() + pady/2;
765         disk_space = new CreateBD_DiskSpace(this, x, y);
766         add_subwindow(disk_space);
767         int x0 = get_w() - xs170;
768         title = new BC_Title(x0, y, _("Media:"), MEDIUMFONT, YELLOW);
769         add_subwindow(title);
770         int x1 =  x0+title->get_w()+padx;
771         media_size = new CreateBD_MediaSize(this, x1, y);
772         media_size->create_objects();
773         media_sizes.append(new BC_ListBoxItem("25GB"));
774         media_sizes.append(new BC_ListBoxItem("50GB"));
775         media_size->update_list(&media_sizes);
776         media_size->update(media_sizes[0]->get_text());
777         disk_space->update();
778         y += disk_space->get_h() + pady/2;
779         title = new BC_Title(x, y, _("Format:"), MEDIUMFONT, YELLOW);
780         add_subwindow(title);
781         standard = new CreateBD_Format(this, title->get_w() + padx, y);
782         add_subwindow(standard);
783         standard->create_objects();
784         standard->set_text(bd_formats[thread->use_standard].name);
785         x0 -= xs30;
786         title = new BC_Title(x0, y, _("Scale:"), MEDIUMFONT, YELLOW);
787         add_subwindow(title);
788         x1 = x0+title->get_w()+padx;
789         scale = new CreateBD_Scale(this, x1, y);
790         add_subwindow(scale);
791         scale->create_objects();
792         y += standard->get_h() + pady/2;
793         x1 = x;  int y1 = y;
794         need_deinterlace = new CreateBD_Deinterlace(this, x1, y);
795         add_subwindow(need_deinterlace);
796         y += need_deinterlace->get_h() + pady/2;
797         need_histogram = new CreateBD_Histogram(this, x1, y);
798         add_subwindow(need_histogram);
799         y += need_histogram->get_h() + pady/2;
800         non_standard = new BC_Title(x1, y+ys5, "", MEDIUMFONT, RED);
801         add_subwindow(non_standard);
802         x1 += xs160;  y = y1;
803         need_inverse_telecine = new CreateBD_InverseTelecine(this, x1, y);
804         add_subwindow(need_inverse_telecine);
805         y += need_inverse_telecine->get_h() + pady/2;
806         need_wide_audio = new CreateBD_WideAudio(this, x1, y);
807         add_subwindow(need_wide_audio);
808         y += need_wide_audio->get_h() + pady/2;
809         need_resize_tracks = new CreateBD_ResizeTracks(this, x1, y);
810         add_subwindow(need_resize_tracks);
811         x1 += xs160;  y = y1;
812         need_labeled = new CreateBD_LabelChapters(this, x1, y);
813         add_subwindow(need_labeled);
814         y += need_labeled->get_h() + pady/2;
815         need_farmed = new CreateBD_UseRenderFarm(this, x1, y);
816         add_subwindow(need_farmed);
817         ok_w = BC_OKButton::calculate_w();
818         ok_h = BC_OKButton::calculate_h();
819         ok_x = xs10;
820         ok_y = get_h() - ok_h - xs10;
821         ok = new CreateBD_OK(this, ok_x, ok_y);
822         add_subwindow(ok);
823         cancel_w = BC_CancelButton::calculate_w();
824         cancel_h = BC_CancelButton::calculate_h();
825         cancel_x = get_w() - cancel_w - xs10,
826         cancel_y = get_h() - cancel_h - ys10;
827         cancel = new CreateBD_Cancel(this, cancel_x, cancel_y);
828         add_subwindow(cancel);
829         show_window();
830         unlock_window();
831 }
832
833 int CreateBD_GUI::resize_event(int w, int h)
834 {
835         int xs10 = xS(10), xs35 = xS(35);
836         int ys10 = yS(10);
837         asset_title->reposition_window(at_x, at_y, get_w()-at_x-xs10);
838         tmp_path->reposition_window(tmp_x, tmp_y,  get_w()-tmp_x-xs35);
839         btmp_path->reposition_window(tmp_x+tmp_path->get_w(), tmp_y);
840         ok_y = h - ok_h - ys10;
841         ok->reposition_window(ok_x, ok_y);
842         cancel_x = w - cancel_w - xs10,
843         cancel_y = h - cancel_h - ys10;
844         cancel->reposition_window(cancel_x, cancel_y);
845         return 0;
846 }
847
848 int CreateBD_GUI::translation_event()
849 {
850         return 1;
851 }
852
853 int CreateBD_GUI::close_event()
854 {
855         set_done(1);
856         return 1;
857 }
858
859 void CreateBD_GUI::update()
860 {
861         scale->set_value(thread->use_scale);
862         need_deinterlace->set_value(thread->use_deinterlace);
863         need_inverse_telecine->set_value(thread->use_inverse_telecine);
864         need_resize_tracks->set_value(thread->use_resize_tracks);
865         need_histogram->set_value(thread->use_histogram);
866         need_wide_audio->set_value(thread->use_wide_audio);
867         need_labeled->set_value(thread->use_labeled);
868         need_farmed->set_value(thread->use_farmed);
869 }
870
871 int CreateBD_Thread::
872 insert_video_plugin(const char *title, KeyFrame *default_keyframe)
873 {
874         Tracks *tracks = mwindow->edl->tracks;
875         for( Track *vtrk=tracks->first; vtrk; vtrk=vtrk->next ) {
876                 if( vtrk->data_type != TRACK_VIDEO ) continue;
877                 if( !vtrk->record ) continue;
878                 vtrk->expand_view = 1;
879                 PluginSet *plugin_set = new PluginSet(mwindow->edl, vtrk);
880                 vtrk->plugin_set.append(plugin_set);
881                 Edits *edits = vtrk->edits;
882                 for( Edit *edit=edits->first; edit; edit=edit->next ) {
883                         plugin_set->insert_plugin(_(title),
884                                 edit->startproject, edit->length,
885                                 PLUGIN_STANDALONE, 0, default_keyframe, 0);
886                 }
887                 vtrk->optimize();
888         }
889         return 0;
890 }
891
892 int CreateBD_Thread::
893 resize_tracks()
894 {
895         Tracks *tracks = mwindow->edl->tracks;
896         int trk_w = max_w, trk_h = max_h;
897         if( trk_w < bd_width ) trk_w = bd_width;
898         if( trk_h < bd_height ) trk_h = bd_height;
899         for( Track *vtrk=tracks->first; vtrk; vtrk=vtrk->next ) {
900                 if( vtrk->data_type != TRACK_VIDEO ) continue;
901                 if( !vtrk->record ) continue;
902                 vtrk->track_w = trk_w;
903                 vtrk->track_h = trk_h;
904         }
905         return 0;
906 }
907
908 int CreateBD_Thread::
909 option_presets()
910 {
911 // reset only probed options
912         use_deinterlace = 0;
913         use_scale = Rescale::none;
914         use_resize_tracks = 0;
915         use_wide_audio = 0;
916         use_labeled = 0;
917         use_farmed = 0;
918
919         if( !mwindow->edl ) return 1;
920
921         bd_width = bd_formats[use_standard].w;
922         bd_height = bd_formats[use_standard].h;
923         bd_framerate = bd_formats[use_standard].framerate;
924         int wide = bd_formats[use_standard].wide;
925         bd_aspect_width  = wide < 0 ? 1. :
926                 wide > 0 ? BD_WIDE_ASPECT_WIDTH  : BD_ASPECT_WIDTH;
927         bd_aspect_height = wide < 0 ? 1. :
928                 wide > 0 ? BD_WIDE_ASPECT_HEIGHT : BD_ASPECT_HEIGHT;
929         bd_interlace_mode = bd_formats[use_standard].interlaced;
930         double bd_aspect = bd_aspect_width / bd_aspect_height;
931
932         Tracks *tracks = mwindow->edl->tracks;
933         max_w = 0;  max_h = 0;
934         int has_deinterlace = 0, has_scale = 0;
935         for( Track *trk=tracks->first; trk; trk=trk->next ) {
936                 if( !trk->record ) continue;
937                 Edits *edits = trk->edits;
938                 switch( trk->data_type ) {
939                 case TRACK_VIDEO:
940                         for( Edit *edit=edits->first; edit; edit=edit->next ) {
941                                 if( edit->silence() ) continue;
942                                 Indexable *indexable = edit->get_source();
943                                 int w = indexable->get_w();
944                                 if( w > max_w ) max_w = w;
945                                 if( w != bd_width ) use_scale = Rescale::scaled;
946                                 int h = indexable->get_h();
947                                 if( h > max_h ) max_h = h;
948                                 if( h != bd_height ) use_scale = Rescale::scaled;
949                                 float aw, ah;
950                                 MWindow::create_aspect_ratio(aw, ah, w, h);
951                                 double aspect = ah > 0 ? aw / ah : 1;
952                                 if( wide >= 0 && !EQUIV(aspect, bd_aspect) )
953                                         use_scale = Rescale::scaled;
954                         }
955                         for( int i=0; i<trk->plugin_set.size(); ++i ) {
956                                 for( Plugin *plugin = (Plugin*)trk->plugin_set[i]->first;
957                                                 plugin; plugin=(Plugin*)plugin->next ) {
958                                         if( !strcmp(plugin->title, "Deinterlace") )
959                                                 has_deinterlace = 1;
960                                         if( !strcmp(plugin->title, "Auto Scale") ||
961                                             !strcmp(plugin->title, "Scale Ratio") ||
962                                             !strcmp(plugin->title, "Scale") )
963                                                 has_scale = 1;
964                                 }
965                         }
966                         break;
967                 }
968         }
969         if( has_scale )
970                 use_scale = Rescale::none;
971         if( use_scale != Rescale::none ) {
972                 if( max_w != bd_width ) use_resize_tracks = 1;
973                 if( max_h != bd_height ) use_resize_tracks = 1;
974         }
975         for( Track *trk=tracks->first; trk && !use_resize_tracks; trk=trk->next ) {
976                 if( !trk->record ) continue;
977                 switch( trk->data_type ) {
978                 case TRACK_VIDEO:
979                         if( trk->track_w != max_w ) use_resize_tracks = 1;
980                         if( trk->track_h != max_h ) use_resize_tracks = 1;
981                         break;
982                 }
983         }
984         if( !has_deinterlace && max_h > 2*bd_height ) use_deinterlace = 1;
985
986         if( tracks->recordable_audio_tracks() == BD_WIDE_CHANNELS )
987                 use_wide_audio = 1;
988
989         return 0;
990 }
991
992
993 CreateBD_FormatItem::CreateBD_FormatItem(CreateBD_Format *popup,
994                 int standard, const char *name)
995  : BC_MenuItem(name)
996 {
997         this->popup = popup;
998         this->standard = standard;
999 }
1000
1001 CreateBD_FormatItem::~CreateBD_FormatItem()
1002 {
1003 }
1004
1005 int CreateBD_FormatItem::handle_event()
1006 {
1007         const char *text = get_text();
1008         int standard = this->standard;
1009         if( standard < 0 ) {
1010                 BC_SubMenu *submenu = get_submenu();
1011                 CreateBD_FormatItem *sub_item0 =
1012                         (CreateBD_FormatItem *)submenu->get_item(0);
1013                 standard = sub_item0->standard;
1014                 text = sub_item0->get_text();
1015         }
1016         popup->gui->thread->use_standard = standard;
1017         popup->set_text(text);
1018         int n = strlen(text)-1;
1019         int not_standard = n >= 0 && text[n] == '*' ? 1 : 0;
1020         popup->gui->non_standard->update(not_standard ? _("* non-standard format") : "", 0);
1021         return popup->handle_event();
1022 }
1023
1024
1025 CreateBD_Format::CreateBD_Format(CreateBD_GUI *gui, int x, int y)
1026  : BC_PopupMenu(x, y, xS(180), bd_formats[gui->thread->use_standard].name, 1)
1027 {
1028         this->gui = gui;
1029 }
1030
1031 CreateBD_Format::~CreateBD_Format()
1032 {
1033 }
1034
1035 void CreateBD_Format::create_objects()
1036 {
1037         BC_SubMenu *submenu = 0;
1038         CreateBD_FormatItem *item = 0;
1039         int ww = 0, hh = 0;
1040         for( int i=0; i<(int)(sizeof(bd_formats)/sizeof(bd_formats[0])); ++i ) {
1041                 if( ww != bd_formats[i].w || hh != bd_formats[i].h ) {
1042                         ww = bd_formats[i].w;  hh = bd_formats[i].h;
1043                         char string[BCSTRLEN];
1044                         sprintf(string, "%dx%d", ww,hh);
1045                         add_item(item = new CreateBD_FormatItem(this, -1, string));
1046                         item->add_submenu(submenu = new BC_SubMenu());
1047                 }
1048                 submenu->add_submenuitem(new CreateBD_FormatItem(this, i, bd_formats[i].name));
1049         }
1050 }
1051
1052 int CreateBD_Format::handle_event()
1053 {
1054         gui->thread->option_presets();
1055         gui->update();
1056         return 1;
1057 }
1058
1059
1060 CreateBD_ScaleItem::CreateBD_ScaleItem(CreateBD_Scale *popup,
1061                 int scale, const char *text)
1062  : BC_MenuItem(text)
1063 {
1064         this->popup = popup;
1065         this->scale = scale;
1066 }
1067
1068 CreateBD_ScaleItem::~CreateBD_ScaleItem()
1069 {
1070 }
1071
1072 int CreateBD_ScaleItem::handle_event()
1073 {
1074         popup->gui->thread->use_scale = scale;
1075         popup->set_value(scale);
1076         return popup->handle_event();
1077 }
1078
1079
1080 CreateBD_Scale::CreateBD_Scale(CreateBD_GUI *gui, int x, int y)
1081  : BC_PopupMenu(x, y, xS(100), "", 1)
1082 {
1083         this->gui = gui;
1084 }
1085
1086 CreateBD_Scale::~CreateBD_Scale()
1087 {
1088 }
1089
1090 void CreateBD_Scale::create_objects()
1091 {
1092
1093         for( int i=0; i<(int)Rescale::n_scale_types; ++i ) {
1094                 add_item(new CreateBD_ScaleItem(this, i, Rescale::scale_types[i]));
1095         }
1096         set_value(gui->thread->use_scale);
1097 }
1098
1099 int CreateBD_Scale::handle_event()
1100 {
1101         gui->update();
1102         return 1;
1103 }
1104
1105
1106 CreateBD_MediaSize::CreateBD_MediaSize(CreateBD_GUI *gui, int x, int y)
1107  : BC_PopupTextBox(gui, 0, 0, x, y, xS(70),yS(50))
1108 {
1109         this->gui = gui;
1110 }
1111
1112 CreateBD_MediaSize::~CreateBD_MediaSize()
1113 {
1114 }
1115
1116 int CreateBD_MediaSize::handle_event()
1117 {
1118         gui->disk_space->update();
1119         return 1;
1120 }
1121