add audio to proxy, and minor bug fixes
authorGood Guy <good1.2guy@gmail.com>
Sun, 11 Mar 2018 18:29:55 +0000 (12:29 -0600)
committerGood Guy <good1.2guy@gmail.com>
Sun, 11 Mar 2018 18:29:55 +0000 (12:29 -0600)
cinelerra-5.1/cinelerra/assetpopup.C
cinelerra-5.1/cinelerra/awindowgui.C
cinelerra-5.1/cinelerra/awindowgui.h
cinelerra-5.1/cinelerra/indexable.C
cinelerra-5.1/cinelerra/mainsession.C
cinelerra-5.1/cinelerra/mainsession.h
cinelerra-5.1/cinelerra/mwindowedit.C
cinelerra-5.1/cinelerra/proxy.C
cinelerra-5.1/cinelerra/proxy.h

index 07cc8eb4dd1ded8c0f336bd1616bce654247bd32..15620af7a34c35f0f5d4950a445fe0dc5fbec782 100644 (file)
@@ -100,10 +100,11 @@ void AssetPopup::paste_assets()
        mwindow->gui->lock_window("AssetPopup::paste_assets");
        mwindow->cwindow->gui->lock_window("AssetPopup::paste_assets");
 
-       gui->collect_assets();
+       int proxy = mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ? 1 : 0;
+       gui->collect_assets(proxy);
        mwindow->paste_assets(mwindow->edl->local_session->get_selectionstart(1),
-               mwindow->edl->tracks->first,
-               0);   // do not overwrite
+               mwindow->edl->tracks->first, 0);   // do not overwrite
+       mwindow->session->clear_drag_proxy();
 
        gui->unlock_window();
        mwindow->gui->unlock_window();
@@ -140,7 +141,8 @@ void AssetPopup::match_all()
 int AssetPopup::update()
 {
        format->update();
-       gui->collect_assets();
+       int proxy = mwindow->edl->session->awindow_folder == AW_PROXY_FOLDER ? 1 : 0;
+       gui->collect_assets(proxy);
        return 0;
 }
 
index ea21a02cd70256b67222eee0d9c128eb679c3a99..0ed6b1ce0fd3da31afd2e4b1ada67f50711be173 100644 (file)
@@ -56,6 +56,7 @@
 #include "mwindow.h"
 #include "newfolder.h"
 #include "preferences.h"
+#include "proxy.h"
 #include "renderengine.h"
 #include "samples.h"
 #include "theme.h"
@@ -1571,18 +1572,62 @@ void AWindowGUI::sort_folders()
        update_assets();
 }
 
