r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / filempeg.h
blob8dbfeb7db5064bd89a0b81820206734bdce24d8c
1 #ifndef FILEMPEG_H
2 #define FILEMPEG_H
4 #include "bitspopup.inc"
5 #include "file.inc"
6 #include "filebase.h"
7 #include "libmpeg3.h"
8 #include "mutex.h"
9 #include "thread.h"
12 #include <lame/lame.h>
15 extern "C"
19 // Mpeg2enc prototypes
20 void mpeg2enc_init_buffers();
21 int mpeg2enc(int argc, char *argv[]);
22 void mpeg2enc_set_w(int width);
23 void mpeg2enc_set_h(int height);
24 void mpeg2enc_set_rate(double rate);
25 void mpeg2enc_set_input_buffers(int eof, char *y, char *u, char *v);
29 // Toolame prototypes
30 void toolame_init_buffers();
31 int toolame(int argc, char **argv);
32 int toolame_send_buffer(char *data, int bytes);
37 class FileMPEGVideo;
38 class FileMPEGAudio;
40 class FileMPEG : public FileBase
42 public:
43 FileMPEG(Asset *asset, File *file);
44 ~FileMPEG();
46 friend class FileMPEGVideo;
47 friend class FileMPEGAudio;
49 static void get_parameters(BC_WindowBase *parent_window,
50 Asset *asset,
51 BC_WindowBase* &format_window,
52 int audio_options,
53 int video_options);
55 static int check_sig(Asset *asset);
56 int open_file(int rd, int wr);
57 int close_file();
58 int set_video_position(int64_t x);
59 int set_audio_position(int64_t x);
60 int write_samples(double **buffer,
61 int64_t len);
62 int write_frames(VFrame ***frames, int len);
64 int read_frame(VFrame *frame);
65 int read_samples(double *buffer, int64_t len);
67 // Direct copy routines
68 static int get_best_colormodel(Asset *asset, int driver);
69 int colormodel_supported(int colormodel);
70 // This file can copy frames directly from the asset
71 int can_copy_from(Edit *edit, int64_t position);
72 static char *strtocompression(char *string);
73 static char *compressiontostr(char *string);
75 private:
76 void to_streamchannel(int channel, int &stream_out, int &channel_out);
77 int reset_parameters_derived();
78 // File descriptor for decoder
79 mpeg3_t *fd;
81 // Thread for video encoder
82 FileMPEGVideo *video_out;
83 // Command line for video encoder
84 ArrayList<char*> vcommand_line;
85 void append_vcommand_line(const char *string);
87 // Thread for audio encoder
88 FileMPEGAudio *audio_out;
89 // Command line for audio encoder
90 ArrayList<char*> acommand_line;
91 void append_acommand_line(const char *string);
94 // Temporary for color conversion
95 VFrame *temp_frame;
97 unsigned char *toolame_temp;
98 int toolame_allocation;
99 int toolame_result;
102 float *lame_temp[2];
103 int lame_allocation;
104 char *lame_output;
105 int lame_output_allocation;
106 FILE *lame_fd;
107 // Lame puts 0 before stream
108 int lame_started;
110 lame_global_flags *lame_global;
114 class FileMPEGVideo : public Thread
116 public:
117 FileMPEGVideo(FileMPEG *file);
118 ~FileMPEGVideo();
120 void run();
122 FileMPEG *file;
125 class FileMPEGAudio : public Thread
127 public:
128 FileMPEGAudio(FileMPEG *file);
129 ~FileMPEGAudio();
131 void run();
133 FileMPEG *file;
137 class MPEGConfigAudioPopup;
138 class MPEGABitrate;
141 class MPEGConfigAudio : public BC_Window
143 public:
144 MPEGConfigAudio(BC_WindowBase *parent_window, Asset *asset);
145 ~MPEGConfigAudio();
147 int create_objects();
148 int close_event();
150 BC_WindowBase *parent_window;
151 MPEGABitrate *bitrate;
152 char string[BCTEXTLEN];
153 Asset *asset;
157 class MPEGLayer : public BC_PopupMenu
159 public:
160 MPEGLayer(int x, int y, MPEGConfigAudio *gui);
161 void create_objects();
162 int handle_event();
163 static int string_to_layer(char *string);
164 static char* layer_to_string(int derivative);
166 MPEGConfigAudio *gui;
169 class MPEGABitrate : public BC_PopupMenu
171 public:
172 MPEGABitrate(int x, int y, MPEGConfigAudio *gui);
174 void create_objects();
175 void set_layer(int layer);
177 int handle_event();
178 static int string_to_bitrate(char *string);
179 static char* bitrate_to_string(char *string, int bitrate);
181 MPEGConfigAudio *gui;
186 class MPEGFixedBitrate;
187 class MPEGFixedQuant;
189 class MPEGConfigVideo : public BC_Window
191 public:
192 MPEGConfigVideo(BC_WindowBase *parent_window,
193 Asset *asset);
194 ~MPEGConfigVideo();
196 int create_objects();
197 int close_event();
199 BC_WindowBase *parent_window;
200 Asset *asset;
201 MPEGFixedBitrate *fixed_bitrate;
202 MPEGFixedQuant *fixed_quant;
206 class MPEGDerivative : public BC_PopupMenu
208 public:
209 MPEGDerivative(int x, int y, MPEGConfigVideo *gui);
210 void create_objects();
211 int handle_event();
212 static int string_to_derivative(char *string);
213 static char* derivative_to_string(int derivative);
215 MPEGConfigVideo *gui;
218 class MPEGColorModel : public BC_PopupMenu
220 public:
221 MPEGColorModel(int x, int y, MPEGConfigVideo *gui);
222 void create_objects();
223 int handle_event();
224 static int string_to_cmodel(char *string);
225 static char* cmodel_to_string(int cmodel);
227 MPEGConfigVideo *gui;
230 class MPEGBitrate : public BC_TextBox
232 public:
233 MPEGBitrate(int x, int y, MPEGConfigVideo *gui);
234 int handle_event();
235 MPEGConfigVideo *gui;
238 class MPEGQuant : public BC_TumbleTextBox
240 public:
241 MPEGQuant(int x, int y, MPEGConfigVideo *gui);
242 int handle_event();
243 MPEGConfigVideo *gui;
246 class MPEGIFrameDistance : public BC_TumbleTextBox
248 public:
249 MPEGIFrameDistance(int x, int y, MPEGConfigVideo *gui);
250 int handle_event();
251 MPEGConfigVideo *gui;
254 class MPEGFixedBitrate : public BC_Radial
256 public:
257 MPEGFixedBitrate(int x, int y, MPEGConfigVideo *gui);
258 int handle_event();
259 MPEGConfigVideo *gui;
262 class MPEGFixedQuant : public BC_Radial
264 public:
265 MPEGFixedQuant(int x, int y, MPEGConfigVideo *gui);
266 int handle_event();
267 MPEGConfigVideo *gui;
270 class MPEGSeqCodes : public BC_CheckBox
272 public:
273 MPEGSeqCodes(int x, int y, MPEGConfigVideo *gui);
274 int handle_event();
275 MPEGConfigVideo *gui;
280 #endif