fix messed up cut/paste in thirdparty/Makefile / last checkin
[goodguy/history.git] / cinelerra-5.1 / cinelerra / dvdcreate.C
index 89f6d0ab16a4ff957a6b69871413ed6f71cf2f36..f61078148bedaf8cfae29f0725f54926cfe64d36 100644 (file)
@@ -93,6 +93,17 @@ CreateDVD_Thread::CreateDVD_Thread(MWindow *mwindow)
        this->use_ffmpeg = 0;
        this->use_resize_tracks = 0;
        this->use_label_chapters = 0;
+
+       this->dvd_size = DVD_SIZE;
+       this->dvd_width = DVD_WIDTH;
+       this->dvd_height = DVD_HEIGHT;
+       this->dvd_aspect_width = DVD_ASPECT_WIDTH;
+       this->dvd_aspect_height = DVD_ASPECT_HEIGHT;
+       this->dvd_framerate = DVD_FRAMERATE;
+       this->dvd_samplerate = DVD_SAMPLERATE;
+       this->dvd_max_bitrate = DVD_MAX_BITRATE;
+       this->dvd_kaudio_rate = DVD_KAUDIO_RATE;
+       this->max_w = this->max_h = 0;
 }
 
 CreateDVD_Thread::~CreateDVD_Thread()