-void AWindowGUI::collect_assets()
+EDL *AWindowGUI::collect_proxy(Indexable *indexable)
+{
+       Asset *proxy_asset = (Asset *)indexable;
+       char path[BCTEXTLEN];
+       int proxy_scale = mwindow->edl->session->proxy_scale;
+       ProxyRender::from_proxy_path(path, proxy_asset, proxy_scale);
+       Asset *unproxy_asset = mwindow->edl->assets->get_asset(path);
+       if( !unproxy_asset || !unproxy_asset->channels ) return 0;
+// make a clip from proxy video tracks and unproxy audio tracks
+       EDL *proxy_edl = new EDL(mwindow->edl);
+       proxy_edl->create_objects();
+       FileSystem fs;  fs.extract_name(path, proxy_asset->path);
+       strcpy(proxy_edl->local_session->clip_title, path);
+       strcpy(proxy_edl->local_session->clip_notes, _("Proxy clip"));
+       proxy_edl->session->video_tracks = proxy_asset->layers;
+       proxy_edl->session->audio_tracks = unproxy_asset->channels;
+       proxy_edl->create_default_tracks();
+       double length = proxy_asset->frame_rate > 0 ?
+               (double)proxy_asset->video_length / proxy_asset->frame_rate :
+               1.0 / mwindow->edl->session->frame_rate;
+       Track *current = proxy_edl->tracks->first;
+       for( int vtrack=0; current; current=NEXT ) {
+               if( current->data_type != TRACK_VIDEO ) continue;
+               current->insert_asset(proxy_asset, 0, length, 0, vtrack++);
+       }
+       length = (double)unproxy_asset->audio_length / unproxy_asset->sample_rate;
+       current = proxy_edl->tracks->first;
+       for( int atrack=0; current; current=NEXT ) {
+               if( current->data_type != TRACK_AUDIO ) continue;
+               current->insert_asset(unproxy_asset, 0, length, 0, atrack++);
+       }
+       return proxy_edl;
+}
+
+
+void AWindowGUI::collect_assets(int proxy)
 {
-       int i = 0;
        mwindow->session->drag_assets->remove_all();
        mwindow->session->drag_clips->remove_all();
-       while(1)
-       {
-               AssetPicon *result = (AssetPicon*)asset_list->get_selection(0, i++);
-               if( !result ) break;
-
-               if( result->indexable ) mwindow->session->drag_assets->append(result->indexable);
-               if( result->edl ) mwindow->session->drag_clips->append(result->edl);
+       mwindow->session->clear_drag_proxy();
+       int i = 0;  AssetPicon *result;
+       while( (result = (AssetPicon*)asset_list->get_selection(0, i++)) != 0 ) {
+               Indexable *indexable = result->indexable;  EDL *drag_edl;
+               if( proxy && (drag_edl=collect_proxy(indexable)) ) {
+                       mwindow->session->drag_clips->append(drag_edl);
+                       mwindow->session->drag_proxy->append(drag_edl);
+                       continue;
+               }
+               if( indexable ) {
+                       mwindow->session->drag_assets->append(indexable);
+                       continue;
+               }
+               if( result->edl ) {
+                       mwindow->session->drag_clips->append(result->edl);
+                       continue;
+               }
        }
 }
 
@@ -1761,7 +1806,6 @@ int AWindowGUI::drag_motion()
 int AWindowGUI::drag_stop()
 {
        if( get_hidden() ) return 0;
-
        return 0;
 }
 
@@ -2051,7 +2095,7 @@ void AWindowAssets::draw_background()
 int AWindowAssets::drag_start_event()
 {
        int collect_pluginservers = 0;
-       int collect_assets = 0;
+       int collect_assets = 0, proxy = 0;
 
        if( BC_ListBox::drag_start_event() ) {
                switch( mwindow->edl->session->awindow_folder ) {
@@ -2074,6 +2118,10 @@ int AWindowAssets::drag_start_event()
                case AW_LABEL_FOLDER:
                        // do nothing!
                        break;
+               case AW_PROXY_FOLDER:
+                       proxy = 1;
+                       // fall thru
+               case AW_MEDIA_FOLDER:
                default:
                        mwindow->session->current_operation = DRAG_ASSET;
                        collect_assets = 1;
@@ -2093,7 +2141,7 @@ int AWindowAssets::drag_start_event()
                }
 
                if( collect_assets ) {
-                       gui->collect_assets();
+                       gui->collect_assets(proxy);
                }
 
                return 1;
@@ -2169,6 +2217,8 @@ int AWindowAssets::drag_stop_event()
        BC_ListBox::drag_stop_event();
 // since NO_OPERATION is also defined in listbox, we have to reach for global scope...
        mwindow->session->current_operation = ::NO_OPERATION;
+       mwindow->session->clear_drag_proxy();
+
        return 1;
 }
 
index 04d834609bcd33c19f07d151d79e1e02f59e2b9e..4bc256423dd1c67e73bce4e4a5b2aa7639cc7503 100644 (file)
@@ -179,7 +179,8 @@ public:
        int drag_motion();
        int drag_stop();
 // Collect items into the drag vectors of MainSession
-       void collect_assets();
+       void collect_assets(int proxy=0);
+       EDL *collect_proxy(Indexable *indexable);
        void create_persistent_folder(ArrayList<BC_ListBoxItem*> *output,
                int do_audio,
                int do_video,
index a038b3308c0188a089597fb3d23fea165f741d95..1fff3eff0b842e47636ccea3fa9208cce00d5d91 100644 (file)
@@ -62,7 +62,7 @@ void Indexable::update_path(const char *new_path)
 void Indexable::update_index(Indexable *src)
 {
        if( index_state == src->index_state ) return;
-       index_state->remove_user();
+       if( index_state ) index_state->remove_user();
        index_state = src->index_state;
        index_state->add_user();
 }
index f7224b4c0cd84af9ca1174a908f4e79eb81203cf..d919c55604d216e87573ce34d1e4cbcb822e57b1 100644 (file)
@@ -49,6 +49,7 @@ MainSession::MainSession(MWindow *mwindow)
        drag_assets = new ArrayList<Indexable*>;
        drag_auto_gang = new ArrayList<Auto*>;
        drag_clips = new ArrayList<EDL*>;
+       drag_proxy = new ArrayList<EDL*>;
        drag_edits = new ArrayList<Edit*>;
        drag_edit = 0;
        clip_number = 1;
@@ -113,10 +114,12 @@ MainSession::MainSession(MWindow *mwindow)
 
 MainSession::~MainSession()
 {
+       clear_drag_proxy();
        delete drag_pluginservers;
        delete drag_assets;
        delete drag_auto_gang;
        delete drag_clips;
+       delete drag_proxy;
        delete drag_edits;
 }
 
@@ -141,6 +144,13 @@ void MainSession::boundaries()
        CLAMP(cwindow_controls, 0, 1);
 }
 
+void MainSession::clear_drag_proxy()
+{
+       for( int i=drag_proxy->size(); --i>=0; )
+               drag_proxy->get(i)->remove_user();
+       drag_proxy->remove_all();
+}
+
 void MainSession::save_x11_host(int play_config, const char *x11_host)
 {
        strcpy(!play_config ? a_x11_host : b_x11_host, x11_host);
index ab53708d3048615fe11590a6c81cc71a7dc6ed9e..cc16c7375d271e623137438dd43432bbb25f6fa8 100644 (file)
@@ -49,15 +49,12 @@ public:
 
        int load_defaults(BC_Hash *defaults);
        int save_defaults(BC_Hash *defaults);
+       void clear_drag_proxy();
        void save_x11_host(int play_config, const char *x11_host);
        int set_default_x11_host(int win_config=-1);
        void default_window_positions(int window_config=0);
        void boundaries();
 
-
-
-
-
 // For drag and drop events
 // The entire track where the dropped asset is going to go
        Track *track_highlighted;
@@ -77,6 +74,7 @@ public:
        Edits *trim_edits;
        ArrayList<Indexable*> *drag_assets;
        ArrayList<EDL*> *drag_clips;
+       ArrayList<EDL*> *drag_proxy;
        Auto *drag_auto;
        ArrayList<Auto*> *drag_auto_gang;
 
index b406c7b207f12c4d421eedb58e25b045e3292519..2366c3884cb17aa3b1b1739ecd3228fde98d56a6 100644 (file)
@@ -2380,6 +2380,18 @@ void MWindow::set_proxy(int use_scaler, int new_scale, int auto_scale,
                                }
                        }
                }
+               for( int j=0,m=edl->clips.size(); j<m; ++j ) {
+                       EDL *clip = edl->clips[j];
+                       for( Track *track=clip->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;
+                                       }
+                               }
+                       }
+               }
        }
 }
 
