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
);
55 // Get extra info for info dialog.
56 static void get_info(Asset
*asset
, int64_t *bytes
, int *stracks
);
57 int open_file(int rd
, int wr
);
62 int get_index(char *index_path
);
63 int set_video_position(int64_t x
);
64 int set_audio_position(int64_t x
);
65 int write_samples(double **buffer
,
67 int write_frames(VFrame
***frames
, int len
);
69 int read_frame(VFrame
*frame
);
70 int read_samples(double *buffer
, int64_t len
);
71 int read_samples_float(float *buffer
, int64_t len
);
72 int prefer_samples_float();
74 int64_t get_memory_usage();
76 // Direct copy routines
77 static int get_best_colormodel(Asset
*asset
, int driver
);
78 int colormodel_supported(int colormodel
);
79 // This file can copy frames directly from the asset
80 int can_copy_from(Edit
*edit
, int64_t position
);
81 static char *strtocompression(char *string
);
82 static char *compressiontostr(char *string
);
86 void to_streamchannel(int channel
, int &stream_out
, int &channel_out
);
87 int reset_parameters_derived();
88 // File descriptor for decoder
91 // Thread for video encoder
92 FileMPEGVideo
*video_out
;
93 // Command line for video encoder
94 ArrayList
<char*> vcommand_line
;
95 void append_vcommand_line(const char *string
);
105 // MJPEGtools encoder
108 Condition
*next_frame_lock
;
109 Condition
*next_frame_done
;
112 unsigned char *mjpeg_y
;
113 unsigned char *mjpeg_u
;
114 unsigned char *mjpeg_v
;
115 char mjpeg_command
[BCTEXTLEN
];
122 // Thread for audio encoder
123 FileMPEGAudio
*audio_out
;
124 // Command line for audio encoder
125 ArrayList
<char*> acommand_line
;
126 void append_acommand_line(const char *string
);
129 // Temporary for color conversion
132 unsigned char *toolame_temp
;
133 int toolame_allocation
;
140 int lame_output_allocation
;
142 // Lame puts 0 before stream
145 lame_global_flags
*lame_global
;
149 class FileMPEGVideo
: public Thread
152 FileMPEGVideo(FileMPEG
*file
);
160 class FileMPEGAudio
: public Thread
163 FileMPEGAudio(FileMPEG
*file
);
172 class MPEGConfigAudioPopup
;
176 class MPEGConfigAudio
: public BC_Window
179 MPEGConfigAudio(BC_WindowBase
*parent_window
, Asset
*asset
);
182 int create_objects();
185 BC_WindowBase
*parent_window
;
186 MPEGABitrate
*bitrate
;
187 char string
[BCTEXTLEN
];
192 class MPEGLayer
: public BC_PopupMenu
195 MPEGLayer(int x
, int y
, MPEGConfigAudio
*gui
);
196 void create_objects();
198 static int string_to_layer(char *string
);
199 static char* layer_to_string(int derivative
);
201 MPEGConfigAudio
*gui
;
204 class MPEGABitrate
: public BC_PopupMenu
207 MPEGABitrate(int x
, int y
, MPEGConfigAudio
*gui
);
209 void create_objects();
210 void set_layer(int layer
);
213 static int string_to_bitrate(char *string
);
214 static char* bitrate_to_string(char *string
, int bitrate
);
216 MPEGConfigAudio
*gui
;
221 class MPEGConfigVideo
;
225 class MPEGPreset
: public BC_PopupMenu
228 MPEGPreset(int x
, int y
, MPEGConfigVideo
*gui
);
229 void create_objects();
231 static int string_to_value(char *string
);
232 static char* value_to_string(int value
);
233 MPEGConfigVideo
*gui
;
236 class MPEGColorModel
: public BC_PopupMenu
239 MPEGColorModel(int x
, int y
, MPEGConfigVideo
*gui
);
240 void create_objects();
242 static int string_to_cmodel(char *string
);
243 static char* cmodel_to_string(int cmodel
);
245 MPEGConfigVideo
*gui
;
249 class MPEGDerivative
: public BC_PopupMenu
252 MPEGDerivative(int x
, int y
, MPEGConfigVideo
*gui
);
253 void create_objects();
255 static int string_to_derivative(char *string
);
256 static char* derivative_to_string(int derivative
);
258 MPEGConfigVideo
*gui
;
261 class MPEGBitrate
: public BC_TextBox
264 MPEGBitrate(int x
, int y
, MPEGConfigVideo
*gui
);
266 MPEGConfigVideo
*gui
;
269 class MPEGQuant
: public BC_TumbleTextBox
272 MPEGQuant(int x
, int y
, MPEGConfigVideo
*gui
);
274 MPEGConfigVideo
*gui
;
277 class MPEGIFrameDistance
: public BC_TumbleTextBox
280 MPEGIFrameDistance(int x
, int y
, MPEGConfigVideo
*gui
);
282 MPEGConfigVideo
*gui
;
285 class MPEGPFrameDistance
: public BC_TumbleTextBox
288 MPEGPFrameDistance(int x
, int y
, MPEGConfigVideo
*gui
);
290 MPEGConfigVideo
*gui
;
293 class MPEGFixedBitrate
: public BC_Radial
296 MPEGFixedBitrate(int x
, int y
, MPEGConfigVideo
*gui
);
298 MPEGConfigVideo
*gui
;
301 class MPEGFixedQuant
: public BC_Radial
304 MPEGFixedQuant(int x
, int y
, MPEGConfigVideo
*gui
);
306 MPEGConfigVideo
*gui
;
309 class MPEGSeqCodes
: public BC_CheckBox
312 MPEGSeqCodes(int x
, int y
, MPEGConfigVideo
*gui
);
314 MPEGConfigVideo
*gui
;
320 class MPEGConfigVideo
: public BC_Window
323 MPEGConfigVideo(BC_WindowBase
*parent_window
,
327 int create_objects();
329 void delete_cmodel_objs();
331 void update_cmodel_objs();
333 BC_WindowBase
*parent_window
;
336 MPEGColorModel
*cmodel
;
337 MPEGDerivative
*derivative
;
338 MPEGBitrate
*bitrate
;
339 MPEGFixedBitrate
*fixed_bitrate
;
341 MPEGFixedQuant
*fixed_quant
;
342 MPEGIFrameDistance
*iframe_distance
;
343 MPEGPFrameDistance
*pframe_distance
;
344 BC_CheckBox
*top_field_first
;
345 BC_CheckBox
*progressive
;
346 BC_CheckBox
*denoise
;
347 BC_CheckBox
*seq_codes
;
349 ArrayList
<BC_Title
*> titles
;
350 ArrayList
<BC_SubWindow
*> tools
;