r870: Merge 2.1:
[cinelerra_cv.git] / cinelerra / render.h
blob585d903290b18da03a465447de1618e2970211bb
1 #ifndef RENDER_H
2 #define RENDER_H
5 #include "asset.inc"
6 #include "batchrender.inc"
7 #include "bitspopup.h"
8 #include "browsebutton.h"
9 #include "cache.inc"
10 #include "compresspopup.h"
11 #include "condition.inc"
12 #include "bchash.inc"
13 #include "edit.inc"
14 #include "errorbox.inc"
15 #include "file.inc"
16 #include "formatpopup.inc"
17 #include "formattools.inc"
18 #include "guicast.h"
19 #include "loadmode.inc"
20 #include "mainprogress.inc"
21 #include "maxchannels.h"
22 #include "mutex.inc"
23 #include "mwindow.inc"
24 #include "packagedispatcher.inc"
25 #include "packagerenderer.h"
26 #include "playabletracks.inc"
27 #include "preferences.inc"
28 #include "bcprogressbox.inc"
29 #include "render.inc"
30 #include "track.inc"
31 #include "transportque.inc"
32 #include "vframe.inc"
34 class RenderItem : public BC_MenuItem
36 public:
37 RenderItem(MWindow *mwindow);
38 int handle_event();
39 MWindow *mwindow;
42 class RenderProgress : public Thread
44 public:
45 RenderProgress(MWindow *mwindow, Render *render);
46 ~RenderProgress();
48 void run();
51 MWindow *mwindow;
52 Render *render;
54 int64_t last_value;
59 class MainPackageRenderer : public PackageRenderer
61 public:
62 MainPackageRenderer(Render *render);
63 ~MainPackageRenderer();
66 int get_master();
67 int get_result();
68 void set_result(int value);
69 void set_progress(int64_t value);
70 int progress_cancelled();
72 Render *render;
75 class RenderWindow;
78 class Render : public Thread
80 public:
81 Render(MWindow *mwindow);
82 ~Render();
84 // Start dialogue box and render interactively.
85 void start_interactive();
86 // Start batch rendering jobs.
87 // A new thread is created and the rendering is interactive.
88 void start_batches(ArrayList<BatchRenderJob*> *jobs);
89 // The batches are processed in the foreground in non interactive mode.
90 void start_batches(ArrayList<BatchRenderJob*> *jobs,
91 BC_Hash *boot_defaults,
92 Preferences *preferences,
93 ArrayList<PluginServer*> *plugindb);
94 // Called by BatchRender to stop the operation.
95 void stop_operation();
96 void run();
99 // Render single job. Used by run.
100 int render(int test_overwrite,
101 Asset *asset,
102 EDL *edl,
103 int strategy);
105 int load_defaults(Asset *asset);
106 int save_defaults(Asset *asset);
107 // force asset parameters regardless of window
108 // This should be integrated into the Asset Class.
109 static int check_asset(EDL *edl, Asset &asset);
110 // Fix strategy to conform with using renderfarm.
111 static int fix_strategy(int strategy, int use_renderfarm);
112 // Force filename to have a 0 padded number if rendering to a list.
113 int check_numbering(Asset &asset);
114 static void create_filename(char *path,
115 char *default_path,
116 int current_number,
117 int total_digits,
118 int number_start);
119 static void get_starting_number(char *path,
120 int &current_number,
121 int &number_start,
122 int &total_digits,
123 int min_digits = 3);
124 int direct_frame_copy(EDL *edl, int64_t &render_video_position, File *file);
125 int direct_copy_possible(EDL *edl,
126 int64_t current_position,
127 Track* playable_track, // The one track which is playable
128 Edit* &playable_edit, // The edit which is playing
129 File *file); // Output file
131 void start_progress();
132 void stop_progress();
134 // Procedure the run function should use.
135 int mode;
136 enum
138 INTERACTIVE,
139 BATCH
141 // When batch rendering is cancelled from the batch dialog
142 int batch_cancelled;
145 int load_mode;
146 int in_progress;
147 // Background compression must be disabled when direct frame copying and reenabled afterwards
148 int direct_frame_copying;
150 CICache *audio_cache, *video_cache;
151 VFrame *compressed_output;
152 MainProgressBar *progress;
153 RenderProgress *render_progress;
154 MWindow *mwindow;
155 PlayableTracks *playable_tracks;
156 PackageDispatcher *packages;
157 Mutex *package_lock, *counter_lock;
158 // Copy of mwindow preferences
159 Preferences *preferences;
160 // For use in non interactive mode
161 ArrayList<PluginServer*> *plugindb;
162 int strategy;
163 // Total selection to render in seconds
164 double total_start, total_end;
165 // External Render farm checks this every frame.
166 int result;
167 Asset *default_asset;
168 TransportCommand *command;
169 // Jobs pointer passed to start_batches
170 ArrayList<BatchRenderJob*> *jobs;
171 // Used by batch rendering to wait until rendering is finished
172 Condition *completion;
175 // Total samples updated by the render farm and the local renderer.
176 // This avoids rounding errors and complies with the use of samples for
177 // timing.
178 int64_t total_rendered;
179 // Speed for the master node
180 double frames_per_second;
181 // Time used in last render
182 double elapsed_time;
184 // Current open RenderWindow
185 RenderWindow *render_window;
187 // For non interactive mode, maintain progress here.
188 int64_t progress_max;
189 Timer *progress_timer;
190 int64_t last_eta;
193 class RenderToTracks;
195 class RenderWindow : public BC_Window
197 public:
198 RenderWindow(MWindow *mwindow, Render *render, Asset *asset);
199 ~RenderWindow();
201 int create_objects();
204 LoadMode *loadmode;
205 FormatTools *format_tools;
207 MWindow *mwindow;
208 Render *render;
209 Asset *asset;
224 #endif