X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fformattools.C;h=ef1a0b3b6032a55f2f4da75a5c21a799fffd4ae7;hb=0b78779e9e75131eee81d2e4689b98df0e91c092;hp=a86fbfa293503879a49232f0c621e498af338150;hpb=30bdb85eb33a8ee7ba675038a86c6be59c43d7bd;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/formattools.C b/cinelerra-5.1/cinelerra/formattools.C index a86fbfa2..ef1a0b3b 100644 --- a/cinelerra-5.1/cinelerra/formattools.C +++ b/cinelerra-5.1/cinelerra/formattools.C @@ -179,21 +179,20 @@ void FormatTools::create_objects(int &init_x, if(!recording) { - window->add_subwindow(path_textbox = new FormatPathText(x, y, this)); - x += path_textbox->get_w() + 5; + int px = x; + window->add_subwindow(path_textbox = new FormatPathText(px, y, this)); + px += path_textbox->get_w() + 5; path_recent = new BC_RecentList("PATH", mwindow->defaults, - path_textbox, 10, x, y, 300, 100); + path_textbox, 10, px, y, 300, 100); window->add_subwindow(path_recent); path_recent->load_items(File::formattostr(asset->format)); - x += path_recent->get_w() + 8; + px += path_recent->get_w() + 8; window->add_subwindow(path_button = new BrowseButton( - mwindow, window, path_textbox, x, y, asset->path, + mwindow, window, path_textbox, px, y, asset->path, _("Output to file"), _("Select a file to write to:"), 0)); // Set w for user. w = MAX(w, 305); -// w = x + path_button->get_w() + 5; - x -= path_textbox->get_w() + 5; y += path_textbox->get_h() + 10; } else @@ -205,18 +204,18 @@ 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, + window->add_subwindow(format_text = new BC_TextBox(x, y, 160, 1, File::formattostr(asset->format))); x += format_text->get_w(); //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, 50, 1, asset->fformat)); + window->add_subwindow(ffmpeg_type = new FFMpegType(x, y, 64, 1, asset->fformat)); + FFMPEG::set_asset_format(asset, asset->fformat); x += ffmpeg_type->get_w(); 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) @@ -493,21 +492,22 @@ void FormatTools::update(Asset *asset, int *strategy) void FormatTools::close_format_windows() { // This is done in ~file - if(aparams_thread && aparams_thread->running()) - { - aparams_thread->file->close_window(); + if( aparams_thread ) { + if( aparams_thread->running() ) + aparams_thread->file->close_window(); aparams_thread->join(); } - if(vparams_thread && vparams_thread->running()) - { - vparams_thread->file->close_window(); + if( vparams_thread ) { + if( vparams_thread->running() ) + vparams_thread->file->close_window(); vparams_thread->join(); } } int FormatTools::get_w() { - return w; + return asset->format != FILE_FFMPEG ? w : + format_ffmpeg->get_x() + format_ffmpeg->get_w(); } void FormatTools::set_w(int w) @@ -522,11 +522,13 @@ void FormatTools::reposition_window(int &init_x, int &init_y) if(path_textbox) { - path_textbox->reposition_window(x, y); - x += path_textbox->get_w() + 5; - path_button->reposition_window(x, y); - x -= path_textbox->get_w() + 5; - y += 35; + int px = x; + path_textbox->reposition_window(px, y); + px += path_textbox->get_w() + 5; + path_recent->reposition_window(px, y); + px += path_recent->get_w() + 8; + path_button->reposition_window(px, y); + y += path_textbox->get_h() + 10; } format_title->reposition_window(x, y); @@ -547,7 +549,7 @@ void FormatTools::reposition_window(int &init_x, int &init_y) if(prompt_audio) audio_switch->reposition_window(x, y); x = init_x; - y += aparams_button->get_h() + 20; + y += aparams_button->get_h() + 10; if(prompt_audio_channels) { channels_title->reposition_window(x, y); @@ -688,9 +690,8 @@ FormatAThread::FormatAThread(FormatTools *format) FormatAThread::~FormatAThread() { + delete file; file = 0; join(); - delete file; - file = 0; } void FormatAThread::start() @@ -719,9 +720,8 @@ FormatVThread::FormatVThread(FormatTools *format) FormatVThread::~FormatVThread() { + delete file; file = 0; join(); - delete file; - file = 0; } void FormatVThread::start() @@ -823,6 +823,8 @@ int FormatFormat::handle_event() asset->format = new_format; asset->audio_data = File::supports_audio(asset->format); asset->video_data = File::supports_video(asset->format); + asset->ff_audio_options[0] = 0; + asset->ff_video_options[0] = 0; format->format_text->update(selection->get_text()); format->update_extension(); format->close_format_windows(); @@ -845,40 +847,15 @@ FormatFFMPEG::~FormatFFMPEG() { } -int FormatFFMPEG::load_defaults(const char *path, const char *type, - char *codec, char *codec_options, int len) -{ - char default_file[BCTEXTLEN]; - FFMPEG::set_option_path(default_file, "%s/%s.dfl", path, type); - FILE *fp = fopen(default_file,"r"); - if( !fp ) return 1; - fgets(codec, BCSTRLEN, fp); - char *cp = codec; - while( *cp && *cp!='\n' ) ++cp; - *cp = 0; - while( len > 0 && fgets(codec_options, len, fp) ) { - int n = strlen(codec_options); - codec_options += n; len -= n; - } - fclose(fp); - FFMPEG::set_option_path(default_file, "%s/%s", path, codec); - return FFMPEG::load_options(default_file, codec_options, len); -} - int FormatFFMPEG::handle_event() { BC_ListBoxItem *selection = get_selection(0, 0); if( selection ) { char *text = get_selection(0, 0)->get_text(); format->ffmpeg_type->update(text); - Asset *asset = format->asset; - strcpy(asset->fformat, text); - strcpy(asset->ff_audio_options, ""); - strcpy(asset->ff_video_options, ""); - asset->audio_data = !load_defaults("audio", text, asset->acodec, - asset->ff_audio_options, sizeof(asset->ff_audio_options)); - asset->video_data = !load_defaults("video", text, asset->vcodec, - asset->ff_video_options, sizeof(asset->ff_video_options)); + format->asset->ff_audio_options[0] = 0; + format->asset->ff_video_options[0] = 0; + FFMPEG::set_asset_format(format->asset, text); format->update_extension(); format->close_format_windows(); format->update_format();