Changeset 1043

Show
Ignore:
Timestamp:
04/20/09 21:32:46 (11 months ago)
Author:
astrange
Message:

Fix the last fix.
- typo (&cookie instead of cookie) annoyed CoreAudio?
- FormatInfo? should have been requested after setting channels and sample rate

Files:

Legend:

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

    r1042 r1043  
    235235        cookie = create_cookie(codec, &cookieSize, asbd.mFormatID, map->vbr); 
    236236         
    237         /* ask the toolbox about more information */ 
    238         // FIXME the cookie for AAC is wrong somehow, passing it in breaks FormatInfo & ASBDFromESDS 
    239         // either fix it (like in MKV) or just ignore it 
    240         if (asbd.mFormatID != kAudioFormatMPEG4AAC) { 
    241                 ioSize = sizeof(AudioStreamBasicDescription); 
    242                 err = AudioFormatGetProperty(kAudioFormatProperty_FormatInfo, cookieSize, &cookie, &ioSize, &asbd); 
    243                 if (err || !asbd.mFormatID) 
    244                         fprintf(stderr, "AudioFormatGetProperty dislikes the magic cookie (error %ld / format id %lx)\n", err, asbd.mFormatID); 
    245         } 
    246          
    247237        /* Set some fields of the AudioStreamBasicDescription. Then ask the AudioToolbox 
    248238                * to fill as much as possible before creating the SoundDescriptionHandle */ 
     
    252242                asbd.mBytesPerPacket = codec->block_align; /* this is tested for alaw/mulaw/msadpcm */ 
    253243         
     244        /* ask the toolbox about more information */ 
     245        ioSize = sizeof(AudioStreamBasicDescription); 
     246        err = AudioFormatGetProperty(kAudioFormatProperty_FormatInfo, cookieSize, cookie, &ioSize, &asbd); 
     247        if (err || !asbd.mFormatID) 
     248                fprintf(stderr, "AudioFormatGetProperty dislikes the magic cookie (error %ld / format id %lx)\n", err, asbd.mFormatID); 
     249         
    254250        /* 
    255251         FIXME:  
    256252         - at least ffmp3 does not set these values without parsing+the decoder being enabled 
    257253           (so we avoid overwriting them from above for now) 
    258          - it is unclear whether the ASBD values correspond to decoded or encoded data (same for lavc) 
    259          - this should be 0 for formats with variable framesPerPacket 
    260          - lavc frame_size is in bytes, mFramesPerPacket is in frames (maybe) 
     254         - this possibly should be 0 for formats with variable framesPerPacket like Vorbis 
     255         - lavc frame_size is in samples, mFramesPerPacket is in frames (maybe) 
    261256         */ 
    262257        if (!asbd.mFramesPerPacket) 
    263258                asbd.mFramesPerPacket = codec->frame_size; 
    264         if (asbd.mFormatID == kAudioFormatMPEG4AAC) 
    265                 asbd.mFramesPerPacket = 1024; 
    266         if (!asbd.mFramesPerPacket && !asbd.mBytesPerPacket) 
     259        if (!asbd.mFramesPerPacket && !asbd.mBytesPerPacket) //FIXME what is this for? 
    267260                asbd.mFramesPerPacket = 1; 
    268261        asbd.mBitsPerChannel = codec->bits_per_coded_sample; 
     
    332325                        fprintf(stderr, "AVI IMPORTER: Error %ld creating the sound description\n", err); 
    333326                        goto bail; 
    334                 } 
    335                  
    336                 // QTSoundDescriptionCreate sets this to 576 which is wrong 
    337                 if ((**sndHdl).version == 1 && asbd.mFormatID == kAudioFormatMPEGLayer3) { 
    338                         SoundDescriptionV1Handle v1h = (SoundDescriptionV1Handle)sndHdl; 
    339                         (**v1h).samplesPerPacket = 1152; 
    340327                } 
    341328        }