00001 #ifndef FILEMPEG_H
00002 #define FILEMPEG_H
00003
00004 #include "bitspopup.inc"
00005 #include "condition.inc"
00006 #include "file.inc"
00007 #include "filebase.h"
00008 #include <lame/lame.h>
00009 #include "libmpeg3.h"
00010 #include "thread.h"
00011
00012
00013 extern "C"
00014 {
00015
00016
00017
00018 void mpeg2enc_init_buffers();
00019 int mpeg2enc(int argc, char *argv[]);
00020 void mpeg2enc_set_w(int width);
00021 void mpeg2enc_set_h(int height);
00022 void mpeg2enc_set_rate(double rate);
00023 void mpeg2enc_set_input_buffers(int eof, char *y, char *u, char *v);
00024
00025
00026
00027
00028 void toolame_init_buffers();
00029 int toolame(int argc, char **argv);
00030 int toolame_send_buffer(char *data, int bytes);
00031
00032
00033 }
00034
00035 class FileMPEGVideo;
00036 class FileMPEGAudio;
00037
00038 class FileMPEG : public FileBase
00039 {
00040 public:
00041 FileMPEG(Asset *asset, File *file);
00042 ~FileMPEG();
00043
00044 friend class FileMPEGVideo;
00045 friend class FileMPEGAudio;
00046
00047 static void get_parameters(BC_WindowBase *parent_window,
00048 Asset *asset,
00049 BC_WindowBase* &format_window,
00050 int audio_options,
00051 int video_options);
00052
00053 static int check_sig(Asset *asset);
00054
00055
00056 static void get_info(Asset *asset, int64_t *bytes, int *stracks);
00057 int open_file(int rd, int wr);
00058 int close_file();
00059 int create_index();
00060
00061
00062 int get_index(char *index_path);
00063 int set_video_position(int64_t x);
00064 int set_audio_position(int64_t x);
00065 int write_samples(double **buffer,
00066 int64_t len);
00067 int write_frames(VFrame ***frames, int len);
00068
00069 int read_frame(VFrame *frame);
00070 int read_samples(double *buffer, int64_t len);
00071 int read_samples_float(float *buffer, int64_t len);
00072 int prefer_samples_float();
00073
00074 int64_t get_memory_usage();
00075
00076
00077 static int get_best_colormodel(Asset *asset, int driver);
00078 int colormodel_supported(int colormodel);
00079
00080 int can_copy_from(Edit *edit, int64_t position);
00081 static char *strtocompression(char *string);
00082 static char *compressiontostr(char *string);
00083
00084
00085 private:
00086 void to_streamchannel(int channel, int &stream_out, int &channel_out);
00087 int reset_parameters_derived();
00088
00089 mpeg3_t *fd;
00090
00091
00092 FileMPEGVideo *video_out;
00093
00094 ArrayList<char*> vcommand_line;
00095 void append_vcommand_line(const char *string);
00096
00097
00098
00099
00100 FILE *dvb_out;
00101
00102
00103
00104
00105
00106 FILE *mjpeg_out;
00107 int mjpeg_error;
00108 Condition *next_frame_lock;
00109 Condition *next_frame_done;
00110 int mjpeg_eof;
00111 int wrote_header;
00112 unsigned char *mjpeg_y;
00113 unsigned char *mjpeg_u;
00114 unsigned char *mjpeg_v;
00115 char mjpeg_command[BCTEXTLEN];
00116
00117
00118
00119
00120
00121
00122
00123 FileMPEGAudio *audio_out;
00124
00125 ArrayList<char*> acommand_line;
00126 void append_acommand_line(const char *string);
00127
00128
00129
00130 VFrame *temp_frame;
00131
00132 unsigned char *toolame_temp;
00133 int toolame_allocation;
00134 int toolame_result;
00135
00136
00137 float *lame_temp[2];
00138 int lame_allocation;
00139 char *lame_output;
00140 int lame_output_allocation;
00141 FILE *lame_fd;
00142
00143 int lame_started;
00144
00145 lame_global_flags *lame_global;
00146 };
00147
00148
00149 class FileMPEGVideo : public Thread
00150 {
00151 public:
00152 FileMPEGVideo(FileMPEG *file);
00153 ~FileMPEGVideo();
00154
00155 void run();
00156
00157 FileMPEG *file;
00158 };
00159
00160 class FileMPEGAudio : public Thread
00161 {
00162 public:
00163 FileMPEGAudio(FileMPEG *file);
00164 ~FileMPEGAudio();
00165
00166 void run();
00167
00168 FileMPEG *file;
00169 };
00170
00171
00172 class MPEGConfigAudioPopup;
00173 class MPEGABitrate;
00174
00175
00176 class MPEGConfigAudio : public BC_Window
00177 {
00178 public:
00179 MPEGConfigAudio(BC_WindowBase *parent_window, Asset *asset);
00180 ~MPEGConfigAudio();
00181
00182 int create_objects();
00183 int close_event();
00184
00185 BC_WindowBase *parent_window;
00186 MPEGABitrate *bitrate;
00187 char string[BCTEXTLEN];
00188 Asset *asset;
00189 };
00190
00191
00192 class MPEGLayer : public BC_PopupMenu
00193 {
00194 public:
00195 MPEGLayer(int x, int y, MPEGConfigAudio *gui);
00196 void create_objects();
00197 int handle_event();
00198 static int string_to_layer(char *string);
00199 static char* layer_to_string(int derivative);
00200
00201 MPEGConfigAudio *gui;
00202 };
00203
00204 class MPEGABitrate : public BC_PopupMenu
00205 {
00206 public:
00207 MPEGABitrate(int x, int y, MPEGConfigAudio *gui);
00208
00209 void create_objects();
00210 void set_layer(int layer);
00211
00212 int handle_event();
00213 static int string_to_bitrate(char *string);
00214 static char* bitrate_to_string(char *string, int bitrate);
00215
00216 MPEGConfigAudio *gui;
00217 };
00218
00219
00220
00221 class MPEGConfigVideo;
00222
00223
00224
00225 class MPEGPreset : public BC_PopupMenu
00226 {
00227 public:
00228 MPEGPreset(int x, int y, MPEGConfigVideo *gui);
00229 void create_objects();
00230 int handle_event();
00231 static int string_to_value(char *string);
00232 static char* value_to_string(int value);
00233 MPEGConfigVideo *gui;
00234 };
00235
00236 class MPEGColorModel : public BC_PopupMenu
00237 {
00238 public:
00239 MPEGColorModel(int x, int y, MPEGConfigVideo *gui);
00240 void create_objects();
00241 int handle_event();
00242 static int string_to_cmodel(char *string);
00243 static char* cmodel_to_string(int cmodel);
00244
00245 MPEGConfigVideo *gui;
00246 };
00247
00248
00249 class MPEGDerivative : public BC_PopupMenu
00250 {
00251 public:
00252 MPEGDerivative(int x, int y, MPEGConfigVideo *gui);
00253 void create_objects();
00254 int handle_event();
00255 static int string_to_derivative(char *string);
00256 static char* derivative_to_string(int derivative);
00257
00258 MPEGConfigVideo *gui;
00259 };
00260
00261 class MPEGBitrate : public BC_TextBox
00262 {
00263 public:
00264 MPEGBitrate(int x, int y, MPEGConfigVideo *gui);
00265 int handle_event();
00266 MPEGConfigVideo *gui;
00267 };
00268
00269 class MPEGQuant : public BC_TumbleTextBox
00270 {
00271 public:
00272 MPEGQuant(int x, int y, MPEGConfigVideo *gui);
00273 int handle_event();
00274 MPEGConfigVideo *gui;
00275 };
00276
00277 class MPEGIFrameDistance : public BC_TumbleTextBox
00278 {
00279 public:
00280 MPEGIFrameDistance(int x, int y, MPEGConfigVideo *gui);
00281 int handle_event();
00282 MPEGConfigVideo *gui;
00283 };
00284
00285 class MPEGPFrameDistance : public BC_TumbleTextBox
00286 {
00287 public:
00288 MPEGPFrameDistance(int x, int y, MPEGConfigVideo *gui);
00289 int handle_event();
00290 MPEGConfigVideo *gui;
00291 };
00292
00293 class MPEGFixedBitrate : public BC_Radial
00294 {
00295 public:
00296 MPEGFixedBitrate(int x, int y, MPEGConfigVideo *gui);
00297 int handle_event();
00298 MPEGConfigVideo *gui;
00299 };
00300
00301 class MPEGFixedQuant : public BC_Radial
00302 {
00303 public:
00304 MPEGFixedQuant(int x, int y, MPEGConfigVideo *gui);
00305 int handle_event();
00306 MPEGConfigVideo *gui;
00307 };
00308
00309 class MPEGSeqCodes : public BC_CheckBox
00310 {
00311 public:
00312 MPEGSeqCodes(int x, int y, MPEGConfigVideo *gui);
00313 int handle_event();
00314 MPEGConfigVideo *gui;
00315 };
00316
00317
00318
00319
00320 class MPEGConfigVideo : public BC_Window
00321 {
00322 public:
00323 MPEGConfigVideo(BC_WindowBase *parent_window,
00324 Asset *asset);
00325 ~MPEGConfigVideo();
00326
00327 int create_objects();
00328 int close_event();
00329 void delete_cmodel_objs();
00330 void reset_cmodel();
00331 void update_cmodel_objs();
00332
00333 BC_WindowBase *parent_window;
00334 Asset *asset;
00335 MPEGPreset *preset;
00336 MPEGColorModel *cmodel;
00337 MPEGDerivative *derivative;
00338 MPEGBitrate *bitrate;
00339 MPEGFixedBitrate *fixed_bitrate;
00340 MPEGQuant *quant;
00341 MPEGFixedQuant *fixed_quant;
00342 MPEGIFrameDistance *iframe_distance;
00343 MPEGPFrameDistance *pframe_distance;
00344 BC_CheckBox *top_field_first;
00345 BC_CheckBox *progressive;
00346 BC_CheckBox *denoise;
00347 BC_CheckBox *seq_codes;
00348
00349 ArrayList<BC_Title*> titles;
00350 ArrayList<BC_SubWindow*> tools;
00351 };
00352
00353
00354 #endif