r999: maintainers added to README_en.
[cinelerra_cv/mob.git] / cinelerra / filemov.h
blob661dd33f6efd8ba5a60e6b8c3ac691c71825d9c4
1 #ifndef FILEMOV_H
2 #define FILEMOV_H
4 #include "bitspopup.inc"
5 #include "condition.inc"
6 #include "filebase.h"
7 #include "file.inc"
9 #ifdef HAVE_STDLIB_H
10 #undef HAVE_STDLIB_H
11 #endif
13 #include "libmjpeg.h"
14 #include "mutex.inc"
15 #include "quicktime.h"
16 #include "thread.h"
18 class FileMOVThread;
20 class ThreadStruct
22 public:
23 ThreadStruct();
24 ~ThreadStruct();
26 void load_output(mjpeg_t *mjpeg);
28 VFrame *input;
29 unsigned char *output; // Output buffer
30 int64_t output_size; // Size of output buffer
31 int64_t output_allocated; // Allocation of output buffer
32 Condition *completion_lock;
35 class FileMOV : public FileBase
37 public:
38 FileMOV(Asset *asset, File *file);
39 ~FileMOV();
41 friend class FileMOVThread;
43 static void get_parameters(BC_WindowBase *parent_window,
44 Asset *asset,
45 BC_WindowBase* &format_window,
46 int audio_options,
47 int video_options,
48 char *locked_compressor);
49 static int check_sig(Asset *asset);
51 int open_file(int rd, int wr);
52 int close_file();
53 void asset_to_format();
54 void format_to_asset();
55 int64_t get_video_length();
56 int64_t get_audio_length();
57 int set_video_position(int64_t x);
58 int set_audio_position(int64_t x);
59 int write_samples(double **buffer,
60 int64_t len);
61 int write_frames(VFrame ***frames, int len);
62 int64_t compressed_frame_size();
63 int read_compressed_frame(VFrame *buffer);
64 int write_compressed_frame(VFrame *buffer);
66 int read_frame(VFrame *frame);
67 int read_samples(double *buffer, int64_t len);
69 // Direct copy routines
70 static int get_best_colormodel(Asset *asset, int driver);
71 int64_t get_memory_usage();
72 int colormodel_supported(int colormodel);
73 int can_copy_from(Edit *edit, int64_t position); // This file can copy frames directly from the asset
74 static char *strtocompression(char *string);
75 static char *compressiontostr(char *string);
77 // Fix codec to what AVI or MOV support
78 static void fix_codecs(Asset *asset);
79 // Check if resolutions match the DV codec when used
80 int check_codec_params(Asset *asset);
82 // set programme timecode
83 void set_frame_start(int64_t offset);
85 private:
86 void new_audio_temp(int64_t len);
87 // read raw audio data
88 int read_raw(char *buffer, int64_t samples, int track);
89 // overlay raw frame from the current layer and position
90 int read_raw(VFrame *frame,
91 float in_x1, float in_y1, float in_x2, float in_y2,
92 float out_x1, float out_y1, float out_x2, float out_y2,
93 int use_float, int interpolate);
94 int reset_parameters_derived();
95 int quicktime_atracks;
96 int quicktime_vtracks;
97 // current positions for when the file descriptor doesn't have the right position
98 quicktime_t *fd;
99 int depth; // Depth in bits per pixel
100 int64_t frames_correction; // Correction after 32bit overflow
101 int64_t samples_correction; // Correction after 32bit overflow
103 // An array of frames for threads to look up and compress on their own.
104 ArrayList<ThreadStruct*> threadframes;
106 int total_threadframes; // Number of thread frames in this buffer
107 int current_threadframe; // Next threadframe to compress
108 Mutex *threadframe_lock; // Lock threadframe array.
110 FileMOVThread **threads; // One thread for every CPU
111 char prefix_path[1024]; // Prefix for new file when 2G limit is exceeded
112 int suffix_number; // Number for new file
114 // Temp buffers for converting from double to float
115 float **temp_float;
116 int64_t temp_allocated;
120 // Encoder thread to parallelize certain compression formats, mainly JPEG.
121 // Only works when no alpha.
123 class FileMOVThread : public Thread
125 public:
126 FileMOVThread(FileMOV *filemov, int fields);
127 ~FileMOVThread();
129 int start_encoding();
130 int stop_encoding();
131 int encode_buffer();
132 void run();
134 ThreadStruct *threadframe; // The frame currently being processed.
135 int done;
136 FileMOV *filemov;
137 Condition *input_lock; // Wait for new array of threads or completion.
138 mjpeg_t *mjpeg;
139 int fields;
143 class MOVConfigAudioNum;
144 class MOVConfigAudioPopup;
145 class MOVConfigAudioToggle;
147 class MOVConfigAudio : public BC_Window
149 public:
150 MOVConfigAudio(BC_WindowBase *parent_window, Asset *asset);
151 ~MOVConfigAudio();
153 int create_objects();
154 int close_event();
155 void update_parameters();
156 void reset();
158 MOVConfigAudioPopup *compression_popup;
159 ArrayList<BC_ListBoxItem*> compression_items;
160 BC_WindowBase *parent_window;
161 BitsPopup *bits_popup;
162 BC_Title *bits_title;
163 BC_CheckBox *dither;
164 Asset *asset;
165 MOVConfigAudioNum *vorbis_min_bitrate;
166 MOVConfigAudioNum *vorbis_bitrate;
167 MOVConfigAudioNum *vorbis_max_bitrate;
168 MOVConfigAudioToggle *vorbis_vbr;
170 MOVConfigAudioNum *mp3_bitrate;
171 MOVConfigAudioNum *mp4a_bitrate;
172 MOVConfigAudioNum *mp4a_quantqual;
176 class MOVConfigAudioPopup : public BC_PopupTextBox
178 public:
179 MOVConfigAudioPopup(MOVConfigAudio *popup, int x, int y);
180 int handle_event();
181 MOVConfigAudio *popup;
185 class MOVConfigAudioToggle : public BC_CheckBox
187 public:
188 MOVConfigAudioToggle(MOVConfigAudio *popup,
189 char *title_text,
190 int x,
191 int y,
192 int *output);
193 int handle_event();
194 int *output;
195 MOVConfigAudio *popup;
199 class MOVConfigAudioNum : public BC_TumbleTextBox
201 public:
202 MOVConfigAudioNum(MOVConfigAudio *popup,
203 char *title_text,
204 int x,
205 int y,
206 int *output);
207 ~MOVConfigAudioNum();
209 void create_objects();
210 int handle_event();
211 int *output;
212 MOVConfigAudio *popup;
213 BC_Title *title;
214 char *title_text;
215 int x, y;
219 class MOVConfigVideoPopup;
220 class MOVConfigVideoNum;
221 class MOVConfigVideoFix;
222 class MOVConfigVideoFixBitrate;
223 class MOVConfigVideoFixQuant;
224 class MOVConfigVideoCheckBox;
227 class MOVConfigVideo : public BC_Window
229 public:
230 MOVConfigVideo(BC_WindowBase *parent_window,
231 Asset *asset,
232 char *locked_compressor);
233 ~MOVConfigVideo();
235 int create_objects();
236 int close_event();
237 void reset();
239 void update_parameters();
241 ArrayList<BC_ListBoxItem*> compression_items;
242 MOVConfigVideoPopup *compression_popup;
243 BC_WindowBase *parent_window;
244 Asset *asset;
245 int param_x, param_y;
246 char *locked_compressor;
248 BC_ISlider *jpeg_quality;
249 BC_Title *jpeg_quality_title;
251 MOVConfigVideoNum *ms_bitrate;
252 MOVConfigVideoNum *ms_bitrate_tolerance;
253 MOVConfigVideoNum *ms_quantization;
254 MOVConfigVideoNum *ms_gop_size;
255 MOVConfigVideoCheckBox *ms_interlaced;
256 MOVConfigVideoFixBitrate *ms_fix_bitrate;
257 MOVConfigVideoFixQuant *ms_fix_quant;
259 MOVConfigVideoNum *divx_bitrate;
260 MOVConfigVideoNum *divx_quantizer;
261 MOVConfigVideoNum *divx_rc_period;
262 MOVConfigVideoNum *divx_rc_reaction_ratio;
263 MOVConfigVideoNum *divx_rc_reaction_period;
264 MOVConfigVideoNum *divx_max_key_interval;
265 MOVConfigVideoNum *divx_max_quantizer;
266 MOVConfigVideoNum *divx_min_quantizer;
267 MOVConfigVideoNum *divx_quality;
268 MOVConfigVideoFixBitrate *divx_fix_bitrate;
269 MOVConfigVideoFixQuant *divx_fix_quant;
271 MOVConfigVideoNum *h264_bitrate;
272 MOVConfigVideoNum *h264_quantizer;
273 MOVConfigVideoFixBitrate *h264_fix_bitrate;
274 MOVConfigVideoFixQuant *h264_fix_quant;
277 class MOVConfigVideoPopup : public BC_PopupTextBox
279 public:
280 MOVConfigVideoPopup(MOVConfigVideo *popup, int x, int y);
281 int handle_event();
282 MOVConfigVideo *popup;
285 class MOVConfigVideoFixBitrate : public BC_Radial
287 public:
288 MOVConfigVideoFixBitrate(int x,
289 int y,
290 int *output,
291 int value);
292 int handle_event();
293 BC_Radial *opposite;
294 int *output;
295 int value;
298 class MOVConfigVideoFixQuant : public BC_Radial
300 public:
301 MOVConfigVideoFixQuant(int x,
302 int y,
303 int *output,
304 int value);
305 int handle_event();
306 BC_Radial *opposite;
307 int *output;
308 int value;
311 class MOVConfigVideoCheckBox : public BC_CheckBox
313 public:
314 MOVConfigVideoCheckBox(char *title_text,
315 int x,
316 int y,
317 int *output);
318 int handle_event();
319 int *output;
322 class MOVConfigVideoNum : public BC_TumbleTextBox
324 public:
325 MOVConfigVideoNum(MOVConfigVideo *popup,
326 char *title_text,
327 int x,
328 int y,
329 int *output);
330 MOVConfigVideoNum(MOVConfigVideo *popup,
331 char *title_text,
332 int x,
333 int y,
334 int min,
335 int max,
336 int *output);
337 ~MOVConfigVideoNum();
339 void create_objects();
340 int handle_event();
341 int *output;
342 MOVConfigVideo *popup;
343 BC_Title *title;
344 char *title_text;
345 int x, y;
348 #endif