Changeset 858

Show
Ignore:
Timestamp:
04/20/08 17:42:32 (4 weeks ago)
Author:
gbooker
Message:

Only use 'ac-3' if the sample contains a single ac3 frame, and nothing else. Otherwise, use 'ms \0' since it can still do passthrough on the ATV in this case

Files:

Legend:

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

    r842 r858  
    2727#include "parser.h" 
    2828#include "golomb.h" 
     29 
     30#include "CodecIDs.h" 
    2931 
    3032int inline MININT(int a, int b) 
     
    5557 
    5658static const uint16_t ac3_freqs[3] = { 48000, 44100, 32000 }; 
     59static const uint16_t ac3_bitratetab[] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 448, 512, 576, 640}; 
     60static const uint8_t ac3_halfrate[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3}; 
    5761 
    5862/* From: http://svn.mplayerhq.hu/ac3/ (LGPL) 
     
    116120         
    117121        /* This is a valid frame!!! */ 
    118 //      uint8_t bitrate = ac3_bitratetab[frmsizecod >> 1]; 
    119         int sample_rate = ac3_freqs[fscod]; 
     122        uint16_t bitrate = ac3_bitratetab[frmsizecod >> 1]; 
     123        uint8_t half = ac3_halfrate[bsid]; 
     124        int sample_rate = ac3_freqs[fscod] >> half; 
     125        int framesize; 
     126        switch (fscod) { 
     127                case 0: 
     128                        framesize = 4 * bitrate; 
     129                        break; 
     130                case 1: 
     131                        framesize = (320 * bitrate / 147 + (frmsizecod & 1 ? 1 : 0)) * 2; 
     132                        break; 
     133                case 2: 
     134                        framesize = 6 * bitrate; 
     135                        break; 
     136                default: 
     137                        break; 
     138        } 
    120139         
    121140        shift = 0; 
     
    126145        memset(asbd, 0, sizeof(AudioStreamBasicDescription)); 
    127146        asbd->mSampleRate = sample_rate >> shift; 
    128         asbd->mFormatID = kAudioFormatAC3; 
     147        if(offset == 0 && buff_size == framesize) 
     148                asbd->mFormatID = kAudioFormatAC3; 
     149        else 
     150                asbd->mFormatID = kAudioFormatAC3MS; 
    129151        asbd->mFramesPerPacket = 1; 
    130152        asbd->mChannelsPerFrame = nfchans_tbl[acmod] + lfe;