/*
 * class AviReader
 *
 * $Date$
 * $Revision$
 *
 */

#ifndef AVI_READER_HH__
#define AVI_READER_HH__

#include "WImage/VideoReader.hh"

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

/**
 * An AVI file reader. Only uncompressed AVIs are supported.
 */
class 
AviReader: public VideoReader
{
public:
  /** Constructor. Only calls the mother class' constructor to initialize
   * the {\em ImageArray} reference. 
   * All frames in the ranges must be of the same size.
   * @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 from 
   * 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 to the last frame  */
  AviReader (char const *name, VideoArray < coeff > *arrays[], 
             int rawy, int rawx, int from, int to); 

  /** Calculates the frame rate.
   * @exception invalid_argument if the file cannot be read
   * @param fname the file name
   * @return the frame rate */
  static double frameRate (const char *fname);
  /** Calculates the number of frames in a file.
   * @exception invalid_argument if the file cannot be read
   * @param fname the file name
   * @return the number of frames */
  static int framesInFile (const char *fname);
  /** Calculates the frame dimensions in a file.
   * @exception invalid_argument if the file cannot be read
   * @param fname the file name
   * @param y the returned number of rows
   * @param x the returned number of columns */
  static void fileDimensions (const char *fname, int &y, int &x);
  
protected:
  /** Read the VID file format. This does the actual work of reading and
   * parsing the image 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;
}; /* class AviReader */

/** @} */

#endif /* AVI_READER_HH__ */
