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();
102 class Render : public BC_DialogThread
105 Render(MWindow *mwindow);
108 // Start dialogue box and render interactively.
109 void start_interactive();
110 // Start batch rendering jobs.
111 // A new thread is created and the rendering is interactive.
112 void start_batches(ArrayList<BatchRenderJob*> *jobs);
113 // The batches are processed in the foreground in non interactive mode.
114 void start_batches(ArrayList<BatchRenderJob*> *jobs,
115 BC_Hash *boot_defaults, Preferences *batch_prefs);
116 // Called by BatchRender to stop the operation.
117 void stop_operation();
118 BC_Window* new_gui();
120 void handle_done_event(int result);
121 void handle_close_event(int result);
124 int load_defaults(Asset *asset);
125 int save_defaults(Asset *asset);
126 int load_profile(int profile_slot, Asset *asset);
127 double get_render_range();
128 // force asset parameters regardless of window
129 // This should be integrated into the Asset Class.
130 static int check_asset(EDL *edl, Asset &asset);
131 // strategy to conform with using renderfarm.
132 static int get_strategy(int use_renderfarm, int use_labels);
134 // Force filename to have a 0 padded number if rendering to a list.
135 int check_numbering(Asset &asset);
136 static void create_filename(char *path,
141 static void get_starting_number(char *path,
146 int direct_frame_copy(EDL *edl, int64_t &render_video_position, File *file);
147 int direct_copy_possible(EDL *edl,
148 int64_t current_position,
149 Track* playable_track, // The one track which is playable
150 Edit* &playable_edit, // The edit which is playing
151 File *file); // Output file
153 void start_progress();
154 void stop_progress();
155 void show_progress();
157 // Procedure the run function should use.
164 // When batch rendering is cancelled from the batch dialog
170 // Background compression must be disabled when direct frame copying and reenabled afterwards
171 int direct_frame_copying;
173 Preferences *preferences;
174 VFrame *compressed_output;
175 MainProgressBar *progress;
176 RenderProgress *render_progress;
177 RenderThread *thread;
179 PlayableTracks *playable_tracks;
180 PackageDispatcher *packages;
181 Mutex *package_lock, *counter_lock;
184 // Total selection to render in seconds
185 double total_start, total_end;
186 // External Render farm checks this every frame.
188 Asset *default_asset;
189 // Asset containing the file format
191 // Jobs pointer passed to start_batches
192 ArrayList<BatchRenderJob*> *jobs;
193 // Used by batch rendering to wait until rendering is finished
194 Condition *completion;
196 // Total samples updated by the render farm and the local renderer.
197 // This avoids rounding errors and complies with the use of samples for
199 int64_t total_rendered;
200 // Time used in last render
203 // Current open RenderWindow
204 RenderWindow *render_window;
206 // For non interactive mode, maintain progress here.
207 int64_t progress_max;
208 Timer *progress_timer;
213 class RenderThread : public Thread
216 RenderThread(MWindow *mwindow, Render *render);
221 void render_single(int test_overwrite,
231 class RenderToTracks;
234 class RenderRangeProject : public BC_Radial
237 RenderRangeProject(RenderWindow *rwindow, int value, int x, int y);
239 RenderWindow *rwindow;
242 class RenderRangeSelection : public BC_Radial
245 RenderRangeSelection(RenderWindow *rwindow, int value, int x, int y);
247 RenderWindow *rwindow;
251 class RenderRangeInOut : public BC_Radial
254 RenderRangeInOut(RenderWindow *rwindow, int value, int x, int y);
256 RenderWindow *rwindow;
260 class RenderRange1Frame : public BC_Radial
263 RenderRange1Frame(RenderWindow *rwindow, int value, int x, int y);
265 RenderWindow *rwindow;
269 class RenderFormat : public FormatTools
272 RenderFormat(MWindow *mwindow, BC_WindowBase *window, Asset *asset);
274 void update_format();
278 class RenderWindow : public BC_Window
281 RenderWindow(MWindow *mwindow,
288 void create_objects();
289 void enable_render_range(int v);
290 void update_range_type(int range_type);
291 void load_profile(int profile_slot);
293 RenderRangeProject *rangeproject;
294 RenderRangeSelection *rangeselection;
295 RenderRangeInOut *rangeinout;
296 RenderRange1Frame *range1frame;
298 RenderProfile *renderprofile;
301 RenderFormat *render_format;