4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21 * All rights reserved.
23 * The Original Code is: all of this file.
25 * Contributor(s): none yet.
27 * ***** END GPL LICENSE BLOCK *****
33 * \section aviabout AVI module external interface
35 * \subsection about About the AVI module
37 * This is external code. It provides avi file import/export and
38 * conversions. It has been adapted to make use of Blender memory
39 * management functions, and because of this it needs module
40 * blenlib. You need to provide this lib when linking with libavi.a .
42 * \subsection issues Known issues with AVI
44 * - avi uses mallocN, freeN from blenlib.
45 * - Not all functions that are used externally are properly
48 * This header has not been split, since it interleaves type defines
49 * and functions. You would need the types to be able to include the
50 * function headers anyway. And, after all, it is someone else's
51 * code. So we keep it like this.
58 #include <stdio.h> /* for FILE */
60 typedef struct _AviChunk {
65 typedef struct _AviList {
71 typedef struct _AviMainHeader {
74 int MicroSecPerFrame; /* MicroSecPerFrame - timing between frames */
75 int MaxBytesPerSec; /* MaxBytesPerSec - approx bps system must handle */
76 int PaddingGranularity;
78 #define AVIF_HASINDEX 0x00000010 /* had idx1 chunk */
79 #define AVIF_MUSTUSEINDEX 0x00000020 /* must use idx1 chunk to determine order */
80 #define AVIF_ISINTERLEAVED 0x00000100 /* AVI file is interleaved */
81 #define AVIF_TRUSTCKTYPE 0x00000800
82 #define AVIF_WASCAPTUREFILE 0x00010000 /* specially allocated used for capturing real time video */
83 #define AVIF_COPYRIGHTED 0x00020000 /* contains copyrighted data */
86 int InitialFrames; /* InitialFrames - initial frame before interleaving */
88 int SuggestedBufferSize;
94 typedef struct _AviStreamHeader {
98 #define AVIST_VIDEO FCC("vids")
99 #define AVIST_AUDIO FCC("auds")
100 #define AVIST_MIDI FCC("mids")
101 #define AVIST_TEXT FCC("txts")
105 #define AVISF_DISABLED 0x00000001
106 #define AVISF_VIDEO_PALCHANGES 0x00010000
115 int SuggestedBufferSize;
124 typedef struct _AviBitmapInfoHeader {
138 } AviBitmapInfoHeader;
140 typedef struct _AviMJPEGUnknown {
150 typedef struct _AviIndexEntry {
153 #define AVIIF_LIST 0x00000001
154 #define AVIIF_KEYFRAME 0x00000010
155 #define AVIIF_NO_TIME 0x00000100
156 #define AVIIF_COMPRESSOR 0x0FFF0000
161 typedef struct _AviIndex {
164 AviIndexEntry *entrys;
168 AVI_FORMAT_RGB24, /* The most basic of forms, 3 bytes per pixel, 1 per r, g, b */
169 AVI_FORMAT_RGB32, /* The second most basic of forms, 4 bytes per pixel, 1 per r, g, b, alpha */
170 AVI_FORMAT_AVI_RGB, /* Same as above, but is in the weird AVI order (bottom to top, left to right) */
171 AVI_FORMAT_MJPEG /* Motion-JPEG */
174 typedef struct _AviStreamRec {
181 typedef struct _AviMovie {
185 #define AVI_MOVIE_READ 0
186 #define AVI_MOVIE_WRITE 1
190 AviMainHeader *header;
191 AviStreamRec *streams;
192 AviIndexEntry *entries;
199 /* Local data goes here */
206 AVI_ERROR_COMPRESSION,
216 /* belongs to the option-setting function. */
224 /* The offsets that will always stay the same in AVI files we
225 * write... used to seek around to the places where we need to write
228 #define AVI_RIFF_SOFF 4L
229 #define AVI_HDRL_SOFF 16L
232 * This is a sort of MAKE_ID thing. Used in imbuf :( It is used
233 * through options in the AVI header (AviStreamHeader). */
234 #define FCC(ch4) (ch4[0] | ch4[1]<<8 | ch4[2]<<16 | ch4[3] << 24)
237 * Test whether this is an avi-format.
239 int AVI_is_avi (const char *name);
243 * Open a compressed file, decompress it into memory.
245 AviError AVI_open_compress (char *name, AviMovie *movie, int streams, ...);
248 * Finalize a compressed output stream.
250 AviError AVI_close_compress (AviMovie *movie);
253 * Choose a compression option for <movie>. Possible options are
254 * AVI_OPTION_TYPE_MAIN, AVI_OPTION_TYPE_STRH, AVI_OPTION_TYPE_STRF
256 AviError AVI_set_compress_option (AviMovie *movie,
261 /* Hmmm... there should be some explanantion about what these mean */
263 * Compression option, for use in avi_set_compress_option
265 #define AVI_OPTION_TYPE_MAIN 0
267 * Compression option, for use in avi_set_compress_option
269 #define AVI_OPTION_TYPE_STRH 1
271 * Compression option, for use in avi_set_compress_option
273 #define AVI_OPTION_TYPE_STRF 2
276 * Direct the streams <avist_type> to <movie>. Redirect <stream_num>
279 int AVI_get_stream (AviMovie *movie, int avist_type, int stream_num);
282 * Open a movie stream from file.
284 AviError AVI_open_movie (const char *name, AviMovie *movie);
287 * Read a frame from a movie stream.
289 void *AVI_read_frame (AviMovie *movie,
294 * Close an open movie stream.
296 AviError AVI_close (AviMovie *movie);
299 * Write frames to a movie stream.
301 AviError AVI_write_frame (AviMovie *movie, int frame_num, ...);
304 * Unused but still external
306 AviError AVI_print_error (AviError error);
307 void AVI_set_debug (int mode);
309 #endif /* __AVI_H__ */