Credit Andrew - updating patches for FFmpeg 7.0 as needed since 6.1, now at 7.0,...
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / packagedispatcher.C
index f6d69734d3738741e51108abbf817f569aea8ed7..b6aa9675a6fe818ea12ca07fb5779edab2d5f7ad 100644 (file)
@@ -2,6 +2,7 @@
 /*
  * CINELERRA
  * Copyright (C) 1997-2011 Adam Williams <broadcast at earthling dot net>
+ * Copyright (C) 2003-2016 Cinelerra CV contributors
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,6 +26,7 @@
 #include "edl.h"
 #include "edlsession.h"
 #include "labels.h"
+#include "mainerror.h"
 #include "mutex.h"
 #include "mwindow.h"
 #include "packagedispatcher.h"
@@ -101,7 +103,7 @@ int PackageDispatcher::create_packages(MWindow *mwindow, EDL *edl,
                strcpy(packages[0]->path, default_asset->path);
                break;
        case SINGLE_PASS_FARM:
-               packaging_engine = File::new_packaging_engine(default_asset);
+               packaging_engine = (PackagingEngine*)new PackagingEngineDefault();
                packaging_engine->create_packages_single_farm(edl, preferences,
                                default_asset, total_start, total_end);
                break;
@@ -110,6 +112,11 @@ int PackageDispatcher::create_packages(MWindow *mwindow, EDL *edl,
                label = edl->labels->first;
                total_packages = 0;
                packages = new RenderPackage*[edl->labels->total() + 2];
+               if( !label ) {
+                       eprintf(_("Render file per label and no labels\n"));
+                       result = 1;
+                       break;
+               }
 
                Render::get_starting_number(default_asset->path,
                        current_number, number_start, total_digits, 3);
@@ -183,6 +190,7 @@ int PackageDispatcher::create_packages(MWindow *mwindow, EDL *edl,
 // Only if this isn't a background render or non interactive.
        if( strategy != BRENDER_FARM && test_overwrite && mwindow ) {
                ArrayList<char*> paths;
+               paths.set_array_delete();
                get_package_paths(&paths);
                result = ConfirmSave::test_files(mwindow, &paths);
                paths.remove_all_objects();
@@ -197,8 +205,7 @@ void PackageDispatcher::get_package_paths(ArrayList<char*> *path_list)
                        packaging_engine->get_package_paths(path_list);
                else {
                        for( int i=0; i<total_allocated; ++i )
-                               path_list->append(strdup(packages[i]->path));
-                       path_list->set_free();
+                               path_list->append(cstrdup(packages[i]->path));
                }
 
 }
@@ -273,9 +280,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;
@@ -322,6 +331,11 @@ int64_t PackageDispatcher::get_progress_max()
                                total_allocated * default_asset->sample_rate);
 }
 
+RenderPackage *PackageDispatcher::get_package(int number)
+{
+       return packages[number];
+}
+
 int PackageDispatcher::get_total_packages()
 {
        return total_allocated;