#include <avi.h>
Inheritance diagram for AVI1File:


Public Member Functions | |
| AVI1File () | |
| virtual | ~AVI1File () |
| virtual void | Init (int format, int sampleFrequency, int indexType) |
| Initialize the AVI structure to its initial state, either for PAL or NTSC format. | |
| virtual bool | WriteFrame (const Frame &frame) |
| virtual void | WriteRIFF (void) |
| Writes out the directory structure. | |
| virtual void | setDVINFO (DVINFO &) |
Private Member Functions | |
| AVI1File (const AVI1File &) | |
| AVI1File & | operator= (const AVI1File &) |
Private Attributes | |
| DVINFO | dvinfo |
Definition at line 286 of file avi.h.
|
|
Definition at line 1039 of file avi.cc. 01039 : AVIFile() 01040 {}
|
|
|
Definition at line 1043 of file avi.cc. 01044 {}
|
|
|
|
|
||||||||||||||||
|
Initialize the AVI structure to its initial state, either for PAL or NTSC format. Initialize the AVIFile attributes: mainHdr, indx, ix00, idx1
Reimplemented from AVIFile. Definition at line 1050 of file avi.cc. References RIFFFile::AddDirectoryEntry(), AVI_LARGE_INDEX, AVI_NTSC, AVI_PAL, AVIFile::avih_chunk, AVIFile::dmlh_chunk, dvinfo, AVIFile::file_list, FOURCC, RIFFFile::GetDirectoryEntry(), AVIFile::hdrl_list, AVIFile::index_type, AVIFile::indx, AVIFile::indx_chunk, AVIFile::Init(), AVIFile::ix_chunk, AVIFile::junk_chunk, AVIFile::mainHdr, make_fourcc(), AVIFile::movi_list, AVIFile::odml_list, PADDING_SIZE, RIFF_HEADERSIZE, AVIFile::riff_list, RIFF_LISTSIZE, RIFF_NO_PARENT, AVIFile::streamHdr, AVIFile::strf_chunk, AVIFile::strh_chunk, and AVIFile::strl_list. 01051 {
01052 int num_blocks;
01053 FOURCC type;
01054 FOURCC name;
01055 off_t length;
01056 off_t offset;
01057 int parent;
01058
01059 assert( ( format == AVI_PAL ) || ( format == AVI_NTSC ) );
01060
01061 AVIFile::Init( format, sampleFrequency, indexType );
01062
01063 switch ( format )
01064 {
01065 case AVI_PAL:
01066 mainHdr.dwWidth = 720;
01067 mainHdr.dwHeight = 576;
01068
01069 streamHdr[ 0 ].dwScale = 1;
01070 streamHdr[ 0 ].dwRate = 25;
01071 streamHdr[ 0 ].dwSuggestedBufferSize = 144008;
01072
01073 /* initialize the 'strf' chunk */
01074
01075 /* Meaning of the DV stream format chunk per Microsoft
01076 dwDVAAuxSrc
01077 Specifies the Audio Auxiliary Data Source Pack for the first audio block
01078 (first 5 DV DIF sequences for 525-60 systems or 6 DV DIF sequences for 625-50 systems) of
01079 a frame. A DIF sequence is a data block that contains 150 DIF blocks. A DIF block consists
01080 of 80 bytes. The Audio Auxiliary Data Source Pack is defined in section D.7.1 of Part 2,
01081 Annex D, "The Pack Header Table and Contents of Packs" of the Specification of
01082 Consumer-use Digital VCRs.
01083 dwDVAAuxCtl
01084 Specifies the Audio Auxiliary Data Source Control Pack for the first audio block of a
01085 frame. The Audio Auxiliary Data Control Pack is defined in section D.7.2 of Part 2,
01086 Annex D, "The Pack Header Table and Contents of Packs" of the Specification of
01087 Consumer-use Digital VCRs.
01088 dwDVAAuxSrc1
01089 Specifies the Audio Auxiliary Data Source Pack for the second audio block
01090 (second 5 DV DIF sequences for 525-60 systems or 6 DV DIF sequences for 625-50 systems) of a frame.
01091 dwDVAAuxCtl1
01092 Specifies the Audio Auxiliary Data Source Control Pack for the second audio block of a frame.
01093 dwDVVAuxSrc
01094 Specifies the Video Auxiliary Data Source Pack as defined in section D.8.1 of Part 2,
01095 Annex D, "The Pack Header Table and Contents of Packs" of the Specification of
01096 Consumer-use Digital VCRs.
01097 dwDVVAuxCtl
01098 Specifies the Video Auxiliary Data Source Control Pack as defined in section D.8.2 of Part 2,
01099 Annex D, "The Pack Header Table and Contents of Packs" of the Specification of
01100 Consumer-use Digital VCRs.
01101 dwDVReserved[2]
01102 Reserved. Set this array to zero.
01103 */
01104
01105 dvinfo.dwDVAAuxSrc = 0xd1e030d0;
01106 dvinfo.dwDVAAuxCtl = 0xffa0cf3f;
01107 dvinfo.dwDVAAuxSrc1 = 0xd1e03fd0;
01108 dvinfo.dwDVAAuxCtl1 = 0xffa0cf3f;
01109 dvinfo.dwDVVAuxSrc = 0xff20ffff;
01110 dvinfo.dwDVVAuxCtl = 0xfffdc83f;
01111 dvinfo.dwDVReserved[ 0 ] = 0;
01112 dvinfo.dwDVReserved[ 1 ] = 0;
01113 break;
01114
01115 case AVI_NTSC:
01116 mainHdr.dwWidth = 720;
01117 mainHdr.dwHeight = 480;
01118
01119 streamHdr[ 0 ].dwScale = 1001;
01120 streamHdr[ 0 ].dwRate = 30000;
01121 streamHdr[ 0 ].dwSuggestedBufferSize = 120008;
01122
01123 /* initialize the 'strf' chunk */
01124 dvinfo.dwDVAAuxSrc = 0xc0c000c0;
01125 dvinfo.dwDVAAuxCtl = 0xffa0cf3f;
01126 dvinfo.dwDVAAuxSrc1 = 0xc0c001c0;
01127 dvinfo.dwDVAAuxCtl1 = 0xffa0cf3f;
01128 dvinfo.dwDVVAuxSrc = 0xff80ffff;
01129 dvinfo.dwDVVAuxCtl = 0xfffcc83f;
01130 dvinfo.dwDVReserved[ 0 ] = 0;
01131 dvinfo.dwDVReserved[ 1 ] = 0;
01132 break;
01133
01134 default: /* no default allowed */
01135 assert( 0 );
01136 break;
01137 }
01138
01139 indx[ 0 ] ->dwChunkId = make_fourcc( "00__" );
01140
01141 /* Initialize the 'strh' chunk */
01142
01143 streamHdr[ 0 ].fccType = make_fourcc( "iavs" );
01144 streamHdr[ 0 ].fccHandler = make_fourcc( "dvsd" );
01145 streamHdr[ 0 ].dwFlags = 0;
01146 streamHdr[ 0 ].wPriority = 0;
01147 streamHdr[ 0 ].wLanguage = 0;
01148 streamHdr[ 0 ].dwInitialFrames = 0;
01149 streamHdr[ 0 ].dwStart = 0;
01150 streamHdr[ 0 ].dwLength = 0;
01151 streamHdr[ 0 ].dwQuality = 0;
01152 streamHdr[ 0 ].dwSampleSize = 0;
01153 streamHdr[ 0 ].rcFrame.top = 0;
01154 streamHdr[ 0 ].rcFrame.bottom = 0;
01155 streamHdr[ 0 ].rcFrame.left = 0;
01156 streamHdr[ 0 ].rcFrame.right = 0;
01157
01158 /* This is a simple directory structure setup. For details see the
01159 "OpenDML AVI File Format Extensions" document.
01160
01161 An AVI file contains basically two types of objects, a
01162 "chunk" and a "list" object. The list object contains any
01163 number of chunks. Since a list is also a chunk, it is
01164 possible to create a hierarchical "list of lists"
01165 structure.
01166
01167 Every AVI file starts with a "RIFF" object, which is a list
01168 of several other required objects. The actual DV data is
01169 contained in a "movi" list, each frame is in its own chunk.
01170
01171 Old AVI files (pre OpenDML V. 1.02) contain only one RIFF
01172 chunk of less than 1 GByte size per file. The current
01173 format which allow for almost arbitrary sizes can contain
01174 several RIFF chunks of less than 1 GByte size. Old software
01175 however would only deal with the first RIFF chunk.
01176
01177 Note that the first entry (FILE) isn't actually part
01178 of the AVI file. I use this (pseudo-) directory entry to
01179 keep track of the RIFF chunks and their positions in the
01180 AVI file.
01181 */
01182
01183 /* Create the container directory entry */
01184
01185 file_list = AddDirectoryEntry( make_fourcc( "FILE" ), make_fourcc( "FILE" ), 0, RIFF_NO_PARENT );
01186
01187 /* Create a basic directory structure. Only chunks defined from here on will be written to the AVI file. */
01188
01189 riff_list = AddDirectoryEntry( make_fourcc( "RIFF" ), make_fourcc( "AVI " ), RIFF_LISTSIZE, file_list );
01190 hdrl_list = AddDirectoryEntry( make_fourcc( "LIST" ), make_fourcc( "hdrl" ), RIFF_LISTSIZE, riff_list );
01191 avih_chunk = AddDirectoryEntry( make_fourcc( "avih" ), 0, sizeof( MainAVIHeader ), hdrl_list );
01192 strl_list[ 0 ] = AddDirectoryEntry( make_fourcc( "LIST" ), make_fourcc( "strl" ), RIFF_LISTSIZE, hdrl_list );
01193 strh_chunk[ 0 ] = AddDirectoryEntry( make_fourcc( "strh" ), 0, sizeof( AVIStreamHeader ), strl_list[ 0 ] );
01194 strf_chunk[ 0 ] = AddDirectoryEntry( make_fourcc( "strf" ), 0, sizeof( dvinfo ), strl_list[ 0 ] );
01195 if ( index_type & AVI_LARGE_INDEX )
01196 indx_chunk[ 0 ] = AddDirectoryEntry( make_fourcc( "indx" ), 0, sizeof( AVISuperIndex ), strl_list[ 0 ] );
01197
01198 odml_list = AddDirectoryEntry( make_fourcc( "LIST" ), make_fourcc( "odml" ), RIFF_LISTSIZE, hdrl_list );
01199 dmlh_chunk = AddDirectoryEntry( make_fourcc( "dmlh" ), 0, 0x00f8, odml_list );
01200
01201 /* align movi list to block */
01202 GetDirectoryEntry( hdrl_list, type, name, length, offset, parent );
01203 num_blocks = length / PADDING_SIZE + 1;
01204 length = num_blocks * PADDING_SIZE - length - 5 * RIFF_HEADERSIZE; // why 5?
01205 junk_chunk = AddDirectoryEntry( make_fourcc( "JUNK" ), 0, length, riff_list );
01206
01207 movi_list = AddDirectoryEntry( make_fourcc( "LIST" ), make_fourcc( "movi" ), RIFF_LISTSIZE, riff_list );
01208
01209 /* The ix00 chunk will be added dynamically to the movi_list in avi_write_frame
01210 as needed */
01211
01212 ix_chunk[ 0 ] = -1;
01213 }
|
|
|
|
|
|
Reimplemented from AVIFile. Definition at line 1686 of file avi.cc. References dvinfo. 01687 {
01688 // do not do this until debugged audio against DirectShow
01689 return ;
01690
01691 dvinfo.dwDVAAuxSrc = info.dwDVAAuxSrc;
01692 dvinfo.dwDVAAuxCtl = info.dwDVAAuxCtl;
01693 dvinfo.dwDVAAuxSrc1 = info.dwDVAAuxSrc1;
01694 dvinfo.dwDVAAuxCtl1 = info.dwDVAAuxCtl1;
01695 dvinfo.dwDVVAuxSrc = info.dwDVVAuxSrc;
01696 dvinfo.dwDVVAuxCtl = info.dwDVVAuxCtl;
01697 }
|
|
|
Reimplemented from AVIFile. Definition at line 1218 of file avi.cc. References RIFFFile::AddDirectoryEntry(), AVI_LARGE_INDEX, AVI_SMALL_INDEX, Frame::data, AVIFile::dmlh, AVIFile::file_list, AVIFile::FlushIndx(), FOURCC, g_zeroes, RIFFFile::GetDirectoryEntry(), Frame::GetFrameSize(), AVIFile::idx1, AVIFile::idx1_chunk, AVIFile::index_type, AVIFile::isUpdateIdx1, AVIFile::ix, IX00_INDEX_SIZE, AVIFile::junk_chunk, AVIFile::mainHdr, make_fourcc(), AVIFile::movi_list, PADDING_SIZE, RIFF_HEADERSIZE, AVIFile::riff_list, RIFF_LISTSIZE, AVIFile::streamHdr, AVIFile::UpdateIdx1(), AVIFile::UpdateIndx(), and RIFFFile::WriteChunk(). 01219 {
01220 int frame_chunk;
01221 int junk_chunk;
01222 int num_blocks;
01223 FOURCC type;
01224 FOURCC name;
01225 off_t length;
01226 off_t offset;
01227 int parent;
01228
01229 /* exit if no large index and 1GB reached */
01230 if ( !( index_type & AVI_LARGE_INDEX ) && isUpdateIdx1 == false )
01231 return false;
01232
01233 /* Check if we need a new ix00 Standard Index. It has a
01234 capacity of IX00_INDEX_SIZE frames. Whenever we exceed that
01235 number, we need a new index. The new ix00 chunk is also
01236 part of the movi list. */
01237
01238 if ( ( index_type & AVI_LARGE_INDEX ) && ( ( ( streamHdr[ 0 ].dwLength - 0 ) % IX00_INDEX_SIZE ) == 0 ) )
01239 FlushIndx( 0 );
01240
01241 /* Write the DV frame data.
01242
01243 Make a new 00__ chunk for the new frame, write out the
01244 frame. */
01245
01246 frame_chunk = AddDirectoryEntry( make_fourcc( "00__" ), 0, frame.GetFrameSize(), movi_list );
01247 if ( ( index_type & AVI_LARGE_INDEX ) && ( streamHdr[ 0 ].dwLength % IX00_INDEX_SIZE ) == 0 )
01248 {
01249 GetDirectoryEntry( frame_chunk, type, name, length, offset, parent );
01250 ix[ 0 ] ->qwBaseOffset = offset - RIFF_HEADERSIZE;
01251 }
01252 WriteChunk( frame_chunk, frame.data );
01253 // num_blocks = (frame.GetFrameSize() + RIFF_HEADERSIZE) / PADDING_SIZE + 1;
01254 // length = num_blocks * PADDING_SIZE - frame.GetFrameSize() - 2 * RIFF_HEADERSIZE;
01255 // junk_chunk = AddDirectoryEntry(make_fourcc("JUNK"), 0, length, movi_list);
01256 // WriteChunk(junk_chunk, g_zeroes);
01257
01258 if ( index_type & AVI_LARGE_INDEX )
01259 UpdateIndx( 0, frame_chunk, 1 );
01260 if ( ( index_type & AVI_SMALL_INDEX ) && isUpdateIdx1 )
01261 UpdateIdx1( frame_chunk, 0x10 );
01262
01263 /* update some variables with the new frame count. */
01264
01265 if ( isUpdateIdx1 )
01266 ++mainHdr.dwTotalFrames;
01267 ++streamHdr[ 0 ].dwLength;
01268 ++dmlh[ 0 ];
01269
01270 /* Find out if the current riff list is close to 1 GByte in
01271 size. If so, start a new (extended) RIFF. The only allowed
01272 item in the new RIFF chunk is a movi list (with video
01273 frames and indexes as usual). */
01274
01275 GetDirectoryEntry( riff_list, type, name, length, offset, parent );
01276 if ( length > 0x3f000000 )
01277 {
01278 /* write idx1 only once and before end of first GB */
01279 if ( ( index_type & AVI_SMALL_INDEX ) && isUpdateIdx1 )
01280 {
01281 int idx1_chunk = AddDirectoryEntry( make_fourcc( "idx1" ), 0, idx1->nEntriesInUse * 16, riff_list );
01282 WriteChunk( idx1_chunk, ( void* ) idx1 );
01283 }
01284 isUpdateIdx1 = false;
01285
01286 if ( index_type & AVI_LARGE_INDEX )
01287 {
01288 /* pad out to 1GB */
01289 //GetDirectoryEntry(riff_list, type, name, length, offset, parent);
01290 //junk_chunk = AddDirectoryEntry(make_fourcc("JUNK"), 0, PADDING_1GB - length - 5 * RIFF_HEADERSIZE, riff_list);
01291 //WriteChunk(junk_chunk, g_zeroes);
01292
01293 /* padding for alignment */
01294 GetDirectoryEntry( riff_list, type, name, length, offset, parent );
01295 num_blocks = ( length + 4 * RIFF_HEADERSIZE ) / PADDING_SIZE + 1;
01296 length = ( num_blocks * PADDING_SIZE ) - length - 4 * RIFF_HEADERSIZE - 2 * RIFF_LISTSIZE;
01297 if ( length > 0 )
01298 {
01299 junk_chunk = AddDirectoryEntry( make_fourcc( "JUNK" ), 0, length, riff_list );
01300 WriteChunk( junk_chunk, g_zeroes );
01301 }
01302
01303 riff_list = AddDirectoryEntry( make_fourcc( "RIFF" ), make_fourcc( "AVIX" ), RIFF_LISTSIZE, file_list );
01304 movi_list = AddDirectoryEntry( make_fourcc( "LIST" ), make_fourcc( "movi" ), RIFF_LISTSIZE, riff_list );
01305 }
01306 }
01307 return true;
01308 }
|
|
|
Writes out the directory structure. For all items in the directory list that have not been written yet, it seeks to the file position where that item should be stored and writes the type and length field. If the item has a name, it will also write the name field.
Reimplemented from AVIFile. Definition at line 1311 of file avi.cc. References RIFFFile::AddDirectoryEntry(), AVI_LARGE_INDEX, AVI_SMALL_INDEX, AVIFile::avih_chunk, AVIFile::dmlh, AVIFile::dmlh_chunk, dvinfo, AVIFile::idx1, AVIFile::idx1_chunk, AVIFile::index_type, AVIFile::indx, AVIFile::indx_chunk, AVIFile::isUpdateIdx1, AVIFile::ix, AVIFile::ix_chunk, AVIFile::mainHdr, make_fourcc(), AVIFile::riff_list, AVIFile::streamHdr, AVIFile::strf_chunk, AVIFile::strh_chunk, RIFFFile::WriteChunk(), and RIFFFile::WriteRIFF(). 01312 {
01313
01314 WriteChunk( avih_chunk, ( void* ) & mainHdr );
01315 WriteChunk( strh_chunk[ 0 ], ( void* ) & streamHdr[ 0 ] );
01316 WriteChunk( strf_chunk[ 0 ], ( void* ) & dvinfo );
01317 WriteChunk( dmlh_chunk, ( void* ) & dmlh );
01318
01319 if ( index_type & AVI_LARGE_INDEX )
01320 {
01321 WriteChunk( indx_chunk[ 0 ], ( void* ) indx[ 0 ] );
01322 WriteChunk( ix_chunk[ 0 ], ( void* ) ix[ 0 ] );
01323 }
01324
01325 if ( ( index_type & AVI_SMALL_INDEX ) && isUpdateIdx1 )
01326 {
01327 int idx1_chunk = AddDirectoryEntry( make_fourcc( "idx1" ), 0, idx1->nEntriesInUse * 16, riff_list );
01328 WriteChunk( idx1_chunk, ( void* ) idx1 );
01329 }
01330
01331 RIFFFile::WriteRIFF();
01332 }
|
|
|
Definition at line 298 of file avi.h. Referenced by Init(), setDVINFO(), and WriteRIFF(). |
1.4.2