r136: This commit was manufactured by cvs2svn to create tag 'hv_1_1_8'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / filempeg.h
blobdd6340a92d89a8db9e6a3ef9bf6ec5cb68c56e86
1 #ifndef FILEMPEG_H
2 #define FILEMPEG_H
4 #include "bitspopup.inc"
5 #include "file.inc"
6 #include "filebase.h"
7 #include "lame.h"
8 #include "libmpeg3.h"
9 #include "mutex.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);
54 int open_file(int rd, int wr);
55 int close_file();
56 int set_video_position(int64_t x);
57 int set_audio_position(int64_t x);
58 int write_samples(double **buffer,
59 int64_t len);
60 int write_frames(VFrame ***frames, int len);
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 // This file can copy frames directly from the asset
69 int can_copy_from(Edit *edit, int64_t position);
70 static char *strtocompression(char *string);
71 static char *compressiontostr(char *string);
73 private:
74 void to_streamchannel(int channel, int &stream_out, int &channel_out);
75 int reset_parameters_derived();
76 // File descriptor for decoder
77 mpeg3_t *fd;
79 // Thread for video encoder
80 FileMPEGVideo *video_out;
81 // Command line for video encoder
82 ArrayList<char*> vcommand_line;
83 void append_vcommand_line(const char *string);
85 // Thread for audio encoder
86 FileMPEGAudio *audio_out;
87 // Command line for audio encoder
88 ArrayList<char*> acommand_line;
89 void append_acommand_line(const char *string);
92 // Temporary for color conversion
93 VFrame *temp_frame;
95 unsigned char *toolame_temp;
96 int toolame_allocation;
97 int toolame_result;
100 float *lame_temp[2];
101 int lame_allocation;
102 char *lame_output;
103 int lame_output_allocation;
104 FILE *lame_fd;
105 // Lame puts 0 before stream
106 int lame_started;
108 lame_global_flags *lame_global;
112 class FileMPEGVideo : public Thread
114 public:
115 FileMPEGVideo(FileMPEG *file);
116 ~FileMPEGVideo();
118 void run();
120 FileMPEG *file;
123 class FileMPEGAudio : public Thread
125 public:
126 FileMPEGAudio(FileMPEG *file);
127 ~FileMPEGAudio();
129 void run();
131 FileMPEG *file;
135 class MPEGConfigAudioPopup;
136 class MPEGABitrate;
139 class MPEGConfigAudio : public BC_Window
141 public:
142 MPEGConfigAudio(BC_WindowBase *parent_window, Asset *asset);
143 ~MPEGConfigAudio();
145 int create_objects();
146 int close_event();
148 BC_WindowBase *parent_window;
149 MPEGABitrate *bitrate;
150 char string[BCTEXTLEN];
151 Asset *asset;
155 class MPEGLayer : public BC_PopupMenu
157 public:
158 MPEGLayer(int x, int y, MPEGConfigAudio *gui);
159 void create_objects();
160 int handle_event();
161 static int string_to_layer(char *string);
162 static char* layer_to_string(int derivative);
164 MPEGConfigAudio *gui;
167 class MPEGABitrate : public BC_PopupMenu
169 public:
170 MPEGABitrate(int x, int y, MPEGConfigAudio *gui);
172 void create_objects();
173 void set_layer(int layer);
175 int handle_event();
176 static int string_to_bitrate(char *string);
177 static char* bitrate_to_string(char *string, int bitrate);
179 MPEGConfigAudio *gui;
184 class MPEGFixedBitrate;
185 class MPEGFixedQuant;
187 class MPEGConfigVideo : public BC_Window
189 public:
190 MPEGConfigVideo(BC_WindowBase *parent_window,
191 Asset *asset);
192 ~MPEGConfigVideo();
194 int create_objects();
195 int close_event();
197 BC_WindowBase *parent_window;
198 Asset *asset;
199 MPEGFixedBitrate *fixed_bitrate;
200 MPEGFixedQuant *fixed_quant;
204 class MPEGDerivative : public BC_PopupMenu
206 public:
207 MPEGDerivative(int x, int y, MPEGConfigVideo *gui);
208 void create_objects();
209 int handle_event();
210 static int string_to_derivative(char *string);
211 static char* derivative_to_string(int derivative);
213 MPEGConfigVideo *gui;
216 class MPEGColorModel : public BC_PopupMenu
218 public:
219 MPEGColorModel(int x, int y, MPEGConfigVideo *gui);
220 void create_objects();
221 int handle_event();
222 static int string_to_cmodel(char *string);
223 static char* cmodel_to_string(int cmodel);
225 MPEGConfigVideo *gui;
228 class MPEGBitrate : public BC_TextBox
230 public:
231 MPEGBitrate(int x, int y, MPEGConfigVideo *gui);
232 int handle_event();
233 MPEGConfigVideo *gui;
236 class MPEGQuant : public BC_TumbleTextBox
238 public:
239 MPEGQuant(int x, int y, MPEGConfigVideo *gui);
240 int handle_event();
241 MPEGConfigVideo *gui;
244 class MPEGIFrameDistance : public BC_TumbleTextBox
246 public:
247 MPEGIFrameDistance(int x, int y, MPEGConfigVideo *gui);
248 int handle_event();
249 MPEGConfigVideo *gui;
252 class MPEGFixedBitrate : public BC_Radial
254 public:
255 MPEGFixedBitrate(int x, int y, MPEGConfigVideo *gui);
256 int handle_event();
257 MPEGConfigVideo *gui;
260 class MPEGFixedQuant : public BC_Radial
262 public:
263 MPEGFixedQuant(int x, int y, MPEGConfigVideo *gui);
264 int handle_event();
265 MPEGConfigVideo *gui;
268 class MPEGSeqCodes : public BC_CheckBox
270 public:
271 MPEGSeqCodes(int x, int y, MPEGConfigVideo *gui);
272 int handle_event();
273 MPEGConfigVideo *gui;
278 #endif