#include "bcsignals.h"
#include "cache.h"
#include "clip.h"
-#include "confirmsave.h"
#include "cstrdup.h"
#include "edl.h"
#include "edlsession.h"
#include "vrender.h"
#define WIDTH 400
-#define HEIGHT 300
+#define HEIGHT 330
#define MAX_SCALE 16
ProxyMenuItem::ProxyMenuItem(MWindow *mwindow)
size_text[0] = cstrdup(_("Original size"));
size_factors[0] = 1;
total_sizes = 1;
- proxy_beep = 0;
}
ProxyDialog::~ProxyDialog()
{
- delete proxy_beep;
close_window();
for( int i=0; i<MAX_SIZES; ++i ) delete [] size_text[i];
asset->remove_user();
void ProxyDialog::handle_close_event(int result)
{
+ if( result ) return;
+ mwindow->edl->session->proxy_use_scaler = use_scaler;
+ mwindow->edl->session->proxy_auto_scale = auto_scale;
+ mwindow->edl->session->proxy_beep = beep;
+ mwindow->edl->session->proxy_disabled_scale = 1;
asset->save_defaults(mwindow->defaults, "PROXY_", 1, 1, 0, 0, 0);
-
- if( !result && (result=to_proxy()) >= 0 && beep && new_scale != 1 )
- if( result > 0 )
- mwindow->beep(2000., 3., 0.5);
- else
- mwindow->beep(4000., 0.5, 0.5);
-}
-
-int ProxyDialog::to_proxy()
-{
- ArrayList<Indexable*> orig_idxbls;
- ArrayList<Indexable*> proxy_assets;
-
- EDL *edl = mwindow->edl;
- mwindow->edl->Garbage::add_user();
- mwindow->save_backup();
- mwindow->undo->update_undo_before(_("proxy"), this);
- ProxyRender proxy_render(mwindow, asset);
-
-// revert project to original size from current size
-// remove all session proxy assets at the at the current proxy_scale
- int proxy_scale = edl->session->proxy_scale;
- if( proxy_scale > 1 ) {
- Asset *orig_asset = edl->assets->first;
- for( ; orig_asset; orig_asset=orig_asset->next ) {
- char new_path[BCTEXTLEN];
- proxy_render.to_proxy_path(new_path, orig_asset, proxy_scale);
-// test if proxy asset was already added to proxy_assets
- int got_it = 0;
- for( int i = 0; !got_it && i<proxy_assets.size(); ++i )
- got_it = !strcmp(proxy_assets[i]->path, new_path);
- if( got_it ) continue;
- Asset *proxy_asset = edl->assets->get_asset(new_path);
- if( !proxy_asset ) continue;
-// add pointer to existing EDL asset if it exists
-// EDL won't delete it unless it's the same pointer.
- proxy_assets.append(proxy_asset);
- proxy_asset->add_user();
- orig_idxbls.append(orig_asset);
- orig_asset->add_user();
- }
- for( int i=0,n=edl->nested_edls.size(); i<n; ++i ) {
- EDL *orig_nested = edl->nested_edls[i];
- char new_path[BCTEXTLEN];
- if( !ProxyRender::from_proxy_path(new_path, orig_nested, proxy_scale) )
- continue;
- proxy_render.to_proxy_path(new_path, orig_nested, proxy_scale);
-// test if proxy asset was already added to proxy_assets
- int got_it = 0;
- for( int i = 0; !got_it && i<proxy_assets.size(); ++i )
- got_it = !strcmp(proxy_assets[i]->path, new_path);
- if( got_it ) continue;
- Asset *proxy_nested = edl->assets->get_asset(new_path);
- if( !proxy_nested ) continue;
-// add pointer to existing EDL asset if it exists
-// EDL won't delete it unless it's the same pointer.
- proxy_assets.append(proxy_nested);
- proxy_nested->add_user();
- orig_idxbls.append(orig_nested);
- orig_nested->add_user();
- }
-
-// convert from the proxy assets to the original assets
- int auto_scale = edl->session->proxy_auto_scale;
- int beep = edl->session->proxy_beep;
- mwindow->set_proxy(0, 1, auto_scale, beep, &proxy_assets, &orig_idxbls);
-
-// remove the references
- for( int i=0; i<proxy_assets.size(); ++i ) {
- Asset *proxy = (Asset *) proxy_assets[i];
- proxy->width = proxy->actual_width;
- proxy->height = proxy->actual_height;
- proxy->remove_user();
- mwindow->edl->assets->remove_pointer(proxy);
- proxy->remove_user();
- }
- proxy_assets.remove_all();
- for( int i = 0; i < orig_idxbls.size(); i++ )
- orig_idxbls[i]->remove_user();
- orig_idxbls.remove_all();
+ result = mwindow->to_proxy(asset, new_scale);
+ 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);
}
-
- ArrayList<char *> confirm_paths; // test for new files
- confirm_paths.set_array_delete();
-
-// convert to new size if not original size
- if( new_scale != 1 ) {
- FileSystem fs;
- Asset *orig = mwindow->edl->assets->first;
- for( ; orig; orig=orig->next ) {
- Asset *proxy = proxy_render.add_original(orig, new_scale);
- if( !proxy ) continue;
- int exists = fs.get_size(proxy->path) > 0 ? 1 : 0;
- int got_it = exists && // if proxy exists, and is newer than orig
- fs.get_date(proxy->path) > fs.get_date(orig->path) ? 1 : 0;
- if( !got_it ) {
- if( exists ) // prompt user to overwrite
- confirm_paths.append(cstrdup(proxy->path));
- proxy_render.add_needed(orig, proxy);
- }
- }
- for( int i=0,n=edl->nested_edls.size(); i<n; ++i ) {
- EDL *orig_nested = edl->nested_edls[i];
- Asset *proxy = proxy_render.add_original(orig_nested, new_scale);
- if( !proxy ) continue;
- int exists = fs.get_size(proxy->path) > 0 ? 1 : 0;
- int got_it = exists && // if proxy exists, and is newer than orig_nested
- fs.get_date(proxy->path) > fs.get_date(orig_nested->path) ? 1 : 0;
- if( !got_it ) {
- if( exists ) // prompt user to overwrite
- confirm_paths.append(cstrdup(proxy->path));
- proxy_render.add_needed(orig_nested, proxy);
- }
- }
- }
-
- int result = 0;
-// test for existing files
- if( confirm_paths.size() ) {
- result = ConfirmSave::test_files(mwindow, &confirm_paths);
- confirm_paths.remove_all_objects();
- }
-
- if( !result )
- result = proxy_render.create_needed_proxies(new_scale);
-
- if( !result ) // resize project
- mwindow->set_proxy(use_scaler, new_scale, auto_scale, beep,
- &proxy_render.orig_idxbls, &proxy_render.orig_proxies);
-
- mwindow->undo->update_undo_after(_("proxy"), LOAD_ALL);
- mwindow->edl->Garbage::remove_user();
- mwindow->restart_brender();
-
- mwindow->gui->lock_window("ProxyDialog::to_proxy");
- mwindow->update_project(LOADMODE_REPLACE);
- mwindow->gui->unlock_window();
- return !result ? proxy_render.needed_proxies.size() : -1;
}
-
void ProxyRender::to_proxy_path(char *new_path, Indexable *indexable, int scale)
{
// path is already a proxy
add_subwindow(new_dimensions = new BC_Title(x, y, ""));
y += new_dimensions->get_h() + margin;
+ x = margin;
+ 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;
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
void ProxyWindow::update()
{
-// preview the new size
- char string[BCTEXTLEN];
-//printf("ProxyWindow::update %d %d %d %d %d\n",
-// __LINE__, mwindow->edl->session->output_w, mwindow->edl->session->output_h,
-// dialog->orig_scale, dialog->new_scale);
+ char string[BCSTRLEN];
int orig_w = mwindow->edl->session->output_w * dialog->orig_scale;
int orig_h = mwindow->edl->session->output_h * dialog->orig_scale;
int new_w = orig_w / dialog->new_scale;
scale_factor->set_text(string);
use_scaler->update();
auto_scale->update();
+ int scale = mwindow->edl->session->proxy_scale;
+ if( scale == 1 ) scale = mwindow->edl->session->proxy_disabled_scale;
+ sprintf(string, scale>1 ? "1/%d" : "%d", scale);
+ active_scale->update(string);
}
int ProxyUseScaler::handle_event()
{
- pwindow->dialog->new_scale = 1;
pwindow->dialog->use_scaler = get_value();
pwindow->scale_factor->update_sizes();
pwindow->update();
ProxyBeep::~ProxyBeep()
{
+ stop(0);
delete audio;
}
double out0[bfrsz], out1[bfrsz], *out[2] = { out0, out1 };
const double two_pi = 2*M_PI;
- int64_t audio_size = BEEP_SAMPLE_RATE * secs;
- int audio_len = audio_size/sizeof(audio_data_t);
+ int64_t audio_len = BEEP_SAMPLE_RATE * secs;
const double dt = two_pi * freq/BEEP_SAMPLE_RATE;
double th = 0;