r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / filemov.h
bloba5a430d1739784d69ead3df1ede9df3a2ae4ffe1
1 #ifndef FILEMOV_H
2 #define FILEMOV_H
4 #include "bitspopup.inc"
5 #include "file.inc"
6 #include "filebase.h"
7 #include "mutex.h"
8 #include "thread.h"
10 // ./Quicktime
11 #include "libmjpeg.h"
12 #include "quicktime.h"
14 class FileMOVThread;
16 class ThreadStruct
18 public:
19 ThreadStruct();
20 ~ThreadStruct();
22 void load_output(mjpeg_t *mjpeg);
24 VFrame *input;
25 unsigned char *output; // Output buffer
26 int64_t output_size; // Size of output buffer
27 int64_t output_allocated; // Allocation of output buffer
28 Mutex completion_lock;
31 class FileMOV : public FileBase
33 public:
34 FileMOV(Asset *asset, File *file);
35 ~FileMOV();
37 friend class FileMOVThread;
39 static void get_parameters(BC_WindowBase *parent_window,
40 Asset *asset,
41 BC_WindowBase* &format_window,
42 int audio_options,
43 int video_options,
44 int lock_compressor);
45 static int check_sig(Asset *asset);
47 int open_file(int rd, int wr);
48 int close_file();
49 void asset_to_format();
50 void format_to_asset();
51 int64_t get_video_length();
52 int64_t get_audio_length();
53 int set_video_position(int64_t x);
54 int set_audio_position(int64_t x);
55 int write_samples(double **buffer,
56 int64_t len);
57 int write_frames(VFrame ***frames, int len);
58 int64_t compressed_frame_size();
59 int read_compressed_frame(VFrame *buffer);
60 int write_compressed_frame(VFrame *buffer);
62 int read_frame(VFrame *frame);
63 int read_samples(double *buffer, int64_t len);
65 // Direct copy routines
66 static int get_best_colormodel(Asset *asset, int driver);
67 int colormodel_supported(int colormodel);
68 int can_copy_from(Edit *edit, int64_t position); // This file can copy frames directly from the asset
69 static char *strtocompression(char *string);
70 static char *compressiontostr(char *string);
72 // Fix codec to what AVI or MOV support
73 static void fix_codecs(Asset *asset);
75 private:
76 void new_audio_temp(int64_t len);
77 // read raw audio data
78 int read_raw(char *buffer, int64_t samples, int track);
79 // overlay raw frame from the current layer and position
80 int read_raw(VFrame *frame,
81 float in_x1, float in_y1, float in_x2, float in_y2,
82 float out_x1, float out_y1, float out_x2, float out_y2,
83 int use_float, int interpolate);
84 int reset_parameters_derived();
85 int quicktime_atracks;
86 int quicktime_vtracks;
87 // current positions for when the file descriptor doesn't have the right position
88 quicktime_t *fd;
89 // frame to return through read_frame
90 VFrame *frame;
91 // Temporary storage for color conversions
92 VFrame *temp_frame;
93 int depth; // Depth in bits per pixel
94 int64_t frames_correction; // Correction after 32bit overflow
95 int64_t samples_correction; // Correction after 32bit overflow
97 // An array of frames for threads to look up and compress on their own.
98 ArrayList<ThreadStruct*> threadframes;
100 int total_threadframes; // Number of thread frames in this buffer
101 int current_threadframe; // Next threadframe to compress
102 Mutex threadframe_lock; // Lock threadframe array.
104 FileMOVThread **threads; // One thread for every CPU
105 char prefix_path[1024]; // Prefix for new file when 2G limit is exceeded
106 int suffix_number; // Number for new file
108 // Temp buffers for converting from double to float
109 float **temp_float;
110 int64_t temp_allocated;
114 // Encoder thread to parallelize certain compression formats, mainly JPEG.
115 // Only works when no alpha.
117 class FileMOVThread : public Thread
119 public:
120 FileMOVThread(FileMOV *filemov, int fields);
121 ~FileMOVThread();
123 int start_encoding();
124 int stop_encoding();
125 int encode_buffer();
126 void run();
128 ThreadStruct *threadframe; // The frame currently being processed.
129 int done;
130 FileMOV *filemov;
131 Mutex input_lock; // Wait for new array of threads or completion.
132 Mutex quicktime_lock; // Lock out reopen_file
133 mjpeg_t *mjpeg;
134 int fields;
138 class MOVConfigAudioNum;
139 class MOVConfigAudioPopup;
140 class MOVConfigAudioToggle;
142 class MOVConfigAudio : public BC_Window
144 public:
145 MOVConfigAudio(BC_WindowBase *parent_window, Asset *asset);
146 ~MOVConfigAudio();
148 int create_objects();
149 int close_event();
150 void update_parameters();
152 MOVConfigAudioPopup *compression_popup;
153 ArrayList<BC_ListBoxItem*> compression_items;
154 BC_WindowBase *parent_window;
155 BitsPopup *bits_popup;
156 BC_Title *bits_title;
157 BC_CheckBox *dither;
158 Asset *asset;
159 MOVConfigAudioNum *vorbis_min_bitrate;
160 MOVConfigAudioNum *vorbis_bitrate;
161 MOVConfigAudioNum *vorbis_max_bitrate;
162 MOVConfigAudioToggle *vorbis_vbr;
164 MOVConfigAudioNum *mp3_bitrate;
168 class MOVConfigAudioPopup : public BC_PopupTextBox
170 public:
171 MOVConfigAudioPopup(MOVConfigAudio *popup, int x, int y);
172 int handle_event();
173 MOVConfigAudio *popup;
177 class MOVConfigAudioToggle : public BC_CheckBox
179 public:
180 MOVConfigAudioToggle(MOVConfigAudio *popup,
181 char *title_text,
182 int x,
183 int y,
184 int *output);
185 int handle_event();
186 int *output;
187 MOVConfigAudio *popup;
191 class MOVConfigAudioNum : public BC_TumbleTextBox
193 public:
194 MOVConfigAudioNum(MOVConfigAudio *popup,
195 char *title_text,
196 int x,
197 int y,
198 int *output);
199 ~MOVConfigAudioNum();
201 void create_objects();
202 int handle_event();
203 int *output;
204 MOVConfigAudio *popup;
205 BC_Title *title;
206 char *title_text;
207 int x, y;
211 class MOVConfigVideoPopup;
212 class MOVConfigVideoNum;
213 class MOVConfigVideoFix;
214 class MOVConfigVideoFixBitrate;
215 class MOVConfigVideoFixQuant;
216 class MOVConfigVideoCheckBox;
219 class MOVConfigVideo : public BC_Window
221 public:
222 MOVConfigVideo(BC_WindowBase *parent_window,
223 Asset *asset,
224 int lock_compressor);
225 ~MOVConfigVideo();
227 int create_objects();
228 int close_event();
229 void reset();
231 void update_parameters();
233 ArrayList<BC_ListBoxItem*> compression_items;
234 MOVConfigVideoPopup *compression_popup;
235 BC_WindowBase *parent_window;
236 Asset *asset;
237 int param_x, param_y;
238 int lock_compressor;
240 BC_ISlider *jpeg_quality;
241 BC_Title *jpeg_quality_title;
243 MOVConfigVideoNum *ms_bitrate;
244 MOVConfigVideoNum *ms_bitrate_tolerance;
245 MOVConfigVideoNum *ms_quantization;
246 MOVConfigVideoNum *ms_gop_size;
247 MOVConfigVideoCheckBox *ms_interlaced;
248 MOVConfigVideoFixBitrate *ms_fix_bitrate;
249 MOVConfigVideoFixQuant *ms_fix_quant;
251 MOVConfigVideoNum *divx_bitrate;
252 MOVConfigVideoNum *divx_quantizer;
253 MOVConfigVideoNum *divx_rc_period;
254 MOVConfigVideoNum *divx_rc_reaction_ratio;
255 MOVConfigVideoNum *divx_rc_reaction_period;
256 MOVConfigVideoNum *divx_max_key_interval;
257 MOVConfigVideoNum *divx_max_quantizer;
258 MOVConfigVideoNum *divx_min_quantizer;
259 MOVConfigVideoNum *divx_quality;
260 MOVConfigVideoFixBitrate *divx_fix_bitrate;
261 MOVConfigVideoFixQuant *divx_fix_quant;
264 class MOVConfigVideoPopup : public BC_PopupTextBox
266 public:
267 MOVConfigVideoPopup(MOVConfigVideo *popup, int x, int y);
268 int handle_event();
269 MOVConfigVideo *popup;
272 class MOVConfigVideoFixBitrate : public BC_Radial
274 public:
275 MOVConfigVideoFixBitrate(int x,
276 int y,
277 int *output,
278 int value);
279 int handle_event();
280 BC_Radial *opposite;
281 int *output;
282 int value;
285 class MOVConfigVideoFixQuant : public BC_Radial
287 public:
288 MOVConfigVideoFixQuant(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 MOVConfigVideoCheckBox : public BC_CheckBox
300 public:
301 MOVConfigVideoCheckBox(char *title_text,
302 int x,
303 int y,
304 int *output);
305 int handle_event();
306 int *output;
309 class MOVConfigVideoNum : public BC_TumbleTextBox
311 public:
312 MOVConfigVideoNum(MOVConfigVideo *popup,
313 char *title_text,
314 int x,
315 int y,
316 int *output);
317 ~MOVConfigVideoNum();
319 void create_objects();
320 int handle_event();
321 int *output;
322 MOVConfigVideo *popup;
323 BC_Title *title;
324 char *title_text;
325 int x, y;
328 #endif