auto interpolate_from orig_id fix, move brender set_video_map update to write_frame_done
authorGood Guy <[email protected]>
Sat, 5 Sep 2020 01:45:47 +0000 (19:45 -0600)
committerGood Guy <[email protected]>
Sat, 5 Sep 2020 01:45:47 +0000 (19:45 -0600)
cinelerra-5.1/cinelerra/auto.C
cinelerra-5.1/cinelerra/brender.C
cinelerra-5.1/cinelerra/file.h
cinelerra-5.1/cinelerra/fileref.C
cinelerra-5.1/cinelerra/fileref.h
cinelerra-5.1/cinelerra/filethread.C
cinelerra-5.1/cinelerra/packagedispatcher.C
cinelerra-5.1/cinelerra/packagerenderer.C
cinelerra-5.1/cinelerra/packagerenderer.h
cinelerra-5.1/cinelerra/packagerenderer.inc
cinelerra-5.1/plugins/compressormulti/comprmultigui.C

index cd950dad0fae9907a1668391c7fa548a9a967fd1..87a2ddafe08d4b58bff46f224b40811892ecf1ed 100644 (file)
@@ -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;
 }
index 8a3b22b2be50d22ec05a33b6f53d0f00b247e602..0d19bf025cca426a9715532c4b34bc240366831c 100644 (file)
@@ -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();
index c86a1b4f72b1d9b8911798d1b297779de665ab7d..6b660b5edf92597834f9d4da0eb278cf29a99dcf 100644 (file)
@@ -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
index 8d9b1ae9f22154bbf976d6eee1128853409bb723..a60b3f3e4e5b678a75a69b0543a91af868c7cee8 100644 (file)
@@ -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"
index 7f4d67f2ba869d0ab05881e3e8f28b20c297858e..bfbca7eb4a6e31cbda44fede6493ed2bb3be9aca 100644 (file)
 
 #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"
index 84b20fcdd45fbf289833c9c8dd6623143f8b2ba4..8fadbeea9fd45e64835bb66d1fec285d0950b11e 100644 (file)
@@ -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; j<layers && !result; ++j )
+                                                               for( i=0; i<count && !result; ++i )
+                                                                       result = file->write_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; j<layers && !result; ++j )
+                                                               for( i=0; i<count && !result; ++i )
+                                                                       file->write_frame_done(frames[j][i]->get_number());
                                                }
                                        }
 
index dccec03a2896c3f8676a0f66b44f589b285bc090..17d02c0d3bad198b0e60f228f5403689ad93f3bc 100644 (file)
@@ -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;
index a76d736ae5839f9f03f87329bcd45238af6ad19b..2cdc807039414daf2825ff4b2c401f0c0d04947f 100644 (file)
@@ -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 ) {
index 3c444b2e9f296a6f5a1bff689952a0733283ca53..828194597269729d7e7d03a1b8720a0a364557ca 100644 (file)
 #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;
index 461272d2a028cebc755fcf1d9e05f076225b765a..fbb2f44939d13826e214a7e73973be6784def73a 100644 (file)
 #ifndef PACKAGERENDERER_INC
 #define PACKAGERENDERER_INC
 
-
-
-class PackageRenderer;
 class RenderPackage;
-
+class PackageFile;
+class PackageRenderer;
 
 #endif
index 24aea81b58124e4ac461bbbd6de3736e7f3976ed..06951f06dc9b470d47b97eaf76e1f1c3bd6de696 100644 (file)
@@ -30,6 +30,7 @@
 #include "file.h"
 #include "language.h"
 #include "theme.h"
+#include "transportque.inc"
 #include "units.h"
 
 #include <string.h>