Annotation of generator/hdr/avi.h, revision 1.1

1.1     ! root        1: /* these structures are based on vfw.h
        !             2:  *
        !             3:  * here is a nice example from http://www.microsoft.com/
        !             4:  *   DirectX/dxm/help/ds/FiltDev/DV_Data_AVI_File_Format.htm
        !             5:  * 
        !             6:  * 00000000 RIFF (103E2920) 'AVI '
        !             7:  * 0000000C     LIST (00000146) 'hdrl'
        !             8:  * 00000018         avih (00000038)
        !             9:  *                      dwMicroSecPerFrame    : 33367
        !            10:  *                      dwMaxBytesPerSec      : 3728000
        !            11:  *                      dwPaddingGranularity  : 0
        !            12:  *                      dwFlags               : 0x810 HASINDEX | TRUSTCKTYPE
        !            13:  *                      dwTotalFrames         : 2192
        !            14:  *                      dwInitialFrames       : 0
        !            15:  *                      dwStreams             : 2
        !            16:  *                      dwSuggestedBufferSize : 120000
        !            17:  *                      dwWidth               : 720
        !            18:  *                      dwHeight              : 480
        !            19:  *                      dwReserved            : 0x0
        !            20:  * 00000058         LIST (00000094) 'strl'
        !            21:  * 00000064             strh (00000038)
        !            22:  *                          fccType               : 'vids'
        !            23:  *                          fccHandler            : 'dvsd'
        !            24:  *                          dwFlags               : 0x0
        !            25:  *                          wPriority             : 0
        !            26:  *                          wLanguage             : 0x0 undefined
        !            27:  *                          dwInitialFrames       : 0
        !            28:  *                          dwScale               : 100 (29.970 Frames/Sec)
        !            29:  *                          dwRate                : 2997
        !            30:  *                          dwStart               : 0
        !            31:  *                          dwLength              : 2192
        !            32:  *                          dwSuggestedBufferSize : 120000
        !            33:  *                          dwQuality             : 0
        !            34:  *                          dwSampleSize          : 0
        !            35:  *                          rcFrame               : 0,0,720,480
        !            36:  * 000000A4             strf (00000048)
        !            37:  *                          biSize          : 40
        !            38:  *                          biWidth         : 720
        !            39:  *                          biHeight        : 480
        !            40:  *                          biPlanes        : 1
        !            41:  *                          biBitCount      : 24
        !            42:  *                          biCompression   : 0x64737664 'dvsd'
        !            43:  *                          biSizeImage     : 120000
        !            44:  *                          biXPelsPerMeter : 0
        !            45:  *                          biYPelsPerMeter : 0
        !            46:  *                          biClrUsed       : 0
        !            47:  *                          biClrImportant  : 0
        !            48:  *                          dwDVAAuxSrc     : 0x........
        !            49:  *                          dwDVAAuxCtl     : 0x........
        !            50:  *                          dwDVAAuxSrc1    : 0x........
        !            51:  *                          dwDVAAuxCtl1    : 0x........
        !            52:  *                          dwDVVAuxSrc     : 0x........
        !            53:  *                          dwDVVAuxCtl     : 0x........
        !            54:  *                          dwDVReserved[2] : 0,0
        !            55:  * 000000F4         LIST (0000005E) 'strl'
        !            56:  * 00000100             strh (00000038)
        !            57:  *                          fccType               : 'auds'
        !            58:  *                          fccHandler            : '    '
        !            59:  *                          dwFlags               : 0x0
        !            60:  *                          wPriority             : 0
        !            61:  *                          wLanguage             : 0x0 undefined
        !            62:  *                          dwInitialFrames       : 0
        !            63:  *                          dwScale               : 1 (32000.000 Samples/Sec)
        !            64:  *                          dwRate                : 32000
        !            65:  *                          dwStart               : 0
        !            66:  *                          dwLength              : 2340474
        !            67:  *                          dwSuggestedBufferSize : 4272
        !            68:  *                          dwQuality             : 0
        !            69:  *                          dwSampleSize          : 4
        !            70:  *                          rcFrame               : 0,0,0,0
        !            71:  * 00000140             strf (00000012)
        !            72:  *                          wFormatTag      : 1 PCM
        !            73:  *                          nChannels       : 2
        !            74:  *                          nSamplesPerSec  : 32000
        !            75:  *                          nAvgBytesPerSec : 128000
        !            76:  *                          nBlockAlign     : 4
        !            77:  *                          wBitsPerSample  : 16
        !            78:  *                          cbSize          : 0
        !            79:  * 00000814     LIST (103D0EF4) 'movi'
        !            80:  * 103D1710     idx1 (00011210)
        !            81:  *
        !            82:  */
        !            83: 
        !            84: typedef struct {
        !            85:   uint32 left;
        !            86:   uint32 top;
        !            87:   uint32 right;
        !            88:   uint32 bottom;
        !            89: } t_win_rect;
        !            90: 
        !            91: typedef struct {
        !            92:   char avih[4];                 /* "avih" */
        !            93:   uint32 length;                /* chunk length */
        !            94:   uint32 MicroSecPerFrame;      /* frame display rate (or 0L) */
        !            95:   uint32 MaxBytesPerSec;        /* max. transfer rate */
        !            96:   uint32 PaddingGranularity;    /* pad to multiples of this
        !            97:                                    size; normally 2K. */
        !            98:   uint32 Flags;                 /* the ever-present flags */
        !            99:   uint32 TotalFrames;           /* # frames in file */
        !           100:   uint32 InitialFrames;
        !           101:   uint32 Streams;
        !           102:   uint32 SuggestedBufferSize;
        !           103:   uint32 Width;
        !           104:   uint32 Height;
        !           105:   uint32 Reserved[4];
        !           106: } t_avichunk_avih;
        !           107: 
        !           108: typedef struct {
        !           109:   char strh[4];                 /* "strh" */
        !           110:   uint32 length;                /* chunk length */
        !           111:   char Type[4];
        !           112:   char Handler[4];
        !           113:   uint32 Flags;                 /* Contains AVITF_* flags */
        !           114:   uint16 Priority;
        !           115:   uint16 Language;
        !           116:   uint32 InitialFrames;
        !           117:   uint32 Scale;
        !           118:   uint32 Rate;                  /* dwRate / dwScale == samples/second */
        !           119:   uint32 Start;
        !           120:   uint32 Length;                /* In units above... */
        !           121:   uint32 SuggestedBufferSize;
        !           122:   uint32 Quality;
        !           123:   uint32 SampleSize;
        !           124:   t_win_rect rcFrame; /* should this be 4 16 bit vals or 4 32 bit vals? */
        !           125: } t_avichunk_strh;
        !           126: 
        !           127: /* BITMAPINFOHEADER - see dib.h */
        !           128: 
        !           129: /* the structure below is for PCMWAVEFORMAT - as far as I understand it the
        !           130:    WAVEFORMAT structure was extended to include wBitsPerSample.  The
        !           131:    PCMWAVEFORMAT was in turn extended to be the WAVEFORMATEX structure which
        !           132:    includes an extra word cbSize that indicates the size of the extension
        !           133:    words for whatever wFormatTag specifies.  We do not include the cbSize
        !           134:    word (i.e. this really is a PCMWAVEFORMAT not a WAVEFORMATEX) as this
        !           135:    would un-align 32-bit words.  Some chips, Sparc for example, can't cope
        !           136:    with non-aligned 32-bit access, and I want to construct this stuff in
        !           137:    memory without hassles. */
        !           138: 
        !           139: /* http://www.xiph.org/archives/vorbis-dev/200108/0199.html */
        !           140: 
        !           141: typedef struct {
        !           142:   char strf[4];                 /* "strf" */
        !           143:   uint32 length;                /* chunk length */
        !           144:   uint16 wFormatTag;            /* WAVE_FORMAT_PCM = 1 */
        !           145:   uint16 nChannels;             /* 1 for mono, 2 for stereo */
        !           146:   uint32 nSamplesPerSec;        /* typically 22050 or 44100 */
        !           147:   uint32 nAvgBytesPerSec;       /* must be nBlockAlign * nSamplesPerSec */
        !           148:   uint16 nBlockAlign;           /* must be nChannels * BitsPerSample / 8 */
        !           149:   uint16 wBitsPerSample;        /* must be 8 or 16 */
        !           150: } t_avichunk_strf_audio;
        !           151: 
        !           152: typedef struct {
        !           153:   char strf[4];                 /* "strf" */
        !           154:   uint32 length;                /* chunk length */
        !           155:   t_bmih bmih;                  /* BMP header */
        !           156: } t_avichunk_strf_video;
        !           157: 
        !           158: /* the structure below is a BITMAPINFO (or so says vfw.h), which is simply
        !           159:    a DIB header (the structure found in BMP files) */
        !           160: 
        !           161: typedef struct {
        !           162:   t_bmih bmih;                  /* DIB bit map header */
        !           163: } t_avilist_strf_video;
        !           164: 
        !           165: typedef struct {
        !           166:   char list[4];                 /* "LIST" */
        !           167:   uint32 length;                /* list length */
        !           168:   char strl[4];                 /* "strl" */
        !           169:   t_avichunk_strh strh;         /* stream header block */
        !           170:   t_avichunk_strf_video strf;   /* stream format block */
        !           171: } t_avilist_strl_video;
        !           172: 
        !           173: typedef struct {
        !           174:   char list[4];                 /* "LIST" */
        !           175:   uint32 length;                /* list length */
        !           176:   char strl[4];                 /* "strl" */
        !           177:   t_avichunk_strh strh;         /* stream header block */
        !           178:   t_avichunk_strf_audio strf;   /* stream format block */
        !           179: } t_avilist_strl_audio;
        !           180: 
        !           181: typedef struct {
        !           182:   char list[4];                 /* "LIST" */
        !           183:   uint32 length;                /* list length */
        !           184:   char hdrl[4];                 /* hdrl */
        !           185:   t_avichunk_avih avih;         /* avi header */
        !           186:   t_avilist_strl_video strl_video;      /* strl block for video stream */
        !           187:   t_avilist_strl_audio strl_audio;      /* strl block for audio stream */
        !           188: } t_avilist_hdrl;
        !           189: 
        !           190: typedef struct {
        !           191:   char list[4];                 /* "LIST" */
        !           192:   uint32 length;                /* list length */
        !           193:   char movi[4];                 /* movi */
        !           194:   /* the rest of the data is streamed to disk... */
        !           195: } t_avilist_movi;
        !           196: 
        !           197: typedef struct {
        !           198:   char riff[4];                 /* "RIFF" */
        !           199:   uint32 length;                /* size of whole file */
        !           200:   char avi[4];                  /* "AVI " */
        !           201:   t_avilist_hdrl hdrl;
        !           202:   t_avilist_movi movi;
        !           203: } t_avi_header;
        !           204: 
        !           205: typedef struct {
        !           206:   uint32 width;
        !           207:   uint32 height;
        !           208:   uint32 sampspersec;
        !           209:   uint32 fps;                   /* fps * 1000 */
        !           210:   uint32 jpegquality;           /* 0 - 100, if applicable */
        !           211: } t_aviinfo;
        !           212: 
        !           213: typedef struct {
        !           214:   t_aviinfo info;
        !           215:   FILE *fd;
        !           216:   uint32 linebytes;             /* number of video bytes per line */
        !           217:   char dibchunkh[8];            /* 00dbXXXX where XXXX is size */
        !           218:   char wavechunkh[8];           /* 01wbXXXX where XXXX is size */
        !           219:   uint32 frames;                /* video frames done */
        !           220:   uint32 audiolength;           /* samples output so far */
        !           221:   uint32 movilength;            /* movi bytes output so far */
        !           222:   uint32 off_length;            /* offset in file to update */
        !           223:   uint32 off_movilength;        /* offset in file to update */
        !           224:   uint32 off_totalframes;       /* offset in file to update */
        !           225:   uint32 off_videolength;       /* offset in file to update */
        !           226:   uint32 off_audiolength;       /* offset in file to update */
        !           227:   uint32 error;                 /* 1000ths of a byte we haven't output */
        !           228:   uint32 jpeg;                  /* writing jpegs? */
        !           229:   uint32 bgr;                   /* need BGR data instead of RGB? */
        !           230: } t_avi;
        !           231: 
        !           232: #define AVIF_HASINDEX       0x00000010 /* Index at end of file? */
        !           233: #define AVIF_MUSTUSEINDEX   0x00000020
        !           234: #define AVIF_ISINTERLEAVED  0x00000100
        !           235: #define AVIF_TRUSTCKTYPE    0x00000800 /* Use CKType to find key frames? */
        !           236: #define AVIF_WASCAPTUREFILE 0x00010000
        !           237: #define AVIF_COPYRIGHTED    0x00020000
        !           238: #define WAVE_FORMAT_PCM 1
        !           239: 
        !           240: t_avi *avi_open(char *filename, t_aviinfo *info, int jpeg);
        !           241: int avi_close(t_avi *avi);
        !           242: int avi_video(t_avi *avi, uint8 *video);
        !           243: int avi_audio(t_avi *avi, uint8 *audio, uint32 samples);

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.