olaf neophyte and de.po updates, valgrind tweaks, delete green lady, inkscape dpi=96
[goodguy/history.git] / cinelerra-5.1 / cinelerra / formattools.C
index ea74b396e3c3c37e8825364f3bce49814112cdeb..312f39c8bb218776556fb6584ec28f4c883855ec 100644 (file)
@@ -27,7 +27,9 @@
 #include "filesystem.h"
 #include "formattools.h"
 #include "language.h"
+#ifdef HAVE_DV
 #include "libdv.h"
+#endif
 #include "libmjpeg.h"
 #include "maxchannels.h"
 #include "mwindow.h"
@@ -46,13 +48,11 @@ FormatTools::FormatTools(MWindow *mwindow,
        this->mwindow = mwindow;
        this->window = window;
        this->asset = asset;
-       this->plugindb = mwindow->plugindb;
 
        aparams_button = 0;
        vparams_button = 0;
        aparams_thread = 0;
        vparams_thread = 0;
-       channels_tumbler = 0;
        audio_switch = 0;
        video_switch = 0;
        path_textbox = 0;
@@ -63,9 +63,7 @@ FormatTools::FormatTools(MWindow *mwindow,
        format_text = 0;
        audio_title = 0;
        video_title = 0;
-       channels_title = 0;
-       channels_button = 0;
-       multiple_files = 0;
+       labeled_files = 0;
        w = window->get_w();
 
        recording = 0;
@@ -76,7 +74,7 @@ FormatTools::FormatTools(MWindow *mwindow,
        prompt_audio_channels = 0;
        prompt_video = 0;
        prompt_video_compression = 0;
-       strategy = 0;
+       file_per_label = 0;
        locked_compressor = 0;
        video_driver = 0;
 }
@@ -100,7 +98,6 @@ SET_TRACE
 SET_TRACE
        if(vparams_thread) delete vparams_thread;
 SET_TRACE
-       if(channels_tumbler) delete channels_tumbler;
 }
 
 void FormatTools::create_objects(
@@ -111,7 +108,7 @@ void FormatTools::create_objects(
                int prompt_video_compression,
                const char *locked_compressor,
                int recording,
-               int *strategy,
+               int *file_per_label,
                int brender,
                int horizontal_layout)
 {
@@ -129,31 +126,10 @@ void FormatTools::create_objects(
        this->prompt_audio_channels = prompt_audio_channels;
        this->prompt_video = prompt_video;
        this->prompt_video_compression = prompt_video_compression;
-       this->strategy = strategy;
+       this->file_per_label = file_per_label;
 
 //printf("FormatTools::create_objects 1\n");
 
-// Modify strategy depending on render farm
-       if(strategy)
-       {
-               if(mwindow->preferences->use_renderfarm)
-               {
-                       if(*strategy == FILE_PER_LABEL)
-                               *strategy = FILE_PER_LABEL_FARM;
-                       else
-                       if(*strategy == SINGLE_PASS)
-                               *strategy = SINGLE_PASS_FARM;
-               }
-               else
-               {
-                       if(*strategy == FILE_PER_LABEL_FARM)
-                               *strategy = FILE_PER_LABEL;
-                       else
-                       if(*strategy == SINGLE_PASS_FARM)
-                               *strategy = SINGLE_PASS;
-               }
-       }
-
        if(!recording)
        {
                int px = x;
@@ -189,7 +165,7 @@ void FormatTools::create_objects(
        format_button->create_objects();
        x += format_button->get_w() + 5;
        window->add_subwindow(ffmpeg_type = new FFMpegType(x, y, 70, 1, asset->fformat));
-       FFMPEG::set_asset_format(asset, asset->fformat);
+       FFMPEG::set_asset_format(asset, mwindow->edl, asset->fformat);
        x += ffmpeg_type->get_w();
        window->add_subwindow(format_ffmpeg = new FormatFFMPEG(x, y, this));
        format_ffmpeg->create_objects();
@@ -208,18 +184,6 @@ void FormatTools::create_objects(
                ylev = y;
                y += aparams_button->get_h() + 10;
 
-// Audio channels only used for recording.
-//             if(prompt_audio_channels)
-//             {
-//                     window->add_subwindow(channels_title = new BC_Title(x, y, _("Number of audio channels to record:")));
-//                     x += 260;
-//                     window->add_subwindow(channels_button = new FormatChannels(x, y, this));
-//                     x += channels_button->get_w() + 5;
-//                     window->add_subwindow(channels_tumbler = new BC_ITumbler(channels_button, 1, MAXCHANNELS, x, y));
-//                     y += channels_button->get_h() + 20;
-//                     x = init_x;
-//             }
-
 //printf("FormatTools::create_objects 6\n");
                aparams_thread = new FormatAThread(this);
        }
@@ -257,10 +221,10 @@ void FormatTools::create_objects(
 //printf("FormatTools::create_objects 11\n");
 
        x = init_x;
-       if(strategy)
-       {
-               window->add_subwindow(multiple_files = new FormatMultiple(mwindow, x, y, strategy));
-               y += multiple_files->get_h() + 10;
+       if( file_per_label ) {
+               labeled_files = new FormatFilePerLabel(this, x, y, file_per_label);
+               window->add_subwindow(labeled_files);
+               y += labeled_files->get_h() + 10;
        }
 
 //printf("FormatTools::create_objects 12\n");
@@ -298,11 +262,12 @@ void FormatTools::update_driver(int driver)
                        format_text->update(File::formattostr(asset->format));
 
                        switch(driver) {
+#ifdef HAVE_DV
                        case CAPTURE_IEC61883:
                        case CAPTURE_FIREWIRE:
                                locked_compressor = (char*)CODEC_TAG_DVSD;
                                break;
-
+#endif
                        case VIDEO4LINUX2JPEG:
                                locked_compressor = (char*)CODEC_TAG_MJPEG;
                                break;
@@ -439,19 +404,14 @@ void FormatTools::update_extension()
        }
 }
 
-void FormatTools::update(Asset *asset, int *strategy)
+void FormatTools::update(Asset *asset, int *file_per_label)
 {
        this->asset = asset;
-       this->strategy = strategy;
-
-       if(path_textbox)
-               path_textbox->update(asset->path);
+       this->file_per_label = file_per_label;
+       if( file_per_label ) labeled_files->update(file_per_label);
+       if( path_textbox ) path_textbox->update(asset->path);
        format_text->update(File::formattostr(asset->format));
        update_format();
-       if(strategy)
-       {
-               multiple_files->update(strategy);
-       }
        close_format_windows();
 }
 
@@ -516,16 +476,6 @@ void FormatTools::reposition_window(int &init_x, int &init_y)
 
                x = init_x;
                y += aparams_button->get_h() + 10;
-               if(prompt_audio_channels)
-               {
-                       channels_title->reposition_window(x, y);
-                       x += 260;
-                       channels_button->reposition_window(x, y);
-                       x += channels_button->get_w() + 5;
-                       channels_tumbler->reposition_window(x, y);
-                       y += channels_button->get_h() + 20;
-                       x = init_x;
-               }
        }
 
 
@@ -553,10 +503,9 @@ void FormatTools::reposition_window(int &init_x, int &init_y)
                x = init_x;
        }
 
-       if(strategy)
-       {
-               multiple_files->reposition_window(x, y);
-               y += multiple_files->get_h() + 10;
+       if( file_per_label ) {
+               labeled_files->reposition_window(x, y);
+               y += labeled_files->get_h() + 10;
        }
 
        init_y = y;
@@ -618,6 +567,7 @@ FormatAParams::~FormatAParams()
 int FormatAParams::handle_event()
 {
        format->set_audio_options();
+       format->handle_event();
        return 1;
 }
 
@@ -639,6 +589,7 @@ FormatVParams::~FormatVParams()
 int FormatVParams::handle_event()
 {
        format->set_video_options();
+       format->handle_event();
        return 1;
 }
 
@@ -741,6 +692,7 @@ FormatAudio::~FormatAudio() {}
 int FormatAudio::handle_event()
 {
        format->asset->audio_data = get_value();
+       format->handle_event();
        return 1;
 }
 
@@ -758,6 +710,7 @@ FormatVideo::~FormatVideo() {}
 int FormatVideo::handle_event()
 {
        format->asset->video_data = get_value();
+       format->handle_event();
        return 1;
 }
 
@@ -795,13 +748,14 @@ int FormatFormat::handle_event()
                                load_items(File::formattostr(format->asset->format));
                        format->update_format();
                }
+               format->handle_event();
        }
        return 1;
 }
 
 
 FormatFFMPEG::FormatFFMPEG(int x, int y, FormatTools *format)
- : FFMPEGPopup(format->plugindb, x, y)
+ : FFMPEGPopup(x, y)
 {
        this->format = format;
 }
@@ -818,92 +772,39 @@ int FormatFFMPEG::handle_event()
                format->ffmpeg_type->update(text);
                format->asset->ff_audio_options[0] = 0;
                format->asset->ff_video_options[0] = 0;
-               FFMPEG::set_asset_format(format->asset, text);
+               FFMPEG::set_asset_format(format->asset, format->mwindow->edl, text);
                format->update_extension();
                format->close_format_windows();
                format->update_format();
+               format->handle_event();
        }
        return 1;
 }
 
 
-
-
-FormatChannels::FormatChannels(int x, int y, FormatTools *format)
- : BC_TextBox(x, y, 100, 1, format->asset->channels)
-{
-       this->format = format;
-}
-
-FormatChannels::~FormatChannels()
-{
-}
-
-int FormatChannels::handle_event()
-{
-       format->asset->channels = atol(get_text());
-       return 1;
-}
-
-
-FormatToTracks::FormatToTracks(int x, int y, int *output)
- : BC_CheckBox(x, y, *output, _("Overwrite project with output"))
+FormatFilePerLabel::FormatFilePerLabel(FormatTools *format,
+       int x, int y, int *output)
+ : BC_CheckBox(x, y, *output, _("Create new file at each label"))
 {
+       this->format = format;
        this->output = output;
 }
 
-FormatToTracks::~FormatToTracks()
+FormatFilePerLabel::~FormatFilePerLabel()
 {
 }
 
-int FormatToTracks::handle_event()
+int FormatFilePerLabel::handle_event()
 {
        *output = get_value();
+       format->handle_event();
        return 1;
 }
 
-
-FormatMultiple::FormatMultiple(MWindow *mwindow, int x, int y, int *output)
- : BC_CheckBox(x,
-       y,
-       (*output == FILE_PER_LABEL) || (*output == FILE_PER_LABEL_FARM),
-       _("Create new file at each label"))
-{
-       this->output = output;
-       this->mwindow = mwindow;
-}
-
-FormatMultiple::~FormatMultiple()
-{
-}
-
-int FormatMultiple::handle_event()
-{
-       if(get_value())
-       {
-               if(mwindow->preferences->use_renderfarm)
-                       *output = FILE_PER_LABEL_FARM;
-               else
-                       *output = FILE_PER_LABEL;
-       }
-       else
-       {
-               if(mwindow->preferences->use_renderfarm)
-                       *output = SINGLE_PASS_FARM;
-               else
-                       *output = SINGLE_PASS;
-       }
-       return 1;
-}
-
-void FormatMultiple::update(int *output)
+void FormatFilePerLabel::update(int *output)
 {
        this->output = output;
-       if(*output == FILE_PER_LABEL_FARM ||
-               *output ==FILE_PER_LABEL)
-               set_value(1);
-       else
-               set_value(0);
+       set_value(*output ? 1 : 0);
 }