2 * avi.h library for AVI file format i/o
3 * Copyright (C) 2000 - 2002 Arne Schirmacher <arne@schirmacher.de>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 * Revision 1.3 2005/06/21 20:59:39 lilo_booter
25 * src/framework/mlt_consumer.c src/framework/mlt_consumer.h
26 * + Added a general profile handling for size, aspect ratio and display ratio
28 * src/framework/mlt_producer.c
29 * + Correction to aspect ratio properties
32 * + Minimalist support for sdl_preview (still not very good)
34 * src/modules/avformat/consumer_avformat.c
35 * + Takes consumer profile into account
37 * src/modules/core/filter_resize.c
38 * + Corrections for synthesised producers and aspect ratio (inherits from consumer)
40 * src/modules/core/producer_colour.c
41 * src/modules/core/producer_noise.c
42 * src/modules/gtk2/producer_pango.c
43 * + Ensures that resize picks up consumer aspect ratio
45 * src/modules/dv/consumer_libdv.c
46 * + Honour wide screen output
48 * src/modules/gtk2/producer_pixbuf.c
49 * + Correction for 1:1 aspect ratio
51 * src/modules/kino/Makefile
52 * src/modules/kino/avi.cc
53 * src/modules/kino/avi.h
54 * src/modules/kino/configure
55 * src/modules/kino/filehandler.cc
56 * + Attempt to allow mov dv files to provide audio
58 * src/modules/sdl/consumer_sdl.c
59 * src/modules/sdl/consumer_sdl_preview.c
60 * src/modules/sdl/consumer_sdl_still.c
61 * + Takes consumer profile into account
63 * Revision 1.2 2005/04/15 14:37:03 lilo_booter
66 * Revision 1.1 2005/04/15 14:28:26 lilo_booter
69 * Revision 1.16 2005/04/01 23:43:10 ddennedy
70 * apply endian fixes from Daniel Kobras
72 * Revision 1.15 2004/10/11 01:37:11 ddennedy
73 * mutex safety locks in RIFF and AVI classes, type 2 AVI optimization, mencoder export script
75 * Revision 1.14 2003/11/25 23:00:52 ddennedy
76 * cleanup and a few bugfixes
78 * Revision 1.13 2003/10/21 16:34:32 ddennedy
79 * GNOME2 port phase 1: initial checkin
81 * Revision 1.11.2.5 2003/07/24 14:13:57 ddennedy
82 * support for distinct audio stream in type2 AVI and Quicktime; support for more DV FOURCCs
84 * Revision 1.11.2.4 2003/06/10 23:53:36 ddennedy
85 * Daniel Kobras' WriteFrame error handling and automatic OpenDML, bugfixes in scene list updates, export AV/C Record
87 * Revision 1.11.2.3 2003/02/20 21:59:57 ddennedy
88 * bugfixes to capture and AVI
90 * Revision 1.11.2.2 2003/01/13 05:15:31 ddennedy
91 * added More Info panel and supporting methods
93 * Revision 1.11.2.1 2002/11/25 04:48:31 ddennedy
94 * bugfix to report errors when loading files
96 * Revision 1.11 2002/10/08 07:46:41 ddennedy
97 * AVI bugfixes, compatibility, optimization, warn bad file in capture and export dv file, allow no mplex
99 * Revision 1.10 2002/05/17 08:04:25 ddennedy
100 * revert const-ness of Frame references in Frame, FileHandler, and AVI classes
102 * Revision 1.9 2002/05/15 04:39:35 ddennedy
103 * bugfixes to dv2 AVI write, audio export, Xv init
105 * Revision 1.8 2002/04/29 05:09:22 ddennedy
106 * raw dv file support, Frame::ExtractAudio uses libdv, audioScrub prefs
108 * Revision 1.7 2002/04/09 06:53:42 ddennedy
109 * cleanup, new libdv 0.9.5, large AVI, dnd storyboard
111 * Revision 1.7 2002/03/25 21:34:25 arne
112 * Support for large (64 bit) files mostly completed
114 * Revision 1.6 2002/03/10 13:29:41 arne
115 * more changes for 64 bit access
117 * Revision 1.5 2002/03/09 17:59:28 arne
118 * moved index routines to AVIFile
120 * Revision 1.4 2002/03/09 10:26:26 arne
121 * improved constructors and assignment operator
123 * Revision 1.3 2002/03/09 08:55:57 arne
124 * moved a few variables to AVIFile
126 * Revision 1.2 2002/03/04 19:22:43 arne
127 * updated to latest Kino avi code
129 * Revision 1.1.1.1 2002/03/03 19:08:08 arne
130 * import of version 1.01
134 /** Common AVI declarations
136 Some of this comes from the public domain AVI specification, which
137 explains the microsoft-style definitions.
148 #define PACKED(x) __attribute__((packed)) x
150 #define AVI_SMALL_INDEX (0x01)
151 #define AVI_LARGE_INDEX (0x02)
152 #define KINO_AVI_INDEX_OF_INDEXES (0x00)
153 #define KINO_AVI_INDEX_OF_CHUNKS (0x01)
154 #define AVI_INDEX_2FIELD (0x01)
156 enum
{ AVI_PAL
, AVI_NTSC
, AVI_AUDIO_48KHZ
, AVI_AUDIO_44KHZ
, AVI_AUDIO_32KHZ
};
158 /** Declarations of the main AVI file header
160 The contents of this struct goes into the 'avih' chunk. */
164 /// frame display rate (or 0L)
165 DWORD dwMicroSecPerFrame
;
167 /// max. transfer rate
168 DWORD dwMaxBytesPerSec
;
170 /// pad to multiples of this size, normally 2K
171 DWORD dwPaddingGranularity
;
173 /// the ever-present flags
178 DWORD dwInitialFrames
;
180 DWORD dwSuggestedBufferSize
;
185 DWORD dwReserved
[ 4 ];
187 PACKED(MainAVIHeader
);
191 WORD top
, bottom
, left
, right
;
195 /** Declaration of a stream header
197 The contents of this struct goes into the 'strh' header. */
203 DWORD dwFlags
; /* Contains AVITF_* flags */
206 DWORD dwInitialFrames
;
208 DWORD dwRate
; /* dwRate / dwScale == samples/second */
210 DWORD dwLength
; /* In units above... */
211 DWORD dwSuggestedBufferSize
;
216 PACKED(AVIStreamHeader
);
226 DWORD dwDVReserved
[ 2 ];
239 LONG biXPelsPerMeter
;
240 LONG biYPelsPerMeter
;
242 DWORD biClrImportant
;
244 PACKED(BITMAPINFOHEADER
);
250 DWORD nSamplesPerSec
;
251 DWORD nAvgBytesPerSec
;
257 PACKED(WAVEFORMATEX
);
266 DWORD dwReserved
[ 3 ];
267 struct avisuperindex_entry
275 PACKED(AVISuperIndex
);
284 QUADWORD qwBaseOffset
;
286 struct avifieldindex_entry
297 struct avisimpleindex_entry
307 PACKED(AVISimpleIndex
);
313 DWORD dirEntryLength
;
314 size_t dirEntryOffset
;
315 int dirEntryWrittenFlag
;
316 int dirEntryParentList
;
321 /** base class for all AVI type files
323 It contains methods and members which are the same in all AVI type files regardless of the particular compression, number
326 The AVIFile class also contains methods for handling several indexes to the video frame content. */
328 class AVIFile
: public RIFFFile
332 AVIFile( const AVIFile
& );
334 virtual AVIFile
& operator=( const AVIFile
& );
336 virtual void Init( int format
, int sampleFrequency
, int indexType
);
337 virtual int GetDVFrameInfo( off_t
&offset
, int &size
, int frameNum
);
338 virtual int GetFrameInfo( off_t
&offset
, int &size
, int frameNum
, FOURCC chunkID
);
339 virtual int GetDVFrame( uint8_t *data
, int frameNum
);
340 virtual int getFrame( void *data
, int frameNum
, FOURCC chunkID
);
341 virtual int GetTotalFrames() const;
342 virtual void PrintDirectoryEntryData( const RIFFDirEntry
&entry
) const;
343 //virtual bool WriteFrame( const Frame &frame ) { return false; }
344 virtual void ParseList( int parent
);
345 virtual void ParseRIFF( void );
346 virtual void ReadIndex( void );
347 virtual void WriteRIFF( void )
349 virtual void FlushIndx( int stream
);
350 virtual void UpdateIndx( int stream
, int chunk
, int duration
);
351 virtual void UpdateIdx1( int chunk
, int flags
);
352 virtual bool verifyStreamFormat( FOURCC type
);
353 virtual bool verifyStream( FOURCC type
);
354 virtual bool isOpenDML( void );
355 virtual void setDVINFO( DVINFO
& )
357 virtual void setFccHandler( FOURCC type
, FOURCC handler
);
358 virtual bool getStreamFormat( void* data
, FOURCC type
);
361 MainAVIHeader mainHdr
;
362 AVISimpleIndex
*idx1
;
371 AVIStreamHeader streamHdr
[ 2 ];
372 AVISuperIndex
*indx
[ 2 ];
373 AVIStdIndex
*ix
[ 2 ];
391 /** writing Type 1 DV AVIs
395 class AVI1File
: public AVIFile
401 virtual void Init( int format
, int sampleFrequency
, int indexType
);
402 //virtual bool WriteFrame( const Frame &frame );
403 virtual void WriteRIFF( void );
404 virtual void setDVINFO( DVINFO
& );
409 AVI1File( const AVI1File
& );
410 AVI1File
& operator=( const AVI1File
& );
414 /** writing Type 2 (separate audio data) DV AVIs
416 This file type contains both audio and video tracks. It is therefore more compatible
417 to certain Windows programs, which expect any AVI having both audio and video tracks.
418 The video tracks contain the raw DV data (as in type 1) and the extracted audio tracks.
420 Note that because the DV data contains audio information anyway, this means duplication
421 of data and a slight increase of file size.
425 class AVI2File
: public AVIFile
431 virtual void Init( int format
, int sampleFrequency
, int indexType
);
432 //virtual bool WriteFrame( const Frame &frame );
433 virtual void WriteRIFF( void );
434 virtual void setDVINFO( DVINFO
& );
437 BITMAPINFOHEADER bitmapinfo
;
438 WAVEFORMATEX waveformatex
;
440 AVI2File( const AVI2File
& );
441 AVI2File
& operator=( const AVI2File
& );