/*
 * class VidReader
 *
 * $Date$
 * $Revision$
 *
 */

#ifndef VID_READER_HH__
#define VID_READER_HH__

#include "WImage/VideoReader.hh"

/** 
 * @addtogroup WImage 
 * @{ */

/**
 * A VID file reader. 
 */
class 
VidReader: public VideoReader
{
public:
  /** Constructor. Only calls the mother class' constructor to initialize
   * the {\em ImageArray} reference. 
   * @param name
   * the file name
   * @param arrays
   * the array of video arrays for the values 
   * @param rawy the number of rows 
   * @param rawx the number of cols 
   * @param colors the number of colors
   * @param from the first frame 
   * @param to
   * one greater than the last frame, if equal to `from' then the whole video
   * will be read, if 0, then the video will be read from `from' to the end
   * @param skip the size of the header to skip */
  VidReader (char const * name, VideoArray < coeff > *arrays[], 
             int rawy, int rawx, int colors, int from, int to, int skip = 0);
  
  /** Destructor - does nothing. */
  virtual ~VidReader (void) {}

  /** Return the number of frames in a file. 
   * @param fname the file name.
   * @param rows the number of rows
   * @param cols the number of columns
   * @param colors the number of colors
   * @param skip the number bytes to skip
   * @return the number of frames */
  static int framesInFile (const char *fname, int rows, int cols, 
                           int colors, int skip);

protected:
  /** Read the VID file format. This does the actual work of reading and
   * parsing the video file. It gets called by the {\em read ()} method.
   * @return 
   * 0 if successful, -1 on read error, -2 on file format error. */
  virtual int readfmt (void);
  /** The assumed number of rows */
  int m_ysize;
  /** The assumed number of columns */
  int m_xsize;
  /** If applicable, a header to skip before reading the contents */
  int m_skip;
}; /* class VidReader */

/** @} */

#endif /* VID_READER_HH__ */
