MgzJInputStream.H

Go to the documentation of this file.
00001 /*!@file Media/MgzJInputStream.H Read frames from mgzJ files */
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
00005 // by the University of Southern California (USC) and the iLab at USC.  //
00006 // See http://iLab.usc.edu for information about this project.          //
00007 // //////////////////////////////////////////////////////////////////// //
00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00010 // in Visual Environments, and Applications'' by Christof Koch and      //
00011 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00012 // pending; application number 09/912,225 filed July 23, 2001; see      //
00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00014 // //////////////////////////////////////////////////////////////////// //
00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00016 //                                                                      //
00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00018 // redistribute it and/or modify it under the terms of the GNU General  //
00019 // Public License as published by the Free Software Foundation; either  //
00020 // version 2 of the License, or (at your option) any later version.     //
00021 //                                                                      //
00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00025 // PURPOSE.  See the GNU General Public License for more details.       //
00026 //                                                                      //
00027 // You should have received a copy of the GNU General Public License    //
00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00030 // Boston, MA 02111-1307 USA.                                           //
00031 // //////////////////////////////////////////////////////////////////// //
00032 //
00033 // Primary maintainer for this file: Randolph Voorhies <voorhies at usc dot edu>
00034 //
00035 
00036 #ifndef MEDIA_MGZJINPUTSTREAM_H_DEFINED
00037 #define MEDIA_MGZJINPUTSTREAM_H_DEFINED
00038 
00039 #include "Component/ModelComponent.H"
00040 #include "Component/ModelParam.H"
00041 #include "Transport/FrameIstream.H"
00042 #include "Raster/GenericFrame.H"
00043 
00044 class MgzJDecoder;
00045 class FrameRange;
00046 
00047 // ######################################################################
00048 // ######################################################################
00049 //! MgzJInputStream is a wrapper class to read frames from .mgzj files
00050 /*! mgzJ is a custom format that basically contains the raw frames, each
00051  * individually in gzipped format. One mgz file can contain many frames of
00052  * various sizes and types. Additionally, there is a journal stored at the end
00053  * of the file which contains the file byte positions and types of each frame
00054  * in the file so that seeking can be done in O(1)*/
00055 
00056 class MgzJInputStream : public FrameIstream
00057 {
00058 public:
00059   //! Construct an mgzJstream object for mgzJ input
00060   MgzJInputStream(OptionManager& mgr,
00061       const std::string& descrName = "MgzJ Input Stream",
00062       const std::string& tagName   = "MgzJInputStream");
00063 
00064   //! Virtual destructor
00065   virtual ~MgzJInputStream();
00066 
00067   //! Override from FrameIstream; just calls setFileName()
00068   virtual void setConfigInfo(const std::string& filename);
00069 
00070   //! get frame specifications, peeking at the first frame if necessary
00071   virtual GenericFrameSpec peekFrameSpec();
00072 
00073   //! Configure the MGZJ Stream for decoding
00074   /*! @param fname name of file from which frames are to be read from */
00075   void setFileName(std::string fname);
00076 
00077   //! Read the next frame from the mgz stream
00078   /*! The native representation of the GenericFrame will be the same
00079     as what it was when the frame was stored into the stream. */
00080   virtual GenericFrame readFrame();
00081 
00082   //! Let everyone know that we support random access seeks
00083   virtual bool supportsSeek() { return true; }
00084 
00085   //! Change the current frame number
00086   virtual bool setFrameNumber(int n);
00087 
00088   //! Just increment the frame number
00089   virtual bool readAndDiscardFrame();
00090 
00091   //! Get the frame range information
00092   virtual FrameRange getFrameRange();
00093 
00094 private:
00095   MgzJDecoder *itsDecoder;
00096   GenericFrame itsFrame; // used for peeking of frame specs
00097   GenericFrameSpec itsFrameSpec;
00098   bool itsFrameSpecValid;
00099   int itsFrameNumber;
00100 };
00101 
00102 // ######################################################################
00103 /* So things look consistent in everyone's emacs... */
00104 /* Local Variables: */
00105 /* mode: c++ */
00106 /* indent-tabs-mode: nil */
00107 /* End: */
00108 
00109 #endif // MEDIA_MGZJINPUTSTREAM_H_DEFINED
00110 
Generated on Sun May 8 08:05:20 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3