4 #include "bitspopup.inc"
12 #include <lame/lame.h>
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
);
30 void toolame_init_buffers();
31 int toolame(int argc
, char **argv
);
32 int toolame_send_buffer(char *data
, int bytes
);
40 class FileMPEG
: public FileBase
43 FileMPEG(Asset
*asset
, File
*file
);
46 friend class FileMPEGVideo
;
47 friend class FileMPEGAudio
;
49 static void get_parameters(BC_WindowBase
*parent_window
,
51 BC_WindowBase
* &format_window
,
55 static int check_sig(Asset
*asset
);
56 int open_file(int rd
, int wr
);
58 int set_video_position(int64_t x
);
59 int set_audio_position(int64_t x
);
60 int write_samples(double **buffer
,
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
);
76 void to_streamchannel(int channel
, int &stream_out
, int &channel_out
);
77 int reset_parameters_derived();
78 // File descriptor for decoder
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
97 unsigned char *toolame_temp
;
98 int toolame_allocation
;
105 int lame_output_allocation
;
107 // Lame puts 0 before stream
110 lame_global_flags
*lame_global
;
114 class FileMPEGVideo
: public Thread
117 FileMPEGVideo(FileMPEG
*file
);
125 class FileMPEGAudio
: public Thread
128 FileMPEGAudio(FileMPEG
*file
);
137 class MPEGConfigAudioPopup
;
141 class MPEGConfigAudio
: public BC_Window
144 MPEGConfigAudio(BC_WindowBase
*parent_window
, Asset
*asset
);
147 int create_objects();
150 BC_WindowBase
*parent_window
;
151 MPEGABitrate
*bitrate
;
152 char string
[BCTEXTLEN
];
157 class MPEGLayer
: public BC_PopupMenu
160 MPEGLayer(int x
, int y
, MPEGConfigAudio
*gui
);
161 void create_objects();
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
172 MPEGABitrate(int x
, int y
, MPEGConfigAudio
*gui
);
174 void create_objects();
175 void set_layer(int layer
);
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
192 MPEGConfigVideo(BC_WindowBase
*parent_window
,
196 int create_objects();
199 BC_WindowBase
*parent_window
;
201 MPEGFixedBitrate
*fixed_bitrate
;
202 MPEGFixedQuant
*fixed_quant
;
206 class MPEGDerivative
: public BC_PopupMenu
209 MPEGDerivative(int x
, int y
, MPEGConfigVideo
*gui
);
210 void create_objects();
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
221 MPEGColorModel(int x
, int y
, MPEGConfigVideo
*gui
);
222 void create_objects();
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
233 MPEGBitrate(int x
, int y
, MPEGConfigVideo
*gui
);
235 MPEGConfigVideo
*gui
;
238 class MPEGQuant
: public BC_TumbleTextBox
241 MPEGQuant(int x
, int y
, MPEGConfigVideo
*gui
);
243 MPEGConfigVideo
*gui
;
246 class MPEGIFrameDistance
: public BC_TumbleTextBox
249 MPEGIFrameDistance(int x
, int y
, MPEGConfigVideo
*gui
);
251 MPEGConfigVideo
*gui
;
254 class MPEGFixedBitrate
: public BC_Radial
257 MPEGFixedBitrate(int x
, int y
, MPEGConfigVideo
*gui
);
259 MPEGConfigVideo
*gui
;
262 class MPEGFixedQuant
: public BC_Radial
265 MPEGFixedQuant(int x
, int y
, MPEGConfigVideo
*gui
);
267 MPEGConfigVideo
*gui
;
270 class MPEGSeqCodes
: public BC_CheckBox
273 MPEGSeqCodes(int x
, int y
, MPEGConfigVideo
*gui
);
275 MPEGConfigVideo
*gui
;