Changeset 50

Show
Ignore:
Timestamp:
06/13/07 08:48:53 (1 year ago)
Author:
gbooker
Message:

My multi-channel/2 channel output test.
Bumped the version so that it can be tested with perian

Files:

Legend:

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

    r1 r50  
    4141        //      make sure the sample rate and number of channels match between the input format and the output format 
    4242                 
    43         if( (mInputFormat.mSampleRate != mOutputFormat.mSampleRate) || 
    44                 (mInputFormat.mChannelsPerFrame != mOutputFormat.mChannelsPerFrame)) 
     43        if( (mInputFormat.mSampleRate != mOutputFormat.mSampleRate)) 
    4544        { 
    4645                CODEC_THROW(kAudioCodecUnsupportedFormatError); 
  • trunk/A52/ACShepA52Decoder.cpp

    r43 r50  
    2121 
    2222#define kAudioFormatAVIAC3      0x6D732000 
    23  
     23#define MY_APP_DOMAIN CFSTR("com.cod3r.a52codec") 
     24 
     25//Old 
     26#define USE_STEREO_KEY CFSTR("useStereoOverDolby") 
     27#define USE_DPLII_KEY CFSTR("useDolbyProLogicII") 
     28 
     29#define DYNAMIC_RANGE_KEY CFSTR("dynamicRange") 
     30#define PASSTHROUGH_KEY CFSTR("attemptPassthrough") 
     31#define TWO_CHANNEL_KEY CFSTR("twoChannelMode") 
     32 
     33void ACShepA52Decoder::UpgradeOldPrefs() 
     34
     35        CFStringRef myApp = MY_APP_DOMAIN; 
     36        int useStereoOverDolby = 0; 
     37        CFTypeRef stereo = CFPreferencesCopyAppValue(USE_STEREO_KEY, myApp); 
     38        if(stereo != NULL) 
     39        { 
     40                CFTypeID type = CFGetTypeID(stereo); 
     41                if(type == CFStringGetTypeID()) 
     42                        useStereoOverDolby = CFStringGetIntValue((CFStringRef)stereo); 
     43                else if(type == CFNumberGetTypeID()) 
     44                        CFNumberGetValue((CFNumberRef)stereo, kCFNumberIntType, &useStereoOverDolby); 
     45                else if(type == CFBooleanGetTypeID()) 
     46                        useStereoOverDolby = CFBooleanGetValue((CFBooleanRef)stereo); 
     47                CFRelease(stereo); 
     48        } 
     49         
     50        int useDPL2 = 0; 
     51        CFTypeRef dpl2 = CFPreferencesCopyAppValue(USE_DPLII_KEY, myApp); 
     52        if(dpl2 != NULL) 
     53        { 
     54                CFTypeID type = CFGetTypeID(dpl2); 
     55                if(type == CFStringGetTypeID()) 
     56                        useDPL2 = CFStringGetIntValue((CFStringRef)dpl2); 
     57                else if(type == CFNumberGetTypeID()) 
     58                        CFNumberGetValue((CFNumberRef)dpl2, kCFNumberIntType, &useDPL2); 
     59                else if(type == CFBooleanGetTypeID()) 
     60                        useDPL2 = CFBooleanGetValue((CFBooleanRef)dpl2); 
     61                CFRelease(dpl2); 
     62        } 
     63         
     64        if(useStereoOverDolby) 
     65                TwoChannelMode = A52_STEREO; 
     66        else if(useDPL2) 
     67                TwoChannelMode = A52_DOLBY | A52_USE_DPLII; 
     68        else 
     69                TwoChannelMode = A52_DOLBY; 
     70         
     71        CFNumberRef resultingMode = CFNumberCreate(NULL, kCFNumberIntType, &TwoChannelMode); 
     72        CFPreferencesSetAppValue(TWO_CHANNEL_KEY, resultingMode, myApp); 
     73        CFRelease(resultingMode); 
     74        CFPreferencesAppSynchronize(myApp); 
     75
    2476 
    2577ACShepA52Decoder::ACShepA52Decoder(UInt32 inInputBufferByteSize) : ACShepA52Codec(inInputBufferByteSize) { 
     
    56108        kFloatPCMOutFormatFlag = kLinearPCMFormatFlagIsFloat             | kLinearPCMFormatFlagIsPacked; 
    57109#endif 
    58          
    59         CFPreferencesAppSynchronize(CFSTR("com.cod3r.a52codec")); 
    60         CFTypeRef dynRange = CFPreferencesCopyAppValue(CFSTR("dynamicRange"), CFSTR("com.cod3r.a52codec")); 
     110        CFStringRef myApp = MY_APP_DOMAIN; 
     111         
     112        CFPreferencesAppSynchronize(myApp); 
     113        CFTypeRef dynRange = CFPreferencesCopyAppValue(DYNAMIC_RANGE_KEY, myApp); 
    61114        if(dynRange != NULL) 
    62115        { 
     
    73126                dynamicRangeCompression = 1;  //no compression 
    74127         
    75         int useStereoOverDolby = 0; 
    76         CFTypeRef stereo = CFPreferencesCopyAppValue(CFSTR("useStereoOverDolby"), CFSTR("com.cod3r.a52codec")); 
    77         if(stereo != NULL) 
    78         { 
    79                 CFTypeID type = CFGetTypeID(stereo); 
    80                 if(type == CFStringGetTypeID()) 
    81                         useStereoOverDolby = CFStringGetIntValue((CFStringRef)stereo); 
    82                 else if(type == CFNumberGetTypeID()) 
    83                         CFNumberGetValue((CFNumberRef)stereo, kCFNumberIntType, &useStereoOverDolby); 
    84                 else if(type == CFBooleanGetTypeID()) 
    85                         useStereoOverDolby = CFBooleanGetValue((CFBooleanRef)stereo); 
    86                 CFRelease(stereo); 
    87         } 
    88  
    89         int useDPL2 = 0; 
    90         CFTypeRef dpl2 = CFPreferencesCopyAppValue(CFSTR("useDolbyProLogicII"), CFSTR("com.cod3r.a52codec")); 
    91         if(dpl2 != NULL) 
    92         { 
    93                 CFTypeID type = CFGetTypeID(dpl2); 
    94                 if(type == CFStringGetTypeID()) 
    95                         useDPL2 = CFStringGetIntValue((CFStringRef)dpl2); 
    96                 else if(type == CFNumberGetTypeID()) 
    97                         CFNumberGetValue((CFNumberRef)dpl2, kCFNumberIntType, &useDPL2); 
    98                 else if(type == CFBooleanGetTypeID()) 
    99                         useDPL2 = CFBooleanGetValue((CFBooleanRef)dpl2); 
    100                 CFRelease(dpl2); 
    101         } 
    102          
    103         if(useStereoOverDolby) 
    104                 TwoChannelMode = A52_STEREO; 
    105         else if(useDPL2) 
    106                 TwoChannelMode = A52_DOLBY | A52_USE_DPLII; 
    107         else 
    108                 TwoChannelMode = A52_DOLBY; 
    109          
    110         CFTypeRef pass = CFPreferencesCopyAppValue(CFSTR("attemptPassthrough"), CFSTR("com.cod3r.a52codec")); 
     128        CFTypeRef pass = CFPreferencesCopyAppValue(PASSTHROUGH_KEY, myApp); 
    111129        if(pass != NULL) 
    112130        { 
     
    123141                passthrough = 0; 
    124142         
    125         if(passthrough) 
     143        CFTypeRef twochan = CFPreferencesCopyAppValue(TWO_CHANNEL_KEY, myApp); 
     144        if(twochan != NULL) 
     145        { 
     146                CFTypeID type = CFGetTypeID(twochan); 
     147                if(type == CFStringGetTypeID()) 
     148                        TwoChannelMode = CFStringGetIntValue((CFStringRef)twochan); 
     149                else if(type == CFNumberGetTypeID()) 
     150                        CFNumberGetValue((CFNumberRef)twochan, kCFNumberIntType, &TwoChannelMode); 
     151                else 
     152                        TwoChannelMode = 0; 
     153                /* sanity checks */ 
     154                if(TwoChannelMode & A52_CHANNEL_MASK & 0xf7 != 2) 
     155                { 
     156                        /* matches 2 and 10, which is Stereo and Dolby */ 
     157                        TwoChannelMode = A52_DOLBY; 
     158                } 
     159                TwoChannelMode &= ~A52_ADJUST_LEVEL & ~A52_LFE; 
     160                CFRelease(twochan); 
     161        } 
     162        else 
     163                UpgradeOldPrefs(); 
     164        CFPreferencesSetAppValue(USE_STEREO_KEY, NULL, myApp); 
     165        CFPreferencesSetAppValue(USE_DPLII_KEY, NULL, myApp); 
     166 
     167        if(passthrough || TwoChannelMode) 
    126168        { 
    127169                //begin our passthrough hack 
     
    129171                for (int sample_index = 0; sample_index < 12; sample_index ++) 
    130172                { 
    131                         for (int channels = 1; channels <= 2; channels++) { 
    132                                 CAStreamBasicDescription theOutputFormat(sample_rates[sample_index], kAudioFormatLinearPCM, 0, 1, 0, channels, 16, kIntPCMOutFormatFlag); 
    133                                 AddOutputFormat(theOutputFormat); 
     173                        CAStreamBasicDescription theOutputFormat(sample_rates[sample_index], kAudioFormatLinearPCM, 0, 1, 0, 2, 16, kIntPCMOutFormatFlag); 
     174                        AddOutputFormat(theOutputFormat); 
     175                        if(!passthrough) 
     176                        { 
     177                                // 32 bit int 
     178                                CAStreamBasicDescription theOutputFormat1(sample_rates[sample_index], kAudioFormatLinearPCM, 0, 1, 0, 2, 32, kIntPCMOutFormatFlag); 
     179                                AddOutputFormat(theOutputFormat1); 
     180                                // 32 bit float 
     181                                CAStreamBasicDescription theOutputFormat2(sample_rates[sample_index], kAudioFormatLinearPCM, 0, 1, 0, 2, 32, kFloatPCMOutFormatFlag); 
     182                                AddOutputFormat(theOutputFormat2); 
     183                        } 
     184                        for (int channels = 1; channels <= 6; channels++) { 
    134185                                //      This decoder only takes an A/52 or AC-3 stream as it's input 
    135186                                CAStreamBasicDescription theInputFormat1(sample_rates[sample_index], kAudioFormatAC3, 0, 256*6, 0, channels, 0, 0); 
     
    139190                        } 
    140191                } 
    141                          
    142192        } 
    143193        else 
  • trunk/A52/ACShepA52Decoder.h

    r43 r50  
    5757//      Implementation 
    5858private: 
     59        void    ACShepA52Decoder::UpgradeOldPrefs(); 
    5960        void    DetermineStreamParameters(); 
    6061        UInt32  SyncA52Stream(UInt32 &bytes_to_read, Byte *input_data, int &a52_flags, int &a52_samplerate, int &a52_bitrate, bool shouldResync); 
  • trunk/A52Preferences/A52Preferences.h

    r43 r50  
    77        IBOutlet NSWindow                                       *window_mainWindow; 
    88        IBOutlet NSPopUpButton                          *popup_ac3DynamicRangeType; 
    9         IBOutlet NSPopUpButton                          *popup_2ChannelMode; 
     9        IBOutlet NSPopUpButton                          *popup_OutputMode; 
    1010         
    1111        IBOutlet NSWindow                                       *window_dynRangeSheet; 
     
    1616        float                                                           dynValue; 
    1717        float                                                           savedDynValue; 
    18         BOOL                                                            useStereo; 
    19         BOOL                                                            useDPL2; 
     18        int                                                                     twoChannelMode; 
    2019} 
    2120 
  • trunk/A52Preferences/A52Preferences.m

    r44 r50  
    11#import "A52Preferences.h" 
     2 
     3#include "a52.h" 
     4 
     5//Old 
     6#define USE_STEREO_KEY @"useStereoOverDolby" 
     7#define USE_DPLII_KEY @"useDolbyProLogicII" 
     8 
     9#define DYNAMIC_RANGE_KEY @"dynamicRange" 
     10#define PASSTHROUGH_KEY @"attemptPassthrough" 
     11#define TWO_CHANNEL_KEY @"twoChannelMode" 
    212 
    313@interface A52Preferences (private) 
     
    1727} 
    1828 
     29- (void)upgradeOldPrefs 
     30{ 
     31        if([defaults boolForKey:USE_STEREO_KEY]) 
     32                twoChannelMode = A52_STEREO; 
     33        else if([defaults boolForKey:USE_DPLII_KEY]) 
     34                twoChannelMode = A52_DOLBY | A52_USE_DPLII; 
     35        else 
     36                twoChannelMode = A52_DOLBY; 
     37         
     38        [defaults setInteger:twoChannelMode forKey:TWO_CHANNEL_KEY]; 
     39} 
     40 
    1941- (void)awakeFromNib 
    2042{ 
    21         if([defaults objectForKey:@"dynamicRange"] != nil) 
    22                 [self setAC3DynamicRange:[defaults floatForKey:@"dynamicRange"]]; 
     43        if([defaults objectForKey:DYNAMIC_RANGE_KEY] != nil) 
     44                [self setAC3DynamicRange:[defaults floatForKey:DYNAMIC_RANGE_KEY]]; 
    2345        else 
    2446                [self setAC3DynamicRange:1.0]; 
    25         if([defaults boolForKey:@"useStereoOverDolby"]
     47        if([defaults objectForKey:TWO_CHANNEL_KEY] != nil
    2648        { 
    27                 useStereo = YES
    28                 useDPL2 = NO; 
    29                 [popup_2ChannelMode selectItemAtIndex:0]; 
    30         } 
    31         else if([defaults boolForKey:@"useDolbyProLogicII"]) 
    32         { 
    33                 useStereo = NO
    34                 useDPL2 = YES; 
    35                 [popup_2ChannelMode selectItemAtIndex:2]
     49                twoChannelMode = [defaults integerForKey:TWO_CHANNEL_KEY]
     50 
     51                /* sanity checks */ 
     52               if(twoChannelMode & A52_CHANNEL_MASK & 0xf7 != 2) 
     53               { 
     54                       /* matches 2 and 10, which is Stereo and Dolby */ 
     55                       twoChannelMode = A52_DOLBY
     56                } 
     57                twoChannelMode &= ~A52_ADJUST_LEVEL & ~A52_LFE
    3658        } 
    3759        else 
    3860        { 
    39                 useStereo = NO; 
    40                 useDPL2 = NO; 
    41                 [popup_2ChannelMode selectItemAtIndex:1];                
     61                [self upgradeOldPrefs]; 
     62        } 
     63        [defaults removeObjectForKey:USE_STEREO_KEY]; 
     64        [defaults removeObjectForKey:USE_DPLII_KEY]; 
     65        switch(twoChannelMode) 
     66        { 
     67                case A52_STEREO: 
     68                        [popup_OutputMode selectItemAtIndex:0]; 
     69                        break; 
     70                case A52_DOLBY: 
     71                        [popup_OutputMode selectItemAtIndex:1]; 
     72                        break; 
     73                case A52_DOLBY | A52_USE_DPLII: 
     74                        [popup_OutputMode selectItemAtIndex:2]; 
     75                        break; 
     76                default: 
     77                        [popup_OutputMode selectItemAtIndex:3]; 
     78                        break; 
    4279        } 
    4380} 
     
    71108- (IBAction)set2ChannelModePopup:(id)sender; 
    72109{ 
    73         int selected = [popup_2ChannelMode indexOfSelectedItem]; 
     110        int selected = [popup_OutputMode indexOfSelectedItem]; 
    74111        switch(selected) 
    75112        { 
    76113                case 0: 
    77                         useStereo = YES; 
    78                         useDPL2 = NO; 
     114                        twoChannelMode = A52_STEREO; 
    79115                        break; 
    80116                case 1: 
    81                         useStereo = NO; 
    82                         useDPL2 = NO; 
     117                        twoChannelMode = A52_DOLBY; 
    83118                        break; 
    84119                case 2: 
    85                         useStereo = NO; 
    86                         useDPL2 = YES; 
     120                        twoChannelMode = A52_DOLBY | A52_USE_DPLII; 
    87121                        break; 
     122                case 3: 
     123                        twoChannelMode = 0; 
    88124                default: 
    89125                        break; 
     
    143179- (IBAction)save:(id)sender 
    144180{ 
    145         [defaults setFloat:dynValue forKey:@"dynamicRange"]; 
    146         [defaults setBool:useStereo forKey:@"useStereoOverDolby"]; 
    147         [defaults setBool:useDPL2 forKey:@"useDolbyProLogicII"]; 
     181        [defaults setFloat:dynValue forKey:DYNAMIC_RANGE_KEY]; 
     182        [defaults setInteger:twoChannelMode forKey:TWO_CHANNEL_KEY]; 
    148183        [defaults synchronize]; 
    149184        [[NSApplication sharedApplication] terminate:nil]; 
  • trunk/A52Preferences/English.lproj/A52CodecPreferences.nib/classes.nib

    r43 r50  
    1515            LANGUAGE = ObjC;  
    1616            OUTLETS = { 
    17                 "popup_2ChannelMode" = NSPopUpButton;  
     17                "popup_OutputMode" = NSPopUpButton;  
    1818                "popup_ac3DynamicRangeType" = NSPopUpButton;  
    1919                "slider_ac3DynamicRangeSlider" = NSSlider;  
  • trunk/A52Preferences/English.lproj/A52CodecPreferences.nib/info.nib

    r44 r50  
    44<dict> 
    55        <key>IBDocumentLocation</key> 
    6         <string>56 11 356 240 0 0 1440 878 </string> 
     6        <string>69 14 356 240 0 0 1680 1028 </string> 
    77        <key>IBEditorPositions</key> 
    88        <dict> 
    99                <key>29</key> 
    10                 <string>58 220 185 44 0 0 1440 878 </string> 
     10                <string>69 259 185 44 0 0 1680 1028 </string> 
    1111        </dict> 
    1212        <key>IBFramework Version</key> 
     
    1414        <key>IBOpenObjects</key> 
    1515        <array> 
     16                <integer>286</integer> 
     17                <integer>29</integer> 
    1618                <integer>21</integer> 
    17                 <integer>29</integer> 
    1819        </array> 
    1920        <key>IBSystem Version</key> 
    20         <string>8P2137</string> 
     21        <string>8P135</string> 
    2122</dict> 
    2223</plist> 
  • trunk/A52Preferences/Preferences-Info.plist

    r41 r50  
    1616        <string>????</string> 
    1717        <key>CFBundleVersion</key> 
    18         <string>1.7.5</string> 
     18        <string>1.7.6</string> 
    1919        <key>NSMainNibFile</key> 
    2020        <string>A52CodecPreferences</string> 
  • trunk/Info-A52Codec__Upgraded_.plist

    r41 r50  
    88        <string>A52Codec</string> 
    99        <key>CFBundleGetInfoString</key> 
    10         <string>1.7.5, CoreAudio A/52 and AC-3 Codec Component</string> 
     10        <string>1.7.6, CoreAudio A/52 and AC-3 Codec Component</string> 
    1111        <key>CFBundleIconFile</key> 
    1212        <string></string> 
     
    2020        <string>BNDL</string> 
    2121        <key>CFBundleShortVersionString</key> 
    22         <string>1.7.5</string> 
     22        <string>1.7.6</string> 
    2323        <key>CFBundleSignature</key> 
    2424        <string>SHEP</string> 
    2525        <key>CFBundleVersion</key> 
    26         <string>1.7.5</string> 
     26        <string>1.7.6</string> 
    2727</dict> 
    2828</plist> 
  • trunk/Info-AC3MovieImport.plist

    r41 r50  
    1616        <string>BNDL</string> 
    1717        <key>CFBundleShortVersionString</key> 
    18         <string>1.7.5</string> 
     18        <string>1.7.6</string> 
    1919        <key>CFBundleSignature</key> 
    2020        <string>eat </string> 
    2121        <key>CFBundleVersion</key> 
    22         <string>1.7.5</string> 
     22        <string>1.7.6</string> 
    2323        <key>CSResourcesFileMapped</key> 
    2424        <true/>