initial commit
[goodguy/history.git] / cinelerra-5.0 / 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 "filexml.inc"
31 #include "indexable.h"
32 #include "indexfile.inc"
33 #include "linklist.h"
34 #include "pluginserver.inc"
35
36
37
38 class Asset : public Indexable, public ListItem<Asset>
39 {
40 public:
41         Asset();
42         Asset(Asset &asset);
43         Asset(const char *path);
44         Asset(const int plugin_type, const char *plugin_path);
45         ~Asset();
46
47         int init_values();
48         int dump(FILE *fp=stdout);
49         void boundaries();
50
51         void copy_from(Asset *asset, int do_index);
52         void copy_location(Asset *asset);
53         void copy_format(Asset *asset, int do_index = 1);
54         void copy_index(Asset *asset);
55         int64_t get_index_offset(int channel);
56         int64_t get_index_size(int channel);
57 // Get an english description of the compression.  Used by AssetEdit
58         char* get_compression_text(int audio, int video);
59
60 // Load and save parameters for a render dialog
61 // Used by render, record, menueffects, preferences
62         void load_defaults(BC_Hash *defaults, 
63                 const char *prefix /* = 0 */, 
64                 int do_format /* = 0 */,
65                 int do_compression,
66                 int do_path,
67                 int do_data_types,
68                 int do_bits);
69         void save_defaults(BC_Hash *defaults, 
70                 const char *prefix /* = 0 */,
71                 int do_format,     /* Don't save format which is autodetected by file loader */
72                 int do_compression,    /* Don't save compression which is fixed by driver */
73                 int do_path,
74                 int do_data_types,
75                 int do_bits);
76         const char* construct_param(const char *param, const char *prefix, char *return_value);
77
78
79
80
81 // Executed during index building only
82         void update_index(Asset *asset);
83         int equivalent(Asset &asset, 
84                 int test_audio, 
85                 int test_video);
86         Asset& operator=(Asset &asset);
87         int operator==(Asset &asset);
88         int operator!=(Asset &asset);
89 // Return 1 if the paths match
90         int test_path(const char *path);
91         int test_plugin_title(const char *path);
92         int read(FileXML *file, 
93                 int expand_relative = 1);
94         int read_audio(FileXML *xml);
95         int read_video(FileXML *xml);
96         int read_index(FileXML *xml);
97         void reset_audio();
98         void reset_video();
99         void reset_index();  // When the index file is wrong, reset the asset values
100         int reset_timecode();
101
102 // Output path is the path of the output file if name truncation is desired.
103 // It is a "" if; complete names should be used.
104         int write(FileXML *file, 
105                 int include_index, 
106                 const char *output_path);
107 // Write the index data and asset info.  Used by IndexThread.
108         int write_index(const char *path, int data_bytes);
109
110
111 // For Indexable
112         int get_audio_channels();
113         int get_sample_rate();
114         int64_t get_audio_samples();
115         int have_audio();
116         int have_video();
117         int get_w();
118         int get_h();
119         double get_frame_rate();
120         int get_video_layers();
121         int64_t get_video_frames();
122         int get_program();
123
124
125 // Necessary for renderfarm to get encoding parameters
126         int write_audio(FileXML *xml);
127         int write_video(FileXML *xml);
128         int write_index(FileXML *xml);
129         int update_path(char *new_path);
130
131
132
133 // Format of file.  An enumeration from file.inc.
134         int format;
135
136 // contains audio data
137         int audio_data;
138         int channels;
139         int sample_rate;
140         int bits;
141         int byte_order;
142         int signed_;
143         int header;
144         int dither;
145 // String or FourCC describing compression
146         char acodec[BCTEXTLEN];
147
148         int64_t audio_length;
149
150 // Timecode information. User setable, in case of errors in source
151         char reel_name[BCTEXTLEN];
152         int reel_number;
153         int64_t tcstart;
154         int64_t tcend;
155         int tcformat;
156
157 // contains video data
158         int video_data;       
159         int layers, program;
160         double frame_rate;
161         int actual_width, actual_height;
162         int width, height;
163 // String or FourCC describing compression
164         char vcodec[BCTEXTLEN];
165
166 // Length in frames
167         int64_t video_length;
168
169
170
171 // mpeg audio information
172         int ampeg_bitrate;
173 // 2 - 3
174         int ampeg_derivative;
175
176 // Vorbis compression
177         int vorbis_min_bitrate;
178         int vorbis_bitrate;
179         int vorbis_max_bitrate;
180         int vorbis_vbr;
181
182 // Theora compression
183         int theora_fix_bitrate;
184         int theora_bitrate;
185         int theora_quality;
186         int theora_sharpness;
187         int theora_keyframe_frequency;
188         int theora_keyframe_force_frequency;
189
190
191 // mp3 compression
192         int mp3_bitrate;
193
194 // mp4a compression
195         int mp4a_bitrate;
196         int mp4a_quantqual;
197
198
199 // Set by package render during file creation. -1 means square pixels.
200         double aspect_ratio;
201
202 // for jpeg compression
203         int jpeg_quality;     
204
205 // for mpeg video compression
206         int vmpeg_iframe_distance;
207         int vmpeg_progressive;
208         int vmpeg_denoise;
209         int vmpeg_seq_codes;
210         int vmpeg_bitrate;
211 // 1 - 2
212         int vmpeg_derivative;
213         int vmpeg_quantization;
214         int vmpeg_cmodel;
215         int vmpeg_fix_bitrate;
216
217 // mjpegtools
218         int vmpeg_preset;
219 // top field first
220         int vmpeg_field_order;
221         int vmpeg_pframe_distance;
222
223
224
225
226
227
228
229
230 // Divx video compression
231         int divx_bitrate;
232         int divx_rc_period;
233         int divx_rc_reaction_ratio;
234         int divx_rc_reaction_period;
235         int divx_max_key_interval;
236         int divx_max_quantizer;
237         int divx_min_quantizer;
238         int divx_quantizer;
239         int divx_quality;
240         int divx_fix_bitrate;
241
242 // h264 video compression
243         int h264_bitrate;
244         int h264_quantizer;
245         int h264_fix_bitrate;
246
247 // Divx video decompression
248         int divx_use_deblocking;
249
250 // PNG video compression
251         int png_use_alpha;
252
253 // EXR video compression
254         int exr_use_alpha;
255         int exr_compression;
256
257 // TIFF video compression.  An enumeration from filetiff.h
258         int tiff_cmodel;
259         int tiff_compression;
260
261 // Microsoft MPEG-4
262         int ms_bitrate;
263         int ms_bitrate_tolerance;
264         int ms_interlaced;
265         int ms_quantization;
266         int ms_gop_size;
267         int ms_fix_bitrate;
268
269
270         int ac3_bitrate;
271
272         char pipe[BCTEXTLEN];
273         int use_pipe;
274
275 // Image file sequences.  Background rendering doesn't want to write a 
276 // sequence header but instead wants to start the sequence numbering at a certain
277 // number.  This ensures deletion of all the frames which aren't being used.
278 // We still want sequence headers sometimes because loading a directory full of images
279 // for editing would create new assets for every image.
280         int use_header;
281
282
283 };
284
285
286 #endif