Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

avi.h

Go to the documentation of this file.
00001 /*
00002 * avi.h library for AVI file format i/o
00003 * Copyright (C) 2000 - 2002 Arne Schirmacher <arne@schirmacher.de>
00004 * Copyright (C) 2001-2007 Dan Dennedy <dan@dennedy.org>
00005 *
00006 * This program is free software; you can redistribute it and/or modify
00007 * it under the terms of the GNU General Public License as published by
00008 * the Free Software Foundation; either version 2 of the License, or
00009 * (at your option) any later version.
00010 *
00011 * This program is distributed in the hope that it will be useful,
00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 * GNU General Public License for more details.
00015 *
00016 * You should have received a copy of the GNU General Public License
00017 * along with this program; if not, write to the Free Software Foundation,
00018 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00019 */
00020 
00029 #ifndef _AVI_H
00030 #define _AVI_H 1
00031 
00032 #include "riff.h"
00033 #include "frame.h"
00034 
00035 #define PACKED(x)   __attribute__((packed)) x
00036 
00037 #define AVI_SMALL_INDEX (0x01)
00038 #define AVI_LARGE_INDEX (0x02)
00039 #define KINO_AVI_INDEX_OF_INDEXES (0x00)
00040 #define KINO_AVI_INDEX_OF_CHUNKS (0x01)
00041 #define AVI_INDEX_2FIELD (0x01)
00042 
00043 enum { AVI_PAL, AVI_NTSC, AVI_AUDIO_48KHZ, AVI_AUDIO_44KHZ, AVI_AUDIO_32KHZ };
00044 
00049 typedef struct
00050 {
00052     DWORD dwMicroSecPerFrame;
00053 
00055     DWORD dwMaxBytesPerSec;
00056 
00058     DWORD dwPaddingGranularity;
00059 
00061     DWORD dwFlags;
00062 
00064     DWORD dwTotalFrames;
00065     DWORD dwInitialFrames;
00066     DWORD dwStreams;
00067     DWORD dwSuggestedBufferSize;
00068 
00069     DWORD dwWidth;
00070     DWORD dwHeight;
00071 
00072     DWORD dwReserved[ 4 ];
00073 }
00074 PACKED(MainAVIHeader);
00075 
00076 typedef struct
00077 {
00078     WORD top, bottom, left, right;
00079 }
00080 PACKED(RECT);
00081 
00086 typedef struct
00087 {
00088     FOURCC fccType;
00089     FOURCC fccHandler;
00090     DWORD dwFlags;                /* Contains AVITF_* flags */
00091     WORD wPriority;
00092     WORD wLanguage;
00093     DWORD dwInitialFrames;
00094     DWORD dwScale;
00095     DWORD dwRate;                 /* dwRate / dwScale == samples/second */
00096     DWORD dwStart;
00097     DWORD dwLength;               /* In units above... */
00098     DWORD dwSuggestedBufferSize;
00099     DWORD dwQuality;
00100     DWORD dwSampleSize;
00101     RECT rcFrame;
00102 }
00103 PACKED(AVIStreamHeader);
00104 
00105 typedef struct
00106 {
00107     DWORD dwDVAAuxSrc;
00108     DWORD dwDVAAuxCtl;
00109     DWORD dwDVAAuxSrc1;
00110     DWORD dwDVAAuxCtl1;
00111     DWORD dwDVVAuxSrc;
00112     DWORD dwDVVAuxCtl;
00113     DWORD dwDVReserved[ 2 ];
00114 }
00115 PACKED(DVINFO);
00116 
00117 typedef struct
00118 {
00119     DWORD biSize;
00120     LONG biWidth;
00121     LONG biHeight;
00122     WORD biPlanes;
00123     WORD biBitCount;
00124     DWORD biCompression;
00125     DWORD biSizeImage;
00126     LONG biXPelsPerMeter;
00127     LONG biYPelsPerMeter;
00128     DWORD biClrUsed;
00129     DWORD biClrImportant;
00130 }
00131 PACKED(BITMAPINFOHEADER);
00132 
00133 typedef struct
00134 {
00135     WORD wFormatTag;
00136     WORD nChannels;
00137     DWORD nSamplesPerSec;
00138     DWORD nAvgBytesPerSec;
00139     WORD nBlockAlign;
00140     WORD wBitsPerSample;
00141     WORD cbSize;
00142     WORD dummy;
00143 }
00144 PACKED(WAVEFORMATEX);
00145 
00146 typedef struct
00147 {
00148     WORD wLongsPerEntry;
00149     BYTE bIndexSubType;
00150     BYTE bIndexType;
00151     DWORD nEntriesInUse;
00152     FOURCC dwChunkId;
00153     DWORD dwReserved[ 3 ];
00154     struct avisuperindex_entry
00155     {
00156         QUADWORD qwOffset;
00157         DWORD dwSize;
00158         DWORD dwDuration;
00159     }
00160     aIndex[ 2014 ];
00161 }
00162 PACKED(AVISuperIndex);
00163 
00164 typedef struct
00165 {
00166     WORD wLongsPerEntry;
00167     BYTE bIndexSubType;
00168     BYTE bIndexType;
00169     DWORD nEntriesInUse;
00170     FOURCC dwChunkId;
00171     QUADWORD qwBaseOffset;
00172     DWORD dwReserved;
00173     struct avifieldindex_entry
00174     {
00175         DWORD dwOffset;
00176         DWORD dwSize;
00177     }
00178     aIndex[ 17895 ];
00179 }
00180 PACKED(AVIStdIndex);
00181 
00182 typedef struct
00183 {
00184     struct avisimpleindex_entry
00185     {
00186         FOURCC  dwChunkId;
00187         DWORD   dwFlags;
00188         DWORD   dwOffset;
00189         DWORD   dwSize;
00190     }
00191     aIndex[ 20000 ];
00192     DWORD   nEntriesInUse;
00193 }
00194 PACKED(AVISimpleIndex);
00195 
00196 typedef struct
00197 {
00198     DWORD dirEntryType;
00199     DWORD dirEntryName;
00200     DWORD dirEntryLength;
00201     size_t dirEntryOffset;
00202     int dirEntryWrittenFlag;
00203     int dirEntryParentList;
00204 }
00205 AviDirEntry;
00206 
00207 
00215 class AVIFile : public RIFFFile
00216 {
00217 public:
00218     AVIFile();
00219     AVIFile( const AVIFile& );
00220     virtual ~AVIFile();
00221     virtual AVIFile& operator=( const AVIFile& );
00222 
00223     virtual void Init( int format, int sampleFrequency, int indexType );
00224     virtual int GetDVFrameInfo( off_t &offset, int &size, int frameNum );
00225     virtual int GetFrameInfo( off_t &offset, int &size, int frameNum, FOURCC chunkID );
00226     virtual int GetDVFrame( Frame &frame, int frameNum );
00227     virtual int getFrame( void *data, int frameNum, FOURCC chunkID );
00228     virtual int GetTotalFrames() const;
00229     virtual bool isInterleave1to1();
00230     virtual void PrintDirectoryEntryData( const RIFFDirEntry &entry ) const;
00231     virtual bool WriteFrame( const Frame &frame )
00232     {
00233         return false;
00234     }
00235     virtual void ParseList( int parent );
00236     virtual void ParseRIFF( void );
00237     virtual void ReadIndex( void );
00238     virtual void WriteRIFF( void )
00239     { }
00240     virtual void FlushIndx( int stream );
00241     virtual void UpdateIndx( int stream, int chunk, int duration );
00242     virtual void UpdateIdx1( int chunk, int flags );
00243     virtual bool verifyStreamFormat( FOURCC type );
00244     virtual bool verifyStream( FOURCC type );
00245     virtual bool isOpenDML( void );
00246     virtual void setDVINFO( DVINFO& )
00247     { }
00248     virtual void setFccHandler( FOURCC type, FOURCC handler );
00249     virtual bool getStreamFormat( void* data, FOURCC type );
00250 
00251 protected:
00252     MainAVIHeader mainHdr;
00253     AVISimpleIndex *idx1;
00254     int file_list;
00255     int riff_list;
00256     int hdrl_list;
00257     int avih_chunk;
00258     int movi_list;
00259     int junk_chunk;
00260     int idx1_chunk;
00261 
00262     AVIStreamHeader streamHdr[ 2 ];
00263     AVISuperIndex *indx[ 2 ];
00264     AVIStdIndex *ix[ 2 ];
00265     int indx_chunk[ 2 ];
00266     int ix_chunk[ 2 ];
00267     int strl_list[ 2 ];
00268     int strh_chunk[ 2 ];
00269     int strf_chunk[ 2 ];
00270 
00271     int index_type;
00272     int current_ix[ 2 ];
00273 
00274     DWORD dmlh[ 62 ];
00275     int odml_list;
00276     int dmlh_chunk;
00277     bool isUpdateIdx1;
00278 
00279 };
00280 
00281 
00286 class AVI1File : public AVIFile
00287 {
00288 public:
00289     AVI1File();
00290     virtual ~AVI1File();
00291 
00292     virtual void Init( int format, int sampleFrequency, int indexType );
00293     virtual bool WriteFrame( const Frame &frame );
00294     virtual void WriteRIFF( void );
00295     virtual void setDVINFO( DVINFO& );
00296 
00297 private:
00298     DVINFO dvinfo;
00299 
00300     AVI1File( const AVI1File& );
00301     AVI1File& operator=( const AVI1File& );
00302 };
00303 
00304 
00316 class AVI2File : public AVIFile
00317 {
00318 public:
00319     AVI2File();
00320     virtual ~AVI2File();
00321 
00322     virtual void Init( int format, int sampleFrequency, int indexType );
00323     virtual bool WriteFrame( const Frame &frame );
00324     virtual void WriteRIFF( void );
00325     virtual void setDVINFO( DVINFO& );
00326 
00327 private:
00328     BITMAPINFOHEADER bitmapinfo;
00329     WAVEFORMATEX waveformatex;
00330 
00331     AVI2File( const AVI2File& );
00332     AVI2File& operator=( const AVI2File& );
00333 };
00334 #endif

Generated on Sun Mar 11 22:11:45 2007 for Kino by  doxygen 1.4.2