summaryrefslogtreecommitdiff
path: root/noncore/multimedia/camera/lib/avi.h
Unidiff
Diffstat (limited to 'noncore/multimedia/camera/lib/avi.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/camera/lib/avi.h142
1 files changed, 142 insertions, 0 deletions
diff --git a/noncore/multimedia/camera/lib/avi.h b/noncore/multimedia/camera/lib/avi.h
new file mode 100644
index 0000000..fbdc14a
--- a/dev/null
+++ b/noncore/multimedia/camera/lib/avi.h
@@ -0,0 +1,142 @@
1/**********************************************************************
2** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved.
3** Based on work from Andrew Tridgell and the jpegtoavi project
4**
5** This file is part of Opie Environment.
6**
7** This file may be distributed and/or modified under the terms of the
8** GNU General Public License version 2 as published by the Free Software
9** Foundation and appearing in the file LICENSE.GPL included in the
10** packaging of this file.
11**
12** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14**
15**********************************************************************/
16
17#ifndef AVI_H
18#define AVI_H
19
20#include <unistd.h>
21#include <stdio.h>
22#include <sys/types.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28typedef unsigned char u8;
29typedef unsigned short u16;
30typedef unsigned u32;
31
32// header flags
33
34const u32 AVIF_HASINDEX=0x00000010; /* index at end of file */
35const u32 AVIF_MUSTUSEINDEX=0x00000020;
36const u32 AVIF_ISINTERLEAVED=0x00000100;
37const u32 AVIF_TRUSTCKTYPE=0x00000800;
38const u32 AVIF_WASCAPTUREFILE=0x00010000;
39const u32 AVIF_COPYRIGHTED=0x00020000;
40
41// function prototypes
42
43void avi_start(int fd, int frame);
44void avi_add(int fd, u8 *buf, int size);
45void avi_end(int fd, int width, int height, int fps);
46void fprint_quartet(int fd, unsigned int i);
47
48// the following structures are ordered as they appear in a typical AVI
49
50struct riff_head {
51 char riff[4]; // chunk type = "RIFF"
52 u32 size; // chunk size
53 char avistr[4]; // avi magic = "AVI "
54};
55
56// the avih chunk contains a number of list chunks
57
58struct avi_head {
59 char avih[4]; // chunk type = "avih"
60 u32 size; // chunk size
61 u32 time; // microsec per frame == 1e6 / fps
62 u32 maxbytespersec; // = 1e6*(total size/frames)/per_usec)
63 u32 pad; // pad = 0
64 u32 flags; // e.g. AVIF_HASINDEX
65 u32 nframes; // total number of frames
66 u32 initialframes; // = 0
67 u32 numstreams; // = 1 for now (later = 2 because of audio)
68 u32 suggested_bufsize; // = 0 (no suggestion)
69 u32 width; // width
70 u32 height; // height
71 u32 reserved[4]; // reserved for future use = 0
72};
73
74
75// the LIST chunk contains a number (==#numstreams) of stream chunks
76
77struct list_head {
78 char list[4]; // chunk type = "LIST"
79 u32 size;
80 char type[4];
81};
82
83
84struct dmlh_head {
85 char dmlh[4]; // chunk type dmlh
86 u32 size; // 4
87 u32 nframes; // number of frames
88};
89
90
91struct stream_head {
92 char strh[4]; // chunk type = "strh"
93 u32 size; // chunk size
94 char vids[4]; // stream type = "vids"
95 char codec[4]; // codec name (for us, = "MJPG")
96 u32 flags; // contains AVIT_F* flags
97 u16 priority; // = 0
98 u16 language; // = 0
99 u32 initialframes; // = 0
100 u32 scale; // = usec per frame
101 u32 rate; // 1e6
102 u32 start; // = 0
103 u32 length; // number of frames
104 u32 suggested_bufsize; // = 0
105 u32 quality; // = 0 ?
106 u32 samplesize; // = 0 ?
107};
108
109
110struct db_head {
111 char db[4]; // "00db"
112 u32 size;
113};
114
115// a frame chunk contains one JPEG image
116
117struct frame_head {
118 char strf[4]; // chunk type = "strf"
119 u32 size; // sizeof chunk (big endian) ?
120 u32 size2; // sizeof chunk (little endian) ?
121 u32 width;
122 u32 height;
123 u16 planes; // 1 bitplane
124 u16 bitcount; // 24 bpl
125 char codec[4]; // MJPG (for us)
126 u32 unpackedsize; // = 3*w*h
127 u32 r1; // reserved
128 u32 r2; // reserved
129 u32 clr_used; // reserved
130 u32 clr_important; // reserved
131};
132
133struct idx1_head {
134 char idx1[4]; // chunk type = "idx1"
135 u32 size; // chunk size
136};
137
138#ifdef __cplusplus
139}
140#endif
141
142#endif