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


Public Member Functions | |
| AVIFile () | |
| The constructor. | |
| AVIFile (const AVIFile &) | |
| The copy constructor. | |
| virtual | ~AVIFile () |
| The destructor. | |
| virtual AVIFile & | operator= (const AVIFile &) |
| The assignment operator. | |
| virtual void | Init (int format, int sampleFrequency, int indexType) |
| Initialize the AVI structure to its initial state, either for PAL or NTSC format. | |
| virtual int | GetDVFrameInfo (off_t &offset, int &size, int frameNum) |
| Find position and size of a given frame in the file. | |
| virtual int | GetFrameInfo (off_t &offset, int &size, int frameNum, FOURCC chunkID) |
| Find position and size of a given frame in the file. | |
| virtual int | GetDVFrame (Frame &frame, int frameNum) |
| Read in a frame. | |
| virtual int | getFrame (void *data, int frameNum, FOURCC chunkID) |
| Read in a frame. | |
| virtual int | GetTotalFrames () const |
| virtual bool | isInterleave1to1 () |
| Determine if the audio and video frames have a 1:1 interleave factor. | |
| virtual void | PrintDirectoryEntryData (const RIFFDirEntry &entry) const |
| prints out a directory entry in text form | |
| virtual bool | WriteFrame (const Frame &frame) |
| virtual void | ParseList (int parent) |
| If this is not a movi list, read its contents. | |
| virtual void | ParseRIFF (void) |
| Reads the directory structure of the whole RIFF file. | |
| virtual void | ReadIndex (void) |
| virtual void | WriteRIFF (void) |
| Writes out the directory structure. | |
| virtual void | FlushIndx (int stream) |
| virtual void | UpdateIndx (int stream, int chunk, int duration) |
| virtual void | UpdateIdx1 (int chunk, int flags) |
| virtual bool | verifyStreamFormat (FOURCC type) |
| virtual bool | verifyStream (FOURCC type) |
| virtual bool | isOpenDML (void) |
| virtual void | setDVINFO (DVINFO &) |
| virtual void | setFccHandler (FOURCC type, FOURCC handler) |
| virtual bool | getStreamFormat (void *data, FOURCC type) |
Protected Attributes | |
| MainAVIHeader | mainHdr |
| AVISimpleIndex * | idx1 |
| int | file_list |
| int | riff_list |
| int | hdrl_list |
| int | avih_chunk |
| int | movi_list |
| int | junk_chunk |
| int | idx1_chunk |
| AVIStreamHeader | streamHdr [2] |
| AVISuperIndex * | indx [2] |
| AVIStdIndex * | ix [2] |
| int | indx_chunk [2] |
| int | ix_chunk [2] |
| int | strl_list [2] |
| int | strh_chunk [2] |
| int | strf_chunk [2] |
| int | index_type |
| int | current_ix [2] |
| DWORD | dmlh [62] |
| int | odml_list |
| int | dmlh_chunk |
| bool | isUpdateIdx1 |
It contains methods and members which are the same in all AVI type files regardless of the particular compression, number of streams etc.
The AVIFile class also contains methods for handling several indexes to the video frame content.
Definition at line 215 of file avi.h.
|
|
The constructor.
Definition at line 73 of file avi.cc. References current_ix, idx1, indx, indx_chunk, ix, ix_chunk, strf_chunk, strh_chunk, and strl_list. 00073 : RIFFFile(), 00074 idx1( NULL ), file_list( -1 ), riff_list( -1 ), 00075 hdrl_list( -1 ), avih_chunk( -1 ), movi_list( -1 ), junk_chunk( -1 ), idx1_chunk( -1 ), 00076 index_type( 0 ), odml_list( -1 ), dmlh_chunk( -1 ), isUpdateIdx1( true ) 00077 { 00078 // cerr << "0x" << hex << (long)this << dec << " AVIFile::AVIFile() : RIFFFile(), ..." << endl; 00079 00080 for ( int i = 0; i < 2; ++i ) 00081 { 00082 indx[ i ] = new AVISuperIndex; 00083 memset( indx[ i ], 0, sizeof( AVISuperIndex ) ); 00084 ix[ i ] = new AVIStdIndex; 00085 memset( ix[ i ], 0, sizeof( AVIStdIndex ) ); 00086 indx_chunk[ i ] = -1; 00087 ix_chunk[ i ] = -1; 00088 strl_list[ i ] = -1; 00089 strh_chunk[ i ] = -1; 00090 strf_chunk[ i ] = -1; 00091 current_ix[ i ] = -1; 00092 } 00093 idx1 = new AVISimpleIndex; 00094 memset( idx1, 0, sizeof( AVISimpleIndex ) ); 00095 }
|
|
|
The copy constructor.
Definition at line 104 of file avi.cc. References avih_chunk, current_ix, dmlh, file_list, hdrl_list, idx1, idx1_chunk, index_type, indx, indx_chunk, isUpdateIdx1, ix, ix_chunk, junk_chunk, mainHdr, movi_list, riff_list, strf_chunk, strh_chunk, and strl_list. 00104 : RIFFFile( avi ) 00105 { 00106 // cerr << "0x" << hex << (long)this << dec << " 0x" << hex << (long)&avi << dec << " AVIFile::AVIFile(const AVIFile& avi) : RIFFFile(avi)" << endl; 00107 00108 mainHdr = avi.mainHdr; 00109 idx1 = new AVISimpleIndex; 00110 *idx1 = *avi.idx1; 00111 file_list = avi.file_list; 00112 riff_list = avi.riff_list; 00113 hdrl_list = avi.hdrl_list; 00114 avih_chunk = avi.avih_chunk; 00115 movi_list = avi.movi_list; 00116 junk_chunk = avi.junk_chunk; 00117 idx1_chunk = avi.idx1_chunk; 00118 00119 for ( int i = 0; i < 2; ++i ) 00120 { 00121 indx[ i ] = new AVISuperIndex; 00122 *indx[ i ] = *avi.indx[ i ]; 00123 ix[ i ] = new AVIStdIndex; 00124 *ix[ i ] = *avi.ix[ i ]; 00125 indx_chunk[ i ] = avi.indx_chunk[ i ]; 00126 ix_chunk[ i ] = avi.ix_chunk[ i ]; 00127 strl_list[ i ] = avi.strl_list[ i ]; 00128 strh_chunk[ i ] = avi.strh_chunk[ i ]; 00129 strf_chunk[ i ] = avi.strf_chunk[ i ]; 00130 current_ix[ i ] = avi.current_ix[ i ]; 00131 } 00132 00133 index_type = avi.index_type; 00134 00135 for ( int i = 0; i < 62; ++i ) 00136 dmlh[ i ] = avi.dmlh[ i ]; 00137 00138 isUpdateIdx1 = avi.isUpdateIdx1; 00139 00140 }
|
|
|
The destructor.
Definition at line 191 of file avi.cc. References idx1, indx, and ix. 00192 {
00193 for ( int i = 0; i < 2; ++i )
00194 {
00195 delete ix[ i ];
00196 delete indx[ i ];
00197 }
00198 delete idx1;
00199 }
|
|
|
Definition at line 884 of file avi.cc. References RIFFFile::AddDirectoryEntry(), FOURCC, RIFFFile::GetDirectoryEntry(), indx, ix, IX00_INDEX_SIZE, ix_chunk, KINO_AVI_INDEX_OF_CHUNKS, make_fourcc(), movi_list, RIFF_HEADERSIZE, and RIFFFile::WriteChunk(). Referenced by AVI2File::WriteFrame(), and AVI1File::WriteFrame(). 00885 {
00886 FOURCC type;
00887 FOURCC name;
00888 off_t length;
00889 off_t offset;
00890 int parent;
00891 int i;
00892
00893 /* Write out the previous index. When this function is
00894 entered for the first time, there is no index to
00895 write. Note: this may be an expensive operation
00896 because of a time consuming seek to the former file
00897 position. */
00898
00899 if ( ix_chunk[ stream ] != -1 )
00900 WriteChunk( ix_chunk[ stream ], ix[ stream ] );
00901
00902 /* make a new ix chunk. */
00903
00904 if ( stream == 0 )
00905 type = make_fourcc( "ix00" );
00906 else
00907 type = make_fourcc( "ix01" );
00908 ix_chunk[ stream ] = AddDirectoryEntry( type, 0, sizeof( AVIStdIndex ), movi_list );
00909 GetDirectoryEntry( ix_chunk[ stream ], type, name, length, offset, parent );
00910
00911 /* fill out all required fields. The offsets in the
00912 array are relative to qwBaseOffset, so fill in the
00913 offset to the next free location in the file
00914 there. */
00915
00916 ix[ stream ] ->wLongsPerEntry = 2;
00917 ix[ stream ] ->bIndexSubType = 0;
00918 ix[ stream ] ->bIndexType = KINO_AVI_INDEX_OF_CHUNKS;
00919 ix[ stream ] ->nEntriesInUse = 0;
00920 ix[ stream ] ->dwChunkId = indx[ stream ] ->dwChunkId;
00921 ix[ stream ] ->qwBaseOffset = offset + length;
00922 ix[ stream ] ->dwReserved = 0;
00923
00924 for ( i = 0; i < IX00_INDEX_SIZE; ++i )
00925 {
00926 ix[ stream ] ->aIndex[ i ].dwOffset = 0;
00927 ix[ stream ] ->aIndex[ i ].dwSize = 0;
00928 }
00929
00930 /* add a reference to this new index in our super
00931 index. */
00932
00933 i = indx[ stream ] ->nEntriesInUse++;
00934 indx[ stream ] ->aIndex[ i ].qwOffset = offset - RIFF_HEADERSIZE;
00935 indx[ stream ] ->aIndex[ i ].dwSize = length + RIFF_HEADERSIZE;
00936 indx[ stream ] ->aIndex[ i ].dwDuration = 0;
00937 }
|
|
||||||||||||
|
Read in a frame.
Definition at line 471 of file avi.cc. References Frame::data, fail_if, fail_neg, RIFFFile::fd, RIFFFile::file_mutex, and GetDVFrameInfo(). Referenced by AVIHandler::GetFrame(). 00472 {
00473 off_t offset;
00474 int size;
00475
00476 if ( GetDVFrameInfo( offset, size, frameNum ) != 0 || size < 0 )
00477 return -1;
00478 pthread_mutex_lock( &file_mutex );
00479 fail_if( lseek( fd, offset, SEEK_SET ) == ( off_t ) - 1 );
00480 fail_neg( read( fd, frame.data, size ) );
00481 pthread_mutex_unlock( &file_mutex );
00482
00483 return 0;
00484 }
|
|
||||||||||||||||
|
Find position and size of a given frame in the file. Depending on which index is available, search one of them to find position and frame size
Definition at line 310 of file avi.cc. References AVI_LARGE_INDEX, AVI_SMALL_INDEX, current_ix, fail_if, fail_neg, RIFFFile::fd, FOURCC, RIFFFile::GetDirectoryEntry(), idx1, index_type, indx, ix, make_fourcc(), movi_list, and RIFF_HEADERSIZE. Referenced by GetDVFrame(). 00311 {
00312 int result = -1;
00313
00314 if ( index_type & AVI_LARGE_INDEX )
00315 {
00316 int i;
00317
00318 /* find relevant index in indx0 */
00319 for ( i = 0; frameNum >= indx[ 0 ] ->aIndex[ i ].dwDuration; frameNum -= indx[ 0 ] ->aIndex[ i ].dwDuration, ++i );
00320
00321 if ( i != current_ix[ 0 ] )
00322 {
00323 fail_if( lseek( fd, indx[ 0 ] ->aIndex[ i ].qwOffset + RIFF_HEADERSIZE, SEEK_SET ) == ( off_t ) - 1 );
00324 fail_if( ( unsigned int )( indx[ 0 ] ->aIndex[ i ].dwSize - RIFF_HEADERSIZE ) > sizeof( AVIStdIndex ) );
00325 fail_neg( read( fd, ix[ 0 ], indx[ 0 ] ->aIndex[ i ].dwSize - RIFF_HEADERSIZE ) );
00326 current_ix[ 0 ] = i;
00327 }
00328
00329 if ( i < ix[ 0 ] ->nEntriesInUse )
00330 {
00331 offset = ix[ 0 ] ->qwBaseOffset + ix[ 0 ]->aIndex[ frameNum ].dwOffset;
00332 size = ix[ 0 ] ->aIndex[ frameNum ].dwSize;
00333 result = 0;
00334 }
00335 }
00336 else if ( index_type & AVI_SMALL_INDEX )
00337 {
00338 int index = -1;
00339 int frameNumIndex = 0;
00340 for ( int i = 0; i < idx1->nEntriesInUse; ++i )
00341 {
00342 FOURCC chunkID1 = make_fourcc( "00dc" );
00343 FOURCC chunkID2 = make_fourcc( "00db" );
00344 if ( idx1->aIndex[ i ].dwChunkId == chunkID1 ||
00345 idx1->aIndex[ i ].dwChunkId == chunkID2 )
00346 {
00347 if ( frameNumIndex == frameNum )
00348 {
00349 index = i;
00350 break;
00351 }
00352 ++frameNumIndex;
00353 }
00354 }
00355 if ( index != -1 )
00356 {
00357 // compatibility check for broken dvgrab dv2 format
00358 if ( idx1->aIndex[ 0 ].dwOffset > GetDirectoryEntry( movi_list ).offset )
00359 {
00360 offset = idx1->aIndex[ index ].dwOffset + RIFF_HEADERSIZE;
00361 }
00362 else
00363 {
00364 // new, correct dv2 format
00365 offset = idx1->aIndex[ index ].dwOffset + RIFF_HEADERSIZE + GetDirectoryEntry( movi_list ).offset;
00366 }
00367 size = idx1->aIndex[ index ].dwSize;
00368 result = 0;
00369 }
00370 }
00371 return result;
00372 }
|
|
||||||||||||||||
|
Read in a frame.
Definition at line 494 of file avi.cc. References fail_if, fail_neg, RIFFFile::fd, RIFFFile::file_mutex, and GetFrameInfo(). Referenced by AVIHandler::GetFrame(), and AVIHandler::SeekAudioFrame(). 00495 {
00496 off_t offset;
00497 int size;
00498
00499 if ( GetFrameInfo( offset, size, frameNum, chunkID ) != 0 )
00500 return 0;
00501 pthread_mutex_lock( &file_mutex );
00502 fail_if( lseek( fd, offset, SEEK_SET ) == ( off_t ) - 1 );
00503 fail_neg( read( fd, data, size ) );
00504 pthread_mutex_unlock( &file_mutex );
00505
00506 return size;
00507 }
|
|
||||||||||||||||||||
|
Find position and size of a given frame in the file. Depending on which index is available, search one of them to find position and frame size
Definition at line 388 of file avi.cc. References AVI_LARGE_INDEX, AVI_SMALL_INDEX, current_ix, fail_if, fail_neg, RIFFFile::fd, RIFFFile::GetDirectoryEntry(), idx1, index_type, indx, indx_chunk, ix, movi_list, and RIFF_HEADERSIZE. Referenced by getFrame(), and AVIHandler::SeekAudioFrame(). 00389 {
00390 int result = -1;
00391
00392 if ( index_type & AVI_LARGE_INDEX )
00393 {
00394 // Find the super index matches chunkID
00395 for ( int j = 0; j < 2; j++ )
00396 {
00397 if ( indx_chunk[ j ] != -1 && indx[ j ]->dwChunkId == chunkID )
00398 {
00399 int i = 0;
00400 int totalEntries = 0;
00401 int frameNumIndex = frameNum;
00402
00403 // Find the standard index
00404 for ( i = 0; i < indx[ j ]->nEntriesInUse; ++i )
00405 {
00406 if ( i != current_ix[ j ] )
00407 {
00408 fail_if( lseek( fd, indx[ j ] ->aIndex[ i ].qwOffset + RIFF_HEADERSIZE, SEEK_SET ) == ( off_t ) - 1 );
00409 fail_if( ( unsigned int )( indx[ j ] ->aIndex[ i ].dwSize - RIFF_HEADERSIZE ) > sizeof( AVIStdIndex ) );
00410 fail_neg( read( fd, ix[ j ], indx[ j ] ->aIndex[ i ].dwSize - RIFF_HEADERSIZE ) );
00411 current_ix[ j ] = i;
00412 }
00413 totalEntries += ix[ j ]->nEntriesInUse;
00414 if ( frameNum <= totalEntries )
00415 break;
00416 frameNumIndex -= ix[ j ]->nEntriesInUse;
00417 }
00418 if ( i < indx[ j ]->nEntriesInUse )
00419 {
00420 offset = ix[ j ] ->qwBaseOffset + ix[ j ] ->aIndex[ frameNumIndex ].dwOffset;
00421 size = ix[ j ] ->aIndex[ frameNumIndex ].dwSize;
00422 result = 0;
00423 }
00424 break;
00425 }
00426 }
00427 }
00428 else if ( index_type & AVI_SMALL_INDEX )
00429 {
00430 int index = -1;
00431 int frameNumIndex = 0;
00432 for ( int i = 0; i < idx1->nEntriesInUse; ++i )
00433 {
00434 if ( idx1->aIndex[ i ].dwChunkId == chunkID )
00435 {
00436 if ( frameNumIndex == frameNum )
00437 {
00438 index = i;
00439 break;
00440 }
00441 ++frameNumIndex;
00442 }
00443 }
00444 if ( index != -1 )
00445 {
00446 // compatibility check for broken dvgrab dv2 format
00447 if ( idx1->aIndex[ 0 ].dwOffset > GetDirectoryEntry( movi_list ).offset )
00448 {
00449 offset = idx1->aIndex[ index ].dwOffset + RIFF_HEADERSIZE;
00450 }
00451 else
00452 {
00453 // new, correct dv2 format
00454 offset = idx1->aIndex[ index ].dwOffset + RIFF_HEADERSIZE + GetDirectoryEntry( movi_list ).offset;
00455 }
00456 size = idx1->aIndex[ index ].dwSize;
00457 result = 0;
00458 }
00459 }
00460 return result;
00461 }
|
|
||||||||||||
|
Definition at line 1724 of file avi.cc. References fail_neg, RIFFFile::fd, RIFFFile::file_mutex, RIFFFile::FindDirectoryEntry(), FOURCC, make_fourcc(), and RIFFFile::ReadChunk(). Referenced by AVIHandler::GetFrame(). 01725 {
01726 int i, j = 0;
01727 FOURCC strh = make_fourcc( "strh" );
01728 FOURCC strf = make_fourcc( "strf" );
01729 AVIStreamHeader avi_stream_header;
01730 bool result = false;
01731
01732 while ( ( result == false ) && ( i = FindDirectoryEntry( strh, j++ ) ) != -1 )
01733 {
01734 ReadChunk( i, ( void* ) & avi_stream_header, sizeof( AVIStreamHeader ) );
01735 if ( avi_stream_header.fccType == type )
01736 {
01737 FOURCC chunkID;
01738 int size;
01739
01740 pthread_mutex_lock( &file_mutex );
01741 fail_neg( read( fd, &chunkID, sizeof( FOURCC ) ) );
01742 if ( chunkID == strf )
01743 {
01744 fail_neg( read( fd, &size, sizeof( int ) ) );
01745 fail_neg( read( fd, data, size ) );
01746 result = true;
01747 }
01748 pthread_mutex_unlock( &file_mutex );
01749 }
01750 }
01751 return result;
01752 }
|
|
|
Definition at line 509 of file avi.cc. References mainHdr. Referenced by AVIHandler::GetTotalFrames(). 00510 {
00511 return mainHdr.dwTotalFrames;
00512 }
|
|
||||||||||||||||
|
Initialize the AVI structure to its initial state, either for PAL or NTSC format. Initialize the AVIFile attributes: mainHdr, indx, ix00, idx1
Reimplemented in AVI1File, and AVI2File. Definition at line 212 of file avi.cc. References AVI_NTSC, AVI_PAL, AVI_SMALL_INDEX, AVIF_HASINDEX, AVIF_TRUSTCKTYPE, dmlh, idx1, index_type, indx, KINO_AVI_INDEX_OF_INDEXES, mainHdr, and PADDING_SIZE. Referenced by AVIHandler::Create(), AVI2File::Init(), and AVI1File::Init(). 00213 {
00214 int i, j;
00215
00216 assert( ( format == AVI_PAL ) || ( format == AVI_NTSC ) );
00217
00218 index_type = indexType;
00219
00220 switch ( format )
00221 {
00222 case AVI_PAL:
00223 mainHdr.dwMicroSecPerFrame = 40000;
00224 mainHdr.dwSuggestedBufferSize = 144008;
00225 break;
00226
00227 case AVI_NTSC:
00228 mainHdr.dwMicroSecPerFrame = 33366;
00229 mainHdr.dwSuggestedBufferSize = 120008;
00230 break;
00231
00232 default: /* no default allowed */
00233 assert( 0 );
00234 break;
00235 }
00236
00237 /* Initialize the 'avih' chunk */
00238
00239 mainHdr.dwMaxBytesPerSec = 3600000 + sampleFrequency * 4;
00240 mainHdr.dwPaddingGranularity = PADDING_SIZE;
00241 mainHdr.dwFlags = AVIF_TRUSTCKTYPE;
00242 if ( indexType & AVI_SMALL_INDEX )
00243 mainHdr.dwFlags |= AVIF_HASINDEX;
00244 mainHdr.dwTotalFrames = 0;
00245 mainHdr.dwInitialFrames = 0;
00246 mainHdr.dwStreams = 1;
00247 mainHdr.dwWidth = 0;
00248 mainHdr.dwHeight = 0;
00249 mainHdr.dwReserved[ 0 ] = 0;
00250 mainHdr.dwReserved[ 1 ] = 0;
00251 mainHdr.dwReserved[ 2 ] = 0;
00252 mainHdr.dwReserved[ 3 ] = 0;
00253
00254 /* Initialize the 'idx1' chunk */
00255
00256 for ( int i = 0; i < 8000; ++i )
00257 {
00258 idx1->aIndex[ i ].dwChunkId = 0;
00259 idx1->aIndex[ i ].dwFlags = 0;
00260 idx1->aIndex[ i ].dwOffset = 0;
00261 idx1->aIndex[ i ].dwSize = 0;
00262 }
00263 idx1->nEntriesInUse = 0;
00264
00265 /* Initialize the 'indx' chunk */
00266
00267 for ( i = 0; i < 2; ++i )
00268 {
00269 indx[ i ] ->wLongsPerEntry = 4;
00270 indx[ i ] ->bIndexSubType = 0;
00271 indx[ i ] ->bIndexType = KINO_AVI_INDEX_OF_INDEXES;
00272 indx[ i ] ->nEntriesInUse = 0;
00273 indx[ i ] ->dwReserved[ 0 ] = 0;
00274 indx[ i ] ->dwReserved[ 1 ] = 0;
00275 indx[ i ] ->dwReserved[ 2 ] = 0;
00276 for ( j = 0; j < 2014; ++j )
00277 {
00278 indx[ i ] ->aIndex[ j ].qwOffset = 0;
00279 indx[ i ] ->aIndex[ j ].dwSize = 0;
00280 indx[ i ] ->aIndex[ j ].dwDuration = 0;
00281 }
00282 }
00283
00284 /* The ix00 and ix01 chunk will be added dynamically in avi_write_frame
00285 as needed */
00286
00287 /* Initialize the 'dmlh' chunk. I have no clue what this means
00288 though */
00289
00290 for ( i = 0; i < 62; ++i )
00291 dmlh[ i ] = 0;
00292 //dmlh[0] = -1; /* frame count + 1? */
00293
00294 }
|
|
|
Determine if the audio and video frames have a 1:1 interleave factor.
Definition at line 517 of file avi.cc. References FOURCC, idx1, and make_fourcc(). Referenced by AVIHandler::Open(). 00518 {
00519 bool result = true;
00520 FOURCC dvChunkID1 = make_fourcc( "00dc" );
00521 FOURCC dvChunkID2 = make_fourcc( "00db" );
00522 FOURCC wavChunkID = make_fourcc( "01wb" );
00523
00524 // Scan the index, skipping first entry, which might be bogus (7Fxx).
00525 for ( int i = 2; i < ( idx1->nEntriesInUse - 1 ); ++i )
00526 {
00527 // Look for DV data
00528 if ( ( idx1->aIndex[ i ].dwChunkId == dvChunkID1 ||
00529 idx1->aIndex[ i ].dwChunkId == dvChunkID2 ) )
00530 {
00531 // Determine if WAV data is both prior and following index entries
00532 if ( idx1->aIndex[ i-1 ].dwChunkId != wavChunkID || idx1->aIndex[ i+1 ].dwChunkId != wavChunkID)
00533 {
00534 result = false;
00535 break;
00536 }
00537 }
00538 }
00539 return result;
00540 }
|
|
|
Definition at line 1027 of file avi.cc. References dmlh, RIFFFile::FindDirectoryEntry(), FOURCC, and make_fourcc(). Referenced by AVIHandler::Open(). 01028 {
01029 int i, j = 0;
01030 FOURCC dmlh = make_fourcc( "dmlh" );
01031
01032 while ( ( i = FindDirectoryEntry( dmlh, j++ ) ) != -1 )
01033 {
01034 return true;
01035 }
01036 return false;
01037 }
|
|
|
The assignment operator.
Definition at line 147 of file avi.cc. References avih_chunk, current_ix, dmlh, file_list, hdrl_list, idx1, idx1_chunk, index_type, indx, indx_chunk, isUpdateIdx1, ix, ix_chunk, junk_chunk, mainHdr, movi_list, RIFFFile::operator=(), riff_list, strf_chunk, strh_chunk, and strl_list. 00148 {
00149 // cerr << "0x" << hex << (long)this << dec << " 0x" << hex << (long)&avi << dec << " AVIFile& AVIFile::operator=(const AVIFile& avi)" << endl;
00150
00151 if ( this != &avi )
00152 {
00153 RIFFFile::operator=( avi );
00154 mainHdr = avi.mainHdr;
00155 *idx1 = *avi.idx1;
00156 file_list = avi.file_list;
00157 riff_list = avi.riff_list;
00158 hdrl_list = avi.hdrl_list;
00159 avih_chunk = avi.avih_chunk;
00160 movi_list = avi.movi_list;
00161 junk_chunk = avi.junk_chunk;
00162 idx1_chunk = avi.idx1_chunk;
00163
00164 for ( int i = 0; i < 2; ++i )
00165 {
00166 *indx[ i ] = *avi.indx[ i ];
00167 *ix[ i ] = *avi.ix[ i ];
00168 indx_chunk[ i ] = avi.indx_chunk[ i ];
00169 ix_chunk[ i ] = avi.ix_chunk[ i ];
00170 strl_list[ i ] = avi.strl_list[ i ];
00171 strh_chunk[ i ] = avi.strh_chunk[ i ];
00172 strf_chunk[ i ] = avi.strf_chunk[ i ];
00173 current_ix[ i ] = avi.current_ix[ i ];
00174 }
00175
00176 index_type = avi.index_type;
00177
00178 for ( int i = 0; i < 62; ++i )
00179 dmlh[ i ] = avi.dmlh[ i ];
00180
00181 isUpdateIdx1 = avi.isUpdateIdx1;
00182 }
00183 return *this;
00184 }
|
|
|
If this is not a movi list, read its contents.
Reimplemented from RIFFFile. Definition at line 775 of file avi.cc. References RIFFFile::AddDirectoryEntry(), DWORD, fail_if, fail_neg, RIFFFile::fd, FOURCC, make_fourcc(), movi_list, and RIFFFile::ParseChunk(). 00776 {
00777 FOURCC type;
00778 FOURCC name;
00779 DWORD length;
00780 int list;
00781 off_t pos;
00782 off_t listEnd;
00783
00784 /* Read in the chunk header (type and length). */
00785 fail_neg( read( fd, &type, sizeof( type ) ) );
00786 fail_neg( read( fd, &length, sizeof( length ) ) );
00787 if ( length & 1 )
00788 length++;
00789
00790 /* The contents of the list starts here. Obtain its offset. The list
00791 name (4 bytes) is already part of the contents). */
00792
00793 pos = lseek( fd, 0, SEEK_CUR );
00794 fail_if( pos == ( off_t ) - 1 );
00795 fail_neg( read( fd, &name, sizeof( name ) ) );
00796
00797 /* if we encounter a movi list, do not read it. It takes too much time
00798 and we don't need it anyway. */
00799
00800 if ( name != make_fourcc( "movi" ) )
00801 {
00802 // if (1) {
00803
00804 /* Add an entry for this list. */
00805 list = AddDirectoryEntry( type, name, sizeof( name ), parent );
00806
00807 /* Read in any chunks contained in this list. This list is the
00808 parent for all chunks it contains. */
00809
00810 listEnd = pos + length;
00811 while ( pos < listEnd )
00812 {
00813 ParseChunk( list );
00814 pos = lseek( fd, 0, SEEK_CUR );
00815 fail_if( pos == ( off_t ) - 1 );
00816 }
00817 }
00818 else
00819 {
00820 /* Add an entry for this list. */
00821
00822 movi_list = AddDirectoryEntry( type, name, length, parent );
00823
00824 pos = lseek( fd, length - 4, SEEK_CUR );
00825 fail_if( pos == ( off_t ) - 1 );
00826 }
00827 }
|
|
|
Reads the directory structure of the whole RIFF file.
Reimplemented from RIFFFile. Definition at line 830 of file avi.cc. References avih_chunk, RIFFFile::FindDirectoryEntry(), mainHdr, make_fourcc(), RIFFFile::ParseRIFF(), and RIFFFile::ReadChunk(). Referenced by AVIHandler::Open(). 00831 {
00832 RIFFFile::ParseRIFF();
00833
00834 avih_chunk = FindDirectoryEntry( make_fourcc( "avih" ) );
00835 if ( avih_chunk != -1 )
00836 ReadChunk( avih_chunk, ( void* ) & mainHdr, sizeof( MainAVIHeader ) );
00837 }
|
|
|
prints out a directory entry in text form Every subclass of RIFFFile is supposed to override this function and to implement it for the entry types it knows about. For all other entry types it should call its parent::PrintDirectoryData.
Reimplemented from RIFFFile. Definition at line 552 of file avi.cc. References dmlh, DWORD, fail_if, fail_neg, RIFFFile::fd, FOURCC, idx1, and make_fourcc(). 00553 {
00554 static FOURCC lastStreamType = make_fourcc( " " );
00555
00556 if ( entry.type == make_fourcc( "avih" ) )
00557 {
00558
00559 int i;
00560 MainAVIHeader main_avi_header;
00561
00562 fail_if( lseek( fd, entry.offset, SEEK_SET ) == ( off_t ) - 1 );
00563 fail_neg( read( fd, &main_avi_header, sizeof( MainAVIHeader ) ) );
00564
00565 cout << " dwMicroSecPerFrame: " << ( int ) main_avi_header.dwMicroSecPerFrame << endl
00566 << " dwMaxBytesPerSec: " << ( int ) main_avi_header.dwMaxBytesPerSec << endl
00567 << " dwPaddingGranularity: " << ( int ) main_avi_header.dwPaddingGranularity << endl
00568 << " dwFlags: " << ( int ) main_avi_header.dwFlags << endl
00569 << " dwTotalFrames: " << ( int ) main_avi_header.dwTotalFrames << endl
00570 << " dwInitialFrames: " << ( int ) main_avi_header.dwInitialFrames << endl
00571 << " dwStreams: " << ( int ) main_avi_header.dwStreams << endl
00572 << " dwSuggestedBufferSize: " << ( int ) main_avi_header.dwSuggestedBufferSize << endl
00573 << " dwWidth: " << ( int ) main_avi_header.dwWidth << endl
00574 << " dwHeight: " << ( int ) main_avi_header.dwHeight << endl;
00575 for ( i = 0; i < 4; ++i )
00576 cout << " dwReserved[" << i << "]: " << ( int ) main_avi_header.dwReserved[ i ] << endl;
00577
00578 }
00579 else if ( entry.type == make_fourcc( "strh" ) )
00580 {
00581
00582 AVIStreamHeader avi_stream_header;
00583
00584 fail_if( lseek( fd, entry.offset, SEEK_SET ) == ( off_t ) - 1 );
00585 fail_neg( read( fd, &avi_stream_header, sizeof( AVIStreamHeader ) ) );
00586
00587 lastStreamType = avi_stream_header.fccType;
00588
00589 cout << " fccType: '"
00590 << ((char *)&avi_stream_header.fccType)[0]
00591 << ((char *)&avi_stream_header.fccType)[1]
00592 << ((char *)&avi_stream_header.fccType)[2]
00593 << ((char *)&avi_stream_header.fccType)[3]
00594 << '\'' << endl
00595 << " fccHandler: '"
00596 << ((char *)&avi_stream_header.fccHandler)[0]
00597 << ((char *)&avi_stream_header.fccHandler)[1]
00598 << ((char *)&avi_stream_header.fccHandler)[2]
00599 << ((char *)&avi_stream_header.fccHandler)[3]
00600 << '\'' << endl
00601 << " dwFlags: " << ( int ) avi_stream_header.dwFlags << endl
00602 << " wPriority: " << ( int ) avi_stream_header.wPriority << endl
00603 << " wLanguage: " << ( int ) avi_stream_header.wLanguage << endl
00604 << " dwInitialFrames: " << ( int ) avi_stream_header.dwInitialFrames << endl
00605 << " dwScale: " << ( int ) avi_stream_header.dwScale << endl
00606 << " dwRate: " << ( int ) avi_stream_header.dwRate << endl
00607 << " dwLength: " << ( int ) avi_stream_header.dwLength << endl
00608 << " dwQuality: " << ( int ) avi_stream_header.dwQuality << endl
00609 << " dwSampleSize: " << ( int ) avi_stream_header.dwSampleSize << endl;
00610
00611 }
00612 else if ( entry.type == make_fourcc( "indx" ) )
00613 {
00614
00615 int i;
00616 AVISuperIndex avi_super_index;
00617
00618 fail_if( lseek( fd, entry.offset, SEEK_SET ) == ( off_t ) - 1 );
00619 fail_neg( read( fd, &avi_super_index, sizeof( AVISuperIndex ) ) );
00620
00621 cout << " wLongsPerEntry: " << ( int ) avi_super_index.wLongsPerEntry
00622 << endl
00623 << " bIndexSubType: " << ( int ) avi_super_index.bIndexSubType << endl
00624 << " bIndexType: " << ( int ) avi_super_index.bIndexType << endl
00625 << " nEntriesInUse: " << ( int ) avi_super_index.nEntriesInUse << endl
00626 << " dwChunkId: '"
00627 << ((char *)&avi_super_index.dwChunkId)[0]
00628 << ((char *)&avi_super_index.dwChunkId)[1]
00629 << ((char *)&avi_super_index.dwChunkId)[2]
00630 << ((char *)&avi_super_index.dwChunkId)[3]
00631 << '\'' << endl
00632 << " dwReserved[0]: " << ( int ) avi_super_index.dwReserved[ 0 ] << endl
00633 << " dwReserved[1]: " << ( int ) avi_super_index.dwReserved[ 1 ] << endl
00634 << " dwReserved[2]: " << ( int ) avi_super_index.dwReserved[ 2 ] << endl;
00635 for ( i = 0; i < avi_super_index.nEntriesInUse; ++i )
00636 {
00637 cout << ' ' << setw( 4 ) << setfill( ' ' ) << i
00638 << ": qwOffset : 0x" << setw( 12 ) << setfill( '0' ) << hex << avi_super_index.aIndex[ i ].qwOffset << endl
00639 << " dwSize : 0x" << setw( 8 ) << avi_super_index.aIndex[ i ].dwSize << endl
00640 << " dwDuration : " << dec << avi_super_index.aIndex[ i ].dwDuration << endl;
00641 }
00642 }
00643 else if ( entry.type == make_fourcc( "strf" ) )
00644 {
00645 if ( lastStreamType == make_fourcc( "auds" ) )
00646 {
00647 WAVEFORMATEX waveformatex;
00648 fail_if( lseek( fd, entry.offset, SEEK_SET ) == ( off_t ) - 1 );
00649 fail_neg( read( fd, &waveformatex, sizeof( WAVEFORMATEX ) ) );
00650 cout << " waveformatex.wFormatTag : " << waveformatex.wFormatTag << endl;
00651 cout << " waveformatex.nChannels : " << waveformatex.nChannels << endl;
00652 cout << " waveformatex.nSamplesPerSec : " << waveformatex.nSamplesPerSec << endl;
00653 cout << " waveformatex.nAvgBytesPerSec: " << waveformatex.nAvgBytesPerSec << endl;
00654 cout << " waveformatex.nBlockAlign : " << waveformatex.nBlockAlign << endl;
00655 cout << " waveformatex.wBitsPerSample : " << waveformatex.wBitsPerSample << endl;
00656 cout << " waveformatex.cbSize : " << waveformatex.cbSize << endl;
00657 }
00658 else if ( lastStreamType == make_fourcc( "vids" ) )
00659 {
00660 BITMAPINFOHEADER bitmapinfo;
00661 fail_if( lseek( fd, entry.offset, SEEK_SET ) == ( off_t ) - 1 );
00662 fail_neg( read( fd, &bitmapinfo, sizeof( BITMAPINFOHEADER ) ) );
00663 cout << " bitmapinfo.biSize : " << bitmapinfo.biSize << endl;
00664 cout << " bitmapinfo.biWidth : " << bitmapinfo.biWidth << endl;
00665 cout << " bitmapinfo.biHeight : " << bitmapinfo.biHeight << endl;
00666 cout << " bitmapinfo.biPlanes : " << bitmapinfo.biPlanes << endl;
00667 cout << " bitmapinfo.biBitCount : " << bitmapinfo.biBitCount << endl;
00668 cout << " bitmapinfo.biCompression : " << bitmapinfo.biCompression << endl;
00669 cout << " bitmapinfo.biSizeImage : " << bitmapinfo.biSizeImage << endl;
00670 cout << " bitmapinfo.biXPelsPerMeter: " << bitmapinfo.biXPelsPerMeter << endl;
00671 cout << " bitmapinfo.biYPelsPerMeter: " << bitmapinfo.biYPelsPerMeter << endl;
00672 cout << " bitmapinfo.biClrUsed : " << bitmapinfo.biClrUsed << endl;
00673 cout << " bitmapinfo.biClrImportant : " << bitmapinfo.biClrImportant << endl;
00674 }
00675 else if ( lastStreamType == make_fourcc( "iavs" ) )
00676 {
00677 DVINFO dvinfo;
00678 fail_if( lseek( fd, entry.offset, SEEK_SET ) == ( off_t ) - 1 );
00679 fail_neg( read( fd, &dvinfo, sizeof( DVINFO ) ) );
00680 cout << " dvinfo.dwDVAAuxSrc : 0x" << setw( 8 ) << setfill( '0' ) << hex << dvinfo.dwDVAAuxSrc << endl;
00681 cout << " dvinfo.dwDVAAuxCtl : 0x" << setw( 8 ) << setfill( '0' ) << hex << dvinfo.dwDVAAuxCtl << endl;
00682 cout << " dvinfo.dwDVAAuxSrc1: 0x" << setw( 8 ) << setfill( '0' ) << hex << dvinfo.dwDVAAuxSrc1 << endl;
00683 cout << " dvinfo.dwDVAAuxCtl1: 0x" << setw( 8 ) << setfill( '0' ) << hex << dvinfo.dwDVAAuxCtl1 << endl;
00684 cout << " dvinfo.dwDVVAuxSrc : 0x" << setw( 8 ) << setfill( '0' ) << hex << dvinfo.dwDVVAuxSrc << endl;
00685 cout << " dvinfo.dwDVVAuxCtl : 0x" << setw( 8 ) << setfill( '0' ) << hex << dvinfo.dwDVVAuxCtl << endl;
00686 }
00687 }
00688
00689 /* This is the Standard Index. It is an array of offsets and
00690 sizes relative to some start offset. */
00691
00692 else if ( ( entry.type == make_fourcc( "ix00" ) ) || ( entry.type == make_fourcc( "ix01" ) ) )
00693 {
00694
00695 int i;
00696 AVIStdIndex avi_std_index;
00697
00698 fail_if( lseek( fd, entry.offset, SEEK_SET ) == ( off_t ) - 1 );
00699 fail_neg( read( fd, &avi_std_index, sizeof( AVIStdIndex ) ) );
00700
00701 cout << " wLongsPerEntry: " << ( int ) avi_std_index.wLongsPerEntry
00702 << endl
00703 << " bIndexSubType: " << ( int ) avi_std_index.bIndexSubType << endl
00704 << " bIndexType: " << ( int ) avi_std_index.bIndexType << endl
00705 << " nEntriesInUse: " << ( int ) avi_std_index.nEntriesInUse << endl
00706 << " dwChunkId: '"
00707 << ((char *)&avi_std_index.dwChunkId)[0]
00708 << ((char *)&avi_std_index.dwChunkId)[1]
00709 << ((char *)&avi_std_index.dwChunkId)[2]
00710 << ((char *)&avi_std_index.dwChunkId)[3]
00711 << '\'' << endl
00712 << " qwBaseOffset: 0x" << setw( 12 ) << hex << avi_std_index.qwBaseOffset << endl
00713 << " dwReserved: " << dec << ( int ) avi_std_index.dwReserved << endl;
00714 for ( i = 0; i < avi_std_index.nEntriesInUse; ++i )
00715 {
00716 cout << ' ' << setw( 4 ) << setfill( ' ' ) << i
00717 << ": dwOffset : 0x" << setw( 8 ) << setfill( '0' ) << hex << avi_std_index.aIndex[ i ].dwOffset
00718 << " (0x" << setw( 12 ) << avi_std_index.qwBaseOffset + avi_std_index.aIndex[ i ].dwOffset << ')' << endl
00719 << " dwSize : 0x" << setw( 8 ) << avi_std_index.aIndex[ i ].dwSize << dec << endl;
00720 }
00721
00722 }
00723 else if ( entry.type == make_fourcc( "idx1" ) )
00724 {
00725
00726 int i;
00727 int numEntries = entry.length / sizeof( int ) / 4;
00728 DWORD *idx1 = new DWORD[ numEntries * 4 ];
00729 // FOURCC movi_list = FindDirectoryEntry(make_fourcc("movi"));
00730
00731 fail_if( lseek( fd, entry.offset, SEEK_SET ) == ( off_t ) - 1 );
00732 fail_neg( read( fd, idx1, entry.length ) );
00733
00734 for ( i = 0; i < numEntries; ++i )
00735 {
00736
00737 cout << ' ' << setw( 4 ) << setfill( ' ' ) << i << setfill( '0' ) << ": dwChunkId : '"
00738 << ((char *)&idx1[ i * 4 + 0 ])[0]
00739 << ((char *)&idx1[ i * 4 + 0 ])[1]
00740 << ((char *)&idx1[ i * 4 + 0 ])[2]
00741 << ((char *)&idx1[ i * 4 + 0 ])[3]
00742 << '\'' << endl
00743 << " dwType : 0x" << setw( 8 ) << hex << idx1[ i * 4 + 1 ] << endl
00744 << " dwOffset : 0x" << setw( 8 ) << idx1[ i * 4 + 2 ] << endl
00745 // << " (0x" << setw(8) << idx1[i * 4 + 2] + GetDirectoryEntry(movi_list).offset << ')' << endl
00746 << " dwSize : 0x" << setw( 8 ) << idx1[ i * 4 + 3 ] << dec << endl;
00747 }
00748
00749 delete[] idx1;
00750 }
00751 else if ( entry.type == make_fourcc( "dmlh" ) )
00752 {
00753 int i;
00754 int numEntries = entry.length / sizeof( int );
00755 DWORD *dmlh = new DWORD[ numEntries ];
00756
00757 fail_if( lseek( fd, entry.offset, SEEK_SET ) == ( off_t ) - 1 );
00758 fail_neg( read( fd, dmlh, entry.length ) );
00759
00760 for ( i = 0; i < numEntries; ++i )
00761 {
00762 cout << ' ' << setw( 4 ) << setfill( ' ' ) << i << setfill( '0' ) << ": "
00763 << " dwTotalFrames: 0x" << setw( 8 ) << hex << dmlh[ i ]
00764 << " (" << dec << dmlh[ i ] << ")" << endl;
00765 }
00766 delete[] dmlh;
00767 }
00768 }
|
|
|
Definition at line 840 of file avi.cc. References AVI_LARGE_INDEX, AVI_SMALL_INDEX, RIFFFile::FindDirectoryEntry(), FOURCC, RIFFFile::GetDirectoryEntry(), idx1, idx1_chunk, index_type, indx, indx_chunk, mainHdr, make_fourcc(), and RIFFFile::ReadChunk(). Referenced by AVIHandler::Open(). 00841 {
00842 mainHdr.dwTotalFrames = 0;
00843 for ( int j = 0; j < 2; j++ )
00844 {
00845 indx_chunk[ j ] = FindDirectoryEntry( make_fourcc( "indx" ), j );
00846 if ( indx_chunk[ j ] != -1 )
00847 {
00848 ReadChunk( indx_chunk[ j ], ( void* ) indx[ j ], sizeof( AVISuperIndex ) );
00849 index_type |= AVI_LARGE_INDEX;
00850
00851 /* recalc number of frames from each index */
00852 if ( j == 0 )
00853 {
00854 for ( int i = 0; i < indx[ j ] ->nEntriesInUse;
00855 mainHdr.dwTotalFrames += indx[ j ] ->aIndex[ i++ ].dwDuration );
00856 }
00857 }
00858 }
00859 idx1_chunk = FindDirectoryEntry( make_fourcc( "idx1" ) );
00860 if ( idx1_chunk != -1 )
00861 {
00862 ReadChunk( idx1_chunk, ( void* ) idx1, sizeof( AVISimpleIndex ) );
00863 idx1->nEntriesInUse = GetDirectoryEntry( idx1_chunk ).length / 16;
00864 index_type |= AVI_SMALL_INDEX;
00865 if ( mainHdr.dwTotalFrames == 0 )
00866 {
00867 /* recalc number of frames from the simple index */
00868 FOURCC chunkID1 = make_fourcc( "00dc" );
00869 FOURCC chunkID2 = make_fourcc( "00db" );
00870
00871 for ( int i = 0; i < idx1->nEntriesInUse; ++i )
00872 {
00873 if ( idx1->aIndex[ i ].dwChunkId == chunkID1 ||
00874 idx1->aIndex[ i ].dwChunkId == chunkID2 )
00875 {
00876 ++mainHdr.dwTotalFrames;
00877 }
00878 }
00879 }
00880 }
00881 }
|
|
|
Reimplemented in AVI1File, and AVI2File. Definition at line 246 of file avi.h. Referenced by AVIHandler::Create(). 00247 { }
|
|
||||||||||||
|
Definition at line 1703 of file avi.cc. References RIFFFile::FindDirectoryEntry(), FOURCC, mainHdr, make_fourcc(), RIFFFile::ReadChunk(), and streamHdr. Referenced by AVIHandler::Create(). 01704 {
01705 for ( int i = 0; i < mainHdr.dwStreams; i++ )
01706 {
01707 if ( streamHdr[ i ].fccType == type )
01708 {
01709 int k, j = 0;
01710 FOURCC strf = make_fourcc( "strf" );
01711 BITMAPINFOHEADER bih;
01712
01713 streamHdr[ i ].fccHandler = handler;
01714
01715 while ( ( k = FindDirectoryEntry( strf, j++ ) ) != -1 )
01716 {
01717 ReadChunk( k, ( void* ) & bih, sizeof( BITMAPINFOHEADER ) );
01718 bih.biCompression = handler;
01719 }
01720 }
01721 }
01722 }
|
|
||||||||||||
|
Definition at line 967 of file avi.cc. References FOURCC, RIFFFile::GetDirectoryEntry(), idx1, IDX1_INDEX_SIZE, movi_list, and RIFF_HEADERSIZE. Referenced by AVI2File::WriteFrame(), and AVI1File::WriteFrame(). 00968 {
00969 if ( idx1->nEntriesInUse < IDX1_INDEX_SIZE )
00970 {
00971 FOURCC type;
00972 FOURCC name;
00973 off_t length;
00974 off_t offset;
00975 int parent;
00976
00977 GetDirectoryEntry( chunk, type, name, length, of |