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