#include "formattools.h"
#include "language.h"
#include "mainerror.h"
+#include "mainindexes.h"
#include "mainprogress.h"
#include "mainundo.h"
#include "mutex.h"
{
this->mwindow = mwindow;
set_alt();
+ dialog = 0;
+}
+ProxyMenuItem::~ProxyMenuItem()
+{
+ delete dialog;
}
void ProxyMenuItem::create_objects()
asset = new Asset;
bzero(size_text, sizeof(char*) * MAX_SIZES);
bzero(size_factors, sizeof(int) * MAX_SIZES);
- total_sizes = 0;
+ size_text[0] = cstrdup(_("Original size"));
+ size_factors[0] = 1;
+ total_sizes = 1;
}
ProxyDialog::~ProxyDialog()
asset->load_defaults(mwindow->defaults, "PROXY_", 1, 1, 0, 0, 0);
mwindow->gui->lock_window("ProxyDialog::new_gui");
int cx, cy;
- mwindow->gui->get_abs_cursor_xy(cx, cy);
+ mwindow->gui->get_abs_cursor(cx, cy);
gui = new ProxyWindow(mwindow, this, cx - WIDTH/2, cy - HEIGHT/2);
gui->create_objects();
mwindow->gui->unlock_window();
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 proxy_auto_scale = edl->session->proxy_auto_scale;
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++ )
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;
mwindow->restart_brender();
mwindow->gui->lock_window("ProxyDialog::to_proxy");
- mwindow->update_project(LOAD_ALL);
+ mwindow->update_project(LOADMODE_REPLACE);
mwindow->gui->unlock_window();
}
//printf("ProxyRender::to_proxy_path %d %s %s\n", __LINE__, new_path), asset->path);
}
-void ProxyRender::from_proxy_path(char *new_path, Asset *asset, int scale)
+int ProxyRender::from_proxy_path(char *new_path, Indexable *indexable, int scale)
{
char prxy[BCTEXTLEN];
int n = sprintf(prxy, ".proxy%d", scale);
- strcpy(new_path, asset->path);
- char *ptr = strstr(asset->path, prxy);
- if( !ptr || (ptr[n] != '-' && ptr[n] != '.') ) return;
+ strcpy(new_path, indexable->path);
+ char *ptr = strstr(new_path, prxy);
+ if( !ptr || (ptr[n] != '-' && ptr[n] != '.') ) return 1;
// remove proxy, path.proxy#-sfx.ext => path.sfx
char *ext = strrchr(ptr, '.');
if( !ext ) ext = ptr + strlen(ptr);
char *cp = ptr + n;
for( *cp='.'; cp<ext; ++cp ) *ptr++ = *cp;
*ptr = 0;
+ return 0;
}
ProxyRender::ProxyRender(MWindow *mwindow, Asset *format_asset)
add_subwindow(text = new BC_Title(x, y, _("Scale factor:")));
x += text->get_w() + margin;
- dialog->size_text[0] = cstrdup(_("Original size"));
- dialog->size_factors[0] = 1;
- dialog->total_sizes = 1;
int popupmenu_w = BC_PopupMenu::calculate_w(get_text_width(MEDIUMFONT, dialog->size_text[0]));
add_subwindow(scale_factor = new ProxyMenu(mwindow, this, x, y, popupmenu_w, ""));
scale_factor->update_sizes();
}
proxy_render->update_progress();
}
+ if( !proxy_render->failed && !proxy_render->is_canceled() ) {
+ Asset *asset = mwindow->edl->assets->update(proxy);
+ mwindow->mainindexes->add_next_asset(0, asset);
+ mwindow->mainindexes->start_build();
+ }
}