4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5 * Copyright (C) 2003-2016 Cinelerra CV contributors
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "batchrender.inc"
30 #include "bitspopup.h"
31 #include "browsebutton.h"
33 #include "compresspopup.h"
34 #include "condition.inc"
37 #include "errorbox.inc"
39 #include "formatpopup.inc"
40 #include "formattools.h"
42 #include "loadmode.inc"
43 #include "mainprogress.inc"
44 #include "maxchannels.h"
46 #include "mwindow.inc"
47 #include "packagedispatcher.inc"
48 #include "packagerenderer.h"
49 #include "playabletracks.inc"
50 #include "preferences.inc"
51 #include "bcprogressbox.inc"
54 #include "transportque.inc"
56 #include "renderprofiles.inc"
59 class RenderItem : public BC_MenuItem
62 RenderItem(MWindow *mwindow);
67 class RenderProgress : public Thread
70 RenderProgress(MWindow *mwindow, Render *render);
84 class MainPackageRenderer : public PackageRenderer
87 MainPackageRenderer(Render *render);
88 ~MainPackageRenderer();
93 void set_result(int value);
94 void set_progress(int64_t value);
95 int progress_cancelled();
102 class RenderAssets : public ArrayList<Indexable *>
111 class Render : public BC_DialogThread
114 Render(MWindow *mwindow);
117 // Start dialogue box and render interactively.
118 void start_interactive();
119 // Start batch rendering jobs.
120 // A new thread is created and the rendering is interactive.
121 void start_batches(ArrayList<BatchRenderJob*> *jobs);
122 // The batches are processed in the foreground in non interactive mode.
123 void start_batches(ArrayList<BatchRenderJob*> *jobs,
124 BC_Hash *boot_defaults, Preferences *batch_prefs);
125 // Called by BatchRender to stop the operation.
126 void stop_operation();
127 BC_Window* new_gui();
129 void handle_done_event(int result);
130 void handle_close_event(int result);
133 int load_defaults(Asset *asset);
134 int save_defaults(Asset *asset);
135 int load_profile(int profile_slot, Asset *asset);
136 double get_render_range();
137 // force asset parameters regardless of window
138 // This should be integrated into the Asset Class.
139 static int check_asset(EDL *edl, Asset &asset);
140 // strategy to conform with using renderfarm.
141 static int get_strategy(int use_renderfarm, int use_labels, int range_type);
143 // Force filename to have a 0 padded number if rendering to a list.
144 int check_numbering(Asset &asset);
145 static void create_filename(char *path,
150 static void get_starting_number(char *path,
155 int direct_frame_copy(EDL *edl, int64_t &render_video_position, File *file);
156 int direct_copy_possible(EDL *edl,
157 int64_t current_position,
158 Track* playable_track, // The one track which is playable
159 Edit* &playable_edit, // The edit which is playing
160 File *file); // Output file
162 void start_progress();
163 void stop_progress();
164 void show_progress();
165 void update_assets();
167 // Procedure the run function should use.
174 // When batch rendering is cancelled from the batch dialog
180 // Background compression must be disabled when direct frame copying and reenabled afterwards
181 int direct_frame_copying;
185 Preferences *preferences;
186 VFrame *compressed_output;
187 MainProgressBar *progress;
188 RenderProgress *render_progress;
189 RenderThread *thread;
192 PlayableTracks *playable_tracks;
193 PackageDispatcher *packages;
194 Mutex *package_lock, *counter_lock;
197 // Total selection to render in seconds
198 double total_start, total_end;
199 // External Render farm checks this every frame.
201 Asset *default_asset;
202 // Asset containing the file format
204 // Jobs pointer passed to start_batches
205 ArrayList<BatchRenderJob*> *jobs;
206 // Used by batch rendering to wait until rendering is finished
207 Condition *completion;
209 // Total samples updated by the render farm and the local renderer.
210 // This avoids rounding errors and complies with the use of samples for
212 int64_t total_rendered;
213 // Time used in last render
216 // Current open RenderWindow
217 RenderWindow *render_window;
219 // For non interactive mode, maintain progress here.
220 int64_t progress_max;
221 Timer *progress_timer;
226 class RenderThread : public Thread
229 RenderThread(MWindow *mwindow, Render *render);
234 void render_single(int test_overwrite,
242 int64_t render_frames;
245 class RenderToTracks;
248 class RenderRangeProject : public BC_Radial
251 RenderRangeProject(RenderWindow *rwindow, int value, int x, int y);
253 RenderWindow *rwindow;
256 class RenderRangeSelection : public BC_Radial
259 RenderRangeSelection(RenderWindow *rwindow, int value, int x, int y);
261 RenderWindow *rwindow;
265 class RenderRangeInOut : public BC_Radial
268 RenderRangeInOut(RenderWindow *rwindow, int value, int x, int y);
270 RenderWindow *rwindow;
274 class RenderRange1Frame : public BC_Radial
277 RenderRange1Frame(RenderWindow *rwindow, int value, int x, int y);
279 RenderWindow *rwindow;
283 class RenderFormat : public FormatTools
286 RenderFormat(MWindow *mwindow, BC_WindowBase *window, Asset *asset);
288 void update_format();
293 class RenderBeepOnDone : public BC_FPot
296 RenderBeepOnDone(RenderWindow *rwindow, int x, int y);
299 RenderWindow *rwindow;
303 class RenderWindow : public BC_Window
306 RenderWindow(MWindow *mwindow,
313 void create_objects();
314 void enable_render_range(int v);
315 void update_range_type(int range_type);
316 void load_profile(int profile_slot);
318 RenderRangeProject *rangeproject;
319 RenderRangeSelection *rangeselection;
320 RenderRangeInOut *rangeinout;
321 RenderRange1Frame *range1frame;
322 RenderBeepOnDone *beep_on_done;
324 RenderProfile *renderprofile;
327 BC_Title *file_format;
328 RenderFormat *render_format;