Changeset 261

Show
Ignore:
Timestamp:
01/06/07 22:12:17 (2 years ago)
Author:
dconrad
Message:

Use the first AC3 packet to determine audio parameters in MKV as well.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/MatroskaImport.h

    r242 r261  
    7373        QTSampleDescriptionID   qtSampleDesc; 
    7474        SInt64                                  timecodeScale; 
     75        bool                                    seenFirstFrame; 
    7576         
    7677private: 
  • trunk/MatroskaImportPrivate.cpp

    r245 r261  
    4545#include "CommonUtils.h" 
    4646#include "Codecprintf.h" 
     47#include "bitstream_info.h" 
    4748 
    4849using namespace std; 
     
    559560        qtSampleDesc = 0; 
    560561        timecodeScale = 1000000; 
     562        seenFirstFrame = false; 
    561563} 
    562564 
     
    580582        qtSampleDesc = copy.qtSampleDesc; 
    581583        timecodeScale = copy.timecodeScale; 
     584        seenFirstFrame = copy.seenFirstFrame; 
    582585         
    583586        for (int i = 0; i < copy.lastFrames.size(); i++) 
     
    598601        KaxBlock & block = GetChild<KaxBlock>(blockGroup); 
    599602        KaxBlockDuration & blockDuration = GetChild<KaxBlockDuration>(blockGroup); 
     603         
     604        if (!seenFirstFrame) { 
     605                // we want to parse the first ac3 frame so that we can get a more correct channel layout 
     606                if ((*desc)->dataFormat == kAudioFormatAC3) { 
     607                        AudioStreamBasicDescription asbd = {0}; 
     608                        AudioChannelLayout acl = {0}; 
     609                         
     610                        if (parse_ac3_bitstream(&asbd, &acl, block.GetBuffer(0).Buffer(), block.GetFrameSize(0))) { 
     611                                // successful in parsing, so the acl and asbd are more correct than what we generated in  
     612                                // AddAudioTrack() so replace our sound description 
     613                                SoundDescriptionHandle sndDesc = NULL; 
     614                                asbd.mFormatID = kAudioFormatAC3; 
     615                                 
     616                                OSStatus err = QTSoundDescriptionCreate(&asbd, &acl, sizeof(AudioChannelLayout), NULL, 0,  
     617                                                                                                                kQTSoundDescriptionKind_Movie_AnyVersion, &sndDesc); 
     618                                if (err == noErr) { 
     619                                        DisposeHandle((Handle) desc); 
     620                                        desc = (SampleDescriptionHandle) sndDesc; 
     621                                } 
     622                        } 
     623                } 
     624                seenFirstFrame = true; 
     625        } 
    600626         
    601627        for (int i = 0; i < lastFrames.size(); i++) { 
  • trunk/bitstream_info.h

    r256 r261  
    1111#include <QuickTime/QuickTime.h> 
    1212 
     13#ifdef __cplusplus 
     14extern "C" { 
     15#endif 
     16 
    1317int parse_ac3_bitstream(AudioStreamBasicDescription *asbd, AudioChannelLayout *acl, uint8_t *buffer, int buff_size); 
     18 
     19#ifdef __cplusplus 
     20} 
     21#endif