rework set default transtion, nested proxy edl fixes, doubleclick proxy media fix...
[goodguy/history.git] / cinelerra-5.1 / cinelerra / proxy.C
index 5432f478546fb1927cd64e7c20667e843545bb06..9f25a7e1131ca32b0db95594adefa037b539ebbb 100644 (file)
@@ -199,6 +199,26 @@ void ProxyDialog::to_proxy()
                        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;
@@ -238,6 +258,19 @@ void ProxyDialog::to_proxy()
                                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;
@@ -291,19 +324,20 @@ 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);
 }
 
-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);
+       strcpy(new_path, indexable->path);
        char *ptr = strstr(new_path, prxy);
-       if( !ptr || (ptr[n] != '-' && ptr[n] != '.') ) return;
+       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)