X-Git-Url: https://git.cinelerra-gg.org/git/?p=goodguy%2Fcinelerra.git;a=blobdiff_plain;f=cinelerra-5.1%2Fcinelerra%2Fproxy.C;h=fff64f37fb1eb850e8df5505f818f3abc4bcc871;hp=a0f5fa72cf4a258fd32042daa4453b85da9d1e73;hb=84ac8a2bb3357c04a3f67cf763b0f61ddbbd021d;hpb=ac8f3979437fb45effb135a1bb6bee871f52d635 diff --git a/cinelerra-5.1/cinelerra/proxy.C b/cinelerra-5.1/cinelerra/proxy.C index a0f5fa72..fff64f37 100644 --- a/cinelerra-5.1/cinelerra/proxy.C +++ b/cinelerra-5.1/cinelerra/proxy.C @@ -47,8 +47,8 @@ #include "transportque.h" #include "vrender.h" -#define WIDTH 400 -#define HEIGHT 330 +#define WIDTH xS(400) +#define HEIGHT yS(330) #define MAX_SCALE 16 ProxyMenuItem::ProxyMenuItem(MWindow *mwindow) @@ -167,30 +167,44 @@ void ProxyDialog::handle_close_event(int result) { if( result ) return; if( !File::renders_video(asset) ) { - eprintf("Specified format does not render video"); + eprintf(_("Specified format does not render video")); return; } mwindow->edl->session->proxy_auto_scale = auto_scale; mwindow->edl->session->proxy_beep = beep; - mwindow->edl->session->proxy_disabled_scale = 1; - mwindow->gui->lock_window("ProxyDialog::handle_close_event"); - mwindow->gui->update_proxy_toggle(); - mwindow->gui->unlock_window(); asset->save_defaults(mwindow->defaults, "PROXY_", 1, 1, 0, 0, 0); result = mwindow->to_proxy(asset, new_scale, use_scaler); - if( result >= 0 && beep && new_scale != 1 ) { - static struct { double freq, secs, gain; } - tone[2] = { { 2000., 1.5, 0.5 }, { 4000., 0.25, 0.5 } }; - int i = result > 0 ? 0 : 1; - mwindow->beep(tone[i].freq, tone[i].secs, tone[i].gain); + if( result >= 0 && beep > 0 && new_scale != 1 ) { + if( !result ) { + mwindow->beep(4000., 0.5, beep); + usleep(250000); + mwindow->beep(1000., 0.5, beep); + usleep(250000); + mwindow->beep(4000., 0.5, beep); + } + else + mwindow->beep(2000., 2.0, beep); } + mwindow->edl->session->proxy_disabled_scale = 1; + mwindow->gui->lock_window("ProxyDialog::handle_close_event"); + mwindow->update_project(LOADMODE_REPLACE); + mwindow->gui->unlock_window(); } void ProxyRender::to_proxy_path(char *new_path, Indexable *indexable, int scale) { // path is already a proxy if( strstr(indexable->path, ".proxy") ) return; - strcpy(new_path, indexable->path); + if( !indexable->is_asset ) { + char *ifn = indexable->path, *cp = strrchr(ifn, '/'); + if( cp ) ifn = cp+1; + char proxy_path[BCTEXTLEN]; + File::getenv_path(proxy_path, + mwindow->preferences->nested_proxy_path); + sprintf(new_path, "%s/%s", proxy_path, ifn); + } + else + strcpy(new_path, indexable->path); char prxy[BCSTRLEN]; int n = sprintf(prxy, ".proxy%d", scale); // insert proxy, path.sfx => path.proxy#-sfx.ext @@ -215,11 +229,11 @@ void ProxyRender::to_proxy_path(char *new_path, Indexable *indexable, int scale) //printf("ProxyRender::to_proxy_path %d %s %s\n", __LINE__, new_path), asset->path); } -int ProxyRender::from_proxy_path(char *new_path, Indexable *indexable, int scale) +int ProxyRender::from_proxy_path(char *new_path, Asset *asset, int scale) { char prxy[BCTEXTLEN]; int n = sprintf(prxy, ".proxy%d", scale); - strcpy(new_path, indexable->path); + strcpy(new_path, asset->path); char *ptr = strstr(new_path, prxy); if( !ptr || (ptr[n] != '-' && ptr[n] != '.') ) return 1; // remove proxy, path.proxy#-sfx.ext => path.sfx @@ -228,6 +242,12 @@ int ProxyRender::from_proxy_path(char *new_path, Indexable *indexable, int scale char *cp = ptr + n; for( *cp='.'; cpproxy_edl ) { + if( (cp = strrchr(new_path, '/')) != 0 ) { + for( ptr=new_path; *++cp; ) *ptr++ = *cp; + *ptr = 0; + } + } return 0; } @@ -260,8 +280,18 @@ Asset *ProxyRender::add_original(Indexable *idxbl, int new_scale) if( strstr(idxbl->path,".proxy") ) return 0; char new_path[BCTEXTLEN]; to_proxy_path(new_path, idxbl, new_scale); -// don't proxy if not readable +// don't proxy if not readable, or proxy_path not writable if( idxbl->is_asset && access(idxbl->path, R_OK) ) return 0; + int ret = access(new_path, W_OK); + if( ret ) { + int fd = ::open(new_path,O_WRONLY); + if( fd < 0 ) fd = open(new_path,O_WRONLY+O_CREAT,0666); + if( fd >= 0 ) { close(fd); ret = 0; } + } + if( ret ) { + eprintf(_("bad proxy path: %s\n"), new_path); + return 0; + } // add to orig_idxbls & orig_proxies if it isn't already there. int got_it = 0; for( int i = 0; !got_it && ivideo_length = video_frames; } proxy->folder_no = AW_PROXY_FOLDER; + proxy->proxy_edl = !idxbl->is_asset ? 1 : 0; proxy->audio_data = 0; proxy->video_data = 1; proxy->layers = 1; @@ -334,8 +365,10 @@ int ProxyRender::create_needed_proxies(int new_scale) } // start progress bar. MWindow is locked inside this + mwindow->gui->lock_window("ProxyRender::create_needed_proxies"); progress = mwindow->mainprogress-> start_progress(_("Creating proxy files..."), total_len); + mwindow->gui->unlock_window(); ProxyFarm engine(mwindow, this, &needed_idxbls, &needed_proxies); engine.process_packages(); @@ -347,7 +380,7 @@ printf("proxy: failed=%d canceled=%d\n", failed, progress->is_cancelled()); delete progress; progress = 0; if( failed && !canceled ) { - eprintf("Error making proxy."); + eprintf(_("Error making proxy.")); } return !failed && !canceled ? 0 : 1; } @@ -374,6 +407,7 @@ void ProxyWindow::create_objects() { lock_window("ProxyWindow::create_objects"); int margin = mwindow->theme->widget_border; + int lmargin = margin + xS(10); dialog->use_scaler = mwindow->edl->session->proxy_use_scaler; dialog->orig_scale = mwindow->edl->session->proxy_scale; @@ -387,8 +421,8 @@ void ProxyWindow::create_objects() dialog->orig_h *= dialog->orig_scale; } - int x = margin; - int y = margin+10; + int x = lmargin; + int y = margin+yS(10); add_subwindow(use_scaler = new ProxyUseScaler(this, x, y)); y += use_scaler->get_h() + margin; @@ -396,7 +430,7 @@ void ProxyWindow::create_objects() add_subwindow(text = new BC_Title(x, y, _("Scale factor:"))); x += text->get_w() + margin; - int popupmenu_w = BC_PopupMenu::calculate_w(get_text_width(MEDIUMFONT, dialog->size_text[0])+15); + int popupmenu_w = BC_PopupMenu::calculate_w(get_text_width(MEDIUMFONT, dialog->size_text[0])+xS(15)); add_subwindow(scale_factor = new ProxyMenu(mwindow, this, x, y, popupmenu_w, "")); scale_factor->update_sizes(); x += scale_factor->get_w() + margin; @@ -405,28 +439,30 @@ void ProxyWindow::create_objects() add_subwindow(tumbler = new ProxyTumbler(mwindow, this, x, y)); y += tumbler->get_h() + margin; - x = margin; + x = lmargin; add_subwindow(text = new BC_Title(x, y, _("New media dimensions: "))); x += text->get_w() + margin; add_subwindow(new_dimensions = new BC_Title(x, y, "")); y += new_dimensions->get_h() + margin; - x = margin; + x = lmargin; add_subwindow(text = new BC_Title(x, y, _("Active Scale: "))); x += text->get_w() + margin; add_subwindow(active_scale = new BC_Title(x, y, "")); y += active_scale->get_h() + margin; - x = margin; y += 25; + x = lmargin; y += yS(25); format_tools = new ProxyFormatTools(mwindow, this, dialog->asset); format_tools->create_objects(x, y, 0, 1, 0, 0, 0, 1, 0, 1, // skip the path 0, 0); - x = margin; + x = lmargin; add_subwindow(auto_scale = new ProxyAutoScale(this, x, y)); y += auto_scale->get_h() + margin; add_subwindow(beep_on_done = new ProxyBeepOnDone(this, x, y)); - y += beep_on_done->get_h() + margin; + x += beep_on_done->get_w() + margin + xS(10); + add_subwindow(new BC_Title(x, y+yS(10), _("Beep on done volume"))); +// y += beep_on_done->get_h() + margin; update(); @@ -518,14 +554,14 @@ int ProxyAutoScale::handle_event() } ProxyBeepOnDone::ProxyBeepOnDone(ProxyWindow *pwindow, int x, int y) - : BC_CheckBox(x, y, pwindow->dialog->beep, _("Beep on done")) + : BC_FPot(x, y, pwindow->dialog->beep*100.f, 0.f, 100.f) { this->pwindow = pwindow; } int ProxyBeepOnDone::handle_event() { - pwindow->dialog->beep = get_value(); + pwindow->dialog->beep = get_value()/100.f; pwindow->update(); return 1; } @@ -621,7 +657,8 @@ ProxyClient::ProxyClient(MWindow *mwindow, ProxyClient::~ProxyClient() { delete render_engine; - delete video_cache; + if( video_cache ) + video_cache->remove_user(); delete src_file; } @@ -731,7 +768,7 @@ void ProxyClient::process_package(LoadPackage *ptr) if( !scale ) scale = 1; asset->width = asset->actual_width * scale; asset->height = asset->actual_height * scale; - mwindow->mainindexes->add_next_asset(0, asset); + mwindow->mainindexes->add_indexable(asset); mwindow->mainindexes->start_build(); } else @@ -770,85 +807,3 @@ LoadPackage* ProxyFarm::new_package() return new ProxyPackage; } - -ProxyBeep::ProxyBeep(MWindow *mwindow) - : Thread(1, 0, 0) -{ - this->mwindow = mwindow; - audio = new AudioDevice(mwindow); - playing_audio = 0; - interrupted = -1; -} - -ProxyBeep::~ProxyBeep() -{ - stop(0); - delete audio; -} - -void ProxyBeep::run() -{ - int channels = 2; - int64_t bfrsz = BEEP_SAMPLE_RATE; - EDL *edl = mwindow->edl; - EDLSession *session = edl->session; - AudioOutConfig *aconfig = session->playback_config->aconfig; - audio->open_output(aconfig, BEEP_SAMPLE_RATE, bfrsz, channels, 0); - audio->start_playback(); - - double out0[bfrsz], out1[bfrsz], *out[2] = { out0, out1 }; - const double two_pi = 2*M_PI; - int64_t audio_len = BEEP_SAMPLE_RATE * secs; - const double dt = two_pi * freq/BEEP_SAMPLE_RATE; - double th = 0; - - audio_pos = 0; - playing_audio = 1; - while( !interrupted ) { - int len = audio_len - audio_pos; - if( len <= 0 ) break; - if( len > bfrsz ) len = bfrsz; - int k = audio_pos; - for( int i=0; i= 0 ) th = t; - out0[i] = out1[i] = sin(th) * gain; - } - audio->write_buffer(out, channels, len); - audio_pos = k; - } - - if( !interrupted ) - audio->set_last_buffer(); - audio->stop_audio(interrupted ? 0 : 1); - playing_audio = 0; - - audio->close_all(); -} - -void ProxyBeep::start() -{ - if( running() ) return; - audio_pos = -1; - interrupted = 0; - Thread::start(); -} - -void ProxyBeep::stop(int wait) -{ - if( running() && !interrupted ) { - interrupted = 1; - audio->stop_audio(wait); - } - Thread::join(); -} - -void ProxyBeep::tone(double freq, double secs, double gain) -{ - stop(0); - this->freq = freq; - this->secs = secs; - this->gain = gain; - start(); -} -