2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): none yet.
25 * ***** END GPL LICENSE BLOCK *****
32 * \section avi_about About the AVI module
34 * This is external code. It provides avi file import/export and
35 * conversions. It has been adapted to make use of Blender memory
36 * management functions, and because of this it needs module
37 * blenlib. You need to provide this lib when linking with libavi.a .
39 * \subsection avi_issues Known issues with AVI
41 * - avi uses #MEM_mallocN, #MEM_freeN from blenlib.
42 * - Not all functions that are used externally are properly
45 * This header has not been split, since it interleaves type defines
46 * and functions. You would need the types to be able to include the
47 * function headers anyway. And, after all, it is someone else's
48 * code. So we keep it like this.
55 #include "BLI_sys_types.h"
56 #include <stdio.h> /* for FILE */
58 typedef struct _AviChunk {
63 typedef struct _AviList {
69 typedef struct _AviMainHeader {
72 int MicroSecPerFrame; /* MicroSecPerFrame - timing between frames */
73 int MaxBytesPerSec; /* MaxBytesPerSec - approx bps system must handle */
74 int PaddingGranularity;
76 #define AVIF_HASINDEX 0x00000010 /* had idx1 chunk */
77 #define AVIF_MUSTUSEINDEX 0x00000020 /* must use idx1 chunk to determine order */
78 #define AVIF_ISINTERLEAVED 0x00000100 /* AVI file is interleaved */
79 #define AVIF_TRUSTCKTYPE 0x00000800
80 #define AVIF_WASCAPTUREFILE 0x00010000 /* specially allocated used for capturing real time video */
81 #define AVIF_COPYRIGHTED 0x00020000 /* contains copyrighted data */
84 int InitialFrames; /* InitialFrames - initial frame before interleaving */
86 int SuggestedBufferSize;
92 typedef struct _AviStreamHeader {
96 #define AVIST_VIDEO FCC("vids")
97 #define AVIST_AUDIO FCC("auds")
98 #define AVIST_MIDI FCC("mids")
99 #define AVIST_TEXT FCC("txts")
103 #define AVISF_DISABLED 0x00000001
104 #define AVISF_VIDEO_PALCHANGES 0x00010000
113 int SuggestedBufferSize;
122 typedef struct _AviBitmapInfoHeader {
136 } AviBitmapInfoHeader;
138 typedef struct _AviMJPEGUnknown {
148 typedef struct _AviIndexEntry {
151 #define AVIIF_LIST 0x00000001
152 #define AVIIF_KEYFRAME 0x00000010
153 #define AVIIF_NO_TIME 0x00000100
154 #define AVIIF_COMPRESSOR 0x0FFF0000
159 typedef struct _AviIndex {
162 AviIndexEntry *entrys;
166 AVI_FORMAT_RGB24, /* The most basic of forms, 3 bytes per pixel, 1 per r, g, b */
167 AVI_FORMAT_RGB32, /* The second most basic of forms, 4 bytes per pixel, 1 per r, g, b, alpha */
168 AVI_FORMAT_AVI_RGB, /* Same as above, but is in the weird AVI order (bottom to top, left to right) */
169 AVI_FORMAT_MJPEG /* Motion-JPEG */
172 typedef struct _AviStreamRec {
179 typedef struct _AviMovie {
183 #define AVI_MOVIE_READ 0
184 #define AVI_MOVIE_WRITE 1
188 AviMainHeader *header;
189 AviStreamRec *streams;
190 AviIndexEntry *entries;
195 int64_t *offset_table;
197 /* Local data goes here */
204 AVI_ERROR_COMPRESSION,
214 /* belongs to the option-setting function. */
216 AVI_OPTION_WIDTH = 0,
222 /* The offsets that will always stay the same in AVI files we
223 * write... used to seek around to the places where we need to write
226 #define AVI_RIFF_SOFF 4L
227 #define AVI_HDRL_SOFF 16L
230 * This is a sort of MAKE_ID thing. Used in imbuf :( It is used
231 * through options in the AVI header (AviStreamHeader). */
232 #define FCC(ch4) (ch4[0] | ch4[1] << 8 | ch4[2] << 16 | ch4[3] << 24)
235 * Test whether this is an avi-format.
237 bool AVI_is_avi(const char *name);
241 * Open a compressed file, decompress it into memory.
243 AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...);
246 * Finalize a compressed output stream.
248 AviError AVI_close_compress(AviMovie *movie);
251 * Choose a compression option for \<movie\>. Possible options are
252 * AVI_OPTION_TYPE_MAIN, AVI_OPTION_TYPE_STRH, AVI_OPTION_TYPE_STRF
254 AviError AVI_set_compress_option(AviMovie *movie,
259 /* Hmmm... there should be some explanation about what these mean */
261 * Compression option, for use in avi_set_compress_option
263 #define AVI_OPTION_TYPE_MAIN 0
265 * Compression option, for use in avi_set_compress_option
267 #define AVI_OPTION_TYPE_STRH 1
269 * Compression option, for use in avi_set_compress_option
271 #define AVI_OPTION_TYPE_STRF 2
274 * Direct the streams \<avist_type\> to \<movie\>. Redirect \<stream_num\>
277 int AVI_get_stream(AviMovie *movie, int avist_type, int stream_num);
280 * Open a movie stream from file.
282 AviError AVI_open_movie(const char *name, AviMovie *movie);
285 * Read a frame from a movie stream.
287 void *AVI_read_frame(AviMovie *movie,
292 * Close an open movie stream.
294 AviError AVI_close(AviMovie *movie);
297 * Write frames to a movie stream.
299 AviError AVI_write_frame(AviMovie *movie, int frame_num, ...);
302 * Unused but still external
304 AviError AVI_print_error(AviError error);
305 void AVI_set_debug(int mode);
307 #endif /* __AVI_AVI_H__ */