From: Good Guy Date: Sun, 28 Jun 2020 01:00:12 +0000 (-0600) Subject: collect_proxy nested_clip/edl fixes X-Git-Tag: 2020-06~3 X-Git-Url: https://cinelerra-gg.org/git/?a=commitdiff_plain;h=b2d226c1f41e84bbb3af93ebc0aa89f98ec0fd52;p=goodguy%2Fcinelerra.git collect_proxy nested_clip/edl fixes --- diff --git a/cinelerra-5.1/cinelerra/asset.C b/cinelerra-5.1/cinelerra/asset.C index fe169cbc..751660ad 100644 --- a/cinelerra-5.1/cinelerra/asset.C +++ b/cinelerra-5.1/cinelerra/asset.C @@ -165,6 +165,7 @@ void Asset::reset_video() actual_width = width = 0; actual_height = height = 0; proxy_scale = 0; // not a proxy + proxy_edl = 0; // not proxy from edl video_length = 0; single_frame = 0; vmpeg_cmodel = BC_YUV420P; @@ -226,6 +227,7 @@ void Asset::copy_format(Asset *asset, int do_index) actual_width = asset->actual_width; actual_height = asset->actual_height; proxy_scale = asset->proxy_scale; + proxy_edl = asset->proxy_edl; strcpy(vcodec, asset->vcodec); strcpy(acodec, asset->acodec); @@ -470,6 +472,7 @@ int Asset::read_video(FileXML *file) height = file->tag.get_property("HEIGHT", height); width = file->tag.get_property("WIDTH", width); proxy_scale = file->tag.get_property("PROXY_SCALE", 0); + proxy_edl = file->tag.get_property("PROXY_EDL", 0); layers = file->tag.get_property("LAYERS", layers); program = file->tag.get_property("PROGRAM", program); // This is loaded from the index file after the EDL but this @@ -638,6 +641,7 @@ int Asset::write_video(FileXML *file) file->tag.set_property("HEIGHT", height); file->tag.set_property("WIDTH", width); file->tag.set_property("PROXY_SCALE", proxy_scale); + file->tag.set_property("PROXY_EDL", proxy_edl); file->tag.set_property("LAYERS", layers); file->tag.set_property("PROGRAM", program); file->tag.set_property("FRAMERATE", frame_rate); @@ -741,6 +745,7 @@ void Asset::load_defaults(BC_Hash *defaults, actual_height = GET_DEFAULT("ACTUAL_HEIGHT", actual_height); actual_width = GET_DEFAULT("ACTUAL_WIDTH", actual_width); proxy_scale = GET_DEFAULT("PROXY_SCALE", proxy_scale); + proxy_edl = GET_DEFAULT("PROXY_SCALE", proxy_edl); program = GET_DEFAULT("PROGRAM", program); layers = GET_DEFAULT("LAYERS", layers); if(EQUIV(frame_rate, 0)) frame_rate = GET_DEFAULT("FRAMERATE", frame_rate); @@ -944,6 +949,7 @@ void Asset::save_defaults(BC_Hash *defaults, UPDATE_DEFAULT("ACTUAL_HEIGHT", actual_height); UPDATE_DEFAULT("ACTUAL_WIDTH", actual_width); UPDATE_DEFAULT("PROXY_SCALE", proxy_scale); + UPDATE_DEFAULT("PROXY_EDL", proxy_edl); UPDATE_DEFAULT("PROGRAM", program); UPDATE_DEFAULT("LAYERS", layers); UPDATE_DEFAULT("FRAMERATE", frame_rate); @@ -989,9 +995,9 @@ int Asset::dump(FILE *fp) " height %d vcodec %s aspect_ratio %f ilace_mode %s\n", video_data, layers, program, frame_rate, width, height, vcodec, aspect_ratio,string); - fprintf(fp," actual_width %d actual_height %d proxy_scale %d" + fprintf(fp," actual_width %d actual_height %d proxy_scale %d proxy_edl %d" " video_length %jd repeat %d\n", - actual_width, actual_height, proxy_scale, video_length, + actual_width, actual_height, proxy_scale, proxy_edl, video_length, single_frame); fprintf(fp," video_length %jd repeat %d\n", video_length, single_frame); fprintf(fp," mov_sphere=%d jpeg_sphere=%d\n", mov_sphere, jpeg_sphere); diff --git a/cinelerra-5.1/cinelerra/asset.h b/cinelerra-5.1/cinelerra/asset.h index 92b15794..ce922c22 100644 --- a/cinelerra-5.1/cinelerra/asset.h +++ b/cinelerra-5.1/cinelerra/asset.h @@ -147,8 +147,8 @@ public: int actual_width, actual_height; int width, height; -// scale factor or 0 if not proxy - int proxy_scale; +// scale factor or 0 if not proxy, proxy_edl if proxyed from nested_edl + int proxy_scale, proxy_edl; // String or FourCC describing compression char vcodec[BCTEXTLEN]; diff --git a/cinelerra-5.1/cinelerra/awindowgui.C b/cinelerra-5.1/cinelerra/awindowgui.C index 33e3cbc8..a0a2d5cf 100644 --- a/cinelerra-5.1/cinelerra/awindowgui.C +++ b/cinelerra-5.1/cinelerra/awindowgui.C @@ -2210,14 +2210,16 @@ void AWindowGUI::sort_folders() update_assets(); } -EDL *AWindowGUI::collect_proxy(Indexable *indexable) +EDL *AWindowGUI::collect_proxy(Asset *proxy_asset) { - 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->layers ) return 0; + Indexable *unproxy_idxbl = + proxy_asset->proxy_edl ? + (Indexable *) mwindow->edl->get_nested_edl(path) : + (Indexable *) mwindow->edl->assets->get_asset(path); + if( !unproxy_idxbl || !unproxy_idxbl->get_video_layers() ) return 0; // make a clip from proxy video tracks and unproxy audio tracks EDL *proxy_edl = new EDL(mwindow->edl); proxy_edl->create_objects(); @@ -2226,7 +2228,7 @@ EDL *AWindowGUI::collect_proxy(Indexable *indexable) 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->session->audio_tracks = unproxy_idxbl->get_audio_channels(); proxy_edl->create_default_tracks(); double length = proxy_asset->frame_rate > 0 ? ( proxy_asset->video_length >= 0 ? @@ -2240,11 +2242,15 @@ EDL *AWindowGUI::collect_proxy(Indexable *indexable) 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; + int64_t samples = unproxy_idxbl->get_audio_samples(); + int sample_rate = unproxy_idxbl->get_sample_rate(); + length = sample_rate > 0 ? (double)samples / sample_rate : 0; 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++); + Asset *asset = unproxy_idxbl->is_asset ? (Asset *)unproxy_idxbl : 0; + EDL *nested_edl = unproxy_idxbl->is_asset ? 0 : (EDL *)unproxy_idxbl; + current->insert_asset(asset, nested_edl, length, 0, atrack++); } proxy_edl->folder_no = AW_PROXY_FOLDER; return proxy_edl; @@ -2260,7 +2266,7 @@ void AWindowGUI::collect_assets(int proxy) Indexable *indexable = result->indexable; if( proxy && indexable && indexable->is_asset && indexable->folder_no == AW_PROXY_FOLDER ) { - EDL *drag_edl = collect_proxy(indexable); + EDL *drag_edl = collect_proxy((Asset*)indexable); if( drag_edl ) mwindow->session->drag_clips->append(drag_edl); continue; } @@ -2822,8 +2828,8 @@ int AWindowAssets::handle_event() break; } if( !vwindow || !vwindow->is_running() ) return 1; - if( proxy && picon_idxbl ) { - picon_edl = gui->collect_proxy(picon_idxbl); + if( proxy && picon_idxbl && picon_idxbl->is_asset ) { + picon_edl = gui->collect_proxy((Asset*)picon_idxbl); picon_idxbl = 0; } diff --git a/cinelerra-5.1/cinelerra/awindowgui.h b/cinelerra-5.1/cinelerra/awindowgui.h index 6004247d..8584049d 100644 --- a/cinelerra-5.1/cinelerra/awindowgui.h +++ b/cinelerra-5.1/cinelerra/awindowgui.h @@ -271,7 +271,7 @@ public: int drag_stop(); // Collect items into the drag vectors of MainSession void collect_assets(int proxy=0); - EDL *collect_proxy(Indexable *indexable); + EDL *collect_proxy(Asset *asset); void create_persistent_folder(ArrayList *output, int do_audio, int do_video, diff --git a/cinelerra-5.1/cinelerra/edl.C b/cinelerra-5.1/cinelerra/edl.C index 5df16099..cb080aca 100644 --- a/cinelerra-5.1/cinelerra/edl.C +++ b/cinelerra-5.1/cinelerra/edl.C @@ -601,7 +601,7 @@ void EDL::copy_indexables(EDL *edl) } } -EDL *EDL::new_nested_edl(EDL *edl, const char *path) +EDL *EDL::new_nested_clip(EDL *edl, const char *path) { EDL *nested = new EDL; // no parent for nested edl nested->create_objects(); @@ -614,19 +614,14 @@ EDL *EDL::new_nested_edl(EDL *edl, const char *path) return nested; } -EDL *EDL::get_nested_edl() +EDL *EDL::get_nested_edl(const char *path) { - Track *track = tracks->first; - Edit *edit = track ? track->edits->first : 0; - EDL *nested = edit && !edit->next && !edit->asset ? edit->nested_edl : 0; - while( nested && (track=track->next)!=0 ) { - Edit *edit = track->edits->first; - if( !edit || edit->next || - ( edit->nested_edl != nested && - strcmp(edit->nested_edl->path, nested->path) ) ) - nested = 0; + for( int i=0; ipath) ) + return nested_edl; } - return nested; + return 0; } @@ -642,8 +637,8 @@ void EDL::create_nested(EDL *nested) { int video_tracks = 0, audio_tracks = 0; for( Track *track=nested->tracks->first; track!=0; track=track->next ) { - if( track->data_type == TRACK_VIDEO && track->is_armed() ) ++video_tracks; - if( track->data_type == TRACK_AUDIO && track->is_armed() ) ++audio_tracks; + if( track->data_type == TRACK_VIDEO && track->play ) ++video_tracks; + if( track->data_type == TRACK_AUDIO && track->play ) ++audio_tracks; } // renderengine properties if( video_tracks > 0 ) diff --git a/cinelerra-5.1/cinelerra/edl.h b/cinelerra-5.1/cinelerra/edl.h index 80aadb2c..5d08285b 100644 --- a/cinelerra-5.1/cinelerra/edl.h +++ b/cinelerra-5.1/cinelerra/edl.h @@ -197,8 +197,8 @@ public: int copy_assets(int copy_flags, double start, double end, FileXML *file, const char *output_path); void copy_indexables(EDL *edl); - EDL *new_nested_edl(EDL *edl, const char *path); - EDL *get_nested_edl(); + EDL *new_nested_clip(EDL *edl, const char *path); + EDL *get_nested_edl(const char *path); EDL *create_nested_clip(EDL *nested); void create_nested(EDL *nested); void overwrite_clip(EDL *clip); diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index f072467e..49709028 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -2492,8 +2492,6 @@ int MWindow::to_proxy(Asset *asset, int new_scale, int new_use_scaler) for( int i=0,n=edl->nested_edls.size(); inested_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; @@ -3431,7 +3429,7 @@ int MWindow::get_hash_color(Edit *edit) char path[BCTEXTLEN]; if( !edit->asset || edit->track->data_type != TRACK_VIDEO || edl->session->proxy_scale == 1 || - ProxyRender::from_proxy_path(path, idxbl, edl->session->proxy_scale) ) + ProxyRender::from_proxy_path(path, (Asset*)idxbl, edl->session->proxy_scale) ) strcpy(path, idxbl->path); char *cp = strrchr(path, '/'); cp = !cp ? path : cp+1; @@ -4004,7 +4002,7 @@ void MWindow::clip_to_media() char *bp = strrchr(clip->local_session->clip_title, '/'); bp = bp ? bp+1 : clip->local_session->clip_title; cp += snprintf(cp, ep-cp, "%s", bp); - EDL *nested = edl->new_nested_edl(clip, path); + EDL *nested = edl->new_nested_clip(clip, path); edl->clips.remove(clip); clip->remove_user(); mainindexes->add_indexable(nested); diff --git a/cinelerra-5.1/cinelerra/proxy.C b/cinelerra-5.1/cinelerra/proxy.C index fbb34fcf..34f833fb 100644 --- a/cinelerra-5.1/cinelerra/proxy.C +++ b/cinelerra-5.1/cinelerra/proxy.C @@ -229,11 +229,11 @@ 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); } -int ProxyRender::from_proxy_path(char *new_path, Indexable *indexable, int scale) +int ProxyRender::from_proxy_path(char *new_path, Asset *asset, int scale) { char prxy[BCTEXTLEN]; int n = sprintf(prxy, ".proxy%d", scale); - strcpy(new_path, indexable->path); + strcpy(new_path, asset->path); char *ptr = strstr(new_path, prxy); if( !ptr || (ptr[n] != '-' && ptr[n] != '.') ) return 1; // remove proxy, path.proxy#-sfx.ext => path.sfx @@ -242,6 +242,12 @@ int ProxyRender::from_proxy_path(char *new_path, Indexable *indexable, int scale char *cp = ptr + n; for( *cp='.'; cpproxy_edl ) { + if( (cp = strrchr(new_path, '/')) != 0 ) { + for( ptr=new_path; *++cp; ) *ptr++ = *cp; + *ptr = 0; + } + } return 0; } @@ -307,6 +313,7 @@ Asset *ProxyRender::add_original(Indexable *idxbl, int new_scale) proxy->video_length = video_frames; } proxy->folder_no = AW_PROXY_FOLDER; + proxy->proxy_edl = !idxbl->is_asset ? 1 : 0; proxy->audio_data = 0; proxy->video_data = 1; proxy->layers = 1; diff --git a/cinelerra-5.1/cinelerra/proxy.h b/cinelerra-5.1/cinelerra/proxy.h index 7f88686d..b134b910 100644 --- a/cinelerra-5.1/cinelerra/proxy.h +++ b/cinelerra-5.1/cinelerra/proxy.h @@ -67,7 +67,7 @@ public: ProxyRender(MWindow *mwindow, Asset *format_asset, int asset_scale); ~ProxyRender(); void to_proxy_path(char *new_path, Indexable *indexable, int scale); - static int from_proxy_path(char *new_path, Indexable *indexable, int scale); + static int from_proxy_path(char *new_path, Asset *asset, int scale); ArrayList orig_idxbls; // originals which match the proxy assets ArrayList orig_proxies; // proxy assets