Changeset 15

Show
Ignore:
Timestamp:
08/20/06 19:56:21 (2 years ago)
Author:
gbooker
Message:

Added the ability to have preferences

  • Stereo instead of Dolby
  • Dynamic Range Compression

Now to write an app to set the settings.

Files:

Legend:

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

    r13 r15  
    2020//============================================================================= 
    2121 
    22 #define DEBUG 
    2322#define kAudioFormatAVIAC3      0x6D732000 
    2423 
     
    8584         
    8685        remainingBytesFromLastFrame = 0; 
    87         beginningOfIncompleteHeaderSize = 0;     
     86        beginningOfIncompleteHeaderSize = 0; 
     87         
     88        CFPreferencesAppSynchronize(CFSTR("com.cod3r.a52codec")); 
     89        CFTypeRef dynRange = CFPreferencesCopyAppValue(CFSTR("dynamicRange"), CFSTR("com.cod3r.a52codec")); 
     90        if(dynRange != NULL) 
     91        { 
     92                CFTypeID type = CFGetTypeID(dynRange); 
     93                if(type == CFStringGetTypeID()) 
     94                        dynamicRangeCompression = CFStringGetDoubleValue((CFStringRef)dynRange); 
     95                else if(type == CFNumberGetTypeID()) 
     96                        CFNumberGetValue((CFNumberRef)dynRange, kCFNumberDoubleType, &dynamicRangeCompression); 
     97                else 
     98                        dynamicRangeCompression = 1; 
     99        } 
     100        else 
     101                dynamicRangeCompression = 1;  //no compression 
     102         
     103        CFTypeRef stereo = CFPreferencesCopyAppValue(CFSTR("useStereoOverDolby"), CFSTR("com.cod3r.a52codec")); 
     104        if(stereo != NULL) 
     105        { 
     106                CFTypeID type = CFGetTypeID(dynRange); 
     107                if(type == CFStringGetTypeID()) 
     108                        dynamicRangeCompression = CFStringGetIntValue((CFStringRef)dynRange); 
     109                else if(type == CFNumberGetTypeID()) 
     110                        CFNumberGetValue((CFNumberRef)dynRange, kCFNumberIntType, &dynamicRangeCompression); 
     111                else 
     112                        useStereoOverDolby = 0;          
     113        } 
     114        else 
     115                useStereoOverDolby = 0; 
    88116         
    89117        //fprintf(stderr, "ACShepA52Decoder::Constructor: Number of input formats supported: %lu\n", GetNumberSupportedInputFormats()); 
     
    267295} 
    268296 
     297static sample_t dynrng_call (sample_t c, void *data) 
     298{ 
     299        double *level = (double *)data; 
     300        return pow((double)c, *level); 
     301} 
     302 
    269303UInt32 ACShepA52Decoder::ProduceOutputPackets(void* outOutputData, 
    270304                                                                                           UInt32& ioOutputDataByteSize, 
     
    397431                bias = 0; 
    398432        } 
    399          
    400          
     433                 
    401434        while(processed_frames < frames_to_process) { 
    402435                // Redo the entry, for each loop 
     
    438471                                 
    439472                        case 2: 
    440                                 // All we really need is stereophonic, baby  
    441                                 a52_flags = A52_DOLBY | A52_ADJUST_LEVEL;                        
     473                                // All we really need is stereophonic, baby 
     474                                if(useStereoOverDolby) 
     475                                        a52_flags = A52_STEREO | A52_ADJUST_LEVEL; 
     476                                else 
     477                                        a52_flags = A52_DOLBY | A52_ADJUST_LEVEL; 
    442478                                break; 
    443479                                 
     
    459495                readLength = bytes_to_read; 
    460496                input_data = GetBytes(readLength); 
    461                 // TODO: Try to test for stereo return and shift to Dolby? 
    462497                a52_frame(decoder_state, input_data, &a52_flags, &level, bias); 
     498                a52_dynrng(decoder_state, dynrng_call, &dynamicRangeCompression); 
    463499                 
    464500                // Cycle through the blocks, and actually do stuff  
  • trunk/A52/ACShepA52Decoder.h

    r13 r15  
    7272        UInt32  total_bytes; 
    7373         
    74         bool firstInput; 
     74        bool   firstInput; 
    7575         
    7676        //For badly packetized data 
     
    7878        Byte    beginningOfIncompleteHeader[6]; 
    7979        UInt32  beginningOfIncompleteHeaderSize; 
     80         
     81        //Prefs 
     82        bool    useStereoOverDolby; 
     83        double  dynamicRangeCompression; 
    8084}; 
    8185 
  • trunk/A52Codec.xcodeproj/project.pbxproj

    r14 r15  
    803803                                ); 
    804804                                INFOPLIST_FILE = "Info-A52Codec__Upgraded_.plist"; 
    805                                 OTHER_CFLAGS = "-DIS_COMPILER_WORKING=0"; 
     805                                OTHER_CFLAGS = ( 
     806                                        "-DIS_COMPILER_WORKING=0", 
     807                                        "-DDEBUG", 
     808                                ); 
    806809                                OTHER_REZFLAGS = "-d ppc_$ppc -d i386_$i386 -i / -i /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CarbonSound.framework/Versions/A/Headers -I /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers"; 
    807810                                PRODUCT_NAME = A52Codec;