allow ffmpeg video to resample curr_pos, add bluray format
[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 // contains video data
151         int video_data;       
152         int layers, program;
153         double frame_rate;
154         int actual_width, actual_height;
155         int width, height;
156 // String or FourCC describing compression
157         char vcodec[BCTEXTLEN];
158
159 // Length in frames
160         int64_t video_length;
161
162
163
164 // mpeg audio information
165         int ampeg_bitrate;
166 // 2 - 3
167         int ampeg_derivative;
168
169 // Vorbis compression
170         int vorbis_min_bitrate;
171         int vorbis_bitrate;
172         int vorbis_max_bitrate;
173         int vorbis_vbr;
174
175 // Theora compression
176         int theora_fix_bitrate;
177         int theora_bitrate;
178         int theora_quality;
179         int theora_sharpness;
180         int theora_keyframe_frequency;
181         int theora_keyframe_force_frequency;
182
183
184 // mp3 compression
185         int mp3_bitrate;
186
187 // mp4a compression
188         int mp4a_bitrate;
189         int mp4a_quantqual;
190
191
192 // Set by package render during file creation. -1 means square pixels.
193         double aspect_ratio;
194
195 // for jpeg compression
196         int jpeg_quality;     
197
198 // for mpeg video compression
199         int vmpeg_iframe_distance;
200         int vmpeg_progressive;
201         int vmpeg_denoise;
202         int vmpeg_seq_codes;
203         int vmpeg_bitrate;
204 // 1 - 2
205         int vmpeg_derivative;
206         int vmpeg_quantization;
207         int vmpeg_cmodel;
208         int vmpeg_fix_bitrate;
209
210 // mjpegtools
211         int vmpeg_preset;
212 // top field first
213         int vmpeg_field_order;
214         int vmpeg_pframe_distance;
215
216 // ffmpeg muxer file extension
217         char fformat[BCSTRLEN];
218         char ff_audio_options[BCTEXTLEN];
219         char ff_video_options[BCTEXTLEN];
220         int ff_audio_bitrate;
221         int ff_video_bitrate;
222         int ff_video_quality;
223
224 // Divx video compression
225         int divx_bitrate;
226         int divx_rc_period;
227         int divx_rc_reaction_ratio;
228         int divx_rc_reaction_period;
229         int divx_max_key_interval;
230         int divx_max_quantizer;
231         int divx_min_quantizer;
232         int divx_quantizer;
233         int divx_quality;
234         int divx_fix_bitrate;
235
236 // h264 video compression
237         int h264_bitrate;
238         int h264_quantizer;
239         int h264_fix_bitrate;
240
241 // Divx video decompression
242         int divx_use_deblocking;
243
244 // PNG video compression
245         int png_use_alpha;
246
247 // EXR video compression
248         int exr_use_alpha;
249         int exr_compression;
250
251 // TIFF video compression.  An enumeration from filetiff.h
252         int tiff_cmodel;
253         int tiff_compression;
254
255 // Microsoft MPEG-4
256         int ms_bitrate;
257         int ms_bitrate_tolerance;
258         int ms_interlaced;
259         int ms_quantization;
260         int ms_gop_size;
261         int ms_fix_bitrate;
262
263
264         int ac3_bitrate;
265
266 // Image file sequences.  Background rendering doesn't want to write a 
267 // sequence header but instead wants to start the sequence numbering at a certain
268 // number.  This ensures deletion of all the frames which aren't being used.
269 // We still want sequence headers sometimes because loading a directory full of images
270 // for editing would create new assets for every image.
271         int use_header;
272
273
274 };
275
276
277 #endif