add Autosave continuous backups by Andras Reuss and Andrew-R
[goodguy/cinelerra.git] / cinelerra-5.1 / cinelerra / asset.h
1 /*
2  * CINELERRA
3  * Copyright (C) 2010 Adam Williams <broadcast at earthling dot net>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  *
19  */
20
21 #ifndef ASSET_H
22 #define ASSET_H
23
24 #include <stdio.h>
25 #include <stdint.h>
26
27 #include "arraylist.h"
28 #include "bcwindowbase.inc"
29 #include "bchash.inc"
30 #include "edl.inc"
31 #include "filexml.inc"
32 #include "indexable.h"
33 #include "indexfile.inc"
34 #include "indexstate.inc"
35 #include "linklist.h"
36 #include "pluginserver.inc"
37
38
39 class Asset : public Indexable, public ListItem<Asset>
40 {
41 public:
42         Asset();
43         Asset(Asset &asset);
44         Asset(const char *path);
45         Asset(const int plugin_type, const char *plugin_path);
46         ~Asset();
47
48         int init_values();
49         int dump(FILE *fp=stdout);
50         void boundaries();
51
52         void copy_from(Asset *asset, int do_index);
53         void copy_location(Asset *asset);
54         void copy_format(Asset *asset, int do_index = 1);
55         void copy_index(Asset *asset);
56         int64_t get_index_offset(int channel);
57         int64_t get_index_size(int channel);
58 // Get an english description of the compression.  Used by AssetEdit
59         char* get_compression_text(int audio, int video);
60
61 // Load and save parameters for a render dialog
62 // Used by render, record, menueffects, preferences
63         void load_defaults(BC_Hash *defaults,
64                 const char *prefix /* = 0 */,
65                 int do_format /* = 0 */,
66                 int do_compression,
67                 int do_path,
68                 int do_data_types,
69                 int do_bits);
70         void save_defaults(BC_Hash *defaults,
71                 const char *prefix /* = 0 */,
72                 int do_format,     /* Don't save format which is autodetected by file loader */
73                 int do_compression,    /* Don't save compression which is fixed by driver */
74                 int do_path,
75                 int do_data_types,
76                 int do_bits);
77         char* construct_param(const char *param, const char *prefix, char *return_value);
78
79
80
81
82 // Executed during index building only
83         int equivalent(Asset &asset, int test_audio, int test_video, EDL *edl=0);
84 // Return 1 if the paths match
85         int test_path(const char *path);
86         int read(FileXML *file,
87                 int expand_relative = 1);
88         int read_audio(FileXML *xml);
89         int read_video(FileXML *xml);
90         int read_format(FileXML *xml);
91         int read_index(FileXML *xml);
92         void reset_audio();
93         void reset_video();
94
95 // Output path is the path of the output file if name truncation is desired.
96 // It is a "" if; complete names should be used.
97         int write(FileXML *file, int include_index, const char *output_path);
98
99 // For Indexable
100         int get_audio_channels();
101         int get_sample_rate();
102         int64_t get_audio_samples();
103         int have_audio();
104         int have_video();
105         int get_w();
106         int get_h();
107         double get_frame_rate();
108         int get_video_layers();
109         int64_t get_video_frames();
110         int get_program();
111         void write_index(char *path, int data_bytes);
112
113 // Necessary for renderfarm to get encoding parameters
114         int write_audio(FileXML *xml);
115         int write_video(FileXML *xml);
116         int write_index(FileXML *xml);
117
118         double total_length_framealigned(double fps);
119
120 // Format of file.  An enumeration from file.inc.
121         int format;
122
123 // contains audio data
124         int audio_data;
125         int channels;
126         int sample_rate;
127         int bits;
128         int byte_order;
129         int signed_;
130         int header;
131         int dither;
132 // String or FourCC describing compression
133         char acodec[BCTEXTLEN];
134
135         int64_t audio_length;
136
137 // contains video data, single frame data set
138         int video_data, single_frame;
139         int layers, program;
140         double frame_rate;
141
142         int actual_width, actual_height;
143         int width, height;
144 // scale factor or 0 if not proxy, proxy_edl if proxyed from nested_edl
145         int proxy_scale, proxy_edl;
146 // String or FourCC describing compression
147         char vcodec[BCTEXTLEN];
148
149 // Length in frames
150 // -1 means a still photo
151         int64_t video_length;
152 // timecode, unknown=-2, no timecode=-1, timecode>=0 
153         double timecode;
154
155 // mp3 compression
156         int mp3_bitrate;
157
158 // mpeg audio information
159         int ampeg_bitrate;
160 // 2 - 3
161         int ampeg_derivative;
162
163 // Vorbis compression
164         int vorbis_min_bitrate;
165         int vorbis_bitrate;
166         int vorbis_max_bitrate;
167         int vorbis_vbr;
168
169 // Theora compression
170         int theora_fix_bitrate;
171         int theora_bitrate;
172         int theora_quality;
173         int theora_sharpness;
174         int theora_keyframe_frequency;
175         int theora_keyframe_force_frequency;
176
177
178 // Set by package render during file creation. -1 means square pixels.
179         double aspect_ratio;
180
181 // for the interlace mode
182         int interlace_mode;
183 // for jpeg compression
184         int jpeg_quality;
185
186
187 // for mpeg video compression
188         int vmpeg_iframe_distance;
189         int vmpeg_progressive;
190         int vmpeg_denoise;
191         int vmpeg_seq_codes;
192         int vmpeg_bitrate;
193 // 1 - 2
194         int vmpeg_derivative;
195         int vmpeg_quantization;
196         int vmpeg_cmodel;
197         int vmpeg_fix_bitrate;
198
199 // mjpegtools
200         int vmpeg_preset;
201 // top field first
202         int vmpeg_field_order;
203         int vmpeg_pframe_distance;
204
205 // ffmpeg
206         char fformat[BCSTRLEN];
207         char ff_format_options[BCTEXTLEN];
208         char ff_video_options[BCTEXTLEN];
209         char ff_pixel_format[BCSTRLEN];
210         int ff_video_bitrate, ff_video_quality;
211         int ff_color_space, ff_color_range;
212         char ff_audio_options[BCTEXTLEN];
213         char ff_sample_format[BCSTRLEN];
214         int ff_audio_bitrate, ff_audio_quality;
215
216 // PNG video compression
217         int png_use_alpha;
218         int png_depth;
219         int png_compression;
220 // EXR video compression
221         int exr_use_alpha;
222         int exr_compression;
223
224 // TIFF video compression.  An enumeration from filetiff.h
225         int tiff_cmodel;
226         int tiff_compression;
227
228         int ac3_bitrate;
229
230 // Insert tag for spherical playback
231         int mov_sphere, jpeg_sphere;
232
233 // Image file sequences.  Background rendering doesn't want to write a
234 // sequence header but instead wants to start the sequence numbering at a certain
235 // number.  This ensures deletion of all the frames which aren't being used.
236 // We still want sequence headers sometimes because loading a directory full of images
237 // for editing would create new assets for every image.
238         int use_header;
239 };
240
241
242 #endif