Ticket #230: 0002-Move-getting-the-channel-count-to-its-own-function.patch

File 0002-Move-getting-the-channel-count-to-its-own-function.patch, 5.9 KB (added by dconrad, 3 years ago)

Move getting the channel count to its own function

  • A52/ACShepA52Decoder.cpp

    From 63e568e5436aeb2d26d80f5e28648b7cb58a0afe Mon Sep 17 00:00:00 2001
    From: David Conrad <davedc@Crescens.local>
    Date: Sun, 5 Aug 2007 02:54:48 -0400
    Subject: [PATCH] Move getting the channel count to its own function
    
    ---
     A52/ACShepA52Decoder.cpp |  169 ++++++++++++++++++++++++----------------------
     1 files changed, 87 insertions(+), 82 deletions(-)
    
    diff --git a/A52/ACShepA52Decoder.cpp b/A52/ACShepA52Decoder.cpp
    index 9b524c7..9c4d971 100644
    a b  
    382382        //fprintf(stderr, "ACShepA52Decoder::SetCurrentOutputFormat: Exiting function\n"); 
    383383} 
    384384 
     385static 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                         
     397                case (A52_CHANNEL1): { 
     398                        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found first of two independant monaural channel audio\n"); 
     399                        total_channels += 1; 
     400                        break; 
     401                }                        
     402                         
     403                case (A52_CHANNEL2): { 
     404                        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found second of two independant monaural channel audio\n"); 
     405                        total_channels += 1; 
     406                        break; 
     407                } 
     408                         
     409                case (A52_MONO): { 
     410                        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found monaural audio\n"); 
     411                        total_channels += 1; 
     412                        break; 
     413                } 
     414                         
     415                case (A52_STEREO): { 
     416                        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found stereo audio\n"); 
     417                        total_channels += 2; 
     418                        break; 
     419                } 
     420                         
     421                case (A52_DOLBY): { 
     422                        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found Dolby Surround sound audio\n"); 
     423                        total_channels += 2; 
     424                        break; 
     425                } 
     426                         
     427                case (A52_3F): { 
     428                        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found 3 front channel audio\n"); 
     429                        total_channels += 3; 
     430                        break; 
     431                } 
     432                         
     433                case (A52_2F1R): { 
     434                        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found 2 front & 1 back channel audio\n"); 
     435                        total_channels += 3; 
     436                        break; 
     437                } 
     438                         
     439                case (A52_3F1R): { 
     440                        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found 3 front & 1 back channel audio\n"); 
     441                        total_channels += 4; 
     442                        break; 
     443                } 
     444                         
     445                case (A52_2F2R): { 
     446                        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found 2 front & 2 back channel audio\n"); 
     447                        total_channels += 4; 
     448                        break; 
     449                } 
     450                         
     451                case (A52_3F2R): { 
     452                        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found 3 front & 2 back channel audio\n"); 
     453                        total_channels += 5; 
     454                        break; 
     455                } 
     456                         
     457                default: { 
     458                        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: No audio stream information found, probably not good!\n"); 
     459                        break; 
     460                } 
     461        } 
     462         
     463        if (a52_flags & A52_LFE) { 
     464                //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found LFE channel in audio\n"); 
     465                total_channels += 1; 
     466        } 
     467         
     468        return total_channels; 
     469} 
     470 
    385471/* 
    386472 * Custom Dynamic range compression 
    387473 * My logic here: 
     
    10321118        mInputFormat.mFramesPerPacket = 256*6; 
    10331119        mInputFormat.mBytesPerFrame = mInputFormat.mBytesPerPacket / mInputFormat.mFramesPerPacket; 
    10341120         
    1035         switch (a52_flags & A52_CHANNEL_MASK) { 
    1036                  
    1037                 case (A52_CHANNEL): { 
    1038                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found two independant monaural audio\n"); 
    1039                         total_channels += 2; 
    1040                         break; 
    1041                 } 
    1042                          
    1043                 case (A52_CHANNEL1): { 
    1044                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found first of two independant monaural channel audio\n"); 
    1045                         total_channels += 1; 
    1046                         break; 
    1047                 }                        
    1048                          
    1049                 case (A52_CHANNEL2): { 
    1050                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found second of two independant monaural channel audio\n"); 
    1051                         total_channels += 1; 
    1052                         break; 
    1053                 } 
    1054                          
    1055                 case (A52_MONO): { 
    1056                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found monaural audio\n"); 
    1057                         total_channels += 1; 
    1058                         break; 
    1059                 } 
    1060                          
    1061                 case (A52_STEREO): { 
    1062                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found stereo audio\n"); 
    1063                         total_channels += 2; 
    1064                         break; 
    1065                 } 
    1066                          
    1067                 case (A52_DOLBY): { 
    1068                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found Dolby Surround sound audio\n"); 
    1069                         total_channels += 2; 
    1070                         break; 
    1071                 } 
    1072                          
    1073                 case (A52_3F): { 
    1074                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found 3 front channel audio\n"); 
    1075                         total_channels += 3; 
    1076                         break; 
    1077                 } 
    1078                          
    1079                 case (A52_2F1R): { 
    1080                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found 2 front & 1 back channel audio\n"); 
    1081                         total_channels += 3; 
    1082                         break; 
    1083                 } 
    1084                          
    1085                 case (A52_3F1R): { 
    1086                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found 3 front & 1 back channel audio\n"); 
    1087                         total_channels += 4; 
    1088                         break; 
    1089                 } 
    1090                          
    1091                 case (A52_2F2R): { 
    1092                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found 2 front & 2 back channel audio\n"); 
    1093                         total_channels += 4; 
    1094                         break; 
    1095                 } 
    1096                          
    1097                 case (A52_3F2R): { 
    1098                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found 3 front & 2 back channel audio\n"); 
    1099                         total_channels += 5; 
    1100                         break; 
    1101                 } 
    1102                          
    1103                 default: { 
    1104                         //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: No audio stream information found, probably not good!\n"); 
    1105                         break; 
    1106                 } 
    1107                          
    1108                          
    1109         } 
    1110          
    1111         if (a52_flags & A52_LFE) { 
    1112                 //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found LFE channel in audio\n"); 
    1113                 total_channels += 1; 
    1114         } 
     1121        total_channels = ChannelCount(a52_flags); 
    11151122         
    11161123        //fprintf(stderr, "ACShepA52Decoder::DetermineStreamParameters: Found %d total channels\n", total_channels); 
    11171124         
    11181125} 
    11191126 
    1120  
    1121  
    11221127UInt32  ACShepA52Decoder::GetVersion() const { 
    11231128        return 0x00015000; 
    11241129}