Changeset 60

Show
Ignore:
Timestamp:
08/05/07 10:07:49 (1 year ago)
Author:
gbooker
Message:

Patches from perian's trac: http://trac.perian.org/ticket/230

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/A52/ACShepA52Decoder.cpp

    r59 r60  
    381381        ACShepA52Codec::SetCurrentOutputFormat(inOutputFormat); 
    382382        //fprintf(stderr, "ACShepA52Decoder::SetCurrentOutputFormat: Exiting function\n"); 
     383} 
     384 
     385static unsigned int ChannelCount(int a52_flags) 
     386{ 
     387        int total_channels = 0; 
     388         
     389        switch (a52_flags & A52_CHANNEL_MASK) { 
     390                 
     391                case A52_CHANNEL: 
     392                        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found two independant monaural audio\n"); 
     393                        total_channels = 2; 
     394                        break; 
     395                         
     396                case A52_CHANNEL1: 
     397                        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found first of two independant monaural channel audio\n"); 
     398                        total_channels = 1; 
     399                        break; 
     400                         
     401                case A52_CHANNEL2: 
     402                        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found second of two independant monaural channel audio\n"); 
     403                        total_channels = 1; 
     404                        break; 
     405                         
     406                case A52_MONO: 
     407                        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found monaural audio\n"); 
     408                        total_channels = 1; 
     409                        break; 
     410                         
     411                case A52_STEREO: 
     412                        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found stereo audio\n"); 
     413                        total_channels = 2; 
     414                        break; 
     415                         
     416                case A52_DOLBY: 
     417                        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found Dolby Surround sound audio\n"); 
     418                        total_channels = 2; 
     419                        break; 
     420                         
     421                case A52_3F: 
     422                        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found 3 front channel audio\n"); 
     423                        total_channels = 3; 
     424                        break; 
     425                         
     426                case A52_2F1R: 
     427                        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found 2 front & 1 back channel audio\n"); 
     428                        total_channels = 3; 
     429                        break; 
     430                         
     431                case A52_3F1R: 
     432                        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found 3 front & 1 back channel audio\n"); 
     433                        total_channels = 4; 
     434                        break; 
     435                         
     436                case A52_2F2R: 
     437                        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found 2 front & 2 back channel audio\n"); 
     438                        total_channels = 4; 
     439                        break; 
     440                         
     441                case A52_3F2R: 
     442                        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found 3 front & 2 back channel audio\n"); 
     443                        total_channels = 5; 
     444                        break; 
     445 
     446                default: 
     447                        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: No audio stream information found, probably not good!\n"); 
     448                        break; 
     449        } 
     450         
     451        if (a52_flags & A52_LFE) { 
     452                //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found LFE channel in audio\n"); 
     453                total_channels ++; 
     454        } 
     455         
     456        return total_channels; 
    383457} 
    384458 
     
    402476                return c; 
    403477} 
     478 
     479// Output order of liba52: LFE, left, center, right, left surround, right surround. 
     480// Channels missing are skipped 
     481// Supposed input to CoreAudio is: left, right, center, LFE, left surround, right surround 
     482 
     483void getChannelMap(int a52_flags, int chanMap[6]) 
     484{ 
     485        int defaultMap[] = {0, 1, 2, 3, 4, 5}; 
     486        int frontChan = 0; 
     487        int lfe = a52_flags & A52_LFE ? 1 : 0; 
     488         
     489        memcpy(chanMap, defaultMap, sizeof(defaultMap)); 
     490        switch (a52_flags & A52_CHANNEL_MASK) { 
     491                case A52_STEREO: 
     492                case A52_DOLBY: 
     493                case A52_2F1R: 
     494                case A52_2F2R: 
     495                        chanMap[1] = lfe + 1; 
     496                        frontChan = 1; 
     497 
     498                case A52_CHANNEL: 
     499                case A52_CHANNEL1: 
     500                case A52_CHANNEL2: 
     501                case A52_MONO: 
     502                        chanMap[0] = lfe; 
     503                        frontChan++; 
     504                        break; 
     505                         
     506                case A52_3F: 
     507                case A52_3F1R: 
     508                case A52_3F2R: 
     509                        chanMap[0] = lfe; 
     510                        chanMap[1] = lfe + 2; 
     511                        chanMap[2] = lfe + 1; 
     512                        frontChan = 3; 
     513                        break; 
     514                         
     515                default: 
     516                        break; 
     517        } 
     518        if(lfe) 
     519                chanMap[frontChan] = 0; 
     520} 
     521 
     522template <class outPtr, class inPtr> 
     523UInt32 InterleaveSamples(void *output_data_untyped, UInt32 output_data_offset, sample_t *output_samples, int a52_flags) { 
     524        inPtr  *cast_samples; 
     525        outPtr *output_data = (outPtr *)output_data_untyped; 
     526         
     527        cast_samples = (inPtr *)output_samples; 
     528         
     529        int chans = ChannelCount(a52_flags); 
     530         
     531        // each element is the liba52 channel number of the CA channel number of the index 
     532        int chanMap[6]; 
     533        getChannelMap(a52_flags, chanMap); 
     534         
     535        for (int i = 0; i < 256; i++) { 
     536                for (int j = 0; j < chans; j++) { 
     537                        output_data[chans*i + output_data_offset + j] = cast_samples[i + 256*chanMap[j]]; 
     538                } 
     539        } 
     540         
     541        return chans * 256; // Number of 'UInt16' we processed 
     542} 
     543 
    404544 
    405545UInt32 ACShepA52Decoder::ProduceOutputPackets(void* outOutputData, 
     
    616756                else 
    617757                { 
    618                         switch(mOutputFormat.mChannelsPerFrame) { 
    619                                 case 1: 
     758                        if(mOutputFormat.mChannelsPerFrame <= 2) 
     759                        { 
     760                                if(mOutputFormat.mChannelsPerFrame == 1) 
    620761                                        // Just mono 
    621762                                        a52_flags = A52_MONO | A52_ADJUST_LEVEL; 
    622                                         break; 
    623                                          
    624                                 case 2: 
     763                                else 
    625764                                        // All we really need is stereophonic, baby 
    626765                                        a52_flags = TwoChannelMode; 
    627                                         break; 
    628                                          
    629                                 case 5: 
    630                                         // Try to get 5.0 channels 
    631                                         a52_flags = A52_3F2R | A52_ADJUST_LEVEL;         
    632                                         break; 
    633                                          
    634                                 case 6: 
    635                                         // Try to get 5.1 channels 
    636                                         a52_flags = A52_3F2R | A52_LFE | A52_ADJUST_LEVEL; 
    637                                         break; 
    638                                          
    639                                 default: 
    640                                         fprintf(stderr, "ACShepA52Decoder::ProduceOutputPackets: Unknown output channel amount\n"); 
    641                                         break; 
     766                        } 
     767                        else if(mOutputFormat.mChannelsPerFrame == ChannelCount(a52_flags)) 
     768                                //Hope and pray that the channel layout is correct 
     769                                a52_flags |= A52_ADJUST_LEVEL; 
     770                        else 
     771                        { 
     772                                fprintf(stderr, "ACShepA52Decoder::ProduceOutputPackets: channel count doesn't match; expect odd results\n"); 
     773                                //Put in some guesses here 
     774                                switch(mOutputFormat.mChannelsPerFrame) 
     775                                { 
     776                                        case 3: 
     777                                                a52_flags = A52_2F1R | A52_ADJUST_LEVEL; 
     778                                                break; 
     779                                        case 4: 
     780                                                a52_flags = A52_2F2R | A52_ADJUST_LEVEL; 
     781                                                break; 
     782                                        case 5: 
     783                                                a52_flags = A52_3F2R | A52_ADJUST_LEVEL; 
     784                                                break; 
     785                                        case 6: 
     786                                                a52_flags = A52_3F2R | A52_LFE | A52_ADJUST_LEVEL; 
     787                                                break; 
     788                                } 
    642789                        } 
    643790 
     
    655802                                if (mOutputFormat.mFormatFlags == kIntPCMOutFormatFlag) { 
    656803                                        if (mOutputFormat.mBitsPerChannel == 16) { 
    657                                                 output_offset += Process16BitSignedInts(outOutputData, output_offset, output_samples, a52_flags); 
     804                                                /* Use a bias of 384 and a level of 1 to get the range, 383(+) to 385(-). 
     805                                                   In IEEE floating point, the range is 0x0x43bf8001 to 0x43bf7fff. 
     806                                                   If you cast these to ints, the range is -32767 to 32767*/ 
     807                                                output_offset += InterleaveSamples<SInt16, SInt32>(outOutputData, output_offset, output_samples, a52_flags); 
    658808                                        } else { 
    659                                                 output_offset += Process32BitSignedInts(outOutputData, output_offset, output_samples, a52_flags); 
     809                                                output_offset += InterleaveSamples<SInt32, float>(outOutputData, output_offset, output_samples, a52_flags); 
    660810                                        } 
    661811                                } else { 
    662                                         output_offset += ProcessFloats(outOutputData, output_offset, output_samples, a52_flags); 
     812                                        output_offset += InterleaveSamples<float, float>(outOutputData, output_offset, output_samples, a52_flags); 
    663813                                } 
    664814                         
     
    693843         
    694844        return theAnswer; 
    695 } 
    696  
    697  
    698 // Output order of liba52: LFE, left, center, right, left surround, right surround. 
    699 // Channels missing are skipped 
    700 // Supposed input to CoreAudio is: left, right, center, LFE, left surround, right surround 
    701  
    702 UInt32 ACShepA52Decoder::Process16BitSignedInts(void *output_data_untyped, UInt32 output_data_offset, sample_t *output_samples, int a52_flags) { 
    703         SInt32  *cast_samples; 
    704         SInt16 *output_data = (SInt16 *)output_data_untyped; 
    705          
    706         cast_samples = (SInt32 *)output_samples; 
    707  
    708         // Weird things... 
    709         // As far as I can see, we take a float, cast it to an UInt32, then copy it to a UInt16 
    710         // The trick being: level = 1 and bias = 384 
    711          
    712         // It is 256 samples 
    713          
    714         // ME.f is using 16-bit 
    715          
    716         switch(a52_flags & A52_CHANNEL_MASK) {           
    717                  
    718                 // 5 Channel 
    719                 case A52_3F2R: 
    720                          
    721                         // With LFE 
    722                         if (a52_flags & A52_LFE) { 
    723                                 //fprintf(stderr, "ACShepA52Decoder::Process16BitSignedInts: Running 5.1\n"); 
    724                                  
    725                                 for (int k = 0; k < 256; k++) { 
    726                                         output_data[6*k + output_data_offset + 3] =  cast_samples[k + 256*0]; // LFE chan  
    727                                         output_data[6*k + output_data_offset + 0] =  cast_samples[k + 256*1]; // left chan  
    728                                         output_data[6*k + output_data_offset + 2] =  cast_samples[k + 256*2]; // center chan  
    729                                         output_data[6*k + output_data_offset + 1] =  cast_samples[k + 256*3]; // right chan  
    730                                         output_data[6*k + output_data_offset + 4] =  cast_samples[k + 256*4]; // left surround chan  
    731                                         output_data[6*k + output_data_offset + 5] =  cast_samples[k + 256*5]; // right surround chan  
    732                                 } 
    733                                  
    734                                 return 6 * 256; // Number of 'UInt16' we processed 
    735                                  
    736                         } else { 
    737                                 //fprintf(stderr, "ACShepA52Decoder::Process16BitSignedInts: Running 5.0\n"); 
    738                                 for (int k = 0; k < 256; k++) { 
    739                                         output_data[5*k + output_data_offset + 0] = cast_samples[k + 256*0]; // left chan  
    740                                         output_data[5*k + output_data_offset + 2] = cast_samples[k + 256*1]; // center chan  
    741                                         output_data[5*k + output_data_offset + 1] = cast_samples[k + 256*2]; // right chan  
    742                                         output_data[5*k + output_data_offset + 3] = cast_samples[k + 256*3]; // left surround chan  
    743                                         output_data[5*k + output_data_offset + 4] = cast_samples[k + 256*4]; // right surround chan  
    744                                 } 
    745                                  
    746                                 return 5 * 256; // Number of 'UInt16' we processed 
    747                         } 
    748                         break; 
    749                          
    750                 // Stereo 
    751                 case A52_STEREO: 
    752                 case A52_DOLBY:  
    753                         //fprintf(stderr, "ACShepA52Decoder::Process16BitSignedInts: Running stereo\n"); 
    754                          
    755                         for (int k = 0; k < 256; k++) { 
    756                                 output_data[2*k + output_data_offset]     =  cast_samples[k];       // left chan  
    757                                 output_data[2*k + output_data_offset + 1] =  cast_samples[k + 256]; // right chan  
    758                         } 
    759                                  
    760                         return 2 * 256; // Number of 'UInt16' we processed 
    761                          
    762                         break; 
    763                          
    764                 // Mono 
    765                 case A52_MONO: 
    766                         //fprintf(stderr, "ACShepA52Decoder::Process16BitSignedInts: Running mono\n"); 
    767                          
    768                         for (int k = 0; k < 256; k++) { 
    769                                 output_data[k + output_data_offset]     =  cast_samples[k];       // mono chan  
    770                         } 
    771                          
    772                         return 256; // Number of 'UInt16' we processed 
    773                          
    774                         break; 
    775                          
    776                 default: 
    777                         fprintf(stderr, "ACShepA52Decoder::Process16BitSignedInts: Failed to match output channels\n"); 
    778         } 
    779          
    780         return 0; 
    781 } 
    782  
    783 // Output order of liba52: LFE, left, center, right, left surround, right surround. 
    784 // Channels missing are skipped 
    785 // Supposed input to CoreAudio is: left, right, center, LFE, left surround, right surround 
    786  
    787 UInt32 ACShepA52Decoder::Process32BitSignedInts(void *output_data_untyped, UInt32 output_data_offset, sample_t *output_samples, int a52_flags) { 
    788         SInt32 *output_data = (SInt32 *)output_data_untyped; 
    789          
    790         //fprintf(stderr, "ACShepA52Decoder::Process32BitSignedInts: Flags are: 0x%08X\n", a52_flags); 
    791          
    792         // PlayAudioFileLite uses SInt32 
    793          
    794         switch(a52_flags & A52_CHANNEL_MASK) {           
    795                  
    796                 // 5 Channel 
    797                 case A52_3F2R: 
    798                          
    799                         // With LFE 
    800                         if (a52_flags & A52_LFE) { 
    801                                 //fprintf(stderr, "ACShepA52Decoder::Process32BitSignedInts: Running 5.1\n"); 
    802                                  
    803                                 for (int k = 0; k < 256; k++) { 
    804                                         output_data[6*k + output_data_offset + 3] = (SInt32)output_samples[k + 256*0]; // LFE chan  
    805                                         output_data[6*k + output_data_offset + 0] = (SInt32)output_samples[k + 256*1]; // left chan  
    806                                         output_data[6*k + output_data_offset + 2] = (SInt32)output_samples[k + 256*2]; // center chan  
    807                                         output_data[6*k + output_data_offset + 1] = (SInt32)output_samples[k + 256*3]; // right chan  
    808                                         output_data[6*k + output_data_offset + 4] = (SInt32)output_samples[k + 256*4]; // left surround chan  
    809                                         output_data[6*k + output_data_offset + 5] = (SInt32)output_samples[k + 256*5]; // right surround chan  
    810                                 } 
    811                                  
    812                                 return 6 * 256; // Number of 'UInt32' we processed 
    813                         } else { 
    814                                 //fprintf(stderr, "ACShepA52Decoder::Process32BitSignedInts: Running 5.0\n"); 
    815                                 for (int k = 0; k < 256; k++) { 
    816                                         output_data[5*k + output_data_offset + 0] = (SInt32)output_samples[k + 256*0]; // left chan  
    817                                         output_data[5*k + output_data_offset + 2] = (SInt32)output_samples[k + 256*1]; // center chan  
    818                                         output_data[5*k + output_data_offset + 1] = (SInt32)output_samples[k + 256*2]; // right chan  
    819                                         output_data[5*k + output_data_offset + 3] = (SInt32)output_samples[k + 256*3]; // left surround chan  
    820                                         output_data[5*k + output_data_offset + 4] = (SInt32)output_samples[k + 256*4]; // right surround chan  
    821                                 } 
    822                                  
    823                                 return 5 * 256; // Number of 'UInt32' we processed 
    824                         } 
    825                         break; 
    826                          
    827                 // Stereo 
    828                 case A52_STEREO: 
    829                 case A52_DOLBY:  
    830                         //fprintf(stderr, "ACShepA52Decoder::Process32BitSignedInts: Running stereo\n"); 
    831                          
    832                         for (int k = 0; k < 256; k++) { 
    833                                 output_data[2*k + output_data_offset]     =  (SInt32)output_samples[k];       // left chan  
    834                                 output_data[2*k + output_data_offset + 1] =  (SInt32)output_samples[k + 256]; // right chan  
    835                         } 
    836                                  
    837                         return 2 * 256; // Number of 'UInt32' we processed 
    838                         break; 
    839                          
    840                 // Mono 
    841                 case A52_MONO: 
    842                         //fprintf(stderr, "ACShepA52Decoder::Process32BitSignedInts: Running mono\n"); 
    843                          
    844                         for (int k = 0; k < 256; k++) { 
    845                                 output_data[k + output_data_offset]     =  (SInt32)output_samples[k];       // moon chan  
    846                         } 
    847                          
    848                         return 256; // Number of 'UInt32' we processed 
    849                         break; 
    850  
    851                 default: 
    852                          
    853                         fprintf(stderr, "ACShepA52Decoder::Process32BitSignedInts: Failed to match output channels\n"); 
    854         } 
    855          
    856         return 0; 
    857 } 
    858  
    859  
    860 UInt32 ACShepA52Decoder::ProcessFloats(void *output_data_untyped, UInt32 output_data_offset, sample_t *output_samples, int a52_flags) { 
    861         float *output_data = (float *)output_data_untyped; 
    862          
    863          
    864         switch(a52_flags & A52_CHANNEL_MASK) {           
    865                  
    866                 // 5 Channel 
    867                 case A52_3F2R: 
    868                          
    869                         // With LFE 
    870                         if (a52_flags & A52_LFE) { 
    871                                 //fprintf(stderr, "ACShepA52Decoder::ProcessFloats: Running 5.1\n"); 
    872                                  
    873                                 for (int k = 0; k < 256; k++) { 
    874                                         output_data[6*k + output_data_offset + 3] = output_samples[k + 256*0]; // LFE chan  
    875                                         output_data[6*k + output_data_offset + 0] = output_samples[k + 256*1]; // left chan  
    876                                         output_data[6*k + output_data_offset + 2] = output_samples[k + 256*2]; // center chan  
    877                                         output_data[6*k + output_data_offset + 1] = output_samples[k + 256*3]; // right chan  
    878                                         output_data[6*k + output_data_offset + 4] = output_samples[k + 256*4]; // left surround chan  
    879                                         output_data[6*k + output_data_offset + 5] = output_samples[k + 256*5]; // right surround chan  
    880                                 } 
    881                                  
    882                                 return 6 * 256; // Number of 'float' we processed 
    883                         } else { 
    884                                 //fprintf(stderr, "ACShepA52Decoder::ProcessFloats: Running 5.0\n"); 
    885                                 for (int k = 0; k < 256; k++) { 
    886                                         output_data[5*k + output_data_offset + 0] = output_samples[k + 256*0]; // left chan  
    887                                         output_data[5*k + output_data_offset + 2] = output_samples[k + 256*1]; // center chan  
    888                                         output_data[5*k + output_data_offset + 1] = output_samples[k + 256*2]; // right chan  
    889                                         output_data[5*k + output_data_offset + 3] = output_samples[k + 256*3]; // left surround chan  
    890                                         output_data[5*k + output_data_offset + 4] = output_samples[k + 256*4]; // right surround chan  
    891                                 } 
    892                                  
    893                                 return 5 * 256; // Number of 'UInt32' we processed 
    894                         } 
    895                          
    896                         break; 
    897                          
    898                 // Stereo 
    899                 case A52_STEREO: 
    900                 case A52_DOLBY: 
    901                         //fprintf(stderr, "ACShepA52Decoder::ProcessFloats: Running stereo\n"); 
    902                          
    903                         for (int k = 0; k < 256; k++) { 
    904                                 output_data[2*k + output_data_offset]     =  output_samples[k];       // left chan  
    905                                 output_data[2*k + output_data_offset + 1] =  output_samples[k + 256]; // right chan  
    906                         } 
    907                                  
    908                         return 2 * 256; // Number of 'float' we processed 
    909                         break; 
    910                          
    911                 // Mono 
    912                 case A52_MONO: 
    913                         //fprintf(stderr, "ACShepA52Decoder::ProcessFloats: Running mono\n"); 
    914                          
    915                         for (int k = 0; k < 256; k++) { 
    916                                 output_data[k + output_data_offset]     =  output_samples[k];       // mono chan  
    917                         } 
    918                          
    919                         return 256; // Number of 'float' we processed 
    920                         break; 
    921                          
    922                 default: 
    923                         fprintf(stderr, "ACShepA52Decoder::ProcessFloats: Failed to match output channels\n"); 
    924         } 
    925         return 0; 
    926845} 
    927846 
     
    11761095        mInputFormat.mBytesPerFrame = mInputFormat.mBytesPerPacket / mInputFormat.mFramesPerPacket; 
    11771096         
    1178         switch (a52_flags & A52_CHANNEL_MASK) { 
    1179                  
    1180                 case (A52_CHANNEL): { 
    1181                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found two independant monaural audio\n"); 
    1182                         total_channels += 2; 
    1183                         break; 
    1184                 } 
    1185                          
    1186                 case (A52_CHANNEL1): { 
    1187                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found first of two independant monaural channel audio\n"); 
    1188                         total_channels += 1; 
    1189                         break; 
    1190                 }                        
    1191                          
    1192                 case (A52_CHANNEL2): { 
    1193                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found second of two independant monaural channel audio\n"); 
    1194                         total_channels += 1; 
    1195                         break; 
    1196                 } 
    1197                          
    1198                 case (A52_MONO): { 
    1199                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found monaural audio\n"); 
    1200                         total_channels += 1; 
    1201                         break; 
    1202                 } 
    1203                          
    1204                 case (A52_STEREO): { 
    1205                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found stereo audio\n"); 
    1206                         total_channels += 2; 
    1207                         break; 
    1208                 } 
    1209                          
    1210                 case (A52_DOLBY): { 
    1211                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found Dolby Surround sound audio\n"); 
    1212                         total_channels += 2; 
    1213                         break; 
    1214                 } 
    1215                          
    1216                 case (A52_3F): { 
    1217                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found 3 front channel audio\n"); 
    1218                         total_channels += 3; 
    1219                         break; 
    1220                 } 
    1221                          
    1222                 case (A52_2F1R): { 
    1223                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found 2 front & 1 back channel audio\n"); 
    1224                         total_channels += 3; 
    1225                         break; 
    1226                 } 
    1227                          
    1228                 case (A52_3F1R): { 
    1229                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found 3 front & 1 back channel audio\n"); 
    1230                         total_channels += 4; 
    1231                         break; 
    1232                 } 
    1233                          
    1234                 case (A52_2F2R): { 
    1235                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found 2 front & 2 back channel audio\n"); 
    1236                         total_channels += 4; 
    1237                         break; 
    1238                 } 
    1239                          
    1240                 case (A52_3F2R): { 
    1241                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found 3 front & 2 back channel audio\n"); 
    1242                         total_channels += 5; 
    1243                         break; 
    1244                 } 
    1245                          
    1246                 default: { 
    1247                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: No audio stream information found, probably not good!\n"); 
    1248                         break; 
    1249                 } 
    1250                          
    1251                          
    1252         } 
    1253          
    1254         if (a52_flags & A52_LFE) { 
    1255                 //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found LFE channel in audio\n"); 
    1256                 total_channels += 1; 
    1257         } 
     1097        total_channels = ChannelCount(a52_flags); 
    12581098         
    12591099        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found %d total channels\n", total_channels); 
    12601100         
    12611101} 
    1262  
    1263  
    12641102 
    12651103UInt32  ACShepA52Decoder::GetVersion() const { 
  • trunk/A52/ACShepA52Decoder.h

    r50 r60  
    6060        void    DetermineStreamParameters(); 
    6161        UInt32  SyncA52Stream(UInt32 &bytes_to_read, Byte *input_data, int &a52_flags, int &a52_samplerate, int &a52_bitrate, bool shouldResync); 
    62         UInt32  Process16BitSignedInts(void *output_data_untyped, UInt32 output_data_offset, sample_t *output_samples, int a52_flags); 
    63         UInt32  Process32BitSignedInts(void *output_data_untyped, UInt32 output_data_offset, sample_t *output_samples, int a52_flags); 
    64         UInt32  ProcessFloats(void *output_data_untyped, UInt32 output_data_offset, sample_t *output_samples, int a52_flags); 
    6562        UInt32  AppendPacket(const void* inInputData, UInt32 inInputDataSize, UInt32 bufferStartOffset, UInt32 offset, UInt32& packetSize);              
    6663