X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=macosx%2FController.m;h=8fcd1ba7b253e223f66028e1ceb59adf2c8f86bc;hb=240cf3308bf21be4d1918a71a5510d07e7d6d85b;hp=e6860859a19bbcfc0620dcb304b6f141a77eae7d;hpb=665ae8c5db12f46dd579455e4647d0ce3ea73de7;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/macosx/Controller.m b/macosx/Controller.m index e6860859..8fcd1ba7 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -427,25 +427,25 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It [fVidRatePopUp addItemWithTitle: NSLocalizedString( @"Same as source", @"" )]; for( int i = 0; i < hb_video_rates_count; i++ ) { - if ([[NSString stringWithCString: hb_video_rates[i].string] isEqualToString: [NSString stringWithFormat: @"%.3f",23.976]]) + if ([[NSString stringWithUTF8String: hb_video_rates[i].string] isEqualToString: [NSString stringWithFormat: @"%.3f",23.976]]) { [fVidRatePopUp addItemWithTitle:[NSString stringWithFormat: @"%@%@", - [NSString stringWithCString: hb_video_rates[i].string], @" (NTSC Film)"]]; + [NSString stringWithUTF8String: hb_video_rates[i].string], @" (NTSC Film)"]]; } - else if ([[NSString stringWithCString: hb_video_rates[i].string] isEqualToString: [NSString stringWithFormat: @"%d",25]]) + else if ([[NSString stringWithUTF8String: hb_video_rates[i].string] isEqualToString: [NSString stringWithFormat: @"%d",25]]) { [fVidRatePopUp addItemWithTitle:[NSString stringWithFormat: @"%@%@", - [NSString stringWithCString: hb_video_rates[i].string], @" (PAL Film/Video)"]]; + [NSString stringWithUTF8String: hb_video_rates[i].string], @" (PAL Film/Video)"]]; } - else if ([[NSString stringWithCString: hb_video_rates[i].string] isEqualToString: [NSString stringWithFormat: @"%.2f",29.97]]) + else if ([[NSString stringWithUTF8String: hb_video_rates[i].string] isEqualToString: [NSString stringWithFormat: @"%.2f",29.97]]) { [fVidRatePopUp addItemWithTitle:[NSString stringWithFormat: @"%@%@", - [NSString stringWithCString: hb_video_rates[i].string], @" (NTSC Video)"]]; + [NSString stringWithUTF8String: hb_video_rates[i].string], @" (NTSC Video)"]]; } else { [fVidRatePopUp addItemWithTitle: - [NSString stringWithCString: hb_video_rates[i].string]]; + [NSString stringWithUTF8String: hb_video_rates[i].string]]; } } [fVidRatePopUp selectItemAtIndex: 0]; @@ -458,7 +458,7 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It for( int i = 0; i < hb_audio_bitrates_count; i++ ) { [fAudTrack1BitratePopUp addItemWithTitle: - [NSString stringWithCString: hb_audio_bitrates[i].string]]; + [NSString stringWithUTF8String: hb_audio_bitrates[i].string]]; } [fAudTrack1BitratePopUp selectItemAtIndex: hb_audio_bitrates_default]; @@ -468,7 +468,7 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It for( int i = 0; i < hb_audio_rates_count; i++ ) { [fAudTrack1RatePopUp addItemWithTitle: - [NSString stringWithCString: hb_audio_rates[i].string]]; + [NSString stringWithUTF8String: hb_audio_rates[i].string]]; } [fAudTrack1RatePopUp selectItemAtIndex: hb_audio_rates_default]; @@ -1098,6 +1098,11 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It if (fHandle) { hb_state_t s; + + hb_get_state( fHandle, &s ); + if (s.state == HB_STATE_SCANNING && ([ident isEqualToString: StartEncodingIdentifier] || [ident isEqualToString: AddToQueueIdentifier])) + return NO; + hb_get_state2( fQueueEncodeLibhb, &s ); if (s.state == HB_STATE_WORKING || s.state == HB_STATE_MUXING) @@ -1398,7 +1403,7 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It browsedSourceDisplayName = [[[path stringByDeletingPathExtension] lastPathComponent] retain]; NSString *mpgname; int n = [[path stringByAppendingString: @"/"] - completePathIntoString: &mpgname caseSensitive: NO + completePathIntoString: &mpgname caseSensitive: YES matchesIntoArray: nil filterTypes: [NSArray arrayWithObject: @"mpg"]]; if (n > 0) @@ -1515,34 +1520,21 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It if( [detector isVideoDVD] ) { + int hb_arch; +#if defined( __LP64__ ) + /* we are 64 bit */ + hb_arch = 64; +#else + /* we are 32 bit */ + hb_arch = 32; +#endif + + // The chosen path was actually on a DVD, so use the raw block // device path instead. path = [detector devicePath]; [self writeToActivityLog: "trying to open a physical dvd at: %s", [scanPath UTF8String]]; -#if defined( __LP64__ ) - /* If we are 64 bit, we cannot read encrypted dvd's as vlc is 32 bit only */ - cancelScanDecrypt = 1; - [self writeToActivityLog: "64 bit mode cannot read dvd's, scan cancelled"]; - /*On Screen Notification*/ - int status; - NSBeep(); - status = NSRunAlertPanel(@"64-bit HandBrake cannot read encrypted dvds!",@"", @"Cancel Scan", @"Attempt Scan Anyway", nil); - [NSApp requestUserAttention:NSCriticalRequest]; - - if (status == NSAlertDefaultReturn) - { - /* User chose to cancel the scan */ - [self writeToActivityLog: "cannot open physical dvd , scan cancelled"]; - cancelScanDecrypt = 1; - } - else - { - [self writeToActivityLog: "user overrode 64-bit warning trying to open physical dvd without decryption"]; - cancelScanDecrypt = 0; - } - -#else /* lets check for vlc here to make sure we have a dylib available to use for decrypting */ NSString *vlcPath = @"/Applications/VLC.app/Contents/MacOS/lib/libdvdcss.2.dylib"; NSFileManager * fileManager = [NSFileManager defaultManager]; @@ -1558,7 +1550,7 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It if (status == NSAlertDefaultReturn) { /* User chose to go download vlc (as they rightfully should) so we send them to the vlc site */ - [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.videolan.org/"]]; + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.videolan.org/vlc/download-macosx.html"]]; } else if (status == NSAlertAlternateReturn) { @@ -1578,7 +1570,110 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It /* VLC was found in /Applications so all is well, we can carry on using vlc's libdvdcss.dylib for decrypting if needed */ [self writeToActivityLog: "VLC app found for decrypting physical dvd"]; } -#endif + /* test for architecture of the vlc app */ + NSArray *vlc_architecturesArray = [[NSBundle bundleWithPath:@"/Applications/VLC.app"] executableArchitectures]; + BOOL vlcIntel32bit = NO; + BOOL vlcIntel64bit = NO; + BOOL vlcPPC32bit = NO; + BOOL vlcPPC64bit = NO; + /* check the available architectures for vlc and note accordingly */ + NSEnumerator *enumerator = [vlc_architecturesArray objectEnumerator]; + id tempObject; + while (tempObject = [enumerator nextObject]) + { + + if ([tempObject intValue] == NSBundleExecutableArchitectureI386) + { + vlcIntel32bit = YES; + } + if ([tempObject intValue] == NSBundleExecutableArchitectureX86_64) + { + vlcIntel64bit = YES; + } + if ([tempObject intValue] == NSBundleExecutableArchitecturePPC) + { + vlcPPC32bit = YES; + } + if ([tempObject intValue] == NSBundleExecutableArchitecturePPC64) + { + vlcPPC64bit = YES; + } + + } + /* Write vlc architecture findings to activity window */ + if (vlcIntel32bit) + { + [self writeToActivityLog: " 32-Bit VLC app found for decrypting physical dvd"]; + } + if (vlcIntel64bit) + { + [self writeToActivityLog: " 64-Bit VLC app found for decrypting physical dvd"]; + } + + + + if (hb_arch == 64 && !vlcIntel64bit && cancelScanDecrypt != 1) + { + + /* we are 64 bit */ + + /* Appropriate VLC not found, so cancel */ + cancelScanDecrypt = 1; + [self writeToActivityLog: "This version of HandBrake is 64 bit, 64 bit version of vlc not found, scan cancelled"]; + /*On Screen Notification*/ + int status; + NSBeep(); + status = NSRunAlertPanel(@"This version of HandBrake is 64 bit, VLC found but not 64 bit!",@"", @"Cancel Scan", @"Attempt Scan Anyway", @"Get 64 bit VLC", nil); + [NSApp requestUserAttention:NSCriticalRequest]; + + if (status == NSAlertDefaultReturn) + { + /* User chose to cancel the scan */ + [self writeToActivityLog: "cannot open physical dvd VLC found but not 64 bit, scan cancelled"]; + cancelScanDecrypt = 1; + } + else if (status == NSAlertDefaultReturn) + { + [self writeToActivityLog: "user overrode 64-bit warning trying to open physical dvd without proper decryption"]; + cancelScanDecrypt = 0; + } + else + { + /* User chose to go download vlc (as they rightfully should) so we send them to the vlc site */ + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.videolan.org/vlc/download-macosx.html"]]; + } + + } + else if (hb_arch == 32 && !vlcIntel32bit && cancelScanDecrypt != 1) + { + /* we are 32 bit */ + /* Appropriate VLC not found, so cancel */ + cancelScanDecrypt = 1; + [self writeToActivityLog: "This version of HandBrake is 32 bit, 32 bit version of vlc not found, scan cancelled"]; + /*On Screen Notification*/ + int status; + NSBeep(); + status = NSRunAlertPanel(@"This version of HandBrake is 32 bit, VLC found but not 32 bit!",@"", @"Cancel Scan", @"Attempt Scan Anyway", @"Get 32 bit VLC", nil); + [NSApp requestUserAttention:NSCriticalRequest]; + + if (status == NSAlertDefaultReturn) + { + /* User chose to cancel the scan */ + [self writeToActivityLog: "cannot open physical dvd VLC found but not 32 bit, scan cancelled"]; + cancelScanDecrypt = 1; + } + else if (status == NSAlertDefaultReturn) + { + [self writeToActivityLog: "user overrode 32-bit warning trying to open physical dvd without proper decryption"]; + cancelScanDecrypt = 0; + } + else + { + /* User chose to go download vlc (as they rightfully should) so we send them to the vlc site */ + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.videolan.org/vlc/download-macosx.html"]]; + } + + } } if (cancelScanDecrypt == 0) @@ -2059,6 +2154,8 @@ fWorkingCount = 0; /* if we are custom anamorphic, store the exact storage, par and display dims */ if (fTitle->job->anamorphic.mode == 3) { + [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->anamorphic.modulus] forKey:@"PicturePARModulus"]; + [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->width] forKey:@"PicturePARStorageWidth"]; [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->height] forKey:@"PicturePARStorageHeight"]; @@ -2775,12 +2872,6 @@ fWorkingCount = 0; if( job->vcodec & HB_VCODEC_X264 ) { - /* Set this flag to switch from Constant Quantizer(default) to Constant Rate Factor Thanks jbrjake - Currently only used with Constant Quality setting*/ - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultCrf"] > 0 && [fVidQualityMatrix selectedRow] == 2) - { - job->crf = 1; - } /* Below Sends x264 options to the core library if x264 is selected*/ /* Lets use this as per Nyx, Thanks Nyx!*/ @@ -3274,12 +3365,7 @@ bool one_burned = FALSE; job->ipod_atom = 0; } - /* Set this flag to switch from Constant Quantizer(default) to Constant Rate Factor Thanks jbrjake - Currently only used with Constant Quality setting*/ - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultCrf"] > 0 && [[queueToApply objectForKey:@"VideoQualityType"] intValue] == 2) - { - job->crf = 1; - } + /* Below Sends x264 options to the core library if x264 is selected*/ /* Lets use this as per Nyx, Thanks Nyx!*/ job->x264opts = (char *)calloc(1024, 1); /* Fixme, this just leaks */ @@ -3313,6 +3399,8 @@ bool one_burned = FALSE; job->width = [[queueToApply objectForKey:@"PicturePARStorageWidth"] intValue]; job->height = [[queueToApply objectForKey:@"PicturePARStorageHeight"] intValue]; + job->anamorphic.modulus = [[queueToApply objectForKey:@"PicturePARModulus"] intValue]; + job->anamorphic.par_width = [[queueToApply objectForKey:@"PicturePARPixelWidth"] intValue]; job->anamorphic.par_height = [[queueToApply objectForKey:@"PicturePARPixelHeight"] intValue]; @@ -4488,10 +4576,7 @@ the user is using "Custom" settings by determining the sender*/ /* As x264 allows for qp/rf values that are fractional, we get the value from the preferences */ int fractionalGranularity = 1 / [[NSUserDefaults standardUserDefaults] floatForKey:@"x264CqSliderFractional"]; [fVidQualitySlider setNumberOfTickMarks:(([fVidQualitySlider maxValue] - [fVidQualitySlider minValue]) * fractionalGranularity) + 1]; - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultCrf"] > 0) - { - qpRFLabelString = @"RF:"; - } + qpRFLabelString = @"RF:"; } /* ffmpeg 1-31 */ if ([[fVidEncoderPopUp selectedItem] tag] == HB_VCODEC_FFMPEG ) @@ -4902,7 +4987,7 @@ the user is using "Custom" settings by determining the sender*/ [fAudTrack1MixPopUp removeAllItems]; [fAudTrack1RatePopUp removeAllItems]; [fAudTrack1BitratePopUp removeAllItems]; - [fAudTrack1DrcSlider setFloatValue: 1.00]; + [fAudTrack1DrcSlider setFloatValue: 0.00]; [self audioDRCSliderChanged: fAudTrack1DrcSlider]; } else if ([[fAudTrack1MixPopUp selectedItem] tag] == HB_ACODEC_AC3 || [[fAudTrack1MixPopUp selectedItem] tag] == HB_ACODEC_DCA) @@ -4926,7 +5011,7 @@ the user is using "Custom" settings by determining the sender*/ [fAudTrack2MixPopUp removeAllItems]; [fAudTrack2RatePopUp removeAllItems]; [fAudTrack2BitratePopUp removeAllItems]; - [fAudTrack2DrcSlider setFloatValue: 1.00]; + [fAudTrack2DrcSlider setFloatValue: 0.00]; [self audioDRCSliderChanged: fAudTrack2DrcSlider]; } else if ([[fAudTrack2MixPopUp selectedItem] tag] == HB_ACODEC_AC3 || [[fAudTrack2MixPopUp selectedItem] tag] == HB_ACODEC_DCA) @@ -4950,7 +5035,7 @@ the user is using "Custom" settings by determining the sender*/ [fAudTrack3MixPopUp removeAllItems]; [fAudTrack3RatePopUp removeAllItems]; [fAudTrack3BitratePopUp removeAllItems]; - [fAudTrack3DrcSlider setFloatValue: 1.00]; + [fAudTrack3DrcSlider setFloatValue: 0.00]; [self audioDRCSliderChanged: fAudTrack3DrcSlider]; } else if ([[fAudTrack3MixPopUp selectedItem] tag] == HB_ACODEC_AC3 || [[fAudTrack3MixPopUp selectedItem] tag] == HB_ACODEC_DCA) @@ -4974,7 +5059,7 @@ the user is using "Custom" settings by determining the sender*/ [fAudTrack4MixPopUp removeAllItems]; [fAudTrack4RatePopUp removeAllItems]; [fAudTrack4BitratePopUp removeAllItems]; - [fAudTrack4DrcSlider setFloatValue: 1.00]; + [fAudTrack4DrcSlider setFloatValue: 0.00]; [self audioDRCSliderChanged: fAudTrack4DrcSlider]; } else if ([[fAudTrack4MixPopUp selectedItem] tag] == HB_ACODEC_AC3 || [[fAudTrack4MixPopUp selectedItem] tag] == HB_ACODEC_DCA) @@ -5002,7 +5087,7 @@ the user is using "Custom" settings by determining the sender*/ { audio = (hb_audio_config_t *) hb_list_audio_config_item( title->list_audio, i ); [[sender menu] addItemWithTitle: - [NSString stringWithCString: audio->lang.description] + [NSString stringWithUTF8String: audio->lang.description] action: NULL keyEquivalent: @""]; } [sender selectItemAtIndex: 0]; @@ -5268,14 +5353,14 @@ the user is using "Custom" settings by determining the sender*/ { NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle: - [NSString stringWithCString: "AC3 Passthru"] + [NSString stringWithUTF8String: "AC3 Passthru"] action: NULL keyEquivalent: @""]; [menuItem setTag: HB_ACODEC_AC3]; } else if (audio->in.codec == HB_ACODEC_DCA && acodec == HB_ACODEC_DCA) { NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle: - [NSString stringWithCString: "DTS Passthru"] + [NSString stringWithUTF8String: "DTS Passthru"] action: NULL keyEquivalent: @""]; [menuItem setTag: HB_ACODEC_DCA]; } @@ -5297,7 +5382,7 @@ the user is using "Custom" settings by determining the sender*/ if (audioCodecsSupportMono == 1) { NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle: - [NSString stringWithCString: hb_audio_mixdowns[0].human_readable_name] + [NSString stringWithUTF8String: hb_audio_mixdowns[0].human_readable_name] action: NULL keyEquivalent: @""]; [menuItem setTag: hb_audio_mixdowns[0].amixdown]; if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[0].amixdown; @@ -5310,7 +5395,7 @@ the user is using "Custom" settings by determining the sender*/ if ((layout == HB_INPUT_CH_LAYOUT_MONO && audioCodecsSupportMono == 0) || layout >= HB_INPUT_CH_LAYOUT_STEREO) { NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle: - [NSString stringWithCString: hb_audio_mixdowns[1].human_readable_name] + [NSString stringWithUTF8String: hb_audio_mixdowns[1].human_readable_name] action: NULL keyEquivalent: @""]; [menuItem setTag: hb_audio_mixdowns[1].amixdown]; if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[1].amixdown; @@ -5321,7 +5406,7 @@ the user is using "Custom" settings by determining the sender*/ if (layout == HB_INPUT_CH_LAYOUT_3F1R || layout == HB_INPUT_CH_LAYOUT_3F2R || layout == HB_INPUT_CH_LAYOUT_DOLBY) { NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle: - [NSString stringWithCString: hb_audio_mixdowns[2].human_readable_name] + [NSString stringWithUTF8String: hb_audio_mixdowns[2].human_readable_name] action: NULL keyEquivalent: @""]; [menuItem setTag: hb_audio_mixdowns[2].amixdown]; if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[2].amixdown; @@ -5332,7 +5417,7 @@ the user is using "Custom" settings by determining the sender*/ if (layout == HB_INPUT_CH_LAYOUT_3F2R) { NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle: - [NSString stringWithCString: hb_audio_mixdowns[3].human_readable_name] + [NSString stringWithUTF8String: hb_audio_mixdowns[3].human_readable_name] action: NULL keyEquivalent: @""]; [menuItem setTag: hb_audio_mixdowns[3].amixdown]; if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[3].amixdown; @@ -5343,7 +5428,7 @@ the user is using "Custom" settings by determining the sender*/ if (audioCodecsSupport6Ch == 1 && layout == HB_INPUT_CH_LAYOUT_3F2R && (audio->in.channel_layout & HB_INPUT_CH_LAYOUT_HAS_LFE)) { NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle: - [NSString stringWithCString: hb_audio_mixdowns[4].human_readable_name] + [NSString stringWithUTF8String: hb_audio_mixdowns[4].human_readable_name] action: NULL keyEquivalent: @""]; [menuItem setTag: hb_audio_mixdowns[4].amixdown]; if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[4].amixdown; @@ -5354,7 +5439,7 @@ the user is using "Custom" settings by determining the sender*/ if (audio->in.codec == HB_ACODEC_AC3 && acodec == HB_ACODEC_AC3) { NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle: - [NSString stringWithCString: hb_audio_mixdowns[5].human_readable_name] + [NSString stringWithUTF8String: hb_audio_mixdowns[5].human_readable_name] action: NULL keyEquivalent: @""]; [menuItem setTag: HB_ACODEC_AC3]; if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[5].amixdown; @@ -5365,7 +5450,7 @@ the user is using "Custom" settings by determining the sender*/ if (audio->in.codec == HB_ACODEC_DCA && acodec == HB_ACODEC_DCA) { NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle: - [NSString stringWithCString: hb_audio_mixdowns[5].human_readable_name] + [NSString stringWithUTF8String: hb_audio_mixdowns[5].human_readable_name] action: NULL keyEquivalent: @""]; [menuItem setTag: HB_ACODEC_DCA]; if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[5].amixdown; @@ -5595,7 +5680,7 @@ the user is using "Custom" settings by determining the sender*/ { /* add a new menuitem for this bitrate */ NSMenuItem *menuItem = [[bitratePopUp menu] addItemWithTitle: - [NSString stringWithCString: hb_audio_bitrates[i].string] + [NSString stringWithUTF8String: hb_audio_bitrates[i].string] action: NULL keyEquivalent: @""]; /* set its tag to be the actual bitrate as an integer, so we can retrieve it later */ [menuItem setTag: hb_audio_bitrates[i].rate]; @@ -5622,7 +5707,7 @@ the user is using "Custom" settings by determining the sender*/ for( int i = 0; i < hb_audio_rates_count; i++ ) { NSMenuItem *menuItem = [[sampleratePopUp menu] addItemWithTitle: - [NSString stringWithCString: hb_audio_rates[i].string] + [NSString stringWithUTF8String: hb_audio_rates[i].string] action: NULL keyEquivalent: @""]; [menuItem setTag: hb_audio_rates[i].rate]; } @@ -5650,7 +5735,7 @@ the user is using "Custom" settings by determining the sender*/ [bitratePopUp setEnabled: NO]; [sampleratePopUp setEnabled: NO]; - [drcSlider setFloatValue: 1.00]; + [drcSlider setFloatValue: 0.00]; [self audioDRCSliderChanged: drcSlider]; [drcSlider setEnabled: NO]; [drcField setEnabled: NO]; @@ -6264,6 +6349,16 @@ return YES; /* First we check to see if we are using the current audio track layout based on AudioList array */ if ([chosenPreset objectForKey:@"AudioList"]) { + + /* pointer to this track's mixdown, codec, sample rate and bitrate NSPopUpButton's */ + NSPopUpButton * trackLangPopUp = nil; + NSPopUpButton * mixdownPopUp = nil; + NSPopUpButton * audiocodecPopUp = nil; + NSPopUpButton * sampleratePopUp = nil; + NSPopUpButton * bitratePopUp = nil; + NSSlider * drcSlider = nil; + + /* Populate the audio widgets based on the contents of the AudioList array */ int i = 0; NSEnumerator *enumerator = [[chosenPreset objectForKey:@"AudioList"] objectEnumerator]; @@ -6273,74 +6368,105 @@ return YES; i++; if( i == 1 ) { - if ([fAudLang1PopUp indexOfSelectedItem] == 0) - { - [fAudLang1PopUp selectItemAtIndex: 1]; - } - [self audioTrackPopUpChanged: fAudLang1PopUp]; - [fAudTrack1CodecPopUp selectItemWithTitle:[tempObject objectForKey:@"AudioEncoder"]]; - /* check our pref for core audio and use it in place of faac if applicable */ - if ([[NSUserDefaults standardUserDefaults] boolForKey: @"UseCoreAudio"] == YES && - [[tempObject objectForKey:@"AudioEncoder"] isEqualToString: @"AAC (faac)"]) - { - [fAudTrack1CodecPopUp selectItemWithTitle:@"AAC (CoreAudio)"]; - } - - [self audioTrackPopUpChanged: fAudTrack1CodecPopUp]; - [fAudTrack1MixPopUp selectItemWithTitle:[tempObject objectForKey:@"AudioMixdown"]]; - /* check to see if the selections was available, if not, rerun audioTrackPopUpChanged using the codec to just set the default - * mixdown*/ - if ([fAudTrack1MixPopUp selectedItem] == nil) - { - [self audioTrackPopUpChanged: fAudTrack1CodecPopUp]; - } - [fAudTrack1RatePopUp selectItemWithTitle:[tempObject objectForKey:@"AudioSamplerate"]]; - /* We set the presets bitrate if it is *not* an AC3 track since that uses the input bitrate */ - if (![[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"AC3 Passthru"]) - { - [fAudTrack1BitratePopUp selectItemWithTitle:[tempObject objectForKey:@"AudioBitrate"]]; - } - [fAudTrack1DrcSlider setFloatValue:[[tempObject objectForKey:@"AudioTrackDRCSlider"] floatValue]]; - [self audioDRCSliderChanged: fAudTrack1DrcSlider]; + trackLangPopUp = fAudLang1PopUp; + mixdownPopUp = fAudTrack1MixPopUp; + audiocodecPopUp = fAudTrack1CodecPopUp; + sampleratePopUp = fAudTrack1RatePopUp; + bitratePopUp = fAudTrack1BitratePopUp; + drcSlider = fAudTrack1DrcSlider; } - if( i == 2 ) { - - if ([fAudLang2PopUp indexOfSelectedItem] == 0) - { - [fAudLang2PopUp selectItemAtIndex: 1]; - } - [self audioTrackPopUpChanged: fAudLang2PopUp]; - [fAudTrack2CodecPopUp selectItemWithTitle:[tempObject objectForKey:@"AudioEncoder"]]; - /* check our pref for core audio and use it in place of faac if applicable */ - if ([[NSUserDefaults standardUserDefaults] boolForKey: @"UseCoreAudio"] == YES && - [[tempObject objectForKey:@"AudioEncoder"] isEqualToString: @"AAC (faac)"]) - { - [fAudTrack2CodecPopUp selectItemWithTitle:@"AAC (CoreAudio)"]; - } - [self audioTrackPopUpChanged: fAudTrack2CodecPopUp]; - [fAudTrack2MixPopUp selectItemWithTitle:[tempObject objectForKey:@"AudioMixdown"]]; - /* check to see if the selections was available, if not, rerun audioTrackPopUpChanged using the codec to just set the default - * mixdown*/ - if ([fAudTrack2MixPopUp selectedItem] == nil) - { - [self audioTrackPopUpChanged: fAudTrack2CodecPopUp]; - } - [fAudTrack2RatePopUp selectItemWithTitle:[tempObject objectForKey:@"AudioSamplerate"]]; - /* We set the presets bitrate if it is *not* an AC3 track since that uses the input bitrate */ - if (![[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"AC3 Passthru"]) + trackLangPopUp = fAudLang2PopUp; + mixdownPopUp = fAudTrack2MixPopUp; + audiocodecPopUp = fAudTrack2CodecPopUp; + sampleratePopUp = fAudTrack2RatePopUp; + bitratePopUp = fAudTrack2BitratePopUp; + drcSlider = fAudTrack2DrcSlider; + } + if( i == 3 ) + { + trackLangPopUp = fAudLang3PopUp; + mixdownPopUp = fAudTrack3MixPopUp; + audiocodecPopUp = fAudTrack3CodecPopUp; + sampleratePopUp = fAudTrack3RatePopUp; + bitratePopUp = fAudTrack3BitratePopUp; + drcSlider = fAudTrack3DrcSlider; + } + if( i == 4 ) + { + trackLangPopUp = fAudLang4PopUp; + mixdownPopUp = fAudTrack4MixPopUp; + audiocodecPopUp = fAudTrack4CodecPopUp; + sampleratePopUp = fAudTrack4RatePopUp; + bitratePopUp = fAudTrack4BitratePopUp; + drcSlider = fAudTrack4DrcSlider; + } + + + if ([trackLangPopUp indexOfSelectedItem] == 0) + { + [trackLangPopUp selectItemAtIndex: 1]; + } + [self audioTrackPopUpChanged: trackLangPopUp]; + [audiocodecPopUp selectItemWithTitle:[tempObject objectForKey:@"AudioEncoder"]]; + /* check our pref for core audio and use it in place of faac if applicable */ + if ([[NSUserDefaults standardUserDefaults] boolForKey: @"UseCoreAudio"] == YES && + [[tempObject objectForKey:@"AudioEncoder"] isEqualToString: @"AAC (faac)"]) + { + [audiocodecPopUp selectItemWithTitle:@"AAC (CoreAudio)"]; + } + + [self audioTrackPopUpChanged: audiocodecPopUp]; + [mixdownPopUp selectItemWithTitle:[tempObject objectForKey:@"AudioMixdown"]]; + /* check to see if the selections was available, if not, rerun audioTrackPopUpChanged using the codec to just set the default + * mixdown*/ + if ([mixdownPopUp selectedItem] == nil) + { + [self audioTrackPopUpChanged: audiocodecPopUp]; + } + [sampleratePopUp selectItemWithTitle:[tempObject objectForKey:@"AudioSamplerate"]]; + /* We set the presets bitrate if it is *not* an AC3 track since that uses the input bitrate */ + if (![[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"AC3 Passthru"]) + { + [bitratePopUp selectItemWithTitle:[tempObject objectForKey:@"AudioBitrate"]]; + } + [drcSlider setFloatValue:[[tempObject objectForKey:@"AudioTrackDRCSlider"] floatValue]]; + [self audioDRCSliderChanged: drcSlider]; + + + /* If we are any track greater than 1 check to make sure we have a matching source codec is using ac3 passthru or dts passthru, + * if not we will set the track to "None". Track 1 is allowed to mixdown to a suitable DPL2 mix if we cannot passthru */ + + if( i > 1 ) + { + /* Check to see if the preset asks for a passhthru track (AC3 or DTS) and verify there is a matching source track if not, set the track to "None". */ + if (([[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"AC3 Passthru"] || [[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"DTS Passthru"]) && [trackLangPopUp indexOfSelectedItem] != 0) { - [fAudTrack2BitratePopUp selectItemWithTitle:[tempObject objectForKey:@"AudioBitrate"]]; + hb_audio_config_t * audio; + /* get the audio source audio codec */ + audio = (hb_audio_config_t *) hb_list_audio_config_item( fTitle->list_audio, [trackLangPopUp indexOfSelectedItem] - 1 ); + if ([[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"AC3 Passthru"] && audio->in.codec != HB_ACODEC_AC3 || + [[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"DTS Passthru"] && audio->in.codec != HB_ACODEC_DCA ) + { + /* We have a preset using ac3 passthru but no ac3 source audio, so set the track to "None" and bail */ + if ([[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"AC3 Passthru"]) + { + [self writeToActivityLog: "Preset calls for AC3 Pass thru ..."]; + } + if ([[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"DTS Passthru"]) + { + [self writeToActivityLog: "Preset calls for DTS Pass thru ..."]; + } + [self writeToActivityLog: "No matching source codec, setting track %d to None", i]; + [trackLangPopUp selectItemAtIndex: 0]; + [self audioTrackPopUpChanged: trackLangPopUp]; + } } - [fAudTrack2DrcSlider setFloatValue:[[tempObject objectForKey:@"AudioTrackDRCSlider"] floatValue]]; - [self audioDRCSliderChanged: fAudTrack2DrcSlider]; - } - } - /* We now cleanup any extra audio tracks that may have been previously set if we need to */ + /* We now cleanup any extra audio tracks that may have been previously set if we need to */ if (i < 4) { @@ -6394,6 +6520,7 @@ return YES; [fAudTrack1DrcSlider setFloatValue:[[chosenPreset objectForKey:@"Audio1TrackDRCSlider"] floatValue]]; [self audioDRCSliderChanged: fAudTrack1DrcSlider]; } + if ([chosenPreset objectForKey:@"Audio2Track"] > 0) { if ([fAudLang2PopUp indexOfSelectedItem] == 0)