Changeset 43
- Timestamp:
- 04/07/07 17:33:17 (2 years ago)
- Files:
-
- trunk/A52/ACShepA52Decoder.cpp (modified) (3 diffs)
- trunk/A52/ACShepA52Decoder.h (modified) (1 diff)
- trunk/A52Preferences/A52Preferences.h (modified) (1 diff)
- trunk/A52Preferences/A52Preferences.m (modified) (5 diffs)
- trunk/A52Preferences/English.lproj/A52CodecPreferences.nib/classes.nib (modified) (2 diffs)
- trunk/A52Preferences/English.lproj/A52CodecPreferences.nib/info.nib (modified) (1 diff)
- trunk/A52Preferences/English.lproj/A52CodecPreferences.nib/keyedobjects.nib (modified) (previous)
- trunk/Read Me.rtf (modified) (2 diffs)
- trunk/liba52/include/a52.h (modified) (1 diff)
- trunk/liba52/liba52/a52_internal.h (modified) (1 diff)
- trunk/liba52/liba52/downmix.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/A52/ACShepA52Decoder.cpp
r40 r43 73 73 dynamicRangeCompression = 1; //no compression 74 74 75 int useStereoOverDolby = 0; 75 76 CFTypeRef stereo = CFPreferencesCopyAppValue(CFSTR("useStereoOverDolby"), CFSTR("com.cod3r.a52codec")); 76 77 if(stereo != NULL) … … 81 82 else if(type == CFNumberGetTypeID()) 82 83 CFNumberGetValue((CFNumberRef)stereo, kCFNumberIntType, &useStereoOverDolby); 83 else 84 useStereoOverDolby = 0;84 else if(type == CFBooleanGetTypeID()) 85 useStereoOverDolby = CFBooleanGetValue((CFBooleanRef)stereo); 85 86 CFRelease(stereo); 86 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; 87 107 else 88 useStereoOverDolby = 0;108 TwoChannelMode = A52_DOLBY; 89 109 90 110 CFTypeRef pass = CFPreferencesCopyAppValue(CFSTR("attemptPassthrough"), CFSTR("com.cod3r.a52codec")); … … 564 584 case 2: 565 585 // All we really need is stereophonic, baby 566 if(useStereoOverDolby) 567 a52_flags = A52_STEREO | A52_ADJUST_LEVEL; 568 else 569 a52_flags = A52_DOLBY | A52_ADJUST_LEVEL; 586 a52_flags = TwoChannelMode; 570 587 break; 571 588 trunk/A52/ACShepA52Decoder.h
r38 r43 80 80 81 81 //Prefs 82 bool useStereoOverDolby;82 int TwoChannelMode; 83 83 double dynamicRangeCompression; 84 84 bool passthrough; trunk/A52Preferences/A52Preferences.h
r40 r43 5 5 @interface A52Preferences : NSObject 6 6 { 7 IBOutlet NSWindow *window_mainWindow; 8 IBOutlet NSPopUpButton *popup_ac3DynamicRangeType; 9 IBOutlet NSPopUpButton *popup_2ChannelMode; 10 11 IBOutlet NSWindow *window_dynRangeSheet; 7 12 IBOutlet NSTextField *textField_ac3DynamicRangeValue; 8 13 IBOutlet NSSlider *slider_ac3DynamicRangeSlider; 9 IBOutlet NSButton *button_stereo;10 14 11 15 NSUserDefaults *defaults; 12 16 float dynValue; 17 float savedDynValue; 18 BOOL useStereo; 19 BOOL useDPL2; 13 20 } 21 22 - (IBAction)setAC3DynamicRangePopup:(id)sender; 23 - (IBAction)set2ChannelModePopup:(id)sender; 14 24 15 25 - (IBAction)setAC3DynamicRangeValue:(id)sender; 16 26 - (IBAction)setAC3DynamicRangeSlider:(id)sender; 27 - (IBAction)cancelDynRangeSheet:(id)sender; 28 - (IBAction)saveDynRangeSheet:(id)sender; 17 29 18 30 - (IBAction)cancel:(id)sender; trunk/A52Preferences/A52Preferences.m
r40 r43 24 24 [self setAC3DynamicRange:1.0]; 25 25 if([defaults boolForKey:@"useStereoOverDolby"]) 26 [button_stereo setIntValue:1]; 26 { 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]; 36 } 27 37 else 28 [button_stereo setIntValue:0]; 38 { 39 useStereo = NO; 40 useDPL2 = NO; 41 [popup_2ChannelMode selectItemAtIndex:1]; 42 } 29 43 } 30 44 … … 33 47 [defaults release]; 34 48 [super dealloc]; 49 } 50 51 - (IBAction)setAC3DynamicRangePopup:(id)sender 52 { 53 int selected = [popup_ac3DynamicRangeType indexOfSelectedItem]; 54 switch(selected) 55 { 56 case 0: 57 [self setAC3DynamicRange:1.0]; 58 break; 59 case 1: 60 [self setAC3DynamicRange:2.0]; 61 break; 62 case 2: 63 savedDynValue = dynValue; 64 [NSApp beginSheet:window_dynRangeSheet modalForWindow:window_mainWindow modalDelegate:nil didEndSelector:nil contextInfo:NULL]; 65 break; 66 default: 67 break; 68 } 69 } 70 71 - (IBAction)set2ChannelModePopup:(id)sender; 72 { 73 int selected = [popup_2ChannelMode indexOfSelectedItem]; 74 switch(selected) 75 { 76 case 0: 77 useStereo = YES; 78 useDPL2 = NO; 79 break; 80 case 1: 81 useStereo = NO; 82 useDPL2 = NO; 83 break; 84 case 2: 85 useStereo = NO; 86 useDPL2 = YES; 87 break; 88 default: 89 break; 90 } 35 91 } 36 92 … … 45 101 [textField_ac3DynamicRangeValue setFloatValue:newVal]; 46 102 [slider_ac3DynamicRangeSlider setFloatValue:newVal]; 103 if(newVal == 1.0) 104 [popup_ac3DynamicRangeType selectItemAtIndex:0]; 105 else if(newVal == 2.0) 106 [popup_ac3DynamicRangeType selectItemAtIndex:1]; 107 else 108 [popup_ac3DynamicRangeType selectItemAtIndex:2]; 47 109 } 48 110 … … 61 123 } 62 124 125 - (IBAction)cancelDynRangeSheet:(id)sender 126 { 127 [self setAC3DynamicRange:savedDynValue]; 128 [NSApp endSheet:window_dynRangeSheet]; 129 [window_dynRangeSheet orderOut:self]; 130 } 131 132 - (IBAction)saveDynRangeSheet:(id)sender; 133 { 134 [NSApp endSheet:window_dynRangeSheet]; 135 [window_dynRangeSheet orderOut:self]; 136 } 137 63 138 - (IBAction)cancel:(id)sender 64 139 { … … 69 144 { 70 145 [defaults setFloat:dynValue forKey:@"dynamicRange"]; 71 if([button_stereo intValue] != 0) 72 [defaults setBool:YES forKey:@"useStereoOverDolby"]; 73 else 74 [defaults setBool:NO forKey:@"useStereoOverDolby"]; 146 [defaults setBool:useStereo forKey:@"useStereoOverDolby"]; 147 [defaults setBool:useDPL2 forKey:@"useDolbyProLogicII"]; 75 148 [defaults synchronize]; 76 149 [[NSApplication sharedApplication] terminate:nil]; trunk/A52Preferences/English.lproj/A52CodecPreferences.nib/classes.nib
r40 r43 4 4 ACTIONS = { 5 5 cancel = id; 6 cancelDynRangeSheet = id; 6 7 save = id; 8 saveDynRangeSheet = id; 9 set2ChannelModePopup = id; 10 setAC3DynamicRangePopup = id; 7 11 setAC3DynamicRangeSlider = id; 8 12 setAC3DynamicRangeValue = id; … … 11 15 LANGUAGE = ObjC; 12 16 OUTLETS = { 13 "button_stereo" = NSButton; 17 "popup_2ChannelMode" = NSPopUpButton; 18 "popup_ac3DynamicRangeType" = NSPopUpButton; 14 19 "slider_ac3DynamicRangeSlider" = NSSlider; 15 20 "textField_ac3DynamicRangeValue" = NSTextField; 21 "window_dynRangeSheet" = NSWindow; 22 "window_mainWindow" = NSWindow; 16 23 }; 17 24 SUPERCLASS = NSObject; trunk/A52Preferences/English.lproj/A52CodecPreferences.nib/info.nib
r40 r43 14 14 <key>IBOpenObjects</key> 15 15 <array> 16 <integer>29</integer> 16 17 <integer>21</integer> 17 <integer>2 9</integer>18 <integer>286</integer> 18 19 </array> 19 20 <key>IBSystem Version</key> trunk/Read Me.rtf
r41 r43 1 {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf4 201 {\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410 2 2 {\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;} 3 3 {\colortbl;\red255\green255\blue255;} … … 61 61 \'a5 Fixed an incorrect assumption about sample rates.\ 62 62 \'a5 Fixed an error with an incomplete sample at the end of a file\ 63 \'a5 Added the ability to output Pro Logic II\ 63 64 \ 64 65 trunk/liba52/include/a52.h
r1 r43 53 53 #define A52_ADJUST_LEVEL 32 54 54 55 // this next constant can be ORed with A52_DOLBY to tell liba52 to use 5.0 DPLII matrix encoding, 56 // rather than just 4.0 Dolby Surround matrix encoding 57 #define A52_USE_DPLII 64 58 55 59 a52_state_t * a52_init (uint32_t mm_accel); 56 60 sample_t * a52_samples (a52_state_t * state); trunk/liba52/liba52/a52_internal.h
r1 r43 94 94 #define LEVEL_6DB 0.5 95 95 96 // these next two constants are used for DPL matrix encoding in downmix.c 97 #define LEVEL_SQRT_1_2 0.5 98 #define LEVEL_SQRT_3_4 0.8660254037844386 99 96 100 #define EXP_REUSE (0) 97 101 #define EXP_D15 (1) trunk/liba52/liba52/downmix.c
r1 r43 35 35 sample_t clev, sample_t slev) 36 36 { 37 37 38 static uint8_t table[11][8] = { 38 39 {A52_CHANNEL, A52_DOLBY, A52_STEREO, A52_STEREO, … … 149 150 } 150 151 152 // add the DPLII flag back into the output if it was passed in 153 output = output | (flags & A52_USE_DPLII); 154 151 155 return output; 152 156 } … … 395 399 } 396 400 397 static void mix22toS (sample_t * samples, sample_t bias) 398 { 399 int i; 400 sample_t surround; 401 402 for (i = 0; i < 256; i++) { 403 surround = samples[i + 512] + samples[i + 768]; 404 samples[i] += bias - surround; 405 samples[i + 256] += bias + surround; 406 } 401 static void mix22toS (sample_t * samples, sample_t bias, int use_dpl2) 402 { 403 if (use_dpl2 == 1) { 404 int i; 405 sample_t Lt, Rt, Ls, Rs, Lss, Rss; 406 407 for (i = 0; i < 256; i++) { 408 409 Lt = samples[i]; 410 Rt = samples[i + 256]; 411 412 Ls = samples[i + 512]; 413 Rs = samples[i + 768]; 414 415 Lss = (LEVEL_SQRT_3_4 * Ls) - (LEVEL_SQRT_1_2 * Rs); 416 Rss = -(LEVEL_SQRT_1_2 * Ls) + (LEVEL_SQRT_3_4 * Rs); 417 418 samples[i] = Lt + Lss; 419 samples[i + 256] = Rt + Rss; 420 } 421 } else { 422 int i; 423 sample_t surround; 424 425 for (i = 0; i < 256; i++) { 426 surround = samples[i + 512] + samples[i + 768]; 427 samples[i] += bias - surround; 428 samples[i + 256] += bias + surround; 429 } 430 } 407 431 } 408 432 … … 419 443 } 420 444 421 static void mix32toS (sample_t * samples, sample_t bias) 422 { 423 int i; 424 sample_t common, surround; 425 426 for (i = 0; i < 256; i++) { 427 common = samples[i + 256] + bias; 428 surround = samples[i + 768] + samples[i + 1024]; 429 samples[i] += common - surround; 430 samples[i + 256] = samples[i + 512] + common + surround; 431 } 445 static void mix32toS (sample_t * samples, sample_t bias, int use_dpl2) 446 { 447 448 if (use_dpl2 == 1) { 449 450 int i; 451 sample_t cc, Lt, Rt, Ls, Rs, Lss, Rss; 452 453 for (i = 0; i < 256; i++) { 454 455 cc = samples[i + 256] * LEVEL_3DB; 456 457 Lt = samples[i] + cc; 458 Rt = samples[i + 512] + cc; 459 460 Ls = samples[i + 768]; 461 Rs = samples[i + 1024]; 462 463 Lss = (LEVEL_SQRT_3_4 * Ls) - (LEVEL_SQRT_1_2 * Rs); 464 Rss = -(LEVEL_SQRT_1_2 * Ls) + (LEVEL_SQRT_3_4 * Rs); 465 466 samples[i] = Lt + Lss; 467 samples[i + 256] = Rt + Rss; 468 469 } 470 471 } else { 472 473 int i; 474 sample_t common, surround; 475 476 for (i = 0; i < 256; i++) { 477 common = samples[i + 256] + bias; 478 surround = samples[i + 768] + samples[i + 1024]; 479 samples[i] += common - surround; 480 samples[i + 256] = samples[i + 512] + common + surround; 481 } 482 483 } 484 432 485 } 433 486 … … 524 577 525 578 case CONVERT (A52_2F2R, A52_DOLBY): 526 mix22toS (samples, bias );579 mix22toS (samples, bias, ((output & A52_USE_DPLII) == A52_USE_DPLII)); 527 580 break; 528 581 … … 534 587 535 588 case CONVERT (A52_3F2R, A52_DOLBY): 536 mix32toS (samples, bias );589 mix32toS (samples, bias, ((output & A52_USE_DPLII) == A52_USE_DPLII)); 537 590 break; 538 591
