X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Ffileffmpeg.C;h=d4f89e6c47795c4fef2feab4f7b6efb46ae25d3d;hb=a4de4732339bf38b5b225c533be1bdf60748f04a;hp=94205be8d6e2a7beefbb185a9b947d20c7a2033a;hpb=b77dbd97d927405c86a2a8ca0dd927bca3c70175;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/cinelerra/fileffmpeg.C b/cinelerra-5.1/cinelerra/fileffmpeg.C index 94205be8..d4f89e6c 100644 --- a/cinelerra-5.1/cinelerra/fileffmpeg.C +++ b/cinelerra-5.1/cinelerra/fileffmpeg.C @@ -40,8 +40,7 @@ FileFFMPEG::~FileFFMPEG() FFMpegConfigNum::FFMpegConfigNum(BC_Window *window, int x, int y, char *title_text, int *output) - : BC_TumbleTextBox(window, (int64_t)*output, - (int64_t)-1, (int64_t)25000000, 100, y, 100) + : BC_TumbleTextBox(window, *output, -1, INT_MAX, 100, y, 100) { this->window = window; this->x = x; this->y = y; @@ -59,15 +58,23 @@ void FFMpegConfigNum::create_objects() BC_TumbleTextBox::create_objects(); } -int FFMpegConfigNum::update_text(const char *text) +int FFMpegConfigNum::update_param(const char *param, const char *opts) { - BC_TumbleTextBox::update(text); - return handle_event(); + char value[BCTEXTLEN]; + if( !FileFFMPEG::get_ff_option(param, opts, value) ) { + if( (*output = atoi(value)) < 0 ) { + disable(1); + return 0; + } + } + BC_TumbleTextBox::update((int64_t)*output); + enable(); + return 1; } int FFMpegConfigNum::handle_event() { - *output = atol(get_text()); + *output = atoi(get_text()); return 1; } @@ -93,9 +100,9 @@ int FFMpegVideoBitrate::handle_event() { int ret = FFMpegVideoNum::handle_event(); Asset *asset = window()->asset; - if( asset->ff_video_bitrate ) + if( asset->ff_video_bitrate > 0 ) window()->quality->disable(); - else + else if( !window()->quality->get_textbox()->is_hidden() ) window()->quality->enable(); return ret; } @@ -104,13 +111,21 @@ int FFMpegVideoQuality::handle_event() { int ret = FFMpegVideoNum::handle_event(); Asset *asset = window()->asset; - if( asset->ff_video_quality ) + if( asset->ff_video_quality >= 0 ) window()->bitrate->disable(); - else + else if( !window()->bitrate->get_textbox()->is_hidden() ) window()->bitrate->enable(); return ret; } +void FileFFMPEG::set_parameters(char *cp, int len, const char *bp) +{ + char *ep = cp + len-2, ch = 0; + while( cp < ep && *bp != 0 ) { ch = *bp++; *cp++ = ch; } + if( ch != '\n' ) *cp++ = '\n'; + *cp = 0; +} + void FileFFMPEG::get_parameters(BC_WindowBase *parent_window, Asset *asset, BC_WindowBase *&format_window, int audio_options, int video_options) @@ -120,7 +135,8 @@ void FileFFMPEG::get_parameters(BC_WindowBase *parent_window, format_window = window; window->create_objects(); if( !window->run_window() ) - strcpy(asset->ff_audio_options, window->audio_options->get_text()); + set_parameters(asset->ff_audio_options, sizeof(asset->ff_audio_options), + window->audio_options->get_text()); delete window; } else if(video_options) { @@ -128,7 +144,8 @@ void FileFFMPEG::get_parameters(BC_WindowBase *parent_window, format_window = window; window->create_objects(); if( !window->run_window() ) - strcpy(asset->ff_video_options, window->video_options->get_text()); + set_parameters(asset->ff_video_options, sizeof(asset->ff_video_options), + window->video_options->get_text()); delete window; } } @@ -432,6 +449,7 @@ void FFMPEGConfigAudio::create_objects() bitrate = new FFMpegAudioBitrate(this, x, y, _("Bitrate:"), &asset->ff_audio_bitrate); bitrate->create_objects(); bitrate->set_increment(1000); + bitrate->set_boundaries((int64_t)0, (int64_t)INT_MAX); y += bitrate->get_h() + 10; BC_Title *title = new BC_Title(x, y, _("Audio Options:")); @@ -453,13 +471,10 @@ void FFMPEGConfigAudio::create_objects() audio_options->create_objects(); add_subwindow(new BC_OKButton(this)); add_subwindow(new BC_CancelButton(this)); + show_window(1); - char value[BCTEXTLEN]; - if( !FileFFMPEG::get_ff_option("cin_bitrate", asset->ff_audio_options, value) ) - bitrate->update_text(value); + bitrate->update_param("cin_bitrate", asset->ff_audio_options); - show_window(1); - bitrate->handle_event(); unlock_window(); } @@ -476,12 +491,6 @@ FFAudioOptions::FFAudioOptions(FFMPEGConfigAudio *audio_popup, this->audio_popup = audio_popup; } -int FFAudioOptions::handle_event() -{ - strcpy(audio_popup->asset->ff_audio_options, get_text()); - return 1; -} - FFMPEGConfigAudioPopup::FFMPEGConfigAudioPopup(FFMPEGConfigAudio *popup, int x, int y) : BC_PopupTextBox(popup, &popup->presets, popup->asset->acodec, x, y, 300, 300) @@ -493,15 +502,15 @@ int FFMPEGConfigAudioPopup::handle_event() { strcpy(popup->asset->acodec, get_text()); Asset *asset = popup->asset; + asset->ff_audio_bitrate = 0; char option_path[BCTEXTLEN]; FFMPEG::set_option_path(option_path, "audio/%s", asset->acodec); FFMPEG::load_options(option_path, asset->ff_audio_options, sizeof(asset->ff_audio_options)); popup->audio_options->update(asset->ff_audio_options); + popup->audio_options->set_text_row(0); - char value[BCTEXTLEN]; - if( !FileFFMPEG::get_ff_option("cin_bitrate", asset->ff_audio_options, value) ) - popup->bitrate->update_text(value); + popup->bitrate->update_param("cin_bitrate", asset->ff_audio_options); return 1; } @@ -580,20 +589,20 @@ void FFMPEGConfigVideo::create_objects() preset_popup = new FFMPEGConfigVideoPopup(this, x, y); preset_popup->create_objects(); - if( asset->ff_video_bitrate && asset->ff_video_quality ) { - asset->ff_video_bitrate = 0; - asset->ff_video_quality = 0; + if( asset->ff_video_bitrate > 0 && asset->ff_video_quality >= 0 ) { + asset->ff_video_bitrate = 0; asset->ff_video_quality = -1; } y += 50; bitrate = new FFMpegVideoBitrate(this, x, y, _("Bitrate:"), &asset->ff_video_bitrate); bitrate->create_objects(); bitrate->set_increment(100000); + bitrate->set_boundaries((int64_t)0, (int64_t)INT_MAX); y += bitrate->get_h() + 5; quality = new FFMpegVideoQuality(this, x, y, _("Quality:"), &asset->ff_video_quality); quality->create_objects(); quality->set_increment(1); - quality->set_boundaries((int64_t)0, (int64_t)31); + quality->set_boundaries((int64_t)-1, (int64_t)51); y += quality->get_h() + 10; BC_Title *title = new BC_Title(x, y, _("Video Options:")); @@ -615,18 +624,13 @@ void FFMPEGConfigVideo::create_objects() video_options->create_objects(); add_subwindow(new BC_OKButton(this)); add_subwindow(new BC_CancelButton(this)); + show_window(1); - char value[BCTEXTLEN]; - if( !FileFFMPEG::get_ff_option("cin_quality", asset->ff_video_options, value) ) - quality->update_text(value); - if( !FileFFMPEG::get_ff_option("cin_bitrate", asset->ff_video_options, value) ) - bitrate->update_text(value); + bitrate->update_param("cin_bitrate", asset->ff_video_options); + quality->update_param("cin_quality", asset->ff_video_options); - show_window(1); - if( asset->ff_video_bitrate ) - quality->disable(); - if( asset->ff_video_quality ) - bitrate->disable(); + if( asset->ff_video_bitrate > 0 ) quality->disable(); + else if( asset->ff_video_quality >= 0 ) bitrate->disable(); unlock_window(); } @@ -643,12 +647,6 @@ FFVideoOptions::FFVideoOptions(FFMPEGConfigVideo *video_popup, this->video_popup = video_popup; } -int FFVideoOptions::handle_event() -{ - strcpy(video_popup->asset->ff_video_options, get_text()); - return 1; -} - FFMPEGConfigVideoPopup::FFMPEGConfigVideoPopup(FFMPEGConfigVideo *popup, int x, int y) : BC_PopupTextBox(popup, &popup->presets, popup->asset->vcodec, x, y, 300, 300) @@ -661,17 +659,15 @@ int FFMPEGConfigVideoPopup::handle_event() strcpy(popup->asset->vcodec, get_text()); Asset *asset = popup->asset; char option_path[BCTEXTLEN]; + asset->ff_video_bitrate = 0; asset->ff_video_quality = -1; FFMPEG::set_option_path(option_path, "video/%s", asset->vcodec); FFMPEG::load_options(option_path, asset->ff_video_options, sizeof(asset->ff_video_options)); popup->video_options->update(asset->ff_video_options); + popup->video_options->set_text_row(0); - char value[BCTEXTLEN]; - if( !FileFFMPEG::get_ff_option("cin_quality", asset->ff_video_options, value) ) { - popup->quality->update_text(value); - } - if( !FileFFMPEG::get_ff_option("cin_bitrate", asset->ff_video_options, value) ) - popup->bitrate->update_text(value); + popup->bitrate->update_param("cin_bitrate", asset->ff_video_options); + popup->quality->update_param("cin_quality", asset->ff_video_options); return 1; }