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