r1014: Enable horizontal scrolling with the mouse wheel by pressing Ctrl.
[cinelerra_cv/ct.git] / cinelerra / filempeg.h
blobe1669a4b2023dc0452af79b1a9bc502d8b1864f3
1 #ifndef FILEMPEG_H
2 #define FILEMPEG_H
4 #include "bitspopup.inc"
5 #include "condition.inc"
6 #include "file.inc"
7 #include "filebase.h"
8 #include <lame/lame.h>
9 #include "libmpeg3.h"
10 #include "thread.h"
13 extern "C"
17 // Mpeg2enc prototypes
18 void mpeg2enc_init_buffers();
19 int mpeg2enc(int argc, char *argv[]);
20 void mpeg2enc_set_w(int width);
21 void mpeg2enc_set_h(int height);
22 void mpeg2enc_set_rate(double rate);
23 void mpeg2enc_set_input_buffers(int eof, char *y, char *u, char *v);
27 // Toolame prototypes
28 void toolame_init_buffers();
29 int toolame(int argc, char **argv);
30 int toolame_send_buffer(char *data, int bytes);
35 class FileMPEGVideo;
36 class FileMPEGAudio;
38 class FileMPEG : public FileBase
40 public:
41 FileMPEG(Asset *asset, File *file);
42 ~FileMPEG();
44 friend class FileMPEGVideo;
45 friend class FileMPEGAudio;
47 static void get_parameters(BC_WindowBase *parent_window,
48 Asset *asset,
49 BC_WindowBase* &format_window,
50 int audio_options,
51 int video_options);
53 static int check_sig(Asset *asset);
55 // Get extra info for info dialog.
56 static void get_info(Asset *asset, int64_t *bytes, int *stracks);
57 int open_file(int rd, int wr);
58 int close_file();
59 int create_index();
62 int get_index(char *index_path);
63 int set_video_position(int64_t x);
64 int set_audio_position(int64_t x);
65 int write_samples(double **buffer,
66 int64_t len);
67 int write_frames(VFrame ***frames, int len);
69 int read_frame(VFrame *frame);
70 int read_samples(double *buffer, int64_t len);
71 int read_samples_float(float *buffer, int64_t len);
72 int prefer_samples_float();
74 int64_t get_memory_usage();
76 // Direct copy routines
77 static int get_best_colormodel(Asset *asset, int driver);
78 int colormodel_supported(int colormodel);
79 // This file can copy frames directly from the asset
80 int can_copy_from(Edit *edit, int64_t position);
81 static char *strtocompression(char *string);
82 static char *compressiontostr(char *string);
85 private:
86 void to_streamchannel(int channel, int &stream_out, int &channel_out);
87 int reset_parameters_derived();
88 // File descriptor for decoder
89 mpeg3_t *fd;
91 // Thread for video encoder
92 FileMPEGVideo *video_out;
93 // Command line for video encoder
94 ArrayList<char*> vcommand_line;
95 void append_vcommand_line(const char *string);
99 // DVB capture
100 FILE *dvb_out;
105 // MJPEGtools encoder
106 FILE *mjpeg_out;
107 int mjpeg_error;
108 Condition *next_frame_lock;
109 Condition *next_frame_done;
110 int mjpeg_eof;
111 int wrote_header;
112 unsigned char *mjpeg_y;
113 unsigned char *mjpeg_u;
114 unsigned char *mjpeg_v;
115 char mjpeg_command[BCTEXTLEN];
122 // Thread for audio encoder
123 FileMPEGAudio *audio_out;
124 // Command line for audio encoder
125 ArrayList<char*> acommand_line;
126 void append_acommand_line(const char *string);
129 // Temporary for color conversion
130 VFrame *temp_frame;
132 unsigned char *toolame_temp;
133 int toolame_allocation;
134 int toolame_result;
137 float *lame_temp[2];
138 int lame_allocation;
139 char *lame_output;
140 int lame_output_allocation;
141 FILE *lame_fd;
142 // Lame puts 0 before stream
143 int lame_started;
145 lame_global_flags *lame_global;
149 class FileMPEGVideo : public Thread
151 public:
152 FileMPEGVideo(FileMPEG *file);
153 ~FileMPEGVideo();
155 void run();
157 FileMPEG *file;
160 class FileMPEGAudio : public Thread
162 public:
163 FileMPEGAudio(FileMPEG *file);
164 ~FileMPEGAudio();
166 void run();
168 FileMPEG *file;
172 class MPEGConfigAudioPopup;
173 class MPEGABitrate;
176 class MPEGConfigAudio : public BC_Window
178 public:
179 MPEGConfigAudio(BC_WindowBase *parent_window, Asset *asset);
180 ~MPEGConfigAudio();
182 int create_objects();
183 int close_event();
185 BC_WindowBase *parent_window;
186 MPEGABitrate *bitrate;
187 char string[BCTEXTLEN];
188 Asset *asset;
192 class MPEGLayer : public BC_PopupMenu
194 public:
195 MPEGLayer(int x, int y, MPEGConfigAudio *gui);
196 void create_objects();
197 int handle_event();
198 static int string_to_layer(char *string);
199 static char* layer_to_string(int derivative);
201 MPEGConfigAudio *gui;
204 class MPEGABitrate : public BC_PopupMenu
206 public:
207 MPEGABitrate(int x, int y, MPEGConfigAudio *gui);
209 void create_objects();
210 void set_layer(int layer);
212 int handle_event();
213 static int string_to_bitrate(char *string);
214 static char* bitrate_to_string(char *string, int bitrate);
216 MPEGConfigAudio *gui;
221 class MPEGConfigVideo;
225 class MPEGPreset : public BC_PopupMenu
227 public:
228 MPEGPreset(int x, int y, MPEGConfigVideo *gui);
229 void create_objects();
230 int handle_event();
231 static int string_to_value(char *string);
232 static char* value_to_string(int value);
233 MPEGConfigVideo *gui;
236 class MPEGColorModel : public BC_PopupMenu
238 public:
239 MPEGColorModel(int x, int y, MPEGConfigVideo *gui);
240 void create_objects();
241 int handle_event();
242 static int string_to_cmodel(char *string);
243 static char* cmodel_to_string(int cmodel);
245 MPEGConfigVideo *gui;
249 class MPEGDerivative : public BC_PopupMenu
251 public:
252 MPEGDerivative(int x, int y, MPEGConfigVideo *gui);
253 void create_objects();
254 int handle_event();
255 static int string_to_derivative(char *string);
256 static char* derivative_to_string(int derivative);
258 MPEGConfigVideo *gui;
261 class MPEGBitrate : public BC_TextBox
263 public:
264 MPEGBitrate(int x, int y, MPEGConfigVideo *gui);
265 int handle_event();
266 MPEGConfigVideo *gui;
269 class MPEGQuant : public BC_TumbleTextBox
271 public:
272 MPEGQuant(int x, int y, MPEGConfigVideo *gui);
273 int handle_event();
274 MPEGConfigVideo *gui;
277 class MPEGIFrameDistance : public BC_TumbleTextBox
279 public:
280 MPEGIFrameDistance(int x, int y, MPEGConfigVideo *gui);
281 int handle_event();
282 MPEGConfigVideo *gui;
285 class MPEGPFrameDistance : public BC_TumbleTextBox
287 public:
288 MPEGPFrameDistance(int x, int y, MPEGConfigVideo *gui);
289 int handle_event();
290 MPEGConfigVideo *gui;
293 class MPEGFixedBitrate : public BC_Radial
295 public:
296 MPEGFixedBitrate(int x, int y, MPEGConfigVideo *gui);
297 int handle_event();
298 MPEGConfigVideo *gui;
301 class MPEGFixedQuant : public BC_Radial
303 public:
304 MPEGFixedQuant(int x, int y, MPEGConfigVideo *gui);
305 int handle_event();
306 MPEGConfigVideo *gui;
309 class MPEGSeqCodes : public BC_CheckBox
311 public:
312 MPEGSeqCodes(int x, int y, MPEGConfigVideo *gui);
313 int handle_event();
314 MPEGConfigVideo *gui;
320 class MPEGConfigVideo : public BC_Window
322 public:
323 MPEGConfigVideo(BC_WindowBase *parent_window,
324 Asset *asset);
325 ~MPEGConfigVideo();
327 int create_objects();
328 int close_event();
329 void delete_cmodel_objs();
330 void reset_cmodel();
331 void update_cmodel_objs();
333 BC_WindowBase *parent_window;
334 Asset *asset;
335 MPEGPreset *preset;
336 MPEGColorModel *cmodel;
337 MPEGDerivative *derivative;
338 MPEGBitrate *bitrate;
339 MPEGFixedBitrate *fixed_bitrate;
340 MPEGQuant *quant;
341 MPEGFixedQuant *fixed_quant;
342 MPEGIFrameDistance *iframe_distance;
343 MPEGPFrameDistance *pframe_distance;
344 BC_CheckBox *top_field_first;
345 BC_CheckBox *progressive;
346 BC_CheckBox *denoise;
347 BC_CheckBox *seq_codes;
349 ArrayList<BC_Title*> titles;
350 ArrayList<BC_SubWindow*> tools;
354 #endif