1 #ifndef __FILEFFMPEG_H__
2 #define __FILEFFMPEG_H__
6 #include "bcwindowbase.inc"
7 #include "bitspopup.inc"
11 #include "fileffmpeg.inc"
12 #include "indexfile.inc"
13 #include "mainprogress.inc"
25 class FileFFMPEG : public FileBase
30 FileFFMPEG(Asset *asset, File *file);
32 static void ff_lock(const char *cp=0);
33 static void ff_unlock();
35 static void set_options(char *cp, int len, const char *bp);
36 static void get_parameters(BC_WindowBase *parent_window,
37 Asset *asset, BC_WindowBase *&format_window,
38 int audio_options,int video_options, EDL *edl);
39 static int check_sig(Asset *asset);
40 int get_best_colormodel(int driver, int vstream);
41 int get_video_info(int track, int &pid, double &framerate,
42 int &width, int &height, char *title=0);
43 int get_audio_for_video(int vstream, int astream, int64_t &channel_mask);
44 static void get_info(char *path,char *text,int len);
45 int open_file(int rd,int wr);
46 int get_index(IndexFile *index_file, MainProgressBar *progress_bar);
48 int write_samples(double **buffer,int64_t len);
49 int write_frames(VFrame ***frames,int len);
50 int read_samples(double *buffer,int64_t len);
51 int read_frame(VFrame *frame);
52 int can_scale_input() { return 1; }
53 int64_t get_memory_usage(void);
54 int colormodel_supported(int colormodel);
55 static int get_best_colormodel(Asset *asset, int driver);
56 int select_video_stream(Asset *asset, int vstream);
57 int select_audio_stream(Asset *asset, int astream);
60 class FFMpegConfigNum : public BC_TumbleTextBox
63 FFMpegConfigNum(BC_Window *window, int x, int y,
64 char *title_text, int *output);
67 void create_objects();
68 int update_param(const char *param, const char *opts);
77 class FFMpegAudioNum : public FFMpegConfigNum
80 FFMpegAudioNum(BC_Window *window, int x, int y, char *title_text, int *output);
83 FFMPEGConfigAudio *window() { return (FFMPEGConfigAudio *)FFMpegConfigNum::window; }
86 class FFMpegAudioBitrate : public FFMpegAudioNum
89 FFMpegAudioBitrate(BC_Window *window, int x, int y, char *title_text, int *output)
90 : FFMpegAudioNum(window, x, y, title_text, output) {}
94 class FFMpegAudioQuality : public FFMpegAudioNum
97 FFMpegAudioQuality(BC_Window *window, int x, int y, char *title_text, int *output)
98 : FFMpegAudioNum(window, x, y, title_text, output) {}
102 class FFMpegVideoNum : public FFMpegConfigNum
105 FFMpegVideoNum(BC_Window *window, int x, int y, char *title_text, int *output);
108 FFMPEGConfigVideo *window() { return (FFMPEGConfigVideo *)FFMpegConfigNum::window; }
111 class FFMpegVideoBitrate : public FFMpegVideoNum
114 FFMpegVideoBitrate(BC_Window *window, int x, int y, char *title_text, int *output)
115 : FFMpegVideoNum(window, x, y, title_text, output) {}
119 class FFMpegVideoQuality : public FFMpegVideoNum
122 FFMpegVideoQuality(BC_Window *window, int x, int y, char *title_text, int *output)
123 : FFMpegVideoNum(window, x, y, title_text, output) {}
127 class FFMpegPixFmtItems : public ArrayList<BC_ListBoxItem*>
130 FFMpegPixFmtItems() {}
131 ~FFMpegPixFmtItems() { remove_all_objects(); }
134 class FFMpegPixelFormat : public BC_PopupTextBox
137 FFMpegPixelFormat(FFMPEGConfigVideo *vid_config, int x, int y, int w, int list_h);
139 FFMPEGConfigVideo *vid_config;
140 FFMpegPixFmtItems pixfmts;
143 void update_formats();
146 class FFMpegSampleFormat : public BC_PopupTextBox
149 FFMpegSampleFormat(FFMPEGConfigAudio *aud_config, int x, int y, int w, int list_h);
151 FFMPEGConfigAudio *aud_config;
152 ArrayList<BC_ListBoxItem*> samplefmts;
155 void update_formats();
158 class FFMPEGConfigAudio : public BC_Window
161 FFMPEGConfigAudio(BC_WindowBase *parent_window, Asset *asset, EDL *edl);
162 ~FFMPEGConfigAudio();
164 void create_objects();
168 FFMpegSampleFormat *sample_format;
169 ArrayList<BC_ListBoxItem*> presets;
170 FFMPEGConfigAudioPopup *preset_popup;
171 FFMpegAudioBitrate *bitrate;
172 FFMpegAudioQuality *quality;
173 FFAudioOptions *audio_options;
174 BC_WindowBase *parent_window;
177 FFOptionsDialog *ff_options_dialog;
180 class FFAudioOptions : public BC_ScrollTextBox
183 FFAudioOptions(FFMPEGConfigAudio *audio_popup,
184 int x, int y, int w, int rows, int size, char *text);
186 FFMPEGConfigAudio *audio_popup;
190 class FFMPEGConfigAudioPopup : public BC_PopupTextBox
193 FFMPEGConfigAudioPopup(FFMPEGConfigAudio *popup, int x, int y);
195 FFMPEGConfigAudio *popup;
199 class FFMPEGConfigAudioToggle : public BC_CheckBox
202 FFMPEGConfigAudioToggle(FFMPEGConfigAudio *popup,
203 char *title_text, int x, int y, int *output);
206 FFMPEGConfigAudio *popup;
209 class FFMPEGConfigVideo : public BC_Window
212 FFMPEGConfigVideo(BC_WindowBase *parent_window, Asset *asset, EDL *edl);
213 ~FFMPEGConfigVideo();
215 void create_objects();
219 FFMpegPixelFormat *pixel_format;
220 ArrayList<BC_ListBoxItem*> presets;
221 FFMPEGConfigVideoPopup *preset_popup;
222 BC_WindowBase *parent_window;
223 FFMpegVideoBitrate *bitrate;
224 FFMpegVideoQuality *quality;
225 FFVideoOptions *video_options;
228 FFOptionsDialog *ff_options_dialog;
231 class FFVideoOptions : public BC_ScrollTextBox
234 FFVideoOptions(FFMPEGConfigVideo *video_popup,
235 int x, int y, int w, int rows, int size, char *text);
237 FFMPEGConfigVideo *video_popup;
240 class FFMPEGConfigVideoPopup : public BC_PopupTextBox
243 FFMPEGConfigVideoPopup(FFMPEGConfigVideo *popup, int x, int y);
245 FFMPEGConfigVideo *popup;
248 class FFMPEGConfigVideoToggle : public BC_CheckBox
251 FFMPEGConfigVideoToggle(FFMPEGConfigVideo *popup,
252 char *title_text, int x, int y, int *output);
255 FFMPEGConfigVideo *popup;
258 class FFMPEGScanProgress : public Thread
261 IndexFile *index_file;
262 MainProgressBar *progress_bar;
263 char progress_title[BCTEXTLEN];
264 int64_t length, *position;
267 FFMPEGScanProgress(IndexFile *index_file, MainProgressBar *progress_bar,
268 const char *title, int64_t length, int64_t *position, int *canceled);
269 ~FFMPEGScanProgress();
274 class FFOptions_OptName : public BC_ListBoxItem {
278 FFOptions_OptName(FFOptions_Opt *opt, const char *nm);
279 ~FFOptions_OptName();
283 class FFOptions_OptValue : public BC_ListBoxItem {
288 void update(const char *v);
289 FFOptions_OptValue(FFOptions_Opt *opt);
292 class FFOptions_Opt {
296 FFOptions_OptName *item_name;
297 FFOptions_OptValue *item_value;
299 char *get(char *vp, int sz=-1);
300 void set(const char *val);
302 int scalar(double d, char *rp);
303 int ranges(char *rp);
304 int units(ArrayList<const char *> &opts);
305 const char *unit_name(int id);
309 FFOptions_Opt(FFOptions *options, const AVOption *opt, const char *nm);
313 class FFOptions : public ArrayList<FFOptions_Opt *>
318 FFOptionsWindow *win;
319 AVCodecContext *avctx;
322 void initialize(FFOptionsWindow *win, int k);
323 static int cmpr(const void *a, const void *b);
328 class FFOptions_OptPanel : public BC_ListBox {
330 FFOptions_OptPanel(FFOptionsWindow *fwin, int x, int y, int w, int h);
331 ~FFOptions_OptPanel();
332 void create_objects();
333 int cursor_leave_event();
335 FFOptionsWindow *fwin;
336 ArrayList<BC_ListBoxItem*> items[2];
337 ArrayList<BC_ListBoxItem*> &opts;
338 ArrayList<BC_ListBoxItem*> &vals;
339 char tip_text[BCTEXTLEN];
341 int selection_changed();
343 void show_tip(const char *tip);
346 class FFOptionsKindItem : public BC_MenuItem
354 FFOptionsKindItem(FFOptionsKind *kind, const char *name, int idx);
355 ~FFOptionsKindItem();
358 class FFOptionsKind : public BC_PopupMenu
360 static const char *kinds[];
362 FFOptionsWindow *fwin;
365 void create_objects();
369 FFOptionsKind(FFOptionsWindow *fwin, int x, int y, int w);
373 class FFOptionsUnits : public BC_PopupMenu {
375 FFOptionsWindow *fwin;
377 FFOptionsUnits(FFOptionsWindow *fwin, int x, int y, int w);
382 class FFOptionsText : public BC_TextBox {
384 FFOptionsWindow *fwin;
386 FFOptionsText(FFOptionsWindow *fwin, int x, int y, int w);
391 class FFOptionsApply : public BC_GenericButton {
393 FFOptionsWindow *fwin;
395 FFOptionsApply(FFOptionsWindow *fwin, int x, int y);
400 class FFOptionsWindow : public BC_Window
403 FFOptionsWindow(FFOptionsDialog *dialog);
406 void create_objects();
407 void update(FFOptions_Opt *oip);
409 int resize_event(int w, int h);
411 FFOptionsDialog *dialog;
414 FFOptions_OptPanel *panel;
415 int panel_x, panel_y, panel_w, panel_h;
416 BC_Title *type, *range, *kind_title;
417 FFOptions_Opt *selected;
420 FFOptionsUnits *units;
422 FFOptionsApply *apply;
425 class FFOptionsDialog : public BC_DialogThread
430 virtual void update_options(const char *options) = 0;
432 void load_options(const char *bp, int len);
433 void store_options(char *cp, int len);
434 void start(const char *format_name, const char *codec_name,
435 AVCodec *codec, const char *options, int len);
436 BC_Window* new_gui();
437 void handle_done_event(int result);
439 FFOptionsWindow *options_window;
440 const char *format_name, *codec_name;
442 AVDictionary *ff_opts;
446 class FFOptionsAudioDialog : public FFOptionsDialog
449 FFMPEGConfigAudio *aud_config;
450 void update_options(const char *options);
452 FFOptionsAudioDialog(FFMPEGConfigAudio *aud_config);
453 ~FFOptionsAudioDialog();
456 class FFOptionsVideoDialog : public FFOptionsDialog
459 FFMPEGConfigVideo *vid_config;
460 void update_options(const char *options);
462 FFOptionsVideoDialog(FFMPEGConfigVideo *vid_config);
463 ~FFOptionsVideoDialog();
466 class FFOptionsViewAudio: public BC_GenericButton
469 FFOptionsViewAudio(FFMPEGConfigAudio *aud_config, int x, int y, const char *text);
470 ~FFOptionsViewAudio();
473 FFMPEGConfigAudio *aud_config;
476 class FFOptionsViewVideo : public BC_GenericButton
479 FFOptionsViewVideo(FFMPEGConfigVideo *vid_config, int x, int y, const char *text);
480 ~FFOptionsViewVideo();
483 FFMPEGConfigVideo *vid_config;