2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software Foundation,
14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17 * All rights reserved.
23 * \section avi_about About the AVI module
25 * This is external code. It provides avi file import/export and
26 * conversions. It has been adapted to make use of Blender memory
27 * management functions, and because of this it needs module
28 * blenlib. You need to provide this lib when linking with libavi.a .
30 * \subsection avi_issues Known issues with AVI
32 * - avi uses #MEM_mallocN, #MEM_freeN from blenlib.
33 * - Not all functions that are used externally are properly
36 * This header has not been split, since it interleaves type defines
37 * and functions. You would need the types to be able to include the
38 * function headers anyway. And, after all, it is someone else's
39 * code. So we keep it like this.
45 #include "BLI_sys_types.h"
46 #include <stdio.h> /* for FILE */
48 typedef struct _AviChunk {
53 typedef struct _AviList {
59 typedef struct _AviMainHeader {
62 int MicroSecPerFrame; /* MicroSecPerFrame - timing between frames */
63 int MaxBytesPerSec; /* MaxBytesPerSec - approx bps system must handle */
64 int PaddingGranularity;
66 #define AVIF_HASINDEX 0x00000010 /* had idx1 chunk */
67 #define AVIF_MUSTUSEINDEX 0x00000020 /* must use idx1 chunk to determine order */
68 #define AVIF_ISINTERLEAVED 0x00000100 /* AVI file is interleaved */
69 #define AVIF_TRUSTCKTYPE 0x00000800
70 #define AVIF_WASCAPTUREFILE 0x00010000 /* specially allocated used for capturing real time video */
71 #define AVIF_COPYRIGHTED 0x00020000 /* contains copyrighted data */
74 int InitialFrames; /* InitialFrames - initial frame before interleaving */
76 int SuggestedBufferSize;
82 typedef struct _AviStreamHeader {
86 #define AVIST_VIDEO FCC("vids")
87 #define AVIST_AUDIO FCC("auds")
88 #define AVIST_MIDI FCC("mids")
89 #define AVIST_TEXT FCC("txts")
93 #define AVISF_DISABLED 0x00000001
94 #define AVISF_VIDEO_PALCHANGES 0x00010000
103 int SuggestedBufferSize;
112 typedef struct _AviBitmapInfoHeader {
126 } AviBitmapInfoHeader;
128 typedef struct _AviMJPEGUnknown {
138 typedef struct _AviIndexEntry {
141 #define AVIIF_LIST 0x00000001
142 #define AVIIF_KEYFRAME 0x00000010
143 #define AVIIF_NO_TIME 0x00000100
144 #define AVIIF_COMPRESSOR 0x0FFF0000
149 typedef struct _AviIndex {
152 AviIndexEntry *entrys;
156 AVI_FORMAT_RGB24, /* The most basic of forms, 3 bytes per pixel, 1 per r, g, b */
157 AVI_FORMAT_RGB32, /* The second most basic of forms, 4 bytes per pixel, 1 per r, g, b, alpha */
158 AVI_FORMAT_AVI_RGB, /* Same as above, but is in the weird AVI order (bottom to top, left to right) */
159 AVI_FORMAT_MJPEG /* Motion-JPEG */
162 typedef struct _AviStreamRec {
169 typedef struct _AviMovie {
173 #define AVI_MOVIE_READ 0
174 #define AVI_MOVIE_WRITE 1
178 AviMainHeader *header;
179 AviStreamRec *streams;
180 AviIndexEntry *entries;
185 int64_t *offset_table;
187 /* Local data goes here */
194 AVI_ERROR_COMPRESSION,
204 /* belongs to the option-setting function. */
206 AVI_OPTION_WIDTH = 0,
212 /* The offsets that will always stay the same in AVI files we
213 * write... used to seek around to the places where we need to write
216 #define AVI_RIFF_SOFF 4L
217 #define AVI_HDRL_SOFF 16L
220 * This is a sort of MAKE_ID thing. Used in imbuf :( It is used
221 * through options in the AVI header (AviStreamHeader). */
222 #define FCC(ch4) (ch4[0] | ch4[1] << 8 | ch4[2] << 16 | ch4[3] << 24)
225 * Test whether this is an avi-format.
227 bool AVI_is_avi(const char *name);
231 * Open a compressed file, decompress it into memory.
233 AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...);
236 * Finalize a compressed output stream.
238 AviError AVI_close_compress(AviMovie *movie);
241 * Choose a compression option for \<movie\>. Possible options are
242 * AVI_OPTION_TYPE_MAIN, AVI_OPTION_TYPE_STRH, AVI_OPTION_TYPE_STRF
244 AviError AVI_set_compress_option(AviMovie *movie,
249 /* Hmmm... there should be some explanation about what these mean */
251 * Compression option, for use in avi_set_compress_option
253 #define AVI_OPTION_TYPE_MAIN 0
255 * Compression option, for use in avi_set_compress_option
257 #define AVI_OPTION_TYPE_STRH 1
259 * Compression option, for use in avi_set_compress_option
261 #define AVI_OPTION_TYPE_STRF 2
264 * Direct the streams \<avist_type\> to \<movie\>. Redirect \<stream_num\>
267 int AVI_get_stream(AviMovie *movie, int avist_type, int stream_num);
270 * Open a movie stream from file.
272 AviError AVI_open_movie(const char *name, AviMovie *movie);
275 * Read a frame from a movie stream.
277 void *AVI_read_frame(AviMovie *movie,
282 * Close an open movie stream.
284 AviError AVI_close(AviMovie *movie);
287 * Write frames to a movie stream.
289 AviError AVI_write_frame(AviMovie *movie, int frame_num, ...);
292 * Unused but still external
294 AviError AVI_print_error(AviError error);
295 void AVI_set_debug(int mode);
297 #endif /* __AVI_AVI_H__ */