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 FFMPEGConfigWindow : public BC_Window
161 FFMPEGConfigWindow(const char *title, BC_WindowBase *parent_window,
162 int x, int y, int w, int h, Asset *asset, EDL *edl);
163 ~FFMPEGConfigWindow();
164 virtual void read_options() = 0;
165 virtual void save_options() = 0;
166 void start(AVCodecContext *avctx);
167 void start(AVFormatContext *fmt_ctx);
169 BC_WindowBase *parent_window;
170 FFOptionsDialog *ff_options_dialog;
173 AVCodecContext *avctx;
174 AVFormatContext *fmt_ctx;
179 class FFMPEGConfigAudio : public FFMPEGConfigWindow
182 FFMPEGConfigAudio(BC_WindowBase *parent_window,
183 int x, int y, Asset *asset, EDL *edl);
184 ~FFMPEGConfigAudio();
186 void create_objects();
192 FFMpegSampleFormat *sample_format;
193 ArrayList<BC_ListBoxItem*> presets;
194 FFMPEGConfigAudioPopup *preset_popup;
195 FFMpegAudioBitrate *bitrate;
196 FFMpegAudioQuality *quality;
197 FFAudioOptions *audio_options;
198 BC_WindowBase *parent_window;
199 FFOptionsViewAudio *view_audio;
200 FFOptionsViewFormat *view_format;
203 class FFAudioOptions : public BC_ScrollTextBox
206 FFAudioOptions(FFMPEGConfigAudio *audio_popup,
207 int x, int y, int w, int rows, int size, char *text);
209 FFMPEGConfigAudio *audio_popup;
213 class FFMPEGConfigAudioPopup : public BC_PopupTextBox
216 FFMPEGConfigAudioPopup(FFMPEGConfigAudio *popup, int x, int y);
218 FFMPEGConfigAudio *popup;
221 class FFMPEGConfigVideo : public FFMPEGConfigWindow
224 FFMPEGConfigVideo(BC_WindowBase *parent_window,
225 int x, int y, Asset *asset, EDL *edl);
226 ~FFMPEGConfigVideo();
230 void create_objects();
234 FFMpegPixelFormat *pixel_format;
235 ArrayList<BC_ListBoxItem*> presets;
236 FFMPEGConfigVideoPopup *preset_popup;
237 BC_WindowBase *parent_window;
238 FFMpegVideoBitrate *bitrate;
239 FFMpegVideoQuality *quality;
240 FFVideoOptions *video_options;
241 FFOptionsViewVideo *view_video;
242 FFOptionsViewFormat *view_format;
245 class FFVideoOptions : public BC_ScrollTextBox
248 FFVideoOptions(FFMPEGConfigVideo *video_popup,
249 int x, int y, int w, int rows, int size, char *text);
251 FFMPEGConfigVideo *video_popup;
254 class FFMPEGConfigVideoPopup : public BC_PopupTextBox
257 FFMPEGConfigVideoPopup(FFMPEGConfigVideo *popup, int x, int y);
259 FFMPEGConfigVideo *popup;
262 class FFMPEGConfigFormat : public FFMPEGConfigWindow
265 FFMPEGConfigFormat(FFOptionsFormatViewDialog *view_dialog,
266 int x, int y, Asset *asset, EDL *edl);
267 ~FFMPEGConfigFormat();
272 void create_objects();
276 FFOptionsFormatViewDialog *view_dialog;
277 FFFormatOptions *format_options;
280 class FFFormatOptions : public BC_ScrollTextBox
283 FFFormatOptions(FFMPEGConfigFormat *format_popup,
284 int x, int y, int w, int rows, int size, char *text);
286 FFMPEGConfigFormat *format_popup;
290 class FFMPEGScanProgress : public Thread
293 IndexFile *index_file;
294 MainProgressBar *progress_bar;
295 char progress_title[BCTEXTLEN];
296 int64_t length, *position;
299 FFMPEGScanProgress(IndexFile *index_file, MainProgressBar *progress_bar,
300 const char *title, int64_t length, int64_t *position, int *canceled);
301 ~FFMPEGScanProgress();
306 class FFOptions_OptName : public BC_ListBoxItem {
310 FFOptions_OptName(FFOptions_Opt *opt, const char *nm);
311 ~FFOptions_OptName();
315 class FFOptions_OptValue : public BC_ListBoxItem {
320 void update(const char *v);
321 FFOptions_OptValue(FFOptions_Opt *opt);
324 class FFOptions_Opt {
328 FFOptions_OptName *item_name;
329 FFOptions_OptValue *item_value;
331 char *get(char *vp, int sz=-1);
332 void set(const char *val);
334 int scalar(double d, char *rp);
335 int ranges(char *rp);
336 int units(ArrayList<const char *> &opts);
337 const char *unit_name(int id);
341 FFOptions_Opt(FFOptions *options, const AVOption *opt, const char *nm);
345 class FFOptions : public ArrayList<FFOptions_Opt *>
350 FFOptionsWindow *win;
351 AVCodecContext *avctx;
354 void initialize(FFOptionsWindow *win, int kind);
355 static int cmpr(const void *a, const void *b);
360 class FFOptions_OptPanel : public BC_ListBox {
362 FFOptions_OptPanel(FFOptionsWindow *fwin, int x, int y, int w, int h);
363 ~FFOptions_OptPanel();
364 void create_objects();
365 int cursor_leave_event();
367 FFOptionsWindow *fwin;
368 ArrayList<BC_ListBoxItem*> items[2];
369 ArrayList<BC_ListBoxItem*> &opts;
370 ArrayList<BC_ListBoxItem*> &vals;
371 char tip_text[BCTEXTLEN];
373 int selection_changed();
375 void show_tip(const char *tip);
378 class FFOptionsKindItem : public BC_MenuItem
386 FFOptionsKindItem(FFOptionsKind *kind, const char *name, int idx);
387 ~FFOptionsKindItem();
390 class FFOptionsKind : public BC_PopupMenu
392 static const char *kinds[];
394 FFOptionsWindow *fwin;
397 void create_objects();
401 FFOptionsKind(FFOptionsWindow *fwin, int x, int y, int w);
405 class FFOptionsUnits : public BC_PopupMenu {
407 FFOptionsWindow *fwin;
409 FFOptionsUnits(FFOptionsWindow *fwin, int x, int y, int w);
414 class FFOptionsText : public BC_TextBox {
416 FFOptionsWindow *fwin;
418 FFOptionsText(FFOptionsWindow *fwin, int x, int y, int w);
423 class FFOptionsApply : public BC_GenericButton {
425 FFOptionsWindow *fwin;
427 FFOptionsApply(FFOptionsWindow *fwin, int x, int y);
432 class FFOptionsWindow : public BC_Window
435 FFOptionsWindow(FFOptionsDialog *dialog, int x, int y);
438 void create_objects();
439 void update(FFOptions_Opt *oip);
441 int resize_event(int w, int h);
443 FFOptionsDialog *dialog;
446 FFOptions_OptPanel *panel;
447 int panel_x, panel_y, panel_w, panel_h;
448 BC_Title *type, *range, *kind_title;
449 FFOptions_Opt *selected;
452 FFOptionsUnits *units;
454 FFOptionsApply *apply;
457 class FFOptionsDialog : public BC_DialogThread
460 FFOptionsDialog(FFMPEGConfigWindow *cfg_window);
462 virtual void update_options(const char *options) = 0;
464 void load_options(const char *bp, int len);
465 void store_options(char *cp, int len);
467 BC_Window* new_gui();
468 void handle_done_event(int result);
470 FFMPEGConfigWindow *cfg_window;
471 FFOptionsWindow *options_window;
472 AVDictionary *ff_opts;
476 class FFOptionsAudioDialog : public FFOptionsDialog
479 FFMPEGConfigAudio *aud_config;
480 void update_options(const char *options);
482 FFOptionsAudioDialog(FFMPEGConfigAudio *aud_config);
483 ~FFOptionsAudioDialog();
486 class FFOptionsVideoDialog : public FFOptionsDialog
489 FFMPEGConfigVideo *vid_config;
490 void update_options(const char *options);
492 FFOptionsVideoDialog(FFMPEGConfigVideo *vid_config);
493 ~FFOptionsVideoDialog();
496 class FFOptionsFormatDialog : public FFOptionsDialog
499 FFMPEGConfigFormat *fmt_config;
500 void update_options(const char *options);
502 FFOptionsFormatDialog(FFMPEGConfigFormat *fmt_config);
503 ~FFOptionsFormatDialog();
506 class FFOptionsViewAudio : public BC_GenericButton
509 FFOptionsViewAudio(FFMPEGConfigAudio *aud_config, int x, int y, const char *text);
510 ~FFOptionsViewAudio();
513 FFMPEGConfigAudio *aud_config;
514 AVCodecContext *avctx;
517 class FFOptionsViewVideo : public BC_GenericButton
520 FFOptionsViewVideo(FFMPEGConfigVideo *vid_config, int x, int y, const char *text);
521 ~FFOptionsViewVideo();
524 FFMPEGConfigVideo *vid_config;
525 AVCodecContext *avctx;
528 class FFOptionsViewFormat : public BC_GenericButton
531 FFOptionsViewFormat(FFMPEGConfigWindow *cfg_window,
532 EDL *edl, Asset *asset, int x, int y, const char *text);
533 ~FFOptionsViewFormat();
536 FFMPEGConfigWindow *cfg_window;
539 FFOptionsFormatViewDialog *format_dialog;
542 class FFOptionsFormatView : public BC_GenericButton
545 FFOptionsFormatView(FFMPEGConfigFormat *fmt_config, int x, int y, const char *text);
546 ~FFOptionsFormatView();
549 FFMPEGConfigFormat *fmt_config;
550 AVFormatContext *fmt_ctx;
553 class FFOptionsFormatViewDialog : public BC_DialogThread
556 FFOptionsFormatViewDialog(FFOptionsViewFormat *view_format, int wx, int wy);
557 ~FFOptionsFormatViewDialog();
558 BC_Window* new_gui();
559 void handle_done_event(int result);
561 FFOptionsViewFormat *view_format;
562 FFMPEGConfigFormat *cfg_window;