edl plugin names eng, fix segv for opengl brender, renderfarm rework strategy, perf...
[goodguy/history.git] / cinelerra-5.1 / cinelerra / formattools.C
index 1f3fc3caac80295bdcb64ce3d5e25e58376cd6e7..711167215e4ed3fcc9f717887f6c4b807ead86d7 100644 (file)
@@ -62,13 +62,10 @@ FormatTools::FormatTools(MWindow *mwindow,
        format_button = 0;
        format_text = 0;
        audio_title = 0;
-       audio_switch = 0;
        video_title = 0;
-       video_switch = 0;
        channels_title = 0;
        channels_button = 0;
        multiple_files = 0;
-       file_entries = 0;
        w = window->get_w();
 
        recording = 0;
@@ -79,7 +76,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;
 }
@@ -104,31 +101,24 @@ SET_TRACE
        if(vparams_thread) delete vparams_thread;
 SET_TRACE
        if(channels_tumbler) delete channels_tumbler;
-SET_TRACE
-       if(file_entries)
-       {
-               file_entries->remove_all_objects();
-               delete file_entries;
-       }
 }
 
-void FormatTools::create_objects(int &init_x,
-                                               int &init_y,
-                                               int do_audio,    // Include support for audio
-                                               int do_video,   // Include support for video
-                                               int prompt_audio,  // Include checkbox for audio
-                                               int prompt_video,
-                                               int prompt_audio_channels,
-                                               int prompt_video_compression,
-                                               const char *locked_compressor,
-                                               int recording,
-                                               int *strategy,
-                                               int brender,
-                                               int horizontal_layout)
+void FormatTools::create_objects(
+               int &init_x, int &init_y,
+               int do_audio, int do_video,   // Include support for audio, video
+               int prompt_audio, int prompt_video, // Include checkbox for audio, video
+               int prompt_audio_channels,
+               int prompt_video_compression,
+               const char *locked_compressor,
+               int recording,
+               int *file_per_label,
+               int brender,
+               int horizontal_layout)
 {
        int x = init_x;
        int y = init_y;
        int ylev = init_y;
+       int margin = mwindow->theme->widget_border;
 
        this->locked_compressor = locked_compressor;
        this->recording = recording;
@@ -139,44 +129,10 @@ void FormatTools::create_objects(int &init_x,
        this->prompt_audio_channels = prompt_audio_channels;
        this->prompt_video = prompt_video;
        this->prompt_video_compression = prompt_video_compression;
-       this->strategy = strategy;
-
-
-       file_entries = new ArrayList<BC_ListBoxItem*>;
-       FileSystem fs;
-       char string[BCTEXTLEN];
-// Load current directory
-       fs.update(getcwd(string, BCTEXTLEN));
-       for(int i = 0; i < fs.total_files(); i++)
-       {
-               file_entries->append(
-                       new BC_ListBoxItem(
-                               fs.get_entry(i)->get_name()));
-       }
+       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;
@@ -186,9 +142,9 @@ void FormatTools::create_objects(int &init_x,
                                        path_textbox, 10, px, y, 300, 100);
                window->add_subwindow(path_recent);
                path_recent->load_items(File::formattostr(asset->format));
-               px += path_recent->get_w() + 8;
+               px += path_recent->get_w();
                window->add_subwindow(path_button = new BrowseButton(
-                       mwindow, window, path_textbox, px, y, asset->path,
+                       mwindow->theme, window, path_textbox, px, y, asset->path,
                        _("Output to file"), _("Select a file to write to:"), 0));
 
 // Set w for user.
@@ -203,29 +159,28 @@ void FormatTools::create_objects(int &init_x,
 
        x = init_x;
        window->add_subwindow(format_title = new BC_Title(x, y, _("File Format:")));
-       x += 90;
-       window->add_subwindow(format_text = new BC_TextBox(x, y, 180, 1,
+       x += format_title->get_w() + margin;
+       window->add_subwindow(format_text = new BC_TextBox(x, y, 160, 1,
                File::formattostr(asset->format)));
-       x += format_text->get_w();
+       x += format_text->get_w() + margin;
 //printf("FormatTools::create_objects %d %p\n", __LINE__, window);
        window->add_subwindow(format_button = new FormatFormat(x, y, this));
        format_button->create_objects();
        x += format_button->get_w() + 5;
-       window->add_subwindow(ffmpeg_type = new FFMpegType(x, y+5, 50, 1, asset->fformat));
+       window->add_subwindow(ffmpeg_type = new FFMpegType(x, y, 70, 1, asset->fformat));
        FFMPEG::set_asset_format(asset, asset->fformat);
        x += ffmpeg_type->get_w();
-       window->add_subwindow(format_ffmpeg = new FormatFFMPEG(x, y+5, this));
+       window->add_subwindow(format_ffmpeg = new FormatFFMPEG(x, y, this));
        format_ffmpeg->create_objects();
        x = init_x;
        y += format_button->get_h() + 10;
-       if(do_audio)
-       {
-               window->add_subwindow(audio_title = new BC_Title(x, y, _("Audio:"), LARGEFONT,  BC_WindowBase::get_resources()->audiovideo_color));
-               x += 80;
+       if( do_audio ) {
+               window->add_subwindow(audio_title = new BC_Title(x, y, _("Audio:"), LARGEFONT,
+                       BC_WindowBase::get_resources()->audiovideo_color));
+               x += audio_title->get_w() + margin;
                window->add_subwindow(aparams_button = new FormatAParams(mwindow, this, x, y));
-               x += aparams_button->get_w() + 10;
-               if(prompt_audio)
-               {
+               x += aparams_button->get_w() + margin;
+               if(prompt_audio) {
                        window->add_subwindow(audio_switch = new FormatAudio(x, y, this, asset->audio_data));
                }
                x = init_x;
@@ -249,30 +204,27 @@ void FormatTools::create_objects(int &init_x,
        }
 
 //printf("FormatTools::create_objects 7\n");
-       if(do_video)
-       {
-               if(horizontal_layout && do_audio){
+       if( do_video ) {
+               if( horizontal_layout && do_audio ) {
                        x += 370;
                        y = ylev;
                }
 
 //printf("FormatTools::create_objects 8\n");
-               window->add_subwindow(video_title = new BC_Title(x, y, _("Video:"), LARGEFONT,  BC_WindowBase::get_resources()->audiovideo_color));
-               x += 80;
-               if(prompt_video_compression)
-               {
+               window->add_subwindow(video_title = new BC_Title(x, y, _("Video:"), LARGEFONT,
+                       BC_WindowBase::get_resources()->audiovideo_color));
+               x += video_title->get_w() + margin;
+               if(prompt_video_compression) {
                        window->add_subwindow(vparams_button = new FormatVParams(mwindow, this, x, y));
-                       x += vparams_button->get_w() + 10;
+                       x += vparams_button->get_w() + margin;
                }
 
 //printf("FormatTools::create_objects 9\n");
-               if(prompt_video)
-               {
+               if(prompt_video) {
                        window->add_subwindow(video_switch = new FormatVideo(x, y, this, asset->video_data));
                        y += video_switch->get_h();
                }
-               else
-               {
+               else {
                        y += vparams_button->get_h();
                }
 
@@ -284,9 +236,9 @@ void FormatTools::create_objects(int &init_x,
 //printf("FormatTools::create_objects 11\n");
 
        x = init_x;
-       if(strategy)
-       {
-               window->add_subwindow(multiple_files = new FormatMultiple(mwindow, x, y, strategy));
+       if( file_per_label ) {
+               multiple_files = new FormatMultiple(mwindow, x, y, file_per_label);
+               window->add_subwindow(multiple_files);
                y += multiple_files->get_h() + 10;
        }
 
@@ -319,8 +271,6 @@ void FormatTools::update_driver(int driver)
 
                case CAPTURE_IEC61883:
                case CAPTURE_FIREWIRE:
-               case CAPTURE_LML:
-               case CAPTURE_BUZ:
                case VIDEO4LINUX2JPEG:
                case CAPTURE_JPEG_WEBCAM:
                        asset->format = FILE_FFMPEG;
@@ -332,8 +282,6 @@ void FormatTools::update_driver(int driver)
                                locked_compressor = (char*)CODEC_TAG_DVSD;
                                break;
 
-                       case CAPTURE_BUZ:
-                       case CAPTURE_LML:
                        case VIDEO4LINUX2JPEG:
                                locked_compressor = (char*)CODEC_TAG_MJPEG;
                                break;
@@ -363,17 +311,17 @@ void FormatTools::update_format()
 {
        if( do_audio && prompt_audio && audio_switch ) {
                audio_switch->update(asset->audio_data);
-               if( !asset->audio_data )
-                       audio_switch->disable();
-               else
+               if( File::renders_audio(asset) )
                        audio_switch->enable();
+               else
+                       audio_switch->disable();
        }
        if( do_video && prompt_video && video_switch ) {
                video_switch->update(asset->video_data);
-               if( !asset->video_data )
-                       video_switch->disable();
-               else
+               if( File::renders_video(asset) )
                        video_switch->enable();
+               else
+                       video_switch->disable();
        }
        if( asset->format == FILE_FFMPEG ) {
                ffmpeg_type->show();
@@ -470,22 +418,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);
-       format_text->update(File::formattostr(plugindb, asset->format));
-       if(do_audio && prompt_audio && audio_switch)
-               audio_switch->update(asset->audio_data);
-       if(do_video && prompt_video && video_switch)
-               video_switch->update(asset->video_data);
-       if(strategy)
-       {
-               multiple_files->update(strategy);
-       }
+       this->file_per_label = file_per_label;
+       if( file_per_label ) multiple_files->update(file_per_label);
+       if( path_textbox ) path_textbox->update(asset->path);
+       format_text->update(File::formattostr(asset->format));
+       update_format();
        close_format_windows();
 }
 
@@ -587,8 +527,7 @@ void FormatTools::reposition_window(int &init_x, int &init_y)
                x = init_x;
        }
 
-       if(strategy)
-       {
+       if( file_per_label ) {
                multiple_files->reposition_window(x, y);
                y += multiple_files->get_h() + 10;
        }
@@ -753,11 +692,7 @@ FormatPathText::~FormatPathText()
 }
 int FormatPathText::handle_event()
 {
-// Suggestions
-       calculate_suggestions(format->file_entries);
-
-
-
+       calculate_suggestions();
        strcpy(format->asset->path, get_text());
        format->handle_event();
        return 1;
@@ -803,7 +738,7 @@ int FormatVideo::handle_event()
 
 
 FormatFormat::FormatFormat(int x, int y, FormatTools *format)
- : FormatPopup(format->plugindb, x, y, format->use_brender)
+ : FormatPopup(x, y, format->do_audio, format->do_video, format->use_brender)
 {
        this->format = format;
 }
@@ -816,17 +751,18 @@ int FormatFormat::handle_event()
 {
        BC_ListBoxItem *selection = get_selection(0, 0);
        if( selection ) {
-               int new_format = File::strtoformat(format->plugindb, get_selection(0, 0)->get_text());
+               int new_format = File::strtoformat(get_selection(0, 0)->get_text());
 //             if(new_format != format->asset->format)
                {
                        Asset *asset = format->asset;
                        asset->format = new_format;
-                       asset->audio_data = File::supports_audio(asset->format);
-                       asset->video_data = File::supports_video(asset->format);
+                       asset->audio_data = File::renders_audio(asset);
+                       asset->video_data = File::renders_video(asset);
                        asset->ff_audio_options[0] = 0;
                        asset->ff_video_options[0] = 0;
                        format->format_text->update(selection->get_text());
-                       format->update_extension();
+                       if( !format->use_brender )
+                               format->update_extension();
                        format->close_format_windows();
                        if (format->path_recent) format->path_recent->
                                load_items(File::formattostr(format->asset->format));
@@ -901,10 +837,7 @@ int FormatToTracks::handle_event()
 
 
 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"))
+ : BC_CheckBox(x, y, *output, _("Create new file at each label"))
 {
        this->output = output;
        this->mwindow = mwindow;
@@ -916,31 +849,14 @@ 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;
-       }
+       *output = get_value();
        return 1;
 }
 
 void FormatMultiple::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);
 }