From 7efb497e185234700abe3abeaa430471c4e34f58 Mon Sep 17 00:00:00 2001 From: Good Guy Date: Fri, 4 Sep 2020 19:45:47 -0600 Subject: [PATCH] auto interpolate_from orig_id fix, move brender set_video_map update to write_frame_done --- cinelerra-5.1/cinelerra/auto.C | 5 +- cinelerra-5.1/cinelerra/brender.C | 46 ++++++------------- cinelerra-5.1/cinelerra/file.h | 5 +- cinelerra-5.1/cinelerra/fileref.C | 1 + cinelerra-5.1/cinelerra/fileref.h | 2 + cinelerra-5.1/cinelerra/filethread.C | 20 ++++---- cinelerra-5.1/cinelerra/packagedispatcher.C | 4 +- cinelerra-5.1/cinelerra/packagerenderer.C | 28 +++++------ cinelerra-5.1/cinelerra/packagerenderer.h | 14 +++++- cinelerra-5.1/cinelerra/packagerenderer.inc | 6 +-- .../plugins/compressormulti/comprmultigui.C | 1 + 11 files changed, 65 insertions(+), 67 deletions(-) diff --git a/cinelerra-5.1/cinelerra/auto.C b/cinelerra-5.1/cinelerra/auto.C index cd950dad..87a2ddaf 100644 --- a/cinelerra-5.1/cinelerra/auto.C +++ b/cinelerra-5.1/cinelerra/auto.C @@ -79,8 +79,11 @@ int Auto::interpolate_from(Auto *a1, Auto *a2, int64_t new_position, Auto *templ if( !templ ) templ = previous; if( !templ && this->autos ) templ = this->autos->default_auto; - if( templ ) + if( templ ) { + int orig_id = this->orig_id; copy_from(templ); + this->orig_id = orig_id; + } position = new_position; return 0; } diff --git a/cinelerra-5.1/cinelerra/brender.C b/cinelerra-5.1/cinelerra/brender.C index 8a3b22b2..0d19bf02 100644 --- a/cinelerra-5.1/cinelerra/brender.C +++ b/cinelerra-5.1/cinelerra/brender.C @@ -230,56 +230,36 @@ void BRender::allocate_map(int64_t brender_start, int64_t start, int64_t end) int BRender::set_video_map(int64_t position, int value) { - int update_gui = 0; +printf("BRender::set_video_map(%jd, %d)\n", position, value); map_lock->lock("BRender::set_video_map"); - if(value == BRender::NOT_SCANNED) { printf(_("BRender::set_video_map called to set NOT_SCANNED\n")); } - -// Preroll - if(position < 0) - { - ; - } - else -// In range - if(position < map_size) - { - map[position] = value; - } - else -// Obsolete EDL - { + if( position < 0) {} // Preroll + else if( position < map_size ) map[position] = value; // In range + else // Obsolete EDL printf(_("BRender::set_video_map %jd: attempt to set beyond end of map %jd.\n"), position, map_size); - } + int update_gui = 0; // Maintain last contiguous here to reduce search time - if(position == last_contiguous && last_contiguous < map_size ) - { - int i; - for(i = position + 1; i < map_size && map[i]; i++) - { - ; - } - last_contiguous = i; + if( position == last_contiguous && last_contiguous < map_size ) { + while( last_contiguous < map_size && map[last_contiguous] ) + ++last_contiguous; + if( last_contiguous >= map_size ) update_gui = 1; mwindow->session->brender_end = (double)last_contiguous / mwindow->edl->session->frame_rate; - if(timer->get_difference() > 1000 || last_contiguous >= map_size) - { - update_gui = 1; - timer->update(); - } } + if( timer->get_difference() > 1000 ) + update_gui = 1; map_lock->unlock(); - if(update_gui) - { + if( update_gui ) { + timer->update(); mwindow->gui->lock_window("BRender::set_video_map"); mwindow->gui->update_timebar(1); mwindow->gui->unlock_window(); diff --git a/cinelerra-5.1/cinelerra/file.h b/cinelerra-5.1/cinelerra/file.h index c86a1b4f..6b660b5e 100644 --- a/cinelerra-5.1/cinelerra/file.h +++ b/cinelerra-5.1/cinelerra/file.h @@ -45,7 +45,6 @@ #include "preferences.inc" #include "samples.inc" #include "vframe.inc" -#include "packagingengine.h" // ======================================= include file types here @@ -56,7 +55,7 @@ class File { public: File(); - ~File(); + virtual ~File(); int probe(); // Get attributes for various file formats. @@ -266,6 +265,8 @@ public: int bytes_per_sample(int bits); // Convert the bit descriptor into a byte count. // get record stream file descriptor int record_fd(); +// brender update video map + virtual int write_frame_done(int64_t position) { return 0; } Asset *asset; // Copy of asset since File outlives EDL FileBase *file; // virtual class for file type diff --git a/cinelerra-5.1/cinelerra/fileref.C b/cinelerra-5.1/cinelerra/fileref.C index 8d9b1ae9..a60b3f3e 100644 --- a/cinelerra-5.1/cinelerra/fileref.C +++ b/cinelerra-5.1/cinelerra/fileref.C @@ -22,6 +22,7 @@ #include "asset.h" #include "arender.h" #include "cache.h" +#include "edl.h" #include "filebase.h" #include "file.h" #include "fileref.h" diff --git a/cinelerra-5.1/cinelerra/fileref.h b/cinelerra-5.1/cinelerra/fileref.h index 7f4d67f2..bfbca7eb 100644 --- a/cinelerra-5.1/cinelerra/fileref.h +++ b/cinelerra-5.1/cinelerra/fileref.h @@ -22,8 +22,10 @@ #include "asset.inc" #include "cache.inc" +#include "edl.inc" #include "filebase.h" #include "file.inc" +#include "maxchannels.h" #include "renderengine.inc" #include "samples.inc" #include "transportque.inc" diff --git a/cinelerra-5.1/cinelerra/filethread.C b/cinelerra-5.1/cinelerra/filethread.C index 84b20fcd..8fadbeea 100644 --- a/cinelerra-5.1/cinelerra/filethread.C +++ b/cinelerra-5.1/cinelerra/filethread.C @@ -277,16 +277,20 @@ void FileThread::run() else if(do_video) { - if(compressed) - { - for(j = 0; j < file->asset->layers && !result; j++) - for(i = 0; i < output_size[local_buffer] && !result; i++) - result = file->write_compressed_frame(video_buffer[local_buffer][j][i]); + int layers = 1, count = output_size[local_buffer]; + VFrame ***frames = video_buffer[local_buffer]; + if( compressed ) { + layers = file->asset->layers; + for( j=0; jwrite_compressed_frame(frames[j][i]); } else - { - result = file->write_frames(video_buffer[local_buffer], - output_size[local_buffer]); + result = file->write_frames(frames, count); + if( !result ) { + for( j=0; jwrite_frame_done(frames[j][i]->get_number()); } } diff --git a/cinelerra-5.1/cinelerra/packagedispatcher.C b/cinelerra-5.1/cinelerra/packagedispatcher.C index dccec03a..17d02c0d 100644 --- a/cinelerra-5.1/cinelerra/packagedispatcher.C +++ b/cinelerra-5.1/cinelerra/packagedispatcher.C @@ -279,9 +279,11 @@ RenderPackage* PackageDispatcher::get_package(double frames_per_second, result->video_start = video_position; result->audio_end = result->audio_start + Units::to_int64(scaled_len * default_asset->sample_rate); + if( result->audio_end > audio_end ) result->audio_end = audio_end; result->video_end = result->video_start + Units::to_int64(scaled_len * default_asset->frame_rate); - if(result->video_end == result->video_start) result->video_end++; + if( result->video_end > video_end ) result->video_end = video_end; + if( result->video_end == result->video_start ) result->video_end++; audio_position = result->audio_end; video_position = result->video_end; result->audio_do = default_asset->audio_data; diff --git a/cinelerra-5.1/cinelerra/packagerenderer.C b/cinelerra-5.1/cinelerra/packagerenderer.C index a76d736a..2cdc8070 100644 --- a/cinelerra-5.1/cinelerra/packagerenderer.C +++ b/cinelerra-5.1/cinelerra/packagerenderer.C @@ -80,10 +80,19 @@ RenderPackage::~RenderPackage() } +PackageFile::PackageFile(PackageRenderer *package_renderer) +{ + this->package_renderer = package_renderer; +} +PackageFile::~PackageFile() +{ +} - - +int PackageFile::write_frame_done(int64_t position) +{ + return package_renderer->set_video_map(position, BRender::RENDERED); +} // Used by RenderFarm and in the future, Render, to do packages. @@ -160,7 +169,7 @@ void PackageRenderer::create_output() else strncpy(asset->path, package->path, sizeof(asset->path)); - file = new File; + file = new PackageFile(this); file->set_processors(preferences->processors); result = file->open_file(preferences, asset, 0, 1); @@ -396,13 +405,6 @@ void PackageRenderer::do_video() if( video_write_position >= video_write_length ) { result = file->write_video_buffer(video_write_position); -// Update the brender map after writing the files. - if( package->use_brender ) { - for( int i = 0; i < video_write_position && !result; i++ ) { - result = set_video_map(video_position + 1 - video_write_position + i, - BRender::RENDERED); - } - } video_write_position = 0; } } @@ -438,12 +440,6 @@ void PackageRenderer::stop_output() delete compressed_output; if( video_write_position ) file->write_video_buffer(video_write_position); - if( package->use_brender ) { - for( int i = 0; i < video_write_position && !error; i++ ) { - error = set_video_map(video_position - video_write_position + i, - BRender::RENDERED); - } - } video_write_position = 0; if( !error ) file->stop_video_thread(); if( mwindow ) { diff --git a/cinelerra-5.1/cinelerra/packagerenderer.h b/cinelerra-5.1/cinelerra/packagerenderer.h index 3c444b2e..82819459 100644 --- a/cinelerra-5.1/cinelerra/packagerenderer.h +++ b/cinelerra-5.1/cinelerra/packagerenderer.h @@ -29,9 +29,10 @@ #include "cache.inc" #include "edit.inc" #include "edl.inc" -#include "file.inc" +#include "file.h" #include "maxchannels.h" #include "mwindow.inc" +#include "packagerenderer.inc" #include "playabletracks.inc" #include "playbackconfig.inc" #include "pluginserver.inc" @@ -66,6 +67,15 @@ public: int audio_do; }; +class PackageFile : public File +{ +public: + PackageFile(PackageRenderer *package_renderer); + ~PackageFile(); + int write_frame_done(int64_t position); + + PackageRenderer *package_renderer; +}; @@ -131,7 +141,7 @@ public: int64_t audio_position; int64_t audio_preroll; int64_t audio_read_length; - File *file; + PackageFile *file; // This is 1 if an error is encountered. int result; VFrame ***video_output; diff --git a/cinelerra-5.1/cinelerra/packagerenderer.inc b/cinelerra-5.1/cinelerra/packagerenderer.inc index 461272d2..fbb2f449 100644 --- a/cinelerra-5.1/cinelerra/packagerenderer.inc +++ b/cinelerra-5.1/cinelerra/packagerenderer.inc @@ -22,10 +22,8 @@ #ifndef PACKAGERENDERER_INC #define PACKAGERENDERER_INC - - -class PackageRenderer; class RenderPackage; - +class PackageFile; +class PackageRenderer; #endif diff --git a/cinelerra-5.1/plugins/compressormulti/comprmultigui.C b/cinelerra-5.1/plugins/compressormulti/comprmultigui.C index 24aea81b..06951f06 100644 --- a/cinelerra-5.1/plugins/compressormulti/comprmultigui.C +++ b/cinelerra-5.1/plugins/compressormulti/comprmultigui.C @@ -30,6 +30,7 @@ #include "file.h" #include "language.h" #include "theme.h" +#include "transportque.inc" #include "units.h" #include -- 2.26.2