Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

filempeg.h

Go to the documentation of this file.
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 // Mpeg2enc prototypes
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 // Toolame prototypes
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         int open_file(int rd, int wr);
00055         int close_file();
00056         int create_index();
00057 
00058 
00059         int get_index(char *index_path);
00060         int set_video_position(int64_t x);
00061         int set_audio_position(int64_t x);
00062         int write_samples(double **buffer, 
00063                         int64_t len);
00064         int write_frames(VFrame ***frames, int len);
00065 
00066         int read_frame(VFrame *frame);
00067         int read_samples(double *buffer, int64_t len);
00068         int read_samples_float(float *buffer, int64_t len);
00069         int prefer_samples_float();
00070 
00071 // Direct copy routines
00072         static int get_best_colormodel(Asset *asset, int driver);
00073         int colormodel_supported(int colormodel);
00074 // This file can copy frames directly from the asset
00075         int can_copy_from(Edit *edit, int64_t position); 
00076         static char *strtocompression(char *string);
00077         static char *compressiontostr(char *string);
00078 
00079 
00080 private:
00081         void to_streamchannel(int channel, int &stream_out, int &channel_out);
00082         int reset_parameters_derived();
00083 // File descriptor for decoder
00084         mpeg3_t *fd;
00085 
00086 // Thread for video encoder
00087         FileMPEGVideo *video_out;
00088 // Command line for video encoder
00089         ArrayList<char*> vcommand_line;
00090         void append_vcommand_line(const char *string);
00091 
00092 
00093 
00094 
00095 
00096 
00097 // MJPEGtools encoder
00098         FILE *mjpeg_out;        
00099         int mjpeg_error;
00100         Condition *next_frame_lock;
00101         Condition *next_frame_done;
00102         int mjpeg_eof;
00103         int wrote_header;
00104         unsigned char *mjpeg_y; 
00105         unsigned char *mjpeg_u; 
00106         unsigned char *mjpeg_v; 
00107         char mjpeg_command[BCTEXTLEN];
00108 
00109 
00110 
00111 
00112 
00113 
00114 // Thread for audio encoder
00115         FileMPEGAudio *audio_out;
00116 // Command line for audio encoder
00117         ArrayList<char*> acommand_line;
00118         void append_acommand_line(const char *string);
00119 
00120 
00121 // Temporary for color conversion
00122         VFrame *temp_frame;
00123 
00124         unsigned char *toolame_temp;
00125         int toolame_allocation;
00126         int toolame_result;
00127 
00128 
00129         float *lame_temp[2];
00130         int lame_allocation;
00131         char *lame_output;
00132         int lame_output_allocation;
00133         FILE *lame_fd;
00134 // Lame puts 0 before stream
00135         int lame_started;
00136 
00137         lame_global_flags *lame_global;
00138 };
00139 
00140 
00141 class FileMPEGVideo : public Thread
00142 {
00143 public:
00144         FileMPEGVideo(FileMPEG *file);
00145         ~FileMPEGVideo();
00146 
00147         void run();
00148 
00149         FileMPEG *file;
00150 };
00151 
00152 class FileMPEGAudio : public Thread
00153 {
00154 public:
00155         FileMPEGAudio(FileMPEG *file);
00156         ~FileMPEGAudio();
00157 
00158         void run();
00159 
00160         FileMPEG *file;
00161 };
00162 
00163 
00164 class MPEGConfigAudioPopup;
00165 class MPEGABitrate;
00166 
00167 
00168 class MPEGConfigAudio : public BC_Window
00169 {
00170 public:
00171         MPEGConfigAudio(BC_WindowBase *parent_window, Asset *asset);
00172         ~MPEGConfigAudio();
00173 
00174         int create_objects();
00175         int close_event();
00176 
00177         BC_WindowBase *parent_window;
00178         MPEGABitrate *bitrate;
00179         char string[BCTEXTLEN];
00180         Asset *asset;
00181 };
00182 
00183 
00184 class MPEGLayer : public BC_PopupMenu
00185 {
00186 public:
00187         MPEGLayer(int x, int y, MPEGConfigAudio *gui);
00188         void create_objects();
00189         int handle_event();
00190         static int string_to_layer(char *string);
00191         static char* layer_to_string(int derivative);
00192         
00193         MPEGConfigAudio *gui;
00194 };
00195 
00196 class MPEGABitrate : public BC_PopupMenu
00197 {
00198 public:
00199         MPEGABitrate(int x, int y, MPEGConfigAudio *gui);
00200 
00201         void create_objects();
00202         void set_layer(int layer);
00203 
00204         int handle_event();
00205         static int string_to_bitrate(char *string);
00206         static char* bitrate_to_string(char *string, int bitrate);
00207         
00208         MPEGConfigAudio *gui;
00209 };
00210 
00211 
00212 
00213 class MPEGConfigVideo;
00214 
00215 
00216 
00217 class MPEGPreset : public BC_PopupMenu
00218 {
00219 public:
00220         MPEGPreset(int x, int y, MPEGConfigVideo *gui);
00221         void create_objects();
00222         int handle_event();
00223         static int string_to_value(char *string);
00224         static char* value_to_string(int value);
00225         MPEGConfigVideo *gui;
00226 };
00227 
00228 class MPEGColorModel : public BC_PopupMenu
00229 {
00230 public:
00231         MPEGColorModel(int x, int y, MPEGConfigVideo *gui);
00232         void create_objects();
00233         int handle_event();
00234         static int string_to_cmodel(char *string);
00235         static char* cmodel_to_string(int cmodel);
00236         
00237         MPEGConfigVideo *gui;
00238 };
00239 
00240 
00241 class MPEGDerivative : public BC_PopupMenu
00242 {
00243 public:
00244         MPEGDerivative(int x, int y, MPEGConfigVideo *gui);
00245         void create_objects();
00246         int handle_event();
00247         static int string_to_derivative(char *string);
00248         static char* derivative_to_string(int derivative);
00249         
00250         MPEGConfigVideo *gui;
00251 };
00252 
00253 class MPEGBitrate : public BC_TextBox
00254 {
00255 public:
00256         MPEGBitrate(int x, int y, MPEGConfigVideo *gui);
00257         int handle_event();
00258         MPEGConfigVideo *gui;
00259 };
00260 
00261 class MPEGQuant : public BC_TumbleTextBox
00262 {
00263 public:
00264         MPEGQuant(int x, int y, MPEGConfigVideo *gui);
00265         int handle_event();
00266         MPEGConfigVideo *gui;
00267 };
00268 
00269 class MPEGIFrameDistance : public BC_TumbleTextBox
00270 {
00271 public:
00272         MPEGIFrameDistance(int x, int y, MPEGConfigVideo *gui);
00273         int handle_event();
00274         MPEGConfigVideo *gui;
00275 };
00276 
00277 class MPEGPFrameDistance : public BC_TumbleTextBox
00278 {
00279 public:
00280         MPEGPFrameDistance(int x, int y, MPEGConfigVideo *gui);
00281         int handle_event();
00282         MPEGConfigVideo *gui;
00283 };
00284 
00285 class MPEGFixedBitrate : public BC_Radial
00286 {
00287 public:
00288         MPEGFixedBitrate(int x, int y, MPEGConfigVideo *gui);
00289         int handle_event();
00290         MPEGConfigVideo *gui;
00291 };
00292 
00293 class MPEGFixedQuant : public BC_Radial
00294 {
00295 public:
00296         MPEGFixedQuant(int x, int y, MPEGConfigVideo *gui);
00297         int handle_event();
00298         MPEGConfigVideo *gui;
00299 };
00300 
00301 class MPEGSeqCodes : public BC_CheckBox
00302 {
00303 public:
00304         MPEGSeqCodes(int x, int y, MPEGConfigVideo *gui);
00305         int handle_event();
00306         MPEGConfigVideo *gui;
00307 };
00308 
00309 
00310 
00311 
00312 class MPEGConfigVideo : public BC_Window
00313 {
00314 public:
00315         MPEGConfigVideo(BC_WindowBase *parent_window, 
00316                 Asset *asset);
00317         ~MPEGConfigVideo();
00318 
00319         int create_objects();
00320         int close_event();
00321         void delete_cmodel_objs();
00322         void reset_cmodel();
00323         void update_cmodel_objs();
00324 
00325         BC_WindowBase *parent_window;
00326         Asset *asset;
00327         MPEGPreset *preset;
00328         MPEGColorModel *cmodel;
00329         MPEGDerivative *derivative;
00330         MPEGBitrate *bitrate;
00331         MPEGFixedBitrate *fixed_bitrate;
00332         MPEGQuant *quant;
00333         MPEGFixedQuant *fixed_quant;
00334         MPEGIFrameDistance *iframe_distance;
00335         MPEGPFrameDistance *pframe_distance;
00336         BC_CheckBox *top_field_first;
00337         BC_CheckBox *progressive;
00338         BC_CheckBox *denoise;
00339         BC_CheckBox *seq_codes;
00340 
00341         ArrayList<BC_Title*> titles;
00342         ArrayList<BC_SubWindow*> tools;
00343 };
00344 
00345 
00346 #endif

Generated on Sun Jan 8 13:38:54 2006 for Cinelerra-svn by  doxygen 1.4.4