4 #include "bitspopup.inc"
5 #include "condition.inc"
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
);
28 void toolame_init_buffers();
29 int toolame(int argc
, char **argv
);
30 int toolame_send_buffer(char *data
, int bytes
);
38 class FileMPEG
: public FileBase
41 FileMPEG(Asset
*asset
, File
*file
);
44 friend class FileMPEGVideo
;
45 friend class FileMPEGAudio
;
47 static void get_parameters(BC_WindowBase
*parent_window
,
49 BC_WindowBase
* &format_window
,
53 static int check_sig(Asset
*asset
);
54 int open_file(int rd
, int wr
);
59 int get_index(char *index_path
);
60 int set_video_position(int64_t x
);
61 int set_audio_position(int64_t x
);
62 int write_samples(double **buffer
,
64 int write_frames(VFrame
***frames
, int len
);
66 int read_frame(VFrame
*frame
);
67 int read_samples(double *buffer
, int64_t len
);
68 int read_samples_float(float *buffer
, int64_t len
);
69 int prefer_samples_float();
71 // Direct copy routines
72 static int get_best_colormodel(Asset
*asset
, int driver
);
73 int colormodel_supported(int colormodel
);
74 // This file can copy frames directly from the asset
75 int can_copy_from(Edit
*edit
, int64_t position
);
76 static char *strtocompression(char *string
);
77 static char *compressiontostr(char *string
);
81 void to_streamchannel(int channel
, int &stream_out
, int &channel_out
);
82 int reset_parameters_derived();
83 // File descriptor for decoder
86 // Thread for video encoder
87 FileMPEGVideo
*video_out
;
88 // Command line for video encoder
89 ArrayList
<char*> vcommand_line
;
90 void append_vcommand_line(const char *string
);
100 Condition
*next_frame_lock
;
101 Condition
*next_frame_done
;
104 unsigned char *mjpeg_y
;
105 unsigned char *mjpeg_u
;
106 unsigned char *mjpeg_v
;
107 char mjpeg_command
[BCTEXTLEN
];
114 // Thread for audio encoder
115 FileMPEGAudio
*audio_out
;
116 // Command line for audio encoder
117 ArrayList
<char*> acommand_line
;
118 void append_acommand_line(const char *string
);
121 // Temporary for color conversion
124 unsigned char *toolame_temp
;
125 int toolame_allocation
;
132 int lame_output_allocation
;
134 // Lame puts 0 before stream
137 lame_global_flags
*lame_global
;
141 class FileMPEGVideo
: public Thread
144 FileMPEGVideo(FileMPEG
*file
);
152 class FileMPEGAudio
: public Thread
155 FileMPEGAudio(FileMPEG
*file
);
164 class MPEGConfigAudioPopup
;
168 class MPEGConfigAudio
: public BC_Window
171 MPEGConfigAudio(BC_WindowBase
*parent_window
, Asset
*asset
);
174 int create_objects();
177 BC_WindowBase
*parent_window
;
178 MPEGABitrate
*bitrate
;
179 char string
[BCTEXTLEN
];
184 class MPEGLayer
: public BC_PopupMenu
187 MPEGLayer(int x
, int y
, MPEGConfigAudio
*gui
);
188 void create_objects();
190 static int string_to_layer(char *string
);
191 static char* layer_to_string(int derivative
);
193 MPEGConfigAudio
*gui
;
196 class MPEGABitrate
: public BC_PopupMenu
199 MPEGABitrate(int x
, int y
, MPEGConfigAudio
*gui
);
201 void create_objects();
202 void set_layer(int layer
);
205 static int string_to_bitrate(char *string
);
206 static char* bitrate_to_string(char *string
, int bitrate
);
208 MPEGConfigAudio
*gui
;
213 class MPEGConfigVideo
;
217 class MPEGPreset
: public BC_PopupMenu
220 MPEGPreset(int x
, int y
, MPEGConfigVideo
*gui
);
221 void create_objects();
223 static int string_to_value(char *string
);
224 static char* value_to_string(int value
);
225 MPEGConfigVideo
*gui
;
228 class MPEGColorModel
: public BC_PopupMenu
231 MPEGColorModel(int x
, int y
, MPEGConfigVideo
*gui
);
232 void create_objects();
234 static int string_to_cmodel(char *string
);
235 static char* cmodel_to_string(int cmodel
);
237 MPEGConfigVideo
*gui
;
241 class MPEGDerivative
: public BC_PopupMenu
244 MPEGDerivative(int x
, int y
, MPEGConfigVideo
*gui
);
245 void create_objects();
247 static int string_to_derivative(char *string
);
248 static char* derivative_to_string(int derivative
);
250 MPEGConfigVideo
*gui
;
253 class MPEGBitrate
: public BC_TextBox
256 MPEGBitrate(int x
, int y
, MPEGConfigVideo
*gui
);
258 MPEGConfigVideo
*gui
;
261 class MPEGQuant
: public BC_TumbleTextBox
264 MPEGQuant(int x
, int y
, MPEGConfigVideo
*gui
);
266 MPEGConfigVideo
*gui
;
269 class MPEGIFrameDistance
: public BC_TumbleTextBox
272 MPEGIFrameDistance(int x
, int y
, MPEGConfigVideo
*gui
);
274 MPEGConfigVideo
*gui
;
277 class MPEGPFrameDistance
: public BC_TumbleTextBox
280 MPEGPFrameDistance(int x
, int y
, MPEGConfigVideo
*gui
);
282 MPEGConfigVideo
*gui
;
285 class MPEGFixedBitrate
: public BC_Radial
288 MPEGFixedBitrate(int x
, int y
, MPEGConfigVideo
*gui
);
290 MPEGConfigVideo
*gui
;
293 class MPEGFixedQuant
: public BC_Radial
296 MPEGFixedQuant(int x
, int y
, MPEGConfigVideo
*gui
);
298 MPEGConfigVideo
*gui
;
301 class MPEGSeqCodes
: public BC_CheckBox
304 MPEGSeqCodes(int x
, int y
, MPEGConfigVideo
*gui
);
306 MPEGConfigVideo
*gui
;
312 class MPEGConfigVideo
: public BC_Window
315 MPEGConfigVideo(BC_WindowBase
*parent_window
,
319 int create_objects();
321 void delete_cmodel_objs();
323 void update_cmodel_objs();
325 BC_WindowBase
*parent_window
;
328 MPEGColorModel
*cmodel
;
329 MPEGDerivative
*derivative
;
330 MPEGBitrate
*bitrate
;
331 MPEGFixedBitrate
*fixed_bitrate
;
333 MPEGFixedQuant
*fixed_quant
;
334 MPEGIFrameDistance
*iframe_distance
;
335 MPEGPFrameDistance
*pframe_distance
;
336 BC_CheckBox
*top_field_first
;
337 BC_CheckBox
*progressive
;
338 BC_CheckBox
*denoise
;
339 BC_CheckBox
*seq_codes
;
341 ArrayList
<BC_Title
*> titles
;
342 ArrayList
<BC_SubWindow
*> tools
;