add proxy
[goodguy/history.git] / cinelerra-5.1 / cinelerra / mwindowedit.C
index 8fba7bfc95d48b110516db5e6ef81c743d8e59df..a0e9b955f510417dadc2bcd999bb0681b15b6938 100644 (file)
@@ -1084,7 +1084,7 @@ void MWindow::paste()
        int64_t len = gui->clipboard_len(BC_PRIMARY_SELECTION);
 
        if( len ) {
-               char *string = new char[len + 1];
+               char *string = new char[len];
                undo->update_undo_before();
                gui->from_clipboard(string, len, BC_PRIMARY_SELECTION);
                FileXML file;
@@ -1203,7 +1203,7 @@ int MWindow::paste_automation()
 
        if( len ) {
                undo->update_undo_before();
-               char *string = new char[len + 1];
+               char *string = new char[len];
                gui->from_clipboard(string, len, BC_PRIMARY_SELECTION);
                FileXML file;
                file.read_from_string(string);
@@ -1234,7 +1234,7 @@ int MWindow::paste_default_keyframe()
 
        if( len ) {
                undo->update_undo_before();
-               char *string = new char[len + 1];
+               char *string = new char[len];
                gui->from_clipboard(string, len, BC_PRIMARY_SELECTION);
                FileXML file;
                file.read_from_string(string);
@@ -2274,6 +2274,53 @@ void MWindow::remap_audio(int pattern)
        }
 }
 
+void MWindow::set_proxy(int new_scale,
+        ArrayList<Indexable*> *orig_assets, ArrayList<Indexable*> *proxy_assets)
+{
+       int orig_scale = edl->session->proxy_scale;
+       edl->session->proxy_scale = new_scale;
+
+// project size
+       float orig_w = (float)edl->session->output_w * orig_scale;
+       float orig_h = (float)edl->session->output_h * orig_scale;
+       edl->session->output_w = Units::round(orig_w / new_scale);
+       edl->session->output_h = Units::round(orig_h / new_scale);
+
+// track sizes
+       for( Track *track=edl->tracks->first; track; track=track->next ) {
+               if( track->data_type != TRACK_VIDEO ) continue;
+               orig_w = (float)track->track_w * orig_scale;
+               orig_h = (float)track->track_h * orig_scale;
+               track->track_w = Units::round(orig_w / new_scale);
+               track->track_h = Units::round(orig_h / new_scale);
+               ((MaskAutos*)track->automation->autos[AUTOMATION_MASK])->
+                       set_proxy(orig_scale, new_scale);
+               ((FloatAutos*)track->automation->autos[AUTOMATION_CAMERA_X])->
+                       set_proxy(orig_scale, new_scale);
+               ((FloatAutos*)track->automation->autos[AUTOMATION_CAMERA_Y])->
+                       set_proxy(orig_scale, new_scale);
+               ((FloatAutos*)track->automation->autos[AUTOMATION_PROJECTOR_X])->
+                       set_proxy(orig_scale, new_scale);
+               ((FloatAutos*)track->automation->autos[AUTOMATION_PROJECTOR_Y])->
+                       set_proxy(orig_scale, new_scale);
+       }
+
+// assets
+       for( int i=0; i<proxy_assets->size(); i++ ) {
+               Asset *proxy_asset = edl->assets->update((Asset*)proxy_assets->get(i));
+// replace track contents
+               for( Track *track = edl->tracks->first; track; track = track->next ) {
+                       if( track->data_type != TRACK_VIDEO ) continue;
+                       for( Edit *edit = track->edits->first; edit; edit = edit->next ) {
+                               if( !edit->asset ) continue;
+                               if( !strcmp(edit->asset->path, orig_assets->get(i)->path) ) {
+                                       edit->asset = proxy_asset;
+                               }
+                       }
+               }
+       }
+}
+
 void MWindow::cut_commercials()
 {
        undo->update_undo_before();