core/vidl_vil1/vidl_vil1_codec.h

Go to the documentation of this file.
00001 #ifndef vidl_vil1_codec_h
00002 #define vidl_vil1_codec_h
00003 //:
00004 // \file
00005 // \author Nicolas Dano, september 1999
00006 //
00007 // \verbatim
00008 //  Modifications
00009 //   June 2000 Julien ESTEVE          Ported from TargetJr
00010 //   10/4/2001 Ian Scott (Manchester) Converted perceps header to doxygen
00011 //   2004/09/10 Peter Vanroose - Added explicit copy constructor (ref_count !)
00012 // \endverbatim
00013 
00014 #include <vcl_string.h>
00015 #include <vidl_vil1/vidl_vil1_codec_sptr.h>
00016 #include <vbl/vbl_ref_count.h>
00017 
00018 class vidl_vil1_movie;
00019 class vidl_vil1_image_list_codec;
00020 class vidl_vil1_mpegcodec;
00021 class vidl_vil1_avicodec;
00022 
00023 //: Base for video coder/decoder
00024 //   A vidl_vil1_codec is a pure virtual class defining the codecs of video.
00025 //   See also vidl_vil1_io and vidl_vil1_image_list_codec and vidl_vil1_avicodec
00026 //   See also vidl_codec for use with vil instead of vil1.
00027 class vidl_vil1_codec :  public vbl_ref_count
00028 {
00029   vidl_vil1_codec(vidl_vil1_codec const&) : vbl_ref_count() {}
00030  public:
00031 
00032   // Constructors/Initializers/Destructors-------------------------------------
00033   vidl_vil1_codec() { clear_strings(); }
00034   virtual ~vidl_vil1_codec() {}
00035 
00036   //=====================================================
00037   // Casting methods -- lets use a standard form for these, namely
00038   // CastToXXX, where XXX is the subclass
00039   virtual vidl_vil1_image_list_codec* castto_vidl_vil1_image_list_codec() { return 0; }
00040   virtual vidl_vil1_mpegcodec* castto_vidl_vil1_mpegcodec() { return 0; }
00041   virtual vidl_vil1_avicodec* castto_vidl_vil1_avicodec() { return 0; }
00042   // Data Control--------------------------------------------------------------
00043 
00044   inline void set_number_frames(int n = 0) { numberframes = n; }
00045   inline void set_name(vcl_string n = "") { name = n; }
00046   inline void set_description(vcl_string d = "") { description = d; }
00047   inline void set_format(char f = '\0') { format = f; }
00048   inline void set_image_class(char t = 'M') { Class = t; }
00049   inline void set_bits_pixel(int d = 0) { B = d; }
00050   inline void set_width(int x = 0)  { X = x; }
00051   inline void set_height(int y = 0) { Y = y; }
00052   inline void set_size_z(int z = 1) { Z = z; }
00053   inline void set_size_t(int t = 1) { T = t; }
00054 
00055   // Data Access---------------------------------------------------------------
00056 
00057   inline int length() const { return numberframes; }
00058   inline vcl_string get_name() const  { return name; }
00059   inline vcl_string get_description() const { return description; }
00060 
00061   inline char get_image_class()const { return Class; }
00062   inline char get_format() const     { return format; }
00063   inline int  width() const          { return X; }
00064   inline int  height() const         { return Y; }
00065   inline int  get_bits_pixel() const { return B; }
00066   inline int  get_bytes_pixel()const { return (B+7)/8; }
00067 
00068   virtual bool get_section(int position,
00069                            void* ib,
00070                            int x0,
00071                            int y0,
00072                            int width,
00073                            int height) const = 0;
00074 
00075   virtual int put_section(int position,
00076                           void* ib,
00077                           int x0,
00078                           int y0,
00079                           int xs,
00080                           int ys) = 0;
00081 
00082   virtual vcl_string type() const = 0;
00083 
00084   // IO
00085 
00086   //: Try to load fname, and if successful, return the codec that did it
00087   virtual vidl_vil1_codec_sptr load(vcl_string const& fname, char mode = 'r' ) = 0;
00088 
00089   //: Take a vidl_vil1_movie, and save in the format of this codec.
00090   virtual bool save(vidl_vil1_movie* movie, vcl_string const& fname) = 0;
00091 
00092   //: Return true if fname looks like something we can read.
00093   virtual bool probe(vcl_string const& fname) = 0;
00094 
00095   //: Perform any operations required to close down the codec.
00096   // This will typically be called just before program exit.
00097   virtual void close() {}
00098 
00099  private:
00100 
00101   inline void clear_strings() { name = description = date_time = ""; }
00102 
00103   vcl_string name;             //!< Video Name
00104   vcl_string description;      //!< Video Descriptor
00105   vcl_string date_time;        //!< Date/Time Stamp
00106   char       format;           //!< Video format
00107   char       Class;            //!< Video class
00108   int        B;                //!< Pixel Precision
00109   int        X,Y,Z,T;          //!< Frame Size (width,height,up,time)
00110   int        numberframes;     //!< Length of the sequence
00111 };
00112 
00113 #endif // vidl_vil1_codec_h

Generated on Tue Dec 2 05:09:13 2008 for core/vidl_vil1 by  doxygen 1.5.1