@@ -169,6 +180,9 @@ int CreateDVD_Thread::create_dvd_jobs(ArrayList<BatchRenderJob*> *jobs,
        fprintf(fp,"rm -rf $1/iso\n");
        fprintf(fp,"mkdir -p $1/iso\n");
        fprintf(fp,"\n");
+// dvdauthor ver 0.7.0 requires this to work
+       fprintf(fp,"export VIDEO_FORMAT=%s\n",
+               use_standard == HD_720x576_2500 ? "PAL" : "NTSC");
        fprintf(fp,"dvdauthor -x - <<eof\n");
        fprintf(fp,"<dvdauthor dest=\"$1/iso\">\n");
        fprintf(fp,"  <vmgm>\n");
@@ -176,7 +190,8 @@ int CreateDVD_Thread::create_dvd_jobs(ArrayList<BatchRenderJob*> *jobs,
        fprintf(fp,"  </vmgm>\n");
        fprintf(fp,"  <titleset>\n");
        fprintf(fp,"    <titles>\n");
-       fprintf(fp,"    <video format=\"ntsc\" aspect=\"%d:%d\" resolution=\"%dx%d\"/>\n",
+       fprintf(fp,"    <video format=\"%s\" aspect=\"%d:%d\" resolution=\"%dx%d\"/>\n",
+               use_standard == HD_720x576_2500 ? "pal" : "ntsc",
                (int)session->aspect_w, (int)session->aspect_h,
                session->output_w, session->output_h);
        fprintf(fp,"    <audio format=\"ac3\" lang=\"en\"/>\n");
@@ -349,8 +364,12 @@ void CreateDVD_Thread::handle_close_event(int result)
                insert_video_plugin("Inverse Telecine", &keyframe);
        }
        if( use_scale ) {
-               sprintf(data,"<SCALE TYPE=1 X_FACTOR=1 Y_FACTOR=1 "
-                       "WIDTH=%d HEIGHT=%d CONSTRAIN=0>", dvd_width, dvd_height);
+               sprintf(data,"<SCALE TYPE=%d X_FACTOR=%f Y_FACTOR=%f "
+                       "WIDTH=%d HEIGHT=%d CONSTRAIN=0>",
+                       max_w >= dvd_width || max_h >= dvd_height ? 1 : 0,
+                       max_w > 0 ? (double)dvd_width/max_w : 1,
+                       max_h > 0 ? (double)dvd_height/max_h : 1,
+                       dvd_width, dvd_height);
                keyframe.set_data(data);
                insert_video_plugin("Scale", &keyframe);
        }
@@ -417,6 +436,7 @@ BC_Window* CreateDVD_Thread::new_gui()
        dvd_samplerate = DVD_SAMPLERATE;
        dvd_max_bitrate = DVD_MAX_BITRATE;
        dvd_kaudio_rate = DVD_KAUDIO_RATE;
+       max_w = 0; max_h = 0;
 
        int has_standard = -1;
        if( mwindow->edl ) {
@@ -689,6 +709,7 @@ CreateDVD_GUI::CreateDVD_GUI(CreateDVD_Thread *thread, int x, int y, int w, int
        cancel_x = cancel_y = cancel_w = cancel_h = 0;
        asset_title = 0;
        tmp_path = 0;
+       btmp_path = 0;
        disk_space = 0;
        need_deinterlace = 0;
        need_inverse_telecine = 0;
@@ -718,11 +739,15 @@ void CreateDVD_GUI::create_objects()
        asset_title = new CreateDVD_AssetTitle(this, at_x, at_y, get_w()-at_x-10);
        add_subwindow(asset_title);
        y += title->get_h() + pady/2;
-       title = new BC_Title(x, y, _("tmp path:"), MEDIUMFONT, YELLOW);
+       title = new BC_Title(x, y, _("Work path:"), MEDIUMFONT, YELLOW);
        add_subwindow(title);
        tmp_x = x + title->get_w();  tmp_y = y;
-       tmp_path = new CreateDVD_TmpPath(this, tmp_x, tmp_y,  get_w()-tmp_x-10);
+       tmp_path = new CreateDVD_TmpPath(this, tmp_x, tmp_y,  get_w()-tmp_x-35);
        add_subwindow(tmp_path);
+       btmp_path = new BrowseButton(thread->mwindow, this, tmp_path,
+               tmp_x+tmp_path->get_w(), tmp_y, "/tmp",
+               _("Work path"), _("Select a Work directory:"), 1);
+       add_subwindow(btmp_path);
        y += title->get_h() + pady/2;
        disk_space = new CreateDVD_DiskSpace(this, x, y);
        add_subwindow(disk_space);
@@ -786,7 +811,8 @@ void CreateDVD_GUI::create_objects()
 int CreateDVD_GUI::resize_event(int w, int h)
 {
        asset_title->reposition_window(at_x, at_y, get_w()-at_x-10);
-       tmp_path->reposition_window(tmp_x, tmp_y,  get_w()-tmp_x-10);
+       tmp_path->reposition_window(tmp_x, tmp_y,  get_w()-tmp_x-35);
+       btmp_path->reposition_window(tmp_x+tmp_path->get_w(), tmp_y);
        ok_y = h - ok_h - 10;
        ok->reposition_window(ok_x, ok_y);
        cancel_x = w - cancel_w - 10,
@@ -844,25 +870,14 @@ int CreateDVD_Thread::
 resize_tracks()
 {
        Tracks *tracks = mwindow->edl->tracks;
-       int max_w = 0, max_h = 0;
-       for( Track *vtrk=tracks->first; vtrk; vtrk=vtrk->next ) {
-               if( vtrk->data_type != TRACK_VIDEO ) continue;
-               if( !vtrk->record ) continue;
-               Edits *edits = vtrk->edits;
-               for( Edit *edit=edits->first; edit; edit=edit->next ) {
-                       Indexable *indexable = edit->get_source();
-                       int w = indexable->get_w();
-                       if( w > max_w ) max_w = w;
-                       int h = indexable->get_h();
-                       if( h > max_h ) max_h = h;
-               }
-       }
-
+       int trk_w = max_w, trk_h = max_h;
+       if( trk_w < dvd_width ) trk_w = dvd_width;
+       if( trk_h < dvd_height ) trk_h = dvd_height;
        for( Track *vtrk=tracks->first; vtrk; vtrk=vtrk->next ) {
                if( vtrk->data_type != TRACK_VIDEO ) continue;
                if( !vtrk->record ) continue;
-               vtrk->track_w = max_w;
-               vtrk->track_h = max_h;
+               vtrk->track_w = trk_w;
+               vtrk->track_h = trk_h;
        }
        return 0;
 }
@@ -885,7 +900,7 @@ option_presets()
        dvd_framerate = hd_formats[use_standard].framerate;
 
        Tracks *tracks = mwindow->edl->tracks;
-       int max_w = 0, max_h = 0;
+       max_w = 0;  max_h = 0;
        int has_deinterlace = 0, has_scale = 0;
        for( Track *trk=tracks->first; trk; trk=trk->next ) {
                if( !trk->record ) continue;