Changeset 30

Show
Ignore:
Timestamp:
10/16/06 00:21:58 (2 years ago)
Author:
gbooker
Message:
  • Switched importer to use 64-bit functions (Haven't run into this yet, but supposedly something in 10.5 will require this or something and it doesn't hurt).
  • Added a sanity check to make sure the frame is complete at the end of the file. This fixes QT's error about the file could not be saved when messing with Self-contained files.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/AC3MovieImport/AC3MovieImport.c

    r14 r30  
    251251{ 
    252252#pragma unused(globals) 
    253        
     253#define SEARCH_SIZE 2048       
    254254        OSErr err = noErr; 
    255255        DataHandler dataHandler = 0; 
    256         unsigned char header[107]; 
     256        unsigned char header[SEARCH_SIZE+7]; 
    257257         
    258258        *valid = 0; 
     
    276276        int bit_rate; 
    277277        int i; 
    278         for(i=0;i<100;i++) 
     278        for(i=0;i<SEARCH_SIZE;i++) 
    279279        { 
    280280                int frame_size = a52_syncinfo(header+i, &flags, &sample_rate, &bit_rate); 
     
    346346        ComponentInstance dataHandler = 0; 
    347347        unsigned char header[7]; 
    348         long fileOffset = 0, fileSize; 
     348        UInt64 fileOffset = 0, fileSize; 
    349349         
    350350        *outFlags = 0; 
     
    374374// Get the size, in bytes, of the current data reference, this is 
    375375// functionally equivalent to the File Manager's GetEOF function. 
    376         err = DataHGetFileSize(dataHandler, &fileSize); 
     376        wide fileSizeInWide; 
     377        err = DataHGetFileSize64(dataHandler, &fileSizeInWide); 
     378        fileSize = WideToSInt64(fileSizeInWide); 
    377379        if (err) goto bail; 
    378380         
     
    485487        // than one sample--all the samples described by a reference must be the same size. This function does not update the movie data 
    486488        // as part of the add operation therefore you do not have to call BeginMediaEdits before calling AddMediaSampleReference. 
    487                 err = AddMediaSampleReference(audioMedia,               // Specifies the media for this operation 
    488                                                                           fileOffset,           // Specifies the offset into the data file 
    489                                                                           frame_size,           // Specifies the number of bytes of sample data to be identified by the reference 
    490                                                                           6 * 256,      // Specifies the duration of each sample in the reference 
    491                                                                           (SampleDescriptionHandle)globals->audioDesc,   // Handle to a sample description 
    492                                                                           1,                            // Specifies the number of samples contained in the reference 
    493                                                                           0,                            // Contains flags that control the operation     
    494                                                                           NULL);                        // Returns the time where the reference was inserted, NULL to ignore 
     489                SampleReference64Record sampleRec; 
     490                sampleRec.dataOffset = SInt64ToWide(fileOffset); 
     491                sampleRec.dataSize = frame_size; 
     492                sampleRec.durationPerSample = 6 * 256; 
     493                sampleRec.numberOfSamples = 1; 
     494                TimeValue mediaTime; 
     495 
     496                // Increment to the next frame 
     497                fileOffset += frame_size; 
     498                if(fileOffset > fileSize) 
     499                        break;  //frame is incomplete, drop it. 
     500                err = AddMediaSampleReferences64(audioMedia,                                                                            // Specifies the media for this operation 
     501                                                                                 (SampleDescriptionHandle)globals->audioDesc,           // The sampleRecord to add 
     502                                                                                 1,                                                                                                     // 1 sample to add 
     503                                                                                 &sampleRec,                                                                            // the sample to add 
     504                                                                                 &mediaTime);                                                                           // The time of the sample 
    495505                if (err) goto bail; 
    496506                 
    497         // Increment to the next frame 
    498                 fileOffset += frame_size; 
    499507        } 
    500508