Blender V2.61 - r43446

AVI_avi.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  *
00027  */
00028 
00053 #ifndef __AVI_H__
00054 #define __AVI_H__
00055 
00056 #include "MEM_sys_types.h"
00057 #include <stdio.h> /* for FILE */
00058 
00059 typedef struct _AviChunk {
00060   int fcc;
00061   int size;
00062 } AviChunk;
00063 
00064 typedef struct _AviList {
00065   int fcc;
00066   int size;
00067   int ids;
00068 } AviList;
00069 
00070 typedef struct _AviMainHeader {
00071   int fcc;
00072   int size;  
00073   int MicroSecPerFrame;       /* MicroSecPerFrame - timing between frames */
00074   int MaxBytesPerSec;        /* MaxBytesPerSec - approx bps system must handle */
00075   int PaddingGranularity;
00076   int Flags;
00077 #define AVIF_HASINDEX           0x00000010        /* had idx1 chunk */
00078 #define AVIF_MUSTUSEINDEX       0x00000020        /* must use idx1 chunk to determine order */
00079 #define AVIF_ISINTERLEAVED      0x00000100        /* AVI file is interleaved */
00080 #define AVIF_TRUSTCKTYPE        0x00000800
00081 #define AVIF_WASCAPTUREFILE     0x00010000        /* specially allocated used for capturing real time video */
00082 #define AVIF_COPYRIGHTED        0x00020000        /* contains copyrighted data */
00083 
00084   int TotalFrames;
00085   int InitialFrames;    /* InitialFrames - initial frame before interleaving */
00086   int Streams;
00087   int SuggestedBufferSize;
00088   int Width;
00089   int Height;
00090   int Reserved[4];
00091 } AviMainHeader;
00092 
00093 typedef struct _AviStreamHeader {
00094   int fcc;
00095   int size;  
00096   int Type;
00097 #define AVIST_VIDEO FCC("vids")
00098 #define AVIST_AUDIO FCC("auds")
00099 #define AVIST_MIDI  FCC("mids")
00100 #define AVIST_TEXT  FCC("txts")
00101   
00102   int Handler;
00103   int Flags;
00104 #define AVISF_DISABLED 0x00000001
00105 #define AVISF_VIDEO_PALCHANGES 0x00010000
00106 
00107   short Priority;
00108   short Language;
00109   int InitialFrames;
00110   int Scale;
00111   int Rate;
00112   int Start;
00113   int Length;
00114   int SuggestedBufferSize;
00115   int Quality;
00116   int SampleSize;
00117   short left;
00118   short top;
00119   short right;
00120   short bottom;
00121 } AviStreamHeader;
00122 
00123 typedef struct _AviBitmapInfoHeader {
00124   int fcc;
00125   int size;  
00126   int Size;
00127   int Width;
00128   int Height;
00129   short Planes;
00130   short BitCount;
00131   int Compression;
00132   int SizeImage;
00133   int XPelsPerMeter;
00134   int YPelsPerMeter;
00135   int ClrUsed;
00136   int ClrImportant;
00137 } AviBitmapInfoHeader;
00138 
00139 typedef struct _AviMJPEGUnknown {
00140   int a;
00141   int b;
00142   int c;
00143   int d;
00144   int e;
00145   int f;
00146   int g;
00147 } AviMJPEGUnknown;
00148 
00149 typedef struct _AviIndexEntry {
00150   int ChunkId;
00151   int Flags;
00152 #define AVIIF_LIST       0x00000001
00153 #define AVIIF_KEYFRAME   0x00000010 
00154 #define AVIIF_NO_TIME    0x00000100
00155 #define AVIIF_COMPRESSOR 0x0FFF0000
00156   int Offset;
00157   int Size;
00158 } AviIndexEntry;
00159 
00160 typedef struct _AviIndex {
00161   int fcc;
00162   int size;
00163   AviIndexEntry *entrys;
00164 } AviIndex;
00165 
00166 typedef enum {
00167   AVI_FORMAT_RGB24,  /* The most basic of forms, 3 bytes per pixel, 1 per r, g, b */
00168   AVI_FORMAT_RGB32,  /* The second most basic of forms, 4 bytes per pixel, 1 per r, g, b, alpha */
00169   AVI_FORMAT_AVI_RGB, /* Same as above, but is in the weird AVI order (bottom to top, left to right) */
00170   AVI_FORMAT_MJPEG /* Motion-JPEG */
00171 } AviFormat;
00172 
00173 typedef struct _AviStreamRec {
00174   AviStreamHeader sh;
00175   void *sf;
00176   int sf_size;
00177   AviFormat format;
00178 } AviStreamRec;
00179 
00180 typedef struct _AviMovie {
00181     FILE *fp; 
00182     
00183     int type;
00184 #define AVI_MOVIE_READ  0
00185 #define AVI_MOVIE_WRITE 1
00186     
00187     int64_t size;
00188 
00189     AviMainHeader *header;
00190     AviStreamRec *streams;
00191     AviIndexEntry *entries;
00192     int index_entries;
00193     
00194     int64_t movi_offset;
00195     int64_t read_offset;
00196     int64_t *offset_table;
00197     
00198     /* Local data goes here */
00199     int interlace;
00200     int odd_fields;
00201 } AviMovie;
00202 
00203 typedef enum {
00204   AVI_ERROR_NONE=0,
00205   AVI_ERROR_COMPRESSION,
00206   AVI_ERROR_OPEN,
00207   AVI_ERROR_READING,
00208   AVI_ERROR_WRITING,
00209   AVI_ERROR_FORMAT,
00210   AVI_ERROR_ALLOC,
00211   AVI_ERROR_FOUND,
00212   AVI_ERROR_OPTION
00213 } AviError;
00214 
00215 /* belongs to the option-setting function. */
00216 typedef enum {
00217   AVI_OPTION_WIDTH=0,
00218   AVI_OPTION_HEIGHT, 
00219   AVI_OPTION_QUALITY,
00220   AVI_OPTION_FRAMERATE
00221 } AviOption;
00222 
00223 /* The offsets that will always stay the same in AVI files we
00224  * write... used to seek around to the places where we need to write
00225  * the sizes */
00226 
00227 #define AVI_RIFF_SOFF 4L
00228 #define AVI_HDRL_SOFF 16L
00229 
00233 #define FCC(ch4) (ch4[0] | ch4[1]<<8 | ch4[2]<<16 | ch4[3] << 24)
00234 
00238 int AVI_is_avi (const char *name);
00239 
00240 
00244 AviError AVI_open_compress (char *name, AviMovie *movie, int streams, ...);
00245 
00249 AviError AVI_close_compress (AviMovie *movie);
00250 
00255 AviError AVI_set_compress_option (AviMovie *movie,
00256                                   int option_type,
00257                                   int stream,
00258                                   AviOption option,
00259                                   void *opt_data);
00260 /* Hmmm... there should be some explanantion about what these mean */
00264 #define AVI_OPTION_TYPE_MAIN 0
00265 
00268 #define AVI_OPTION_TYPE_STRH 1
00269 
00272 #define AVI_OPTION_TYPE_STRF 2
00273 
00278 int AVI_get_stream (AviMovie *movie, int avist_type, int stream_num);
00279 
00283 AviError AVI_open_movie (const char *name, AviMovie *movie);
00284 
00288 void *AVI_read_frame (AviMovie *movie,
00289                       AviFormat format,
00290                       int frame,
00291                       int stream);
00295 AviError AVI_close (AviMovie *movie);
00296 
00300 AviError AVI_write_frame (AviMovie *movie, int frame_num, ...);
00301 
00305 AviError AVI_print_error (AviError error);
00306 void AVI_set_debug (int mode);
00307 
00308 #endif /* __AVI_H__ */
00309