initial commit
[goodguy/history.git] / cinelerra-5.0 / cinelerra / fileavi.h
1
2 /*
3  * CINELERRA
4  * Copyright (C) 2008 Adam Williams <broadcast at earthling dot net>
5  * 
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * 
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  * 
20  */
21
22 #ifndef FILEAVI_H
23 #define FILEAVI_H
24
25 #include "asset.inc"
26 #include "assets.inc"
27 #include "file.inc"
28 #include "filebase.h"
29
30 #ifdef USE_AVIFILE
31 #include "avifile.h"
32 #include <vector>
33 #endif
34
35 //class IAviWriteFile;
36 //class IAviReadFile;
37 //class IAviReadStream;
38
39 #define MAX_STREAMS 256
40
41 class FileAVI : public FileBase
42 {
43 public:
44         FileAVI(Asset *asset, File *file);
45         ~FileAVI();
46
47         static int check_sig(Asset *asset);
48         static void get_parameters(BC_WindowBase *parent_window, 
49                 Asset *asset, 
50                 BC_WindowBase* &format_window,
51                 int audio_options,
52                 int video_options,
53                 const char *locked_compressor);
54
55         int get_best_colormodel(int driver, int colormodel);
56         int open_file(int rd, int wr);
57         int close_file();
58         void reset();
59         int set_audio_position(int64_t x);
60         int set_video_position(int64_t x);
61         int write_samples(double **buffer, int64_t len);
62         int write_frames(VFrame ***frames, int len);
63         int write_compressed_frame(VFrame *buffer);
64         int read_compressed_frame(VFrame *buffer);
65         int64_t compressed_frame_size();
66         int read_samples(double *buffer, int64_t len);
67         int read_frame(VFrame *frame);
68         static char* vcodec_to_fourcc(const char *input, char *output);
69         static char* fourcc_to_vcodec(char *input, char *output);
70         static char* acodec_to_fourcc(const char *input, char *output);
71         static char* fourcc_to_acodec(char *input, char *output);
72         static int cmodel_bc_to_avi(int input);
73
74         static void initialize_avifile();
75
76
77 private:
78         static int check_sig_arne2(Asset *asset, int &score);
79         static int check_sig_arne1(Asset *asset, int &score);
80         static int check_sig_lavtools(Asset *asset, int &score);
81         static int check_sig_avifile(Asset *asset, int &score);
82
83         int open_avifile_in(Asset *asset);
84         int open_arne2_in(Asset *asset);
85         int open_arne1_in(Asset *asset);
86         int open_lavtools_in(Asset *asset);
87
88
89         int open_avifile_out(Asset *asset);
90         int open_arne2_out(Asset *asset);
91         int open_arne1_out(Asset *asset);
92         int open_lavtools_out(Asset *asset);
93
94 #ifdef USE_AVIFILE
95         IAviWriteFile *out_fd;
96         IAviReadFile *in_fd;
97
98         IAviReadStream *astream_in[MAX_STREAMS];
99         IAviReadStream *vstream_in[MAX_STREAMS];
100         IAviWriteStream *astream_out[MAX_STREAMS];
101         IAviVideoWriteStream *vstream_out[MAX_STREAMS];
102         int out_color_model;
103     BitmapInfo *out_bitmap_info;
104         static int avifile_initialized;
105
106 #endif
107
108
109
110         
111
112
113
114         unsigned char *temp_audio;
115         int64_t temp_allocated;
116         int source_cmodel;
117 };
118
119
120 class AVIConfigAudio;
121
122 class AVIACodecList : public BC_PopupTextBox
123 {
124 public:
125         AVIACodecList(AVIConfigAudio *gui, int x, int y);
126         ~AVIACodecList();
127
128         int handle_event();
129
130         AVIConfigAudio *gui;
131 };
132
133 class AVIConfigAudio : public BC_Window
134 {
135 public:
136         AVIConfigAudio(BC_WindowBase *parent_window, Asset *asset);
137         ~AVIConfigAudio();
138
139         static int calculate_w(int format);
140         static int calculate_h(int format);
141         void create_objects();
142         int close_event();
143         int generate_codeclist();
144         void update_codecs();
145
146         AVIACodecList *list;
147
148         ArrayList<BC_ListBoxItem*> codec_items;
149         ArrayList<BC_ISlider*> attribute_sliders;
150         BC_WindowBase *parent_window;
151         Asset *asset;
152         char string[BCTEXTLEN];
153 };
154
155 class AVIConfigVideo;
156
157 class AVIVCodecList : public BC_PopupTextBox
158 {
159 public:
160         AVIVCodecList(AVIConfigVideo *gui, int x, int y);
161         ~AVIVCodecList();
162
163         int handle_event();
164
165         AVIConfigVideo *gui;
166 };
167
168 class AVIVAttributeList : public BC_ListBox
169 {
170 public:
171         AVIVAttributeList(AVIConfigVideo *gui, int x, int y);
172         int handle_event();
173         int selection_changed();
174         AVIConfigVideo *gui;
175 };
176
177 class AVIVAttribute : public BC_TextBox
178 {
179 public:
180         AVIVAttribute(AVIConfigVideo *gui, int x, int y);
181         int handle_event();
182         AVIConfigVideo *gui;
183 };
184
185 class AVIConfigVideo : public BC_Window
186 {
187 public:
188         AVIConfigVideo(BC_WindowBase *parent_window, 
189                 Asset *asset, 
190                 const char *locked_compressor);
191         ~AVIConfigVideo();
192
193         static int calculate_w(int format);
194         static int calculate_h(int format);
195         void create_objects();
196         int close_event();
197         int generate_codeclist();
198         void generate_attributelist();
199         void update_attribute(int recursive);
200 // Get text associated with current attribute
201         const char* get_current_attribute_text();
202         const char* get_current_attribute_value();
203         void set_current_attribute(const char *text);
204         void reset();
205
206         AVIVCodecList *list;
207         AVIVAttributeList *attributes;
208         AVIVAttribute *attribute;
209         ArrayList<BC_ListBoxItem*> codec_items;
210         ArrayList<BC_ListBoxItem*> attribute_items[2];
211         BC_WindowBase *parent_window;
212         Asset *asset;
213         const char *locked_compressor;
214         char string[BCTEXTLEN];
215 };
216
217
218
219 #endif