avifmt.h 7.4 KB
Newer Older
1 2 3 4 5
/****************************************************************************
 *
 *  AVIFMT - AVI file format definitions
 *
 ****************************************************************************/
6
#ifndef AVIFMT 
7 8
#define AVIFMT

9
#ifndef NOAVIFMT 
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24

#ifndef  __WINE_WINDEF_H
#include "wine/windef.h"
#endif

#ifndef __WINE_MMSYSTEM_H
#ifndef __WINE_MSACM_H
typedef DWORD FOURCC;
#endif
#endif


#ifdef _MSC_VER
#pragma warning(disable:4200)
#endif
25
    
26 27 28 29 30
/* The following is a short description of the AVI file format.  Please
 * see the accompanying documentation for a full explanation.
 *
 * An AVI file is the following RIFF form:
 *
31 32 33
 *	RIFF('AVI' 
 *	      LIST('hdrl'
 *		    avih(<MainAVIHeader>)
34 35 36 37
 *                  LIST ('strl'
 *                      strh(<Stream header>)
 *                      strf(<Stream format>)
 *                      ... additional header data
38 39 40 41 42
 *            LIST('movi'	 
 *      	  { LIST('rec' 
 *      		      SubChunk...
 *      		   )
 *      	      | SubChunk } ....	    
43 44 45 46
 *            )
 *            [ <AVIIndex> ]
 *      )
 *
47 48 49 50 51 52
 *	The main file header specifies how many streams are present.  For
 *	each one, there must be a stream header chunk and a stream format
 *	chunk, enlosed in a 'strl' LIST chunk.  The 'strf' chunk contains
 *	type-specific format information; for a video stream, this should
 *	be a BITMAPINFO structure, including palette.  For an audio stream,
 *	this should be a WAVEFORMAT (or PCMWAVEFORMAT) structure.
53
 *
54 55 56
 *	The actual data is contained in subchunks within the 'movi' LIST 
 *	chunk.  The first two characters of each data chunk are the
 *	stream number with which that data is associated.
57
 *
58
 *	Some defined chunk types:
59
 *           Video Streams:
60 61 62
 *                  ##db:	RGB DIB bits
 *                  ##dc:	RLE8 compressed DIB bits
 *                  ##pc:	Palette Change
63 64
 *
 *           Audio Streams:
65
 *                  ##wb:	waveform audio bytes
66 67 68
 *
 * The grouping into LIST 'rec' chunks implies only that the contents of
 *   the chunk should be read into memory at the same time.  This
69
 *   grouping is used for files specifically intended to be played from 
70 71
 *   CD-ROM.
 *
72
 * The index chunk at the end of the file should contain one entry for 
73
 *   each data chunk in the file.
74
 *       
75
 * Limitations for the current software:
76 77
 *	Only one video stream and one audio stream are allowed.
 *	The streams must start at the beginning of the file.
78
 *
79
 * 
80 81 82 83 84 85 86 87 88 89 90 91
 * To register codec types please obtain a copy of the Multimedia
 * Developer Registration Kit from:
 *
 *  Microsoft Corporation
 *  Multimedia Systems Group
 *  Product Marketing
 *  One Microsoft Way
 *  Redmond, WA 98052-6399
 *
 */

#ifndef mmioFOURCC
92 93 94
#define mmioFOURCC( ch0, ch1, ch2, ch3 )				\
		( (DWORD)(BYTE)(ch0) | ( (DWORD)(BYTE)(ch1) << 8 ) |	\
		( (DWORD)(BYTE)(ch2) << 16 ) | ( (DWORD)(BYTE)(ch3) << 24 ) )
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
#endif

/* Macro to make a TWOCC out of two characters */
#ifndef aviTWOCC
#define aviTWOCC(ch0, ch1) ((WORD)(BYTE)(ch0) | ((WORD)(BYTE)(ch1) << 8))
#endif

typedef WORD TWOCC;

/* form types, list types, and chunk types */
#define formtypeAVI             mmioFOURCC('A', 'V', 'I', ' ')
#define listtypeAVIHEADER       mmioFOURCC('h', 'd', 'r', 'l')
#define ckidAVIMAINHDR          mmioFOURCC('a', 'v', 'i', 'h')
#define listtypeSTREAMHEADER    mmioFOURCC('s', 't', 'r', 'l')
#define ckidSTREAMHEADER        mmioFOURCC('s', 't', 'r', 'h')
#define ckidSTREAMFORMAT        mmioFOURCC('s', 't', 'r', 'f')
#define ckidSTREAMHANDLERDATA   mmioFOURCC('s', 't', 'r', 'd')
112
#define ckidSTREAMNAME		mmioFOURCC('s', 't', 'r', 'n')
113 114 115 116 117 118 119 120 121 122 123

#define listtypeAVIMOVIE        mmioFOURCC('m', 'o', 'v', 'i')
#define listtypeAVIRECORD       mmioFOURCC('r', 'e', 'c', ' ')

#define ckidAVINEWINDEX         mmioFOURCC('i', 'd', 'x', '1')

/*
** Stream types for the <fccType> field of the stream header.
*/
#define streamtypeVIDEO         mmioFOURCC('v', 'i', 'd', 's')
#define streamtypeAUDIO         mmioFOURCC('a', 'u', 'd', 's')
124
#define streamtypeMIDI		mmioFOURCC('m', 'i', 'd', 's')
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
#define streamtypeTEXT          mmioFOURCC('t', 'x', 't', 's')

