yuv colorspace/range + prefs, ffmpeg colorrange probe, x11 direct force colormodel...
[goodguy/history.git] / cinelerra-5.1 / cinelerra / edl.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  *
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.
10  *
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.
15  *
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
19  *
20  */
21
22 #ifndef EDL_H
23 #define EDL_H
24
25 #include <stdio.h>
26 #include <stdint.h>
27
28 #include "asset.inc"
29 #include "assets.inc"
30 #include "autoconf.inc"
31 #include "bchash.inc"
32 #include "edit.inc"
33 #include "edits.inc"
34 #include "edl.inc"
35 #include "edlsession.inc"
36 #include "filexml.inc"
37 #include "indexable.h"
38 #include "indexstate.inc"
39 #include "labels.inc"
40 #include "localsession.inc"
41 #include "maxchannels.h"
42 #include "mutex.inc"
43 #include "nestededls.inc"
44 #include "playabletracks.inc"
45 #include "playbackconfig.h"
46 #include "pluginserver.h"
47 #include "preferences.inc"
48 #include "recordlabel.inc"
49 #include "sharedlocation.inc"
50 #include "theme.inc"
51 #include "tracks.inc"
52 #include "vedit.inc"
53 #include "zwindow.h"
54
55 // Loading and saving are built on load and copy except for automation:
56
57 // Storage:
58 // Load: load new -> paste into master
59 // Save: copy all of master
60 // Undo: selective load into master
61 // Copy: copy from master
62 // Paste: load new -> paste into master
63 // Copy automation: copy just automation from master
64 // Paste automation: paste functions in automation
65
66
67 class EDL : public Indexable
68 {
69 public:
70         EDL(EDL *parent_edl = 0);
71         ~EDL();
72
73         void create_objects();
74         EDL& operator=(EDL &edl);
75
76 // Load configuration and track counts
77         int load_defaults(BC_Hash *defaults);
78         int save_defaults(BC_Hash *defaults);
79 // Clip default settings to boundaries.
80         void boundaries();
81 // Create tracks using existing configuration
82         int create_default_tracks();
83         int load_xml(FileXML *file,
84                 uint32_t load_flags);
85         int save_xml(FileXML *xml,
86                 const char *output_path,
87                 int is_clip,
88                 int is_vwindow);
89     int load_audio_config(FileXML *file, int append_mode, uint32_t load_flags);
90     int load_video_config(FileXML *file, int append_mode, uint32_t load_flags);
91
92 // Return 1 if rendering requires a virtual console.
93         int get_use_vconsole(VEdit* *playable_edit,
94                 int64_t position,
95                 int direction,
96                 PlayableTracks *playable_tracks);
97
98 // Convert position to frame boundry times
99         double frame_align(double position, int round);
100 // frame align if cursor alignment is enabled
101         double align_to_frame(double position, int round);
102
103 // increase track w/h to at least session w/h
104         void retrack();
105 // Scale all sample values since everything is locked to audio
106         void rechannel();
107         void resample(double old_rate, double new_rate, int data_type);
108         void copy_tracks(EDL *edl);
109 // Copies project path, folders, EDLSession, and LocalSession from edl argument.
110 // session_only - used by preferences and format specify
111 // whether to only copy EDLSession
112         void copy_session(EDL *edl, int session_only = 0);
113         int copy_all(EDL *edl);
114         void copy_assets(EDL *edl);
115         void copy_clips(EDL *edl);
116         void copy_mixers(EDL *edl);
117 // Copy pan and fade settings from edl
118         void synchronize_params(EDL *edl);
119 // Determine if the positions are equivalent if they're within half a frame
120 // of each other.
121         int equivalent(double position1, double position2);
122 // Determine if the EDL's produce equivalent video output to the old EDL.
123 // The new EDL is this and the old EDL is the argument.
124 // Return the number of seconds from the beginning of this which are
125 // equivalent to the argument.
126 // If they're completely equivalent, -1 is returned;
127 // This is used by BRender + BatchRender.
128         double equivalent_output(EDL *edl);
129 // Set project path for filename prefixes in the assets
130         void set_path(const char *path);
131 // Set points and labels
132         void set_inpoint(double position);
133         void set_outpoint(double position);
134         void unset_inoutpoint();
135 // Redraw resources during index builds
136         void set_index_file(Indexable *indexable);
137 // Add assets from the src to the destination
138         void update_assets(EDL *src);
139         void optimize();
140 // return next/prev edit starting from position
141         double next_edit(double position);
142         double prev_edit(double position);
143 // Debug
144         int dump(FILE *fp=stdout);
145         static int next_id();
146 // Create a new folder if it doesn't exist already
147         void new_folder(const char *folder);
148         void delete_folder(const char *folder);
149         void modify_edithandles(double oldposition,
150                 double newposition,
151                 int currentend,
152                 int handle_mode,
153                 int edit_labels,
154                 int edit_plugins,
155                 int edit_autos);
156
157         void modify_pluginhandles(double oldposition,
158                 double newposition,
159                 int currentend,
160                 int handle_mode,
161                 int edit_labels,
162                 int edit_autos,
163                 Edits *trim_edits);
164
165         int trim_selection(double start,
166                 double end,
167                 int edit_labels,
168                 int edit_plugins,
169                 int edit_autos);
170
171 // Editing functions
172         int copy_assets(double start,
173                 double end,
174                 FileXML *file,
175                 int all,
176                 const char *output_path);
177         int copy(double start,
178                 double end,
179                 int all,   // Ignore recordable status of tracks for saving
180                 int is_clip,
181                 int is_vwindow,
182                 FileXML *file,
183                 const char *output_path,
184                 int rewind_it);     // Rewind EDL for easy pasting
185         void paste_silence(double start,
186                 double end,
187                 int edit_labels /* = 1 */,
188                 int edit_plugins,
189                 int edit_autos);
190         void remove_from_project(ArrayList<Indexable*> *assets);
191         void remove_from_project(ArrayList<EDL*> *clips);
192         int blade(double position);
193         int clear(double start,
194                 double end,
195                 int clear_labels,
196                 int clear_plugins,
197                 int edit_autos);
198         void deglitch(double position);
199 // Insert the asset at a point in the EDL
200         void insert_asset(Asset *asset,
201                 EDL *nested_edl,
202                 double position,
203                 Track *first_track = 0,
204                 RecordLabels *labels = 0);
205 // Insert the clip at a point in the EDL
206         int insert_clips(ArrayList<EDL*> *new_edls, int load_mode, Track *first_track = 0);
207 // Add a copy of EDL* to the clip array.  Returns the copy.
208         EDL* add_clip(EDL *edl);
209
210         void get_shared_plugins(Track *source, ArrayList<SharedLocation*> *plugin_locations,
211                 int omit_recordable, int data_type);
212         void get_shared_tracks(Track *track, ArrayList<SharedLocation*> *module_locations,
213                 int omit_recordable, int data_type);
214
215     int get_tracks_height(Theme *theme);
216     int64_t get_tracks_width();
217 // Return dimensions for canvas if smaller dimensions has zoom of 1
218         void calculate_conformed_dimensions(int single_channel, float &w, float &h);
219 // Get the total output size scaled to aspect ratio
220         void output_dimensions_scaled(int &w, int &h);
221         float get_aspect_ratio();
222
223
224 // For Indexable
225         int get_audio_channels();
226         int get_sample_rate();
227         int64_t get_audio_samples();
228         int have_audio();
229         int have_video();
230         int get_w();
231         int get_h();
232         double get_frame_rate();
233         int get_video_layers();
234         int64_t get_video_frames();
235
236         EDL* get_vwindow_edl(int number);
237         int total_vwindow_edls();
238         void remove_vwindow_edls();
239         void remove_vwindow_edl(EDL *edl);
240 // Adds to list of EDLs & increase garbage collection counter
241 // Does nothing if EDL already exists
242         void append_vwindow_edl(EDL *edl, int increase_counter);
243
244 // Titles of all subfolders
245         ArrayList<char*> folders;
246 // Clips
247         ArrayList<EDL*> clips;
248 // Nested EDLs
249         NestedEDLs *nested_edls;
250 // EDLs being shown in VWindows
251         ArrayList<EDL*> vwindow_edls;
252 // is the vwindow_edl shared and therefore should not be deleted in destructor
253 //      int vwindow_edl_shared;
254         Mixers mixers;
255
256 // Media files
257 // Shared between all EDLs
258         Assets *assets;
259
260
261
262         Tracks *tracks;
263         Labels *labels;
264 // Shared between all EDLs in a tree, for projects.
265         EDLSession *session;
266 // Specific to this EDL, for clips.
267         LocalSession *local_session;
268
269
270
271
272
273
274 // Use parent Assets if nonzero
275         EDL *parent_edl;
276
277
278         static Mutex *id_lock;
279
280 };
281
282 #endif