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

filemov.h

Go to the documentation of this file.
00001 #ifndef FILEMOV_H
00002 #define FILEMOV_H
00003 
00004 #include "bitspopup.inc"
00005 #include "condition.inc"
00006 #include "filebase.h"
00007 #include "file.inc"
00008 
00009 #ifdef HAVE_STDLIB_H
00010 #undef HAVE_STDLIB_H
00011 #endif
00012 
00013 #include "libmjpeg.h"
00014 #include "mutex.inc"
00015 #include "quicktime.h"
00016 #include "thread.h"
00017 
00018 class FileMOVThread;
00019 
00020 class ThreadStruct
00021 {
00022 public:
00023         ThreadStruct();
00024         ~ThreadStruct();
00025 
00026         void load_output(mjpeg_t *mjpeg);
00027 
00028         VFrame *input;
00029         unsigned char *output;  // Output buffer
00030         int64_t output_size;        // Size of output buffer
00031         int64_t output_allocated;  // Allocation of output buffer
00032         Condition *completion_lock;
00033 };
00034 
00035 class FileMOV : public FileBase
00036 {
00037 public:
00038         FileMOV(Asset *asset, File *file);
00039         ~FileMOV();
00040 
00041         friend class FileMOVThread;
00042 
00043         static void get_parameters(BC_WindowBase *parent_window, 
00044                 Asset *asset, 
00045                 BC_WindowBase* &format_window,
00046                 int audio_options,
00047                 int video_options,
00048                 int lock_compressor);
00049         static int check_sig(Asset *asset);
00050 
00051         int open_file(int rd, int wr);
00052         int close_file();
00053         void asset_to_format();
00054         void format_to_asset();
00055         int64_t get_video_length();
00056         int64_t get_audio_length();
00057         int set_video_position(int64_t x);
00058         int set_audio_position(int64_t x);
00059         int write_samples(double **buffer, 
00060                         int64_t len);
00061         int write_frames(VFrame ***frames, int len);
00062         int64_t compressed_frame_size();
00063         int read_compressed_frame(VFrame *buffer);
00064         int write_compressed_frame(VFrame *buffer);
00065 
00066         int read_frame(VFrame *frame);
00067         int read_samples(double *buffer, int64_t len);
00068 
00069 // Direct copy routines
00070         static int get_best_colormodel(Asset *asset, int driver);
00071         int colormodel_supported(int colormodel);
00072         int can_copy_from(Edit *edit, int64_t position); // This file can copy frames directly from the asset
00073         static char *strtocompression(char *string);
00074         static char *compressiontostr(char *string);
00075 
00076 // Fix codec to what AVI or MOV support
00077         static void fix_codecs(Asset *asset);
00078 
00079 // set programme timecode
00080         void set_frame_start(int64_t offset);
00081 
00082 private:
00083         void new_audio_temp(int64_t len);
00084 // read raw audio data
00085         int read_raw(char *buffer, int64_t samples, int track);  
00086 // overlay raw frame from the current layer and position
00087         int read_raw(VFrame *frame, 
00088                 float in_x1, float in_y1, float in_x2, float in_y2,
00089                 float out_x1, float out_y1, float out_x2, float out_y2, 
00090                 int use_float, int interpolate);
00091         int reset_parameters_derived();
00092         int quicktime_atracks;
00093         int quicktime_vtracks;
00094 // current positions for when the file descriptor doesn't have the right position
00095         quicktime_t *fd;
00096         int depth;        // Depth in bits per pixel
00097         int64_t frames_correction;  // Correction after 32bit overflow
00098         int64_t samples_correction;  // Correction after 32bit overflow
00099 
00100 // An array of frames for threads to look up and compress on their own.
00101         ArrayList<ThreadStruct*> threadframes;
00102 
00103         int total_threadframes;     // Number of thread frames in this buffer
00104         int current_threadframe;    // Next threadframe to compress
00105         Mutex *threadframe_lock;     // Lock threadframe array.
00106 
00107         FileMOVThread **threads;   // One thread for every CPU
00108         char prefix_path[1024];    // Prefix for new file when 2G limit is exceeded
00109         int suffix_number;         // Number for new file
00110 
00111 // Temp buffers for converting from double to float
00112         float **temp_float;
00113         int64_t temp_allocated;
00114 };
00115 
00116 
00117 // Encoder thread to parallelize certain compression formats, mainly JPEG.
00118 // Only works when no alpha.
00119 
00120 class FileMOVThread : public Thread
00121 {
00122 public:
00123         FileMOVThread(FileMOV *filemov, int fields);
00124         ~FileMOVThread();
00125 
00126         int start_encoding();
00127         int stop_encoding();
00128         int encode_buffer();
00129         void run();
00130 
00131         ThreadStruct *threadframe;    // The frame currently being processed.
00132         int done;
00133         FileMOV *filemov;
00134         Condition *input_lock;     // Wait for new array of threads or completion.
00135         mjpeg_t *mjpeg;
00136         int fields;
00137 };
00138 
00139 
00140 class MOVConfigAudioNum;
00141 class MOVConfigAudioPopup;
00142 class MOVConfigAudioToggle;
00143 
00144 class MOVConfigAudio : public BC_Window
00145 {
00146 public:
00147         MOVConfigAudio(BC_WindowBase *parent_window, Asset *asset);
00148         ~MOVConfigAudio();
00149 
00150         int create_objects();
00151         int close_event();
00152         void update_parameters();
00153         void reset();
00154 
00155         MOVConfigAudioPopup *compression_popup;
00156         ArrayList<BC_ListBoxItem*> compression_items;
00157         BC_WindowBase *parent_window;
00158         BitsPopup *bits_popup;
00159         BC_Title *bits_title;
00160         BC_CheckBox *dither;
00161         Asset *asset;
00162         MOVConfigAudioNum *vorbis_min_bitrate;
00163         MOVConfigAudioNum *vorbis_bitrate;
00164         MOVConfigAudioNum *vorbis_max_bitrate;
00165         MOVConfigAudioToggle *vorbis_vbr;
00166 
00167         MOVConfigAudioNum *mp3_bitrate;
00168         MOVConfigAudioNum *mp4a_bitrate;
00169         MOVConfigAudioNum *mp4a_quantqual;
00170 };
00171 
00172 
00173 class MOVConfigAudioPopup : public BC_PopupTextBox
00174 {
00175 public:
00176         MOVConfigAudioPopup(MOVConfigAudio *popup, int x, int y);
00177         int handle_event();
00178         MOVConfigAudio *popup;
00179 };
00180 
00181 
00182 class MOVConfigAudioToggle : public BC_CheckBox
00183 {
00184 public:
00185         MOVConfigAudioToggle(MOVConfigAudio *popup,
00186                 char *title_text,
00187                 int x,
00188                 int y,
00189                 int *output);
00190         int handle_event();
00191         int *output;
00192         MOVConfigAudio *popup;
00193 };
00194 
00195 
00196 class MOVConfigAudioNum : public BC_TumbleTextBox
00197 {
00198 public:
00199         MOVConfigAudioNum(MOVConfigAudio *popup, 
00200                 char *title_text, 
00201                 int x, 
00202                 int y, 
00203                 int *output);
00204         ~MOVConfigAudioNum();
00205         
00206         void create_objects();
00207         int handle_event();
00208         int *output;
00209         MOVConfigAudio *popup;
00210         BC_Title *title;
00211         char *title_text;
00212         int x, y;
00213 };
00214 
00215 
00216 class MOVConfigVideoPopup;
00217 class MOVConfigVideoNum;
00218 class MOVConfigVideoFix;
00219 class MOVConfigVideoFixBitrate;
00220 class MOVConfigVideoFixQuant;
00221 class MOVConfigVideoCheckBox;
00222 
00223 
00224 class MOVConfigVideo : public BC_Window
00225 {
00226 public:
00227         MOVConfigVideo(BC_WindowBase *parent_window, 
00228                 Asset *asset, 
00229                 int lock_compressor);
00230         ~MOVConfigVideo();
00231 
00232         int create_objects();
00233         int close_event();
00234         void reset();
00235 
00236         void update_parameters();
00237 
00238         ArrayList<BC_ListBoxItem*> compression_items;
00239         MOVConfigVideoPopup *compression_popup;
00240         BC_WindowBase *parent_window;
00241         Asset *asset;
00242         int param_x, param_y;
00243         int lock_compressor;
00244         
00245         BC_ISlider *jpeg_quality;
00246         BC_Title *jpeg_quality_title;
00247 
00248         MOVConfigVideoNum *ms_bitrate;
00249         MOVConfigVideoNum *ms_bitrate_tolerance;
00250         MOVConfigVideoNum *ms_quantization;
00251         MOVConfigVideoNum *ms_gop_size;
00252         MOVConfigVideoCheckBox *ms_interlaced;
00253         MOVConfigVideoFixBitrate *ms_fix_bitrate;
00254         MOVConfigVideoFixQuant *ms_fix_quant;
00255 
00256         MOVConfigVideoNum *divx_bitrate;
00257         MOVConfigVideoNum *divx_quantizer;
00258         MOVConfigVideoNum *divx_rc_period;
00259         MOVConfigVideoNum *divx_rc_reaction_ratio;
00260         MOVConfigVideoNum *divx_rc_reaction_period;
00261         MOVConfigVideoNum *divx_max_key_interval;
00262         MOVConfigVideoNum *divx_max_quantizer;
00263         MOVConfigVideoNum *divx_min_quantizer;
00264         MOVConfigVideoNum *divx_quality;
00265         MOVConfigVideoFixBitrate *divx_fix_bitrate;
00266         MOVConfigVideoFixQuant *divx_fix_quant;
00267 
00268         MOVConfigVideoNum *h264_bitrate;
00269         MOVConfigVideoNum *h264_quantizer;
00270         MOVConfigVideoFixBitrate *h264_fix_bitrate;
00271         MOVConfigVideoFixQuant *h264_fix_quant;
00272 };
00273 
00274 class MOVConfigVideoPopup : public BC_PopupTextBox
00275 {
00276 public:
00277         MOVConfigVideoPopup(MOVConfigVideo *popup, int x, int y);
00278         int handle_event();
00279         MOVConfigVideo *popup;
00280 };
00281 
00282 class MOVConfigVideoFixBitrate : public BC_Radial
00283 {
00284 public:
00285         MOVConfigVideoFixBitrate(int x, 
00286                 int y,
00287                 int *output,
00288                 int value);
00289         int handle_event();
00290         BC_Radial *opposite;
00291         int *output;
00292         int value;
00293 };
00294 
00295 class MOVConfigVideoFixQuant : public BC_Radial
00296 {
00297 public:
00298         MOVConfigVideoFixQuant(int x, 
00299                 int y,
00300                 int *output,
00301                 int value);
00302         int handle_event();
00303         BC_Radial *opposite;
00304         int *output;
00305         int value;
00306 };
00307 
00308 class MOVConfigVideoCheckBox : public BC_CheckBox
00309 {
00310 public:
00311         MOVConfigVideoCheckBox(char *title_text,
00312                 int x,
00313                 int y,
00314                 int *output);
00315         int handle_event();
00316         int *output;
00317 };
00318 
00319 class MOVConfigVideoNum : public BC_TumbleTextBox
00320 {
00321 public:
00322         MOVConfigVideoNum(MOVConfigVideo *popup, 
00323                 char *title_text, 
00324                 int x, 
00325                 int y, 
00326                 int *output);
00327         MOVConfigVideoNum(MOVConfigVideo *popup, 
00328                 char *title_text, 
00329                 int x, 
00330                 int y, 
00331                 int min,
00332                 int max,
00333                 int *output);
00334         ~MOVConfigVideoNum();
00335         
00336         void create_objects();
00337         int handle_event();
00338         int *output;
00339         MOVConfigVideo *popup;
00340         BC_Title *title;
00341         char *title_text;
00342         int x, y;
00343 };
00344 
00345 #endif

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