4 * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include "batchrender.inc"
29 #include "bitspopup.h"
30 #include "browsebutton.h"
32 #include "compresspopup.h"
33 #include "condition.inc"
36 #include "errorbox.inc"
38 #include "formatpopup.inc"
39 #include "formattools.h"
41 #include "loadmode.inc"
42 #include "mainprogress.inc"
43 #include "maxchannels.h"
45 #include "mwindow.inc"
46 #include "packagedispatcher.inc"
47 #include "packagerenderer.h"
48 #include "playabletracks.inc"
49 #include "preferences.inc"
50 #include "bcprogressbox.inc"
53 #include "transportque.inc"
55 #include "renderprofiles.inc"
58 class RenderItem : public BC_MenuItem
61 RenderItem(MWindow *mwindow);
66 class RenderProgress : public Thread
69 RenderProgress(MWindow *mwindow, Render *render);
83 class MainPackageRenderer : public PackageRenderer
86 MainPackageRenderer(Render *render);
87 ~MainPackageRenderer();
92 void set_result(int value);
93 void set_progress(int64_t value);
94 int progress_cancelled();
101 class RenderAssets : public ArrayList<Indexable *>
110 class Render : public BC_DialogThread
113 Render(MWindow *mwindow);
116 // Start dialogue box and render interactively.
117 void start_interactive();
118 // Start batch rendering jobs.
119 // A new thread is created and the rendering is interactive.
120 void start_batches(ArrayList<BatchRenderJob*> *jobs);
121 // The batches are processed in the foreground in non interactive mode.
122 void start_batches(ArrayList<BatchRenderJob*> *jobs,
123 BC_Hash *boot_defaults, Preferences *batch_prefs);
124 // Called by BatchRender to stop the operation.
125 void stop_operation();
126 BC_Window* new_gui();
128 void handle_done_event(int result);
129 void handle_close_event(int result);
132 int load_defaults(Asset *asset);
133 int save_defaults(Asset *asset);
134 int load_profile(int profile_slot, Asset *asset);
135 double get_render_range();
136 // force asset parameters regardless of window
137 // This should be integrated into the Asset Class.
138 static int check_asset(EDL *edl, Asset &asset);
139 // strategy to conform with using renderfarm.
140 static int get_strategy(int use_renderfarm, int use_labels, int range_type);
142 // Force filename to have a 0 padded number if rendering to a list.
143 int check_numbering(Asset &asset);
144 static void create_filename(char *path,
149 static void get_starting_number(char *path,
154 int direct_frame_copy(EDL *edl, int64_t &render_video_position, File *file);
155 int direct_copy_possible(EDL *edl,
156 int64_t current_position,
157 Track* playable_track, // The one track which is playable
158 Edit* &playable_edit, // The edit which is playing
159 File *file); // Output file
161 void start_progress();
162 void stop_progress();
163 void show_progress();
164 void update_assets();
166 // Procedure the run function should use.
173 // When batch rendering is cancelled from the batch dialog
179 // Background compression must be disabled when direct frame copying and reenabled afterwards
180 int direct_frame_copying;
184 Preferences *preferences;
185 VFrame *compressed_output;
186 MainProgressBar *progress;
187 RenderProgress *render_progress;
188 RenderThread *thread;
191 PlayableTracks *playable_tracks;
192 PackageDispatcher *packages;
193 Mutex *package_lock, *counter_lock;
196 // Total selection to render in seconds
197 double total_start, total_end;
198 // External Render farm checks this every frame.
200 Asset *default_asset;
201 // Asset containing the file format
203 // Jobs pointer passed to start_batches
204 ArrayList<BatchRenderJob*> *jobs;
205 // Used by batch rendering to wait until rendering is finished
206 Condition *completion;
208 // Total samples updated by the render farm and the local renderer.
209 // This avoids rounding errors and complies with the use of samples for
211 int64_t total_rendered;
212 // Time used in last render
215 // Current open RenderWindow
216 RenderWindow *render_window;
218 // For non interactive mode, maintain progress here.
219 int64_t progress_max;
220 Timer *progress_timer;
225 class RenderThread : public Thread
228 RenderThread(MWindow *mwindow, Render *render);
233 void render_single(int test_overwrite,
241 int64_t render_frames;
244 class RenderToTracks;
247 class RenderRangeProject : public BC_Radial
250 RenderRangeProject(RenderWindow *rwindow, int value, int x, int y);
252 RenderWindow *rwindow;
255 class RenderRangeSelection : public BC_Radial
258 RenderRangeSelection(RenderWindow *rwindow, int value, int x, int y);
260 RenderWindow *rwindow;
264 class RenderRangeInOut : public BC_Radial
267 RenderRangeInOut(RenderWindow *rwindow, int value, int x, int y);
269 RenderWindow *rwindow;
273 class RenderRange1Frame : public BC_Radial
276 RenderRange1Frame(RenderWindow *rwindow, int value, int x, int y);
278 RenderWindow *rwindow;
282 class RenderFormat : public FormatTools
285 RenderFormat(MWindow *mwindow, BC_WindowBase *window, Asset *asset);
287 void update_format();
292 class RenderBeepOnDone : public BC_FPot
295 RenderBeepOnDone(RenderWindow *rwindow, int x, int y);
298 RenderWindow *rwindow;
302 class RenderWindow : public BC_Window
305 RenderWindow(MWindow *mwindow,
312 void create_objects();
313 void enable_render_range(int v);
314 void update_range_type(int range_type);
315 void load_profile(int profile_slot);
317 RenderRangeProject *rangeproject;
318 RenderRangeSelection *rangeselection;
319 RenderRangeInOut *rangeinout;
320 RenderRange1Frame *range1frame;
321 RenderBeepOnDone *beep_on_done;
323 RenderProfile *renderprofile;
326 BC_Title *file_format;
327 RenderFormat *render_format;