1 #ifndef __FILEFFMPEG_H__
2 #define __FILEFFMPEG_H__
6 #include "bcwindowbase.inc"
7 #include "bitspopup.inc"
10 #include "fileffmpeg.inc"
11 #include "indexfile.inc"
12 #include "mainprogress.inc"
24 class FileFFMPEG : public FileBase
29 FileFFMPEG(Asset *asset, File *file);
31 static void ff_lock(const char *cp=0);
32 static void ff_unlock();
34 static void get_parameters(BC_WindowBase *parent_window,Asset *asset,
35 BC_WindowBase *&format_window,int audio_options,int video_options);
36 static int check_sig(Asset *asset);
37 int get_video_info(int track, int &pid, double &framerate,
38 int &width, int &height, char *title=0);
39 int get_audio_for_video(int vstream, int astream, int64_t &channel_mask);
40 static void get_info(char *path,char *text,int len);
41 int open_file(int rd,int wr);
42 int get_index(IndexFile *index_file, MainProgressBar *progress_bar);
44 int write_samples(double **buffer,int64_t len);
45 int write_frames(VFrame ***frames,int len);
46 int read_samples(double *buffer,int64_t len);
47 int read_frame(VFrame *frame);
48 int64_t get_memory_usage(void);
49 int colormodel_supported(int colormodel);
50 static int get_best_colormodel(Asset *asset, int driver);
51 int select_video_stream(Asset *asset, int vstream);
52 int select_audio_stream(Asset *asset, int astream);
55 class FFMpegConfigNum : public BC_TumbleTextBox
58 FFMpegConfigNum(BC_Window *window, int x, int y,
59 char *title_text, int *output);
62 void create_objects();
71 class FFMpegAudioNum : public FFMpegConfigNum
74 FFMpegAudioNum(BC_Window *window, int x, int y, char *title_text, int *output);
77 FFMPEGConfigAudio *window() { return (FFMPEGConfigAudio *)FFMpegConfigNum::window; }
80 class FFMpegAudioBitrate : public FFMpegAudioNum
83 FFMpegAudioBitrate(BC_Window *window, int x, int y, char *title_text, int *output)
84 : FFMpegAudioNum(window, x, y, title_text, output) {}
88 class FFMpegVideoNum : public FFMpegConfigNum
91 FFMpegVideoNum(BC_Window *window, int x, int y, char *title_text, int *output);
94 FFMPEGConfigVideo *window() { return (FFMPEGConfigVideo *)FFMpegConfigNum::window; }
97 class FFMpegVideoBitrate : public FFMpegVideoNum
100 FFMpegVideoBitrate(BC_Window *window, int x, int y, char *title_text, int *output)
101 : FFMpegVideoNum(window, x, y, title_text, output) {}
105 class FFMpegVideoQuality : public FFMpegVideoNum
108 FFMpegVideoQuality(BC_Window *window, int x, int y, char *title_text, int *output)
109 : FFMpegVideoNum(window, x, y, title_text, output) {}
113 class FFMPEGConfigAudio : public BC_Window
116 FFMPEGConfigAudio(BC_WindowBase *parent_window, Asset *asset);
117 ~FFMPEGConfigAudio();
119 void create_objects();
122 ArrayList<BC_ListBoxItem*> presets;
123 FFMPEGConfigAudioPopup *preset_popup;
124 FFMpegAudioBitrate *bitrate;
125 FFAudioOptions *audio_options;
126 BC_WindowBase *parent_window;
128 FFOptionsDialog *ff_options_dialog;
131 class FFAudioOptions : public BC_ScrollTextBox
134 FFAudioOptions(FFMPEGConfigAudio *audio_popup,
135 int x, int y, int w, int rows, int size, char *text);
138 FFMPEGConfigAudio *audio_popup;
142 class FFMPEGConfigAudioPopup : public BC_PopupTextBox
145 FFMPEGConfigAudioPopup(FFMPEGConfigAudio *popup, int x, int y);
147 FFMPEGConfigAudio *popup;
151 class FFMPEGConfigAudioToggle : public BC_CheckBox
154 FFMPEGConfigAudioToggle(FFMPEGConfigAudio *popup,
155 char *title_text, int x, int y, int *output);
158 FFMPEGConfigAudio *popup;
161 class FFMPEGConfigVideo : public BC_Window
164 FFMPEGConfigVideo(BC_WindowBase *parent_window, Asset *asset);
165 ~FFMPEGConfigVideo();
167 void create_objects();
170 ArrayList<BC_ListBoxItem*> presets;
171 FFMPEGConfigVideoPopup *preset_popup;
172 BC_WindowBase *parent_window;
173 FFMpegVideoBitrate *bitrate;
174 FFMpegVideoQuality *quality;
175 FFVideoOptions *video_options;
177 FFOptionsDialog *ff_options_dialog;
180 class FFVideoOptions : public BC_ScrollTextBox
183 FFVideoOptions(FFMPEGConfigVideo *video_popup,
184 int x, int y, int w, int rows, int size, char *text);
187 FFMPEGConfigVideo *video_popup;
190 class FFMPEGConfigVideoPopup : public BC_PopupTextBox
193 FFMPEGConfigVideoPopup(FFMPEGConfigVideo *popup, int x, int y);
195 FFMPEGConfigVideo *popup;
198 class FFMPEGConfigVideoToggle : public BC_CheckBox
201 FFMPEGConfigVideoToggle(FFMPEGConfigVideo *popup,
202 char *title_text, int x, int y, int *output);
205 FFMPEGConfigVideo *popup;
208 class FFMPEGScanProgress : public Thread
211 IndexFile *index_file;
212 MainProgressBar *progress_bar;
213 char progress_title[BCTEXTLEN];
214 int64_t length, *position;
217 FFMPEGScanProgress(IndexFile *index_file, MainProgressBar *progress_bar,
218 const char *title, int64_t length, int64_t *position, int *canceled);
219 ~FFMPEGScanProgress();
224 class FFOptions_OptName : public BC_ListBoxItem {
228 FFOptions_OptName(FFOptions_Opt *opt, const char *nm);
229 ~FFOptions_OptName();
233 class FFOptions_OptValue : public BC_ListBoxItem {
238 void update(const char *v);
239 FFOptions_OptValue(FFOptions_Opt *opt);
242 class FFOptions_Opt {
246 FFOptions_OptName *item_name;
247 FFOptions_OptValue *item_value;
249 char *get(char *vp, int sz=-1);
250 void set(const char *val);
252 int scalar(double d, char *rp);
253 int ranges(char *rp);
254 int units(ArrayList<const char *> &opts);
255 const char *unit_name(int id);
259 FFOptions_Opt(FFOptions *options, const AVOption *opt, const char *nm);
263 class FFOptions : public ArrayList<FFOptions_Opt *>
268 FFOptionsWindow *win;
269 AVCodecContext *avctx;
272 void initialize(FFOptionsWindow *win, int k);
273 static int cmpr(const void *a, const void *b);
278 class FFOptions_OptPanel : public BC_ListBox {
280 FFOptions_OptPanel(FFOptionsWindow *fwin, int x, int y, int w, int h);
281 ~FFOptions_OptPanel();
282 void create_objects();
283 int cursor_leave_event();
285 FFOptionsWindow *fwin;
286 ArrayList<BC_ListBoxItem*> items[2];
287 ArrayList<BC_ListBoxItem*> &opts;
288 ArrayList<BC_ListBoxItem*> &vals;
289 char tip_text[BCTEXTLEN];
291 int selection_changed();
293 void show_tip(const char *tip);
296 class FFOptionsKindItem : public BC_MenuItem
304 FFOptionsKindItem(FFOptionsKind *kind, const char *name, int idx);
305 ~FFOptionsKindItem();
308 class FFOptionsKind : public BC_PopupMenu
310 static const char *kinds[];
312 FFOptionsWindow *fwin;
315 void create_objects();
319 FFOptionsKind(FFOptionsWindow *fwin, int x, int y, int w);
323 class FFOptionsUnits : public BC_PopupMenu {
325 FFOptionsWindow *fwin;
327 FFOptionsUnits(FFOptionsWindow *fwin, int x, int y, int w);
332 class FFOptionsText : public BC_TextBox {
334 FFOptionsWindow *fwin;
336 FFOptionsText(FFOptionsWindow *fwin, int x, int y, int w);
341 class FFOptionsApply : public BC_GenericButton {
343 FFOptionsWindow *fwin;
345 FFOptionsApply(FFOptionsWindow *fwin, int x, int y);
350 class FFOptionsWindow : public BC_Window
353 FFOptionsWindow(FFOptionsDialog *dialog);
356 void create_objects();
357 void update(FFOptions_Opt *oip);
359 int resize_event(int w, int h);
361 FFOptionsDialog *dialog;
364 FFOptions_OptPanel *panel;
365 int panel_x, panel_y, panel_w, panel_h;
366 BC_Title *type, *range, *kind_title;
367 FFOptions_Opt *selected;
370 FFOptionsUnits *units;
372 FFOptionsApply *apply;
375 class FFOptionsDialog : public BC_DialogThread
380 virtual void update_options(const char *options) = 0;
382 void load_options(const char *bp, int len);
383 void store_options(char *cp, int len);
384 void start(const char *format_name, const char *codec_name,
385 AVCodec *codec, const char *options, int len);
386 BC_Window* new_gui();
387 void handle_done_event(int result);
389 FFOptionsWindow *options_window;
390 const char *format_name, *codec_name;
392 AVDictionary *ff_opts;
396 class FFOptionsAudioDialog : public FFOptionsDialog
399 FFMPEGConfigAudio *aud_config;
400 void update_options(const char *options);
402 FFOptionsAudioDialog(FFMPEGConfigAudio *aud_config);
403 ~FFOptionsAudioDialog();
406 class FFOptionsVideoDialog : public FFOptionsDialog
409 FFMPEGConfigVideo *vid_config;
410 void update_options(const char *options);
412 FFOptionsVideoDialog(FFMPEGConfigVideo *vid_config);
413 ~FFOptionsVideoDialog();
416 class FFOptionsViewAudio: public BC_GenericButton
419 FFOptionsViewAudio(FFMPEGConfigAudio *aud_config, int x, int y, const char *text);
420 ~FFOptionsViewAudio();
423 FFMPEGConfigAudio *aud_config;
426 class FFOptionsViewVideo : public BC_GenericButton
429 FFOptionsViewVideo(FFMPEGConfigVideo *vid_config, int x, int y, const char *text);
430 ~FFOptionsViewVideo();
433 FFMPEGConfigVideo *vid_config;