r602: Fix baver's code... don't insert timecode when show_tc is not set
[cinelerra_cv/mob.git] / cinelerra / filempeg.h
blob366d4983558b5c585ba9d5957f3621a83985144a
1 #ifndef FILEMPEG_H
2 #define FILEMPEG_H
4 #include "bitspopup.inc"
5 #include "file.inc"
6 #include "filebase.h"
7 #include <lame/lame.h>
8 #include "libmpeg3.h"
9 #include "thread.h"
12 extern "C"
16 // Mpeg2enc prototypes
17 void mpeg2enc_init_buffers();
18 int mpeg2enc(int argc, char *argv[]);
19 void mpeg2enc_set_w(int width);
20 void mpeg2enc_set_h(int height);
21 void mpeg2enc_set_rate(double rate);
22 void mpeg2enc_set_input_buffers(int eof, char *y, char *u, char *v);
26 // Toolame prototypes
27 void toolame_init_buffers();
28 int toolame(int argc, char **argv);
29 int toolame_send_buffer(char *data, int bytes);
34 class FileMPEGVideo;
35 class FileMPEGAudio;
37 class FileMPEG : public FileBase
39 public:
40 FileMPEG(Asset *asset, File *file);
41 ~FileMPEG();
43 friend class FileMPEGVideo;
44 friend class FileMPEGAudio;
46 static void get_parameters(BC_WindowBase *parent_window,
47 Asset *asset,
48 BC_WindowBase* &format_window,
49 int audio_options,
50 int video_options);
52 static int check_sig(Asset *asset);
53 int open_file(int rd, int wr);
54 int close_file();
55 int set_video_position(int64_t x);
56 int set_audio_position(int64_t x);
57 int write_samples(double **buffer,
58 int64_t len);
59 int write_frames(VFrame ***frames, int len);
61 int read_frame(VFrame *frame);
62 int read_samples(double *buffer, int64_t len);
63 int read_samples_float(float *buffer, int64_t len);
64 int prefer_samples_float();
66 // Direct copy routines
67 static int get_best_colormodel(Asset *asset, int driver);
68 int colormodel_supported(int colormodel);
69 // This file can copy frames directly from the asset
70 int can_copy_from(Edit *edit, int64_t position);
71 static char *strtocompression(char *string);
72 static char *compressiontostr(char *string);
74 private:
75 void to_streamchannel(int channel, int &stream_out, int &channel_out);
76 int reset_parameters_derived();
77 // File descriptor for decoder
78 mpeg3_t *fd;
80 // Thread for video encoder
81 FileMPEGVideo *video_out;
82 // Command line for video encoder
83 ArrayList<char*> vcommand_line;
84 void append_vcommand_line(const char *string);
86 // Thread for audio encoder
87 FileMPEGAudio *audio_out;
88 // Command line for audio encoder
89 ArrayList<char*> acommand_line;
90 void append_acommand_line(const char *string);
93 // Temporary for color conversion
94 VFrame *temp_frame;
96 unsigned char *toolame_temp;
97 int toolame_allocation;
98 int toolame_result;
101 float *lame_temp[2];
102 int lame_allocation;
103 char *lame_output;
104 int lame_output_allocation;
105 FILE *lame_fd;
106 // Lame puts 0 before stream
107 int lame_started;
109 lame_global_flags *lame_global;
113 class FileMPEGVideo : public Thread
115 public:
116 FileMPEGVideo(FileMPEG *file);
117 ~FileMPEGVideo();
119 void run();
121 FileMPEG *file;
124 class FileMPEGAudio : public Thread
126 public:
127 FileMPEGAudio(FileMPEG *file);
128 ~FileMPEGAudio();
130 void run();
132 FileMPEG *file;
136 class MPEGConfigAudioPopup;
137 class MPEGABitrate;
140 class MPEGConfigAudio : public BC_Window
142 public:
143 MPEGConfigAudio(BC_WindowBase *parent_window, Asset *asset);
144 ~MPEGConfigAudio();
146 int create_objects();
147 int close_event();
149 BC_WindowBase *parent_window;
150 MPEGABitrate *bitrate;
151 char string[BCTEXTLEN];
152 Asset *asset;
156 class MPEGLayer : public BC_PopupMenu
158 public:
159 MPEGLayer(int x, int y, MPEGConfigAudio *gui);
160 void create_objects();
161 int handle_event();
162 static int string_to_layer(char *string);
163 static char* layer_to_string(int derivative);
165 MPEGConfigAudio *gui;
168 class MPEGABitrate : public BC_PopupMenu
170 public:
171 MPEGABitrate(int x, int y, MPEGConfigAudio *gui);
173 void create_objects();
174 void set_layer(int layer);
176 int handle_event();
177 static int string_to_bitrate(char *string);
178 static char* bitrate_to_string(char *string, int bitrate);
180 MPEGConfigAudio *gui;
185 class MPEGFixedBitrate;
186 class MPEGFixedQuant;
188 class MPEGConfigVideo : public BC_Window
190 public:
191 MPEGConfigVideo(BC_WindowBase *parent_window,
192 Asset *asset);
193 ~MPEGConfigVideo();
195 int create_objects();
196 int close_event();
198 BC_WindowBase *parent_window;
199 Asset *asset;
200 MPEGFixedBitrate *fixed_bitrate;
201 MPEGFixedQuant *fixed_quant;
205 class MPEGDerivative : public BC_PopupMenu
207 public:
208 MPEGDerivative(int x, int y, MPEGConfigVideo *gui);
209 void create_objects();
210 int handle_event();
211 static int string_to_derivative(char *string);
212 static char* derivative_to_string(int derivative);
214 MPEGConfigVideo *gui;
217 class MPEGColorModel : public BC_PopupMenu
219 public:
220 MPEGColorModel(int x, int y, MPEGConfigVideo *gui);
221 void create_objects();
222 int handle_event();
223 static int string_to_cmodel(char *string);
224 static char* cmodel_to_string(int cmodel);
226 MPEGConfigVideo *gui;
229 class MPEGBitrate : public BC_TextBox
231 public:
232 MPEGBitrate(int x, int y, MPEGConfigVideo *gui);
233 int handle_event();
234 MPEGConfigVideo *gui;
237 class MPEGQuant : public BC_TumbleTextBox
239 public:
240 MPEGQuant(int x, int y, MPEGConfigVideo *gui);
241 int handle_event();
242 MPEGConfigVideo *gui;
245 class MPEGIFrameDistance : public BC_TumbleTextBox
247 public:
248 MPEGIFrameDistance(int x, int y, MPEGConfigVideo *gui);
249 int handle_event();
250 MPEGConfigVideo *gui;
253 class MPEGFixedBitrate : public BC_Radial
255 public:
256 MPEGFixedBitrate(int x, int y, MPEGConfigVideo *gui);
257 int handle_event();
258 MPEGConfigVideo *gui;
261 class MPEGFixedQuant : public BC_Radial
263 public:
264 MPEGFixedQuant(int x, int y, MPEGConfigVideo *gui);
265 int handle_event();
266 MPEGConfigVideo *gui;
269 class MPEGSeqCodes : public BC_CheckBox
271 public:
272 MPEGSeqCodes(int x, int y, MPEGConfigVideo *gui);
273 int handle_event();
274 MPEGConfigVideo *gui;
279 #endif