00001 /********************************************************************** 00002 ** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. 00003 ** Based on work from Andrew Tridgell and the jpegtoavi project 00004 ** 00005 ** This file is part of Opie Environment. 00006 ** 00007 ** This file may be distributed and/or modified under the terms of the 00008 ** GNU General Public License version 2 as published by the Free Software 00009 ** Foundation and appearing in the file LICENSE.GPL included in the 00010 ** packaging of this file. 00011 ** 00012 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00013 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00014 ** 00015 **********************************************************************/ 00016 00017 #ifndef AVI_H 00018 #define AVI_H 00019 00020 #include <unistd.h> 00021 #include <stdio.h> 00022 #include <sys/types.h> 00023 00024 #ifdef __cplusplus 00025 extern "C" { 00026 #endif 00027 00028 typedef unsigned char u8; 00029 typedef unsigned short u16; 00030 typedef unsigned u32; 00031 00032 // header flags 00033 00034 const u32 AVIF_HASINDEX=0x00000010; /* index at end of file */ 00035 const u32 AVIF_MUSTUSEINDEX=0x00000020; 00036 const u32 AVIF_ISINTERLEAVED=0x00000100; 00037 const u32 AVIF_TRUSTCKTYPE=0x00000800; 00038 const u32 AVIF_WASCAPTUREFILE=0x00010000; 00039 const u32 AVIF_COPYRIGHTED=0x00020000; 00040 00041 // function prototypes 00042 00043 void avi_start(int fd, int frame); 00044 void avi_add(int fd, u8 *buf, int size); 00045 void avi_end(int fd, int width, int height, int fps); 00046 void fprint_quartet(int fd, unsigned int i); 00047 00048 // the following structures are ordered as they appear in a typical AVI 00049 00050 struct riff_head { 00051 char riff[4]; // chunk type = "RIFF" 00052 u32 size; // chunk size 00053 char avistr[4]; // avi magic = "AVI " 00054 }; 00055 00056 // the avih chunk contains a number of list chunks 00057 00058 struct avi_head { 00059 char avih[4]; // chunk type = "avih" 00060 u32 size; // chunk size 00061 u32 time; // microsec per frame == 1e6 / fps 00062 u32 maxbytespersec; // = 1e6*(total size/frames)/per_usec) 00063 u32 pad; // pad = 0 00064 u32 flags; // e.g. AVIF_HASINDEX 00065 u32 nframes; // total number of frames 00066 u32 initialframes; // = 0 00067 u32 numstreams; // = 1 for now (later = 2 because of audio) 00068 u32 suggested_bufsize; // = 0 (no suggestion) 00069 u32 width; // width 00070 u32 height; // height 00071 u32 reserved[4]; // reserved for future use = 0 00072 }; 00073 00074 00075 // the LIST chunk contains a number (==#numstreams) of stream chunks 00076 00077 struct list_head { 00078 char list[4]; // chunk type = "LIST" 00079 u32 size; 00080 char type[4]; 00081 }; 00082 00083 00084 struct dmlh_head { 00085 char dmlh[4]; // chunk type dmlh 00086 u32 size; // 4 00087 u32 nframes; // number of frames 00088 }; 00089 00090 00091 struct stream_head { 00092 char strh[4]; // chunk type = "strh" 00093 u32 size; // chunk size 00094 char vids[4]; // stream type = "vids" 00095 char codec[4]; // codec name (for us, = "MJPG") 00096 u32 flags; // contains AVIT_F* flags 00097 u16 priority; // = 0 00098 u16 language; // = 0 00099 u32 initialframes; // = 0 00100 u32 scale; // = usec per frame 00101 u32 rate; // 1e6 00102 u32 start; // = 0 00103 u32 length; // number of frames 00104 u32 suggested_bufsize; // = 0 00105 u32 quality; // = 0 ? 00106 u32 samplesize; // = 0 ? 00107 }; 00108 00109 00110 struct db_head { 00111 char db[4]; // "00db" 00112 u32 size; 00113 }; 00114 00115 // a frame chunk contains one JPEG image 00116 00117 struct frame_head { 00118 char strf[4]; // chunk type = "strf" 00119 u32 size; // sizeof chunk (big endian) ? 00120 u32 size2; // sizeof chunk (little endian) ? 00121 u32 width; 00122 u32 height; 00123 u16 planes; // 1 bitplane 00124 u16 bitcount; // 24 bpl 00125 char codec[4]; // MJPG (for us) 00126 u32 unpackedsize; // = 3*w*h 00127 u32 r1; // reserved 00128 u32 r2; // reserved 00129 u32 clr_used; // reserved 00130 u32 clr_important; // reserved 00131 }; 00132 00133 struct idx1_head { 00134 char idx1[4]; // chunk type = "idx1" 00135 u32 size; // chunk size 00136 }; 00137 00138 #ifdef __cplusplus 00139 } 00140 #endif 00141 00142 #endif
1.4.2