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

filejpeglist.C

Go to the documentation of this file.
00001 #include "assets.h"
00002 #include "file.h"
00003 #include "filejpeglist.h"
00004 #include "guicast.h"
00005 #include "libmjpeg.h"
00006 #include "mwindow.inc"
00007 #include "jpegwrapper.h"
00008 #include "quicktime.h"
00009 #include "vframe.h"
00010 
00011 #include <ctype.h>
00012 #include <stdlib.h>
00013 #include <string.h>
00014 
00015 
00016 FileJPEGList::FileJPEGList(Asset *asset, File *file)
00017  : FileList(asset, file)
00018 {
00019         asset->format = FILE_JPEG_LIST;
00020 }
00021 
00022 FileJPEGList::~FileJPEGList()
00023 {
00024         close_file();
00025 }
00026 
00027 char* FileJPEGList::list_title()
00028 {
00029         return _("JPEGLIST");
00030 }
00031 
00032 char* FileJPEGList::extension()
00033 {
00034         return ".jpg";
00035 }
00036 
00037 void FileJPEGList::get_parameters(BC_WindowBase *parent_window, 
00038         Asset *asset, 
00039         BC_WindowBase* &format_window,
00040         int audio_options,
00041         int video_options)
00042 {
00043         if(video_options)
00044         {
00045                 JPEGConfigVideo *window = new JPEGConfigVideo(parent_window, asset);
00046                 format_window = window;
00047                 window->create_objects();
00048                 window->run_window();
00049                 delete window;
00050         }
00051 }
00052 
00053 int FileJPEGList::can_copy_from(Asset *asset)
00054 {
00055         if(asset->format == FILE_JPEG_LIST)
00056                 return 1;
00057         else
00058         if(asset->format == FILE_MOV && match4(asset->vcodec, QUICKTIME_JPEG))
00059                 return 1;
00060         
00061         return 0;
00062 }
00063 
00064 int FileJPEGList::get_best_colormodel(int driver, int colormodel)
00065 {
00066         if(colormodel > -1)
00067         {
00068                 switch(colormodel)
00069                 {
00070                         case BC_YUV420P:
00071                         case BC_YUV422P:
00072                         case BC_YUV422:
00073                                 return colormodel;
00074                                 break;
00075                         default:
00076                                 return BC_YUV422P;
00077                                 break;
00078                 }
00079         }
00080         return BC_YUV422P;
00081 }
00082 
00083 
00084 int FileJPEGList::read_frame(VFrame *frame, VFrame *data)
00085 {
00086         mjpeg_t *mjpeg = mjpeg_new(asset->width, 
00087                 asset->height, 
00088                 1);
00089         mjpeg_decompress(mjpeg, 
00090                 data->get_data(), 
00091                 data->get_compressed_size(),
00092                 0,  
00093                 frame->get_rows(), 
00094                 frame->get_y(), 
00095                 frame->get_u(), 
00096                 frame->get_v(),
00097                 frame->get_color_model(),
00098                 file->cpus);
00099         mjpeg_delete(mjpeg);
00100         return 0;
00101 }
00102 
00103 int FileJPEGList::write_frame(VFrame *frame, VFrame *data)
00104 {
00105         mjpeg_t *mjpeg = mjpeg_new(asset->width, 
00106                 asset->height, 
00107                 1);
00108         mjpeg_compress(mjpeg, 
00109                 frame->get_rows(), 
00110                 frame->get_y(), 
00111                 frame->get_u(), 
00112                 frame->get_v(),
00113                 frame->get_color_model(),
00114                 file->cpus);
00115         data->allocate_compressed_data(mjpeg_output_size(mjpeg));
00116         bcopy(mjpeg_output_buffer(mjpeg), frame->get_data(), mjpeg_output_size(mjpeg));
00117         mjpeg_delete(mjpeg);
00118         return 0;
00119 }
00120 
00121 
00122 
00123 
00124 
00125 
00126 
00127 
00128 
00129 
00130 
00131 JPEGConfigVideo::JPEGConfigVideo(BC_WindowBase *parent_window, Asset *asset)
00132  : BC_Window(PROGRAM_NAME ": Video Compression",
00133         parent_window->get_abs_cursor_x(),
00134         parent_window->get_abs_cursor_y(),
00135         400,
00136         100)
00137 {
00138         this->parent_window = parent_window;
00139         this->asset = asset;
00140 }
00141 
00142 JPEGConfigVideo::~JPEGConfigVideo()
00143 {
00144 }
00145 
00146 int JPEGConfigVideo::create_objects()
00147 {
00148         int x = 10, y = 10;
00149 
00150         add_subwindow(new BC_Title(x, y, _("Quality:")));
00151         add_subwindow(new BC_ISlider(x + 80, 
00152                 y,
00153                 0,
00154                 200,
00155                 200,
00156                 0,
00157                 100,
00158                 asset->quality,
00159                 0,
00160                 0,
00161                 &asset->quality));
00162 
00163         add_subwindow(new BC_OKButton(this));
00164         return 0;
00165 }
00166 
00167 int JPEGConfigVideo::close_event()
00168 {
00169         set_done(0);
00170         return 1;
00171 }
00172 
00173 
00174 
00175 
00176 
00177 
00178 

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