r602: Fix baver's code... don't insert timecode when show_tc is not set
[cinelerra_cv/mob.git] / cinelerra / filemov.h
blob64e554a4271ad1a6f71d115e07ec1f76da781a12
1 #ifndef FILEMOV_H
2 #define FILEMOV_H
4 #include "bitspopup.inc"
5 #include "condition.inc"
6 #include "filebase.h"
7 #include "file.inc"
8 #include "libmjpeg.h"
9 #include "mutex.inc"
10 #include "quicktime.h"
11 #include "thread.h"
13 class FileMOVThread;
15 class ThreadStruct
17 public:
18 ThreadStruct();
19 ~ThreadStruct();
21 void load_output(mjpeg_t *mjpeg);
23 VFrame *input;
24 unsigned char *output; // Output buffer
25 int64_t output_size; // Size of output buffer
26 int64_t output_allocated; // Allocation of output buffer
27 Condition *completion_lock;
30 class FileMOV : public FileBase
32 public:
33 FileMOV(Asset *asset, File *file);
34 ~FileMOV();
36 friend class FileMOVThread;
38 static void get_parameters(BC_WindowBase *parent_window,
39 Asset *asset,
40 BC_WindowBase* &format_window,
41 int audio_options,
42 int video_options,
43 int lock_compressor);
44 static int check_sig(Asset *asset);
46 int open_file(int rd, int wr);
47 int close_file();
48 void asset_to_format();
49 void format_to_asset();
50 int64_t get_video_length();
51 int64_t get_audio_length();
52 int set_video_position(int64_t x);
53 int set_audio_position(int64_t x);
54 int write_samples(double **buffer,
55 int64_t len);
56 int write_frames(VFrame ***frames, int len);
57 int64_t compressed_frame_size();
58 int read_compressed_frame(VFrame *buffer);
59 int write_compressed_frame(VFrame *buffer);
61 int read_frame(VFrame *frame);
62 int read_samples(double *buffer, int64_t len);
64 // Direct copy routines
65 static int get_best_colormodel(Asset *asset, int driver);
66 int colormodel_supported(int colormodel);
67 int can_copy_from(Edit *edit, int64_t position); // This file can copy frames directly from the asset
68 static char *strtocompression(char *string);
69 static char *compressiontostr(char *string);
71 // Fix codec to what AVI or MOV support
72 static void fix_codecs(Asset *asset);
74 // set programme timecode
75 void set_frame_start(int64_t offset);
77 private:
78 void new_audio_temp(int64_t len);
79 // read raw audio data
80 int read_raw(char *buffer, int64_t samples, int track);
81 // overlay raw frame from the current layer and position
82 int read_raw(VFrame *frame,
83 float in_x1, float in_y1, float in_x2, float in_y2,
84 float out_x1, float out_y1, float out_x2, float out_y2,
85 int use_float, int interpolate);
86 int reset_parameters_derived();
87 int quicktime_atracks;
88 int quicktime_vtracks;
89 // current positions for when the file descriptor doesn't have the right position
90 quicktime_t *fd;
91 int depth; // Depth in bits per pixel
92 int64_t frames_correction; // Correction after 32bit overflow
93 int64_t samples_correction; // Correction after 32bit overflow
95 // An array of frames for threads to look up and compress on their own.
96 ArrayList<ThreadStruct*> threadframes;
98 int total_threadframes; // Number of thread frames in this buffer
99 int current_threadframe; // Next threadframe to compress
100 Mutex *threadframe_lock; // Lock threadframe array.
102 FileMOVThread **threads; // One thread for every CPU
103 char prefix_path[1024]; // Prefix for new file when 2G limit is exceeded
104 int suffix_number; // Number for new file
106 // Temp buffers for converting from double to float
107 float **temp_float;
108 int64_t temp_allocated;
112 // Encoder thread to parallelize certain compression formats, mainly JPEG.
113 // Only works when no alpha.
115 class FileMOVThread : public Thread
117 public:
118 FileMOVThread(FileMOV *filemov, int fields);
119 ~FileMOVThread();
121 int start_encoding();
122 int stop_encoding();
123 int encode_buffer();
124 void run();
126 ThreadStruct *threadframe; // The frame currently being processed.
127 int done;
128 FileMOV *filemov;
129 Condition *input_lock; // Wait for new array of threads or completion.
130 mjpeg_t *mjpeg;
131 int fields;
135 class MOVConfigAudioNum;
136 class MOVConfigAudioPopup;
137 class MOVConfigAudioToggle;
139 class MOVConfigAudio : public BC_Window
141 public:
142 MOVConfigAudio(BC_WindowBase *parent_window, Asset *asset);
143 ~MOVConfigAudio();
145 int create_objects();
146 int close_event();
147 void update_parameters();
149 MOVConfigAudioPopup *compression_popup;
150 ArrayList<BC_ListBoxItem*> compression_items;
151 BC_WindowBase *parent_window;
152 BitsPopup *bits_popup;
153 BC_Title *bits_title;
154 BC_CheckBox *dither;
155 Asset *asset;
156 MOVConfigAudioNum *vorbis_min_bitrate;
157 MOVConfigAudioNum *vorbis_bitrate;
158 MOVConfigAudioNum *vorbis_max_bitrate;
159 MOVConfigAudioToggle *vorbis_vbr;
161 MOVConfigAudioNum *mp3_bitrate;
165 class MOVConfigAudioPopup : public BC_PopupTextBox
167 public:
168 MOVConfigAudioPopup(MOVConfigAudio *popup, int x, int y);
169 int handle_event();
170 MOVConfigAudio *popup;
174 class MOVConfigAudioToggle : public BC_CheckBox
176 public:
177 MOVConfigAudioToggle(MOVConfigAudio *popup,
178 char *title_text,
179 int x,
180 int y,
181 int *output);
182 int handle_event();
183 int *output;
184 MOVConfigAudio *popup;
188 class MOVConfigAudioNum : public BC_TumbleTextBox
190 public:
191 MOVConfigAudioNum(MOVConfigAudio *popup,
192 char *title_text,
193 int x,
194 int y,
195 int *output);
196 ~MOVConfigAudioNum();
198 void create_objects();
199 int handle_event();
200 int *output;
201 MOVConfigAudio *popup;
202 BC_Title *title;
203 char *title_text;
204 int x, y;
208 class MOVConfigVideoPopup;
209 class MOVConfigVideoNum;
210 class MOVConfigVideoFix;
211 class MOVConfigVideoFixBitrate;
212 class MOVConfigVideoFixQuant;
213 class MOVConfigVideoCheckBox;
216 class MOVConfigVideo : public BC_Window
218 public:
219 MOVConfigVideo(BC_WindowBase *parent_window,
220 Asset *asset,
221 int lock_compressor);
222 ~MOVConfigVideo();
224 int create_objects();
225 int close_event();
226 void reset();
228 void update_parameters();
230 ArrayList<BC_ListBoxItem*> compression_items;
231 MOVConfigVideoPopup *compression_popup;
232 BC_WindowBase *parent_window;
233 Asset *asset;
234 int param_x, param_y;
235 int lock_compressor;
237 BC_ISlider *jpeg_quality;
238 BC_Title *jpeg_quality_title;
240 MOVConfigVideoNum *ms_bitrate;
241 MOVConfigVideoNum *ms_bitrate_tolerance;
242 MOVConfigVideoNum *ms_quantization;
243 MOVConfigVideoNum *ms_gop_size;
244 MOVConfigVideoCheckBox *ms_interlaced;
245 MOVConfigVideoFixBitrate *ms_fix_bitrate;
246 MOVConfigVideoFixQuant *ms_fix_quant;
248 MOVConfigVideoNum *divx_bitrate;
249 MOVConfigVideoNum *divx_quantizer;
250 MOVConfigVideoNum *divx_rc_period;
251 MOVConfigVideoNum *divx_rc_reaction_ratio;
252 MOVConfigVideoNum *divx_rc_reaction_period;
253 MOVConfigVideoNum *divx_max_key_interval;
254 MOVConfigVideoNum *divx_max_quantizer;
255 MOVConfigVideoNum *divx_min_quantizer;
256 MOVConfigVideoNum *divx_quality;
257 MOVConfigVideoFixBitrate *divx_fix_bitrate;
258 MOVConfigVideoFixQuant *divx_fix_quant;
261 class MOVConfigVideoPopup : public BC_PopupTextBox
263 public:
264 MOVConfigVideoPopup(MOVConfigVideo *popup, int x, int y);
265 int handle_event();
266 MOVConfigVideo *popup;
269 class MOVConfigVideoFixBitrate : public BC_Radial
271 public:
272 MOVConfigVideoFixBitrate(int x,
273 int y,
274 int *output,
275 int value);
276 int handle_event();
277 BC_Radial *opposite;
278 int *output;
279 int value;
282 class MOVConfigVideoFixQuant : public BC_Radial
284 public:
285 MOVConfigVideoFixQuant(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 MOVConfigVideoCheckBox : public BC_CheckBox
297 public:
298 MOVConfigVideoCheckBox(char *title_text,
299 int x,
300 int y,
301 int *output);
302 int handle_event();
303 int *output;
306 class MOVConfigVideoNum : public BC_TumbleTextBox
308 public:
309 MOVConfigVideoNum(MOVConfigVideo *popup,
310 char *title_text,
311 int x,
312 int y,
313 int *output);
314 ~MOVConfigVideoNum();
316 void create_objects();
317 int handle_event();
318 int *output;
319 MOVConfigVideo *popup;
320 BC_Title *title;
321 char *title_text;
322 int x, y;
325 #endif