/* Basic chunk types */
#define cktypeDIBbits           aviTWOCC('d', 'b')
#define cktypeDIBcompressed     aviTWOCC('d', 'c')
#define cktypePALchange         aviTWOCC('p', 'c')
#define cktypeWAVEbytes         aviTWOCC('w', 'b')

/* Chunk id to use for extra chunks for padding. */
#define ckidAVIPADDING          mmioFOURCC('J', 'U', 'N', 'K')

/*
** Useful macros
**
** Warning: These are nasty macro, and MS C 6.0 compiles some of them
** incorrectly if optimizations are on.  Ack.
*/

/* Macro to get stream number out of a FOURCC ckid */
144
#define FromHex(n)	(((n) >= 'A') ? ((n) + 10 - 'A') : ((n) - '0'))
145 146 147 148 149 150 151 152 153
#define StreamFromFOURCC(fcc) ((WORD) ((FromHex(LOBYTE(LOWORD(fcc))) << 4) + \
                                             (FromHex(HIBYTE(LOWORD(fcc))))))

/* Macro to get TWOCC chunk type out of a FOURCC ckid */
#define TWOCCFromFOURCC(fcc)    HIWORD(fcc)

/* Macro to make a ckid for a chunk out of a TWOCC and a stream number
** from 0-255.
*/
154
#define ToHex(n)	((BYTE) (((n) > 9) ? ((n) - 10 + 'A') : ((n) + '0')))
155 156
#define MAKEAVICKID(tcc, stream) \
        MAKELONG((ToHex((stream) & 0x0f) << 8) | \
157
			    (ToHex(((stream) & 0xf0) >> 4)), tcc)
158 159

/*
160 161 162
** Main AVI File Header 
*/	     
		     
163
/* flags for use in <dwFlags> in AVIFileHdr */
164 165 166 167 168 169
#define AVIF_HASINDEX		0x00000010	// Index at end of file?
#define AVIF_MUSTUSEINDEX	0x00000020
#define AVIF_ISINTERLEAVED	0x00000100
#define AVIF_TRUSTCKTYPE	0x00000800	// Use CKType to find key frames?
#define AVIF_WASCAPTUREFILE	0x00010000
#define AVIF_COPYRIGHTED	0x00020000
170 171 172 173 174 175

/* The AVI File Header LIST chunk should be padded to this size */
#define AVI_HEADERSIZE  2048                    // size of AVI header list

typedef struct
{
176 177 178
    DWORD		dwMicroSecPerFrame;	// frame display rate (or 0L)
    DWORD		dwMaxBytesPerSec;	// max. transfer rate
    DWORD		dwPaddingGranularity;	// pad to multiples of this
179
                                                // size; normally 2K.
180 181 182 183 184 185 186 187 188 189
    DWORD		dwFlags;		// the ever-present flags
    DWORD		dwTotalFrames;		// # frames in file
    DWORD		dwInitialFrames;
    DWORD		dwStreams;
    DWORD		dwSuggestedBufferSize;
    
    DWORD		dwWidth;
    DWORD		dwHeight;
    
    DWORD		dwReserved[4];
190 191 192 193 194 195
} MainAVIHeader;

/*
** Stream header
*/

196
#define AVISF_DISABLED			0x00000001
197

198
#define AVISF_VIDEO_PALCHANGES		0x00010000
199

200
  
201
typedef struct {
202 203 204 205 206 207 208 209 210 211 212 213 214 215
    FOURCC		fccType;
    FOURCC		fccHandler;
    DWORD		dwFlags;	/* Contains AVITF_* flags */
    WORD		wPriority;
    WORD		wLanguage;
    DWORD		dwInitialFrames;
    DWORD		dwScale;	
    DWORD		dwRate;	/* dwRate / dwScale == samples/second */
    DWORD		dwStart;
    DWORD		dwLength; /* In units above... */
    DWORD		dwSuggestedBufferSize;
    DWORD		dwQuality;
    DWORD		dwSampleSize;
    RECT		rcFrame;
216 217 218 219 220 221
} AVIStreamHeader;

/* Flags for index */
#define AVIIF_LIST          0x00000001L // chunk is a 'LIST'
#define AVIIF_KEYFRAME      0x00000010L // this frame is a key frame.

222
#define AVIIF_NOTIME	    0x00000100L // this frame doesn't take any time
223 224 225 226 227 228 229
#define AVIIF_COMPUSE       0x0FFF0000L // these bits are for compressor use

#define FOURCC_RIFF     mmioFOURCC('R', 'I', 'F', 'F')
#define FOURCC_LIST     mmioFOURCC('L', 'I', 'S', 'T')

typedef struct
{
230 231 232 233
    DWORD		ckid;
    DWORD		dwFlags;
    DWORD		dwChunkOffset;		// Position of chunk
    DWORD		dwChunkLength;		// Length of chunk
234 235
} AVIINDEXENTRY;

236
#define AVISTREAMREAD_CONVENIENT	(-1L)
237 238 239 240 241 242 243 244

/*
** Palette change chunk
**
** Used in video streams.
*/
#endif /* NOAVIFMT */
#endif