r668: Configure.in and autogen.sh cleanup based on ideas by giskard.
[cinelerra_cv.git] / cinelerra / filemov.h
blob576092cd3702e58e00042ae0ad0ce92a7465c0d4
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 int lock_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 int colormodel_supported(int colormodel);
72 int can_copy_from(Edit *edit, int64_t position); // This file can copy frames directly from the asset
73 static char *strtocompression(char *string);
74 static char *compressiontostr(char *string);
76 // Fix codec to what AVI or MOV support
77 static void fix_codecs(Asset *asset);
79 // set programme timecode
80 void set_frame_start(int64_t offset);
82 private:
83 void new_audio_temp(int64_t len);
84 // read raw audio data
85 int read_raw(char *buffer, int64_t samples, int track);
86 // overlay raw frame from the current layer and position
87 int read_raw(VFrame *frame,
88 float in_x1, float in_y1, float in_x2, float in_y2,
89 float out_x1, float out_y1, float out_x2, float out_y2,
90 int use_float, int interpolate);
91 int reset_parameters_derived();
92 int quicktime_atracks;
93 int quicktime_vtracks;
94 // current positions for when the file descriptor doesn't have the right position
95 quicktime_t *fd;
96 int depth; // Depth in bits per pixel
97 int64_t frames_correction; // Correction after 32bit overflow
98 int64_t samples_correction; // Correction after 32bit overflow
100 // An array of frames for threads to look up and compress on their own.
101 ArrayList<ThreadStruct*> threadframes;
103 int total_threadframes; // Number of thread frames in this buffer
104 int current_threadframe; // Next threadframe to compress
105 Mutex *threadframe_lock; // Lock threadframe array.
107 FileMOVThread **threads; // One thread for every CPU
108 char prefix_path[1024]; // Prefix for new file when 2G limit is exceeded
109 int suffix_number; // Number for new file
111 // Temp buffers for converting from double to float
112 float **temp_float;
113 int64_t temp_allocated;
117 // Encoder thread to parallelize certain compression formats, mainly JPEG.
118 // Only works when no alpha.
120 class FileMOVThread : public Thread
122 public:
123 FileMOVThread(FileMOV *filemov, int fields);
124 ~FileMOVThread();
126 int start_encoding();
127 int stop_encoding();
128 int encode_buffer();
129 void run();
131 ThreadStruct *threadframe; // The frame currently being processed.
132 int done;
133 FileMOV *filemov;
134 Condition *input_lock; // Wait for new array of threads or completion.
135 mjpeg_t *mjpeg;
136 int fields;
140 class MOVConfigAudioNum;
141 class MOVConfigAudioPopup;
142 class MOVConfigAudioToggle;
144 class MOVConfigAudio : public BC_Window
146 public:
147 MOVConfigAudio(BC_WindowBase *parent_window, Asset *asset);
148 ~MOVConfigAudio();
150 int create_objects();
151 int close_event();
152 void update_parameters();
153 void reset();
155 MOVConfigAudioPopup *compression_popup;
156 ArrayList<BC_ListBoxItem*> compression_items;
157 BC_WindowBase *parent_window;
158 BitsPopup *bits_popup;
159 BC_Title *bits_title;
160 BC_CheckBox *dither;
161 Asset *asset;
162 MOVConfigAudioNum *vorbis_min_bitrate;
163 MOVConfigAudioNum *vorbis_bitrate;
164 MOVConfigAudioNum *vorbis_max_bitrate;
165 MOVConfigAudioToggle *vorbis_vbr;
167 MOVConfigAudioNum *mp3_bitrate;
168 MOVConfigAudioNum *mp4a_bitrate;
169 MOVConfigAudioNum *mp4a_quantqual;
173 class MOVConfigAudioPopup : public BC_PopupTextBox
175 public:
176 MOVConfigAudioPopup(MOVConfigAudio *popup, int x, int y);
177 int handle_event();
178 MOVConfigAudio *popup;
182 class MOVConfigAudioToggle : public BC_CheckBox
184 public:
185 MOVConfigAudioToggle(MOVConfigAudio *popup,
186 char *title_text,
187 int x,
188 int y,
189 int *output);
190 int handle_event();
191 int *output;
192 MOVConfigAudio *popup;
196 class MOVConfigAudioNum : public BC_TumbleTextBox
198 public:
199 MOVConfigAudioNum(MOVConfigAudio *popup,
200 char *title_text,
201 int x,
202 int y,
203 int *output);
204 ~MOVConfigAudioNum();
206 void create_objects();
207 int handle_event();
208 int *output;
209 MOVConfigAudio *popup;
210 BC_Title *title;
211 char *title_text;
212 int x, y;
216 class MOVConfigVideoPopup;
217 class MOVConfigVideoNum;
218 class MOVConfigVideoFix;
219 class MOVConfigVideoFixBitrate;
220 class MOVConfigVideoFixQuant;
221 class MOVConfigVideoCheckBox;
224 class MOVConfigVideo : public BC_Window
226 public:
227 MOVConfigVideo(BC_WindowBase *parent_window,
228 Asset *asset,
229 int lock_compressor);
230 ~MOVConfigVideo();
232 int create_objects();
233 int close_event();
234 void reset();
236 void update_parameters();
238 ArrayList<BC_ListBoxItem*> compression_items;
239 MOVConfigVideoPopup *compression_popup;
240 BC_WindowBase *parent_window;
241 Asset *asset;
242 int param_x, param_y;
243 int lock_compressor;
245 BC_ISlider *jpeg_quality;
246 BC_Title *jpeg_quality_title;
248 MOVConfigVideoNum *ms_bitrate;
249 MOVConfigVideoNum *ms_bitrate_tolerance;
250 MOVConfigVideoNum *ms_quantization;
251 MOVConfigVideoNum *ms_gop_size;
252 MOVConfigVideoCheckBox *ms_interlaced;
253 MOVConfigVideoFixBitrate *ms_fix_bitrate;
254 MOVConfigVideoFixQuant *ms_fix_quant;
256 MOVConfigVideoNum *divx_bitrate;
257 MOVConfigVideoNum *divx_quantizer;
258 MOVConfigVideoNum *divx_rc_period;
259 MOVConfigVideoNum *divx_rc_reaction_ratio;
260 MOVConfigVideoNum *divx_rc_reaction_period;
261 MOVConfigVideoNum *divx_max_key_interval;
262 MOVConfigVideoNum *divx_max_quantizer;
263 MOVConfigVideoNum *divx_min_quantizer;
264 MOVConfigVideoNum *divx_quality;
265 MOVConfigVideoFixBitrate *divx_fix_bitrate;
266 MOVConfigVideoFixQuant *divx_fix_quant;
268 MOVConfigVideoNum *h264_bitrate;
269 MOVConfigVideoNum *h264_quantizer;
270 MOVConfigVideoFixBitrate *h264_fix_bitrate;
271 MOVConfigVideoFixQuant *h264_fix_quant;
274 class MOVConfigVideoPopup : public BC_PopupTextBox
276 public:
277 MOVConfigVideoPopup(MOVConfigVideo *popup, int x, int y);
278 int handle_event();
279 MOVConfigVideo *popup;
282 class MOVConfigVideoFixBitrate : public BC_Radial
284 public:
285 MOVConfigVideoFixBitrate(int x,
286 int y,
287 int *output,
288 int value);
289 int handle_event();
290 BC_Radial *opposite;
291 int *output;
292 int value;
295 class MOVConfigVideoFixQuant : public BC_Radial
297 public:
298 MOVConfigVideoFixQuant(int x,
299 int y,
300 int *output,
301 int value);
302 int handle_event();
303 BC_Radial *opposite;
304 int *output;
305 int value;
308 class MOVConfigVideoCheckBox : public BC_CheckBox
310 public:
311 MOVConfigVideoCheckBox(char *title_text,
312 int x,
313 int y,
314 int *output);
315 int handle_event();
316 int *output;
319 class MOVConfigVideoNum : public BC_TumbleTextBox
321 public:
322 MOVConfigVideoNum(MOVConfigVideo *popup,
323 char *title_text,
324 int x,
325 int y,
326 int *output);
327 MOVConfigVideoNum(MOVConfigVideo *popup,
328 char *title_text,
329 int x,
330 int y,
331 int min,
332 int max,
333 int *output);
334 ~MOVConfigVideoNum();
336 void create_objects();
337 int handle_event();
338 int *output;
339 MOVConfigVideo *popup;
340 BC_Title *title;
341 char *title_text;
342 int x, y;
345 #endif