index 4774ecde51fc69ec81f4f921bed64cf11e9c7ad4..5aff535abd7b37b121fc68fe2c428f3e824827bf 100644 (file)
@@ -83,7 +83,9 @@ ProxyDialog::ProxyDialog(MWindow *mwindow)
        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()
@@ -207,6 +209,8 @@ void ProxyDialog::to_proxy()
                        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++ )
@@ -291,7 +295,7 @@ void ProxyRender::from_proxy_path(char *new_path, Asset *asset, int scale)
        char prxy[BCTEXTLEN];
        int n = sprintf(prxy, ".proxy%d", scale);
        strcpy(new_path, asset->path);
-       char *ptr = strstr(asset->path, prxy);
+       char *ptr = strstr(new_path, prxy);
        if( !ptr || (ptr[n] != '-' && ptr[n] != '.') ) return;
 // remove proxy, path.proxy#-sfx.ext => path.sfx
        char *ext = strrchr(ptr, '.');
@@ -454,9 +458,6 @@ void ProxyWindow::create_objects()
        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();
index c2ad5486ba1c455a4165a70735e906f486bb28c3..8726cb78f0793f4dc44adaa89adb78440d803fa4 100644 (file)
@@ -68,7 +68,7 @@ public:
        ProxyRender(MWindow *mwindow, Asset *format_asset);
        ~ProxyRender();
        void to_proxy_path(char *new_path, Indexable *indexable, int scale);
-       void from_proxy_path(char *new_path, Asset *asset, int scale);
+       static void from_proxy_path(char *new_path, Asset *asset, int scale);
 
        ArrayList<Indexable *> orig_idxbls;   // originals which match the proxy assets
        ArrayList<Indexable *> orig_proxies;  // proxy assets