-
- /* this method can be used to find a language, or a language-and-source-format combination, by passing in the appropriate string */
- /* e.g. to find the first French track, pass in an NSString * of "Francais" */
- /* e.g. to find the first English 5.1 AC3 track, pass in an NSString * of "English (AC3) (5.1 ch)" */
- /* if no matching track is found, then selectIndexIfNotFound is used to choose which track to select instead */
- if (hb_list_count( fTitle->list_audio ) != 0)
- {
- if (searchPrefixString)
- {
-
- for( int i = 0; i < [sender numberOfItems]; i++ )
- {
- /* Try to find the desired search string */
- if ([[[sender itemAtIndex: i] title] hasPrefix:searchPrefixString])
- {
- [sender selectItemAtIndex: i];
- return;
- }
- }
- /* couldn't find the string, so select the requested "search string not found" item */
- /* index of 0 means select the "none" item */
- /* index of 1 means select the first audio track */
- [sender selectItemAtIndex: selectIndexIfNotFound];
- }
- else
- {
- /* if no search string is provided, then select the selectIndexIfNotFound item */
- [sender selectItemAtIndex: selectIndexIfNotFound];
- }
- }
- else
- {
- [sender selectItemAtIndex: 0];
- }
-
-}
-- (IBAction) audioAddAudioTrackCodecs: (id)sender
-{
- int format = [fDstFormatPopUp indexOfSelectedItem];
-
- /* setup pointers to the appropriate popups for the correct track */
- NSPopUpButton * audiocodecPopUp;
- NSPopUpButton * audiotrackPopUp;
- if (sender == fAudTrack1CodecPopUp)
- {
- audiotrackPopUp = fAudLang1PopUp;
- audiocodecPopUp = fAudTrack1CodecPopUp;
- }
- else if (sender == fAudTrack2CodecPopUp)
- {
- audiotrackPopUp = fAudLang2PopUp;
- audiocodecPopUp = fAudTrack2CodecPopUp;
- }
- else if (sender == fAudTrack3CodecPopUp)
- {
- audiotrackPopUp = fAudLang3PopUp;
- audiocodecPopUp = fAudTrack3CodecPopUp;
- }
- else
- {
- audiotrackPopUp = fAudLang4PopUp;
- audiocodecPopUp = fAudTrack4CodecPopUp;
- }
-
- [audiocodecPopUp removeAllItems];
- /* Make sure "None" isnt selected in the source track */
- if ([audiotrackPopUp indexOfSelectedItem] > 0)
- {
- [audiocodecPopUp setEnabled:YES];
- NSMenuItem *menuItem;
- /* We setup our appropriate popups for codecs and put the int value in the popup tag for easy retrieval */
- switch( format )
- {
- case 0:
- /* MP4 */
- // CA_AAC
- menuItem = [[audiocodecPopUp menu] addItemWithTitle:@"AAC (CoreAudio)" action: NULL keyEquivalent: @""];
- [menuItem setTag: HB_ACODEC_CA_AAC];
- // FAAC
- menuItem = [[audiocodecPopUp menu] addItemWithTitle:@"AAC (faac)" action: NULL keyEquivalent: @""];
- [menuItem setTag: HB_ACODEC_FAAC];
- // MP3
- menuItem = [[audiocodecPopUp menu] addItemWithTitle:@"MP3 (lame)" action: NULL keyEquivalent: @""];
- [menuItem setTag: HB_ACODEC_LAME];
- // AC3 Passthru
- menuItem = [[audiocodecPopUp menu] addItemWithTitle:@"AC3 Passthru" action: NULL keyEquivalent: @""];
- [menuItem setTag: HB_ACODEC_AC3];
- break;
-
- case 1:
- /* MKV */
- // CA_AAC
- menuItem = [[audiocodecPopUp menu] addItemWithTitle:@"AAC (CoreAudio)" action: NULL keyEquivalent: @""];
- [menuItem setTag: HB_ACODEC_CA_AAC];
- // FAAC
- menuItem = [[audiocodecPopUp menu] addItemWithTitle:@"AAC (faac)" action: NULL keyEquivalent: @""];
- [menuItem setTag: HB_ACODEC_FAAC];
- // AC3 Passthru
- menuItem = [[audiocodecPopUp menu] addItemWithTitle:@"AC3 Passthru" action: NULL keyEquivalent: @""];
- [menuItem setTag: HB_ACODEC_AC3];
- // DTS Passthru
- menuItem = [[audiocodecPopUp menu] addItemWithTitle:@"DTS Passthru" action: NULL keyEquivalent: @""];
- [menuItem setTag: HB_ACODEC_DCA];
- // MP3
- menuItem = [[audiocodecPopUp menu] addItemWithTitle:@"MP3 (lame)" action: NULL keyEquivalent: @""];
- [menuItem setTag: HB_ACODEC_LAME];
- // Vorbis
- menuItem = [[audiocodecPopUp menu] addItemWithTitle:@"Vorbis (vorbis)" action: NULL keyEquivalent: @""];
- [menuItem setTag: HB_ACODEC_VORBIS];
- break;
- }
- [audiocodecPopUp selectItemAtIndex:0];
- }
- else
- {
- [audiocodecPopUp setEnabled:NO];
- }
-}
-
-- (IBAction) audioTrackPopUpChanged: (id) sender
-{
- /* utility function to call audioTrackPopUpChanged without passing in a mixdown-to-use */
- [self audioTrackPopUpChanged: sender mixdownToUse: 0];
-}
-
-- (IBAction) audioTrackPopUpChanged: (id) sender mixdownToUse: (int) mixdownToUse
-{
-
- /* make sure we have a selected title before continuing */
- if (fTitle == NULL) return;
- /* make sure we have a source audio track before continuing */
- if (hb_list_count( fTitle->list_audio ) == 0)
- {
- [sender selectItemAtIndex:0];
- return;
- }
- /* if the sender is the lanaguage popup and there is nothing in the codec popup, lets call
- * audioAddAudioTrackCodecs on the codec popup to populate it properly before moving on
- */
- if (sender == fAudLang1PopUp && [[fAudTrack1CodecPopUp menu] numberOfItems] == 0)
- {
- [self audioAddAudioTrackCodecs: fAudTrack1CodecPopUp];
- }
- if (sender == fAudLang2PopUp && [[fAudTrack2CodecPopUp menu] numberOfItems] == 0)
- {
- [self audioAddAudioTrackCodecs: fAudTrack2CodecPopUp];
- }
- if (sender == fAudLang3PopUp && [[fAudTrack3CodecPopUp menu] numberOfItems] == 0)
- {
- [self audioAddAudioTrackCodecs: fAudTrack3CodecPopUp];
- }
- if (sender == fAudLang4PopUp && [[fAudTrack4CodecPopUp menu] numberOfItems] == 0)
- {
- [self audioAddAudioTrackCodecs: fAudTrack4CodecPopUp];
- }
-
- /* Now lets make the sender the appropriate Audio Track popup from this point on */
- if (sender == fAudTrack1CodecPopUp || sender == fAudTrack1MixPopUp)
- {
- sender = fAudLang1PopUp;
- }
- if (sender == fAudTrack2CodecPopUp || sender == fAudTrack2MixPopUp)
- {
- sender = fAudLang2PopUp;
- }
- if (sender == fAudTrack3CodecPopUp || sender == fAudTrack3MixPopUp)
- {
- sender = fAudLang3PopUp;
- }
- if (sender == fAudTrack4CodecPopUp || sender == fAudTrack4MixPopUp)
- {
- sender = fAudLang4PopUp;
- }
-
- /* pointer to this track's mixdown, codec, sample rate and bitrate NSPopUpButton's */
- NSPopUpButton * mixdownPopUp;
- NSPopUpButton * audiocodecPopUp;
- NSPopUpButton * sampleratePopUp;
- NSPopUpButton * bitratePopUp;
- if (sender == fAudLang1PopUp)
- {
- mixdownPopUp = fAudTrack1MixPopUp;
- audiocodecPopUp = fAudTrack1CodecPopUp;
- sampleratePopUp = fAudTrack1RatePopUp;
- bitratePopUp = fAudTrack1BitratePopUp;
- }
- else if (sender == fAudLang2PopUp)
- {
- mixdownPopUp = fAudTrack2MixPopUp;
- audiocodecPopUp = fAudTrack2CodecPopUp;
- sampleratePopUp = fAudTrack2RatePopUp;
- bitratePopUp = fAudTrack2BitratePopUp;
- }
- else if (sender == fAudLang3PopUp)
- {
- mixdownPopUp = fAudTrack3MixPopUp;
- audiocodecPopUp = fAudTrack3CodecPopUp;
- sampleratePopUp = fAudTrack3RatePopUp;
- bitratePopUp = fAudTrack3BitratePopUp;
- }
- else
- {
- mixdownPopUp = fAudTrack4MixPopUp;
- audiocodecPopUp = fAudTrack4CodecPopUp;
- sampleratePopUp = fAudTrack4RatePopUp;
- bitratePopUp = fAudTrack4BitratePopUp;
- }
-
- /* get the index of the selected audio Track*/
- int thisAudioIndex = [sender indexOfSelectedItem] - 1;
-
- /* pointer for the hb_audio_s struct we will use later on */
- hb_audio_config_t * audio;
-
- int acodec;
- /* check if the audio mixdown controls need their enabled state changing */
- [self setEnabledStateOfAudioMixdownControls:nil];
-
- if (thisAudioIndex != -1)
- {
-
- /* get the audio */
- audio = (hb_audio_config_t *) hb_list_audio_config_item( fTitle->list_audio, thisAudioIndex );// Should "fTitle" be title and be setup ?
-
- /* actually manipulate the proper mixdowns here */
- /* delete the previous audio mixdown options */
- [mixdownPopUp removeAllItems];
-
- acodec = [[audiocodecPopUp selectedItem] tag];
-
- if (audio != NULL)
- {
-
- /* find out if our selected output audio codec supports 6ch */
- int audioCodecsSupport6Ch = (audio->in.codec && acodec != HB_ACODEC_LAME);
-
- /* check for AC-3 passthru */
- if (audio->in.codec == HB_ACODEC_AC3 && acodec == HB_ACODEC_AC3)
- {
-
- NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle:
- [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 stringWithUTF8String: "DTS Passthru"]
- action: NULL keyEquivalent: @""];
- [menuItem setTag: HB_ACODEC_DCA];
- }
- else
- {
-
- /* add the appropriate audio mixdown menuitems to the popupbutton */
- /* in each case, we set the new menuitem's tag to be the amixdown value for that mixdown,
- so that we can reference the mixdown later */
-
- /* keep a track of the min and max mixdowns we used, so we can select the best match later */
- int minMixdownUsed = 0;
- int maxMixdownUsed = 0;
-
- /* get the input channel layout without any lfe channels */
- int layout = audio->in.channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK;
-
- /* add a mono option */
- NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle:
- [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;
- maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[0].amixdown);
-
- /* do we want to add a stereo option? */
- /* offer stereo if we have a stereo-or-better source */
- if (layout >= HB_INPUT_CH_LAYOUT_STEREO)
- {
- NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle:
- [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;
- maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[1].amixdown);
- }
-
- /* do we want to add a dolby surround (DPL1) option? */
- 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 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;
- maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[2].amixdown);
- }
-
- /* do we want to add a dolby pro logic 2 (DPL2) option? */
- if (layout == HB_INPUT_CH_LAYOUT_3F2R)
- {
- NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle:
- [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;
- maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[3].amixdown);
- }
-
- /* do we want to add a 6-channel discrete option? */
- 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 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;
- maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[4].amixdown);
- }
-
- /* do we want to add an AC-3 passthrough option? */
- if (audio->in.codec == HB_ACODEC_AC3 && acodec == HB_ACODEC_AC3)
- {
- NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle:
- [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;
- maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[5].amixdown);
- }
-
- /* do we want to add a DTS Passthru option ? HB_ACODEC_DCA*/
- if (audio->in.codec == HB_ACODEC_DCA && acodec == HB_ACODEC_DCA)
- {
- NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle:
- [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;
- maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[5].amixdown);
- }
-
- /* auto-select the best mixdown based on our saved mixdown preference */
-
- /* for now, this is hard-coded to a "best" mixdown of HB_AMIXDOWN_DOLBYPLII */
- /* ultimately this should be a prefs option */
- int useMixdown;
-
- /* if we passed in a mixdown to use - in order to load a preset - then try and use it */
- if (mixdownToUse > 0)
- {
- useMixdown = mixdownToUse;
- }
- else
- {
- useMixdown = HB_AMIXDOWN_DOLBYPLII;
- }
-
- /* if useMixdown > maxMixdownUsed, then use maxMixdownUsed */
- if (useMixdown > maxMixdownUsed)
- {
- useMixdown = maxMixdownUsed;
- }
-
- /* if useMixdown < minMixdownUsed, then use minMixdownUsed */
- if (useMixdown < minMixdownUsed)
- {
- useMixdown = minMixdownUsed;
- }
-
- /* select the (possibly-amended) preferred mixdown */
- [mixdownPopUp selectItemWithTag: useMixdown];
-
- }
- /* In the case of a source track that is not AC3 and the user tries to use AC3 Passthru (which does not work)
- * we force the Audio Codec choice back to a workable codec. We use CoreAudio aac for all containers.
- */
- if (audio->in.codec != HB_ACODEC_AC3 && [[audiocodecPopUp selectedItem] tag] == HB_ACODEC_AC3)
- {
- [audiocodecPopUp selectItemWithTag: HB_ACODEC_CA_AAC];
- }
-
- /* In the case of a source track that is not DTS and the user tries to use DTS Passthru (which does not work)
- * we force the Audio Codec choice back to a workable codec. We use CoreAudio aac for all containers.
- */
- if (audio->in.codec != HB_ACODEC_DCA && [[audiocodecPopUp selectedItem] tag] == HB_ACODEC_DCA)
- {
- [audiocodecPopUp selectItemWithTag: HB_ACODEC_CA_AAC];
- }
-
- /* Setup our samplerate and bitrate popups we will need based on mixdown */
- [self audioTrackMixdownChanged: mixdownPopUp];
- }
-
- }
- if( [fDstFormatPopUp indexOfSelectedItem] == 0 )
- {
- [self autoSetM4vExtension: sender];
- }
-}
-
-- (IBAction) audioTrackMixdownChanged: (id) sender
-{
-
- int acodec;
- /* setup pointers to all of the other audio track controls
- * we will need later
- */
- NSPopUpButton * mixdownPopUp;
- NSPopUpButton * sampleratePopUp;
- NSPopUpButton * bitratePopUp;
- NSPopUpButton * audiocodecPopUp;
- NSPopUpButton * audiotrackPopUp;
- NSSlider * drcSlider;
- NSTextField * drcField;
- if (sender == fAudTrack1MixPopUp)
- {
- audiotrackPopUp = fAudLang1PopUp;
- audiocodecPopUp = fAudTrack1CodecPopUp;
- mixdownPopUp = fAudTrack1MixPopUp;
- sampleratePopUp = fAudTrack1RatePopUp;
- bitratePopUp = fAudTrack1BitratePopUp;
- drcSlider = fAudTrack1DrcSlider;
- drcField = fAudTrack1DrcField;
- }
- else if (sender == fAudTrack2MixPopUp)
- {
- audiotrackPopUp = fAudLang2PopUp;
- audiocodecPopUp = fAudTrack2CodecPopUp;
- mixdownPopUp = fAudTrack2MixPopUp;
- sampleratePopUp = fAudTrack2RatePopUp;
- bitratePopUp = fAudTrack2BitratePopUp;
- drcSlider = fAudTrack2DrcSlider;
- drcField = fAudTrack2DrcField;
- }
- else if (sender == fAudTrack3MixPopUp)
- {
- audiotrackPopUp = fAudLang3PopUp;
- audiocodecPopUp = fAudTrack3CodecPopUp;
- mixdownPopUp = fAudTrack3MixPopUp;
- sampleratePopUp = fAudTrack3RatePopUp;
- bitratePopUp = fAudTrack3BitratePopUp;
- drcSlider = fAudTrack3DrcSlider;
- drcField = fAudTrack3DrcField;
- }
- else
- {
- audiotrackPopUp = fAudLang4PopUp;
- audiocodecPopUp = fAudTrack4CodecPopUp;
- mixdownPopUp = fAudTrack4MixPopUp;
- sampleratePopUp = fAudTrack4RatePopUp;
- bitratePopUp = fAudTrack4BitratePopUp;
- drcSlider = fAudTrack4DrcSlider;
- drcField = fAudTrack4DrcField;
- }
- acodec = [[audiocodecPopUp selectedItem] tag];
- /* storage variable for the min and max bitrate allowed for this codec */
- int minbitrate;
- int maxbitrate;
-
- switch( acodec )
- {
- case HB_ACODEC_FAAC:
- /* check if we have a 6ch discrete conversion in either audio track */
- if ([[mixdownPopUp selectedItem] tag] == HB_AMIXDOWN_6CH)
- {
- /* FAAC has a minimum of 192 kbps for 6-channel discrete */
- minbitrate = 192;
- /* If either mixdown popup includes 6-channel discrete, then allow up to 768 kbps */
- maxbitrate = 768;
- break;
- }
- else
- {
- /* FAAC is happy using our min bitrate of 32 kbps for stereo or mono */
- minbitrate = 32;
- /* note: haven't dealt with mono separately here, FAAC will just use the max it can */
- maxbitrate = 320;
- break;
- }
-
- case HB_ACODEC_CA_AAC:
- /* check if we have a 6ch discrete conversion in either audio track */
- if ([[mixdownPopUp selectedItem] tag] == HB_AMIXDOWN_6CH)
- {
- minbitrate = 128;
- maxbitrate = 768;
- break;
- }
- else
- {
- minbitrate = 64;
- maxbitrate = 320;
- break;
- }
-
- case HB_ACODEC_LAME:
- /* Lame is happy using our min bitrate of 32 kbps */
- minbitrate = 32;
- /* Lame won't encode if the bitrate is higher than 320 kbps */
- maxbitrate = 320;
- break;
-
- case HB_ACODEC_VORBIS:
- if ([[mixdownPopUp selectedItem] tag] == HB_AMIXDOWN_6CH)
- {
- /* Vorbis causes a crash if we use a bitrate below 192 kbps with 6 channel */
- minbitrate = 192;
- /* If either mixdown popup includes 6-channel discrete, then allow up to 384 kbps */
- maxbitrate = 384;
- break;
- }
- else
- {
- /* Vorbis causes a crash if we use a bitrate below 48 kbps */
- minbitrate = 48;
- /* Vorbis can cope with 384 kbps quite happily, even for stereo */
- maxbitrate = 384;
- break;
- }
-
- default:
- /* AC3 passthru disables the bitrate dropdown anyway, so we might as well just use the min and max bitrate */
- minbitrate = 32;
- maxbitrate = 384;
-
- }
-
- /* make sure we have a selected title before continuing */
- if (fTitle == NULL || hb_list_count( fTitle->list_audio ) == 0) return;
- /* get the audio so we can find out what input rates are*/
- hb_audio_config_t * audio;
- audio = (hb_audio_config_t *) hb_list_audio_config_item( fTitle->list_audio, [audiotrackPopUp indexOfSelectedItem] - 1 );
- int inputbitrate = audio->in.bitrate / 1000;
- int inputsamplerate = audio->in.samplerate;
-
- if ([[mixdownPopUp selectedItem] tag] != HB_ACODEC_AC3 && [[mixdownPopUp selectedItem] tag] != HB_ACODEC_DCA)
- {
- [bitratePopUp removeAllItems];
-
- for( int i = 0; i < hb_audio_bitrates_count; i++ )
- {
- if (hb_audio_bitrates[i].rate >= minbitrate && hb_audio_bitrates[i].rate <= maxbitrate)
- {
- /* add a new menuitem for this bitrate */
- NSMenuItem *menuItem = [[bitratePopUp menu] addItemWithTitle:
- [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];
- }
- }
-
- /* select the default bitrate (but use 384 for 6-ch AAC) */
- if ([[mixdownPopUp selectedItem] tag] == HB_AMIXDOWN_6CH)
- {
- [bitratePopUp selectItemWithTag: 384];
- }
- else
- {
- [bitratePopUp selectItemWithTag: hb_audio_bitrates[hb_audio_bitrates_default].rate];
- }
- }
- /* populate and set the sample rate popup */
- /* Audio samplerate */
- [sampleratePopUp removeAllItems];
- /* we create a same as source selection (Auto) so that we can choose to use the input sample rate */
- NSMenuItem *menuItem = [[sampleratePopUp menu] addItemWithTitle: @"Auto" action: NULL keyEquivalent: @""];
- [menuItem setTag: inputsamplerate];
-
- for( int i = 0; i < hb_audio_rates_count; i++ )
- {
- NSMenuItem *menuItem = [[sampleratePopUp menu] addItemWithTitle:
- [NSString stringWithUTF8String: hb_audio_rates[i].string]
- action: NULL keyEquivalent: @""];
- [menuItem setTag: hb_audio_rates[i].rate];
- }
- /* We use the input sample rate as the default sample rate as downsampling just makes audio worse
- * and there is no compelling reason to use anything else as default, though the users default
- * preset will likely override any setting chosen here.
- */
- [sampleratePopUp selectItemWithTag: inputsamplerate];
-
-
- /* Since AC3 Pass Thru and DTS Pass Thru uses the input bitrate and sample rate, we get the input tracks
- * bitrate and display it in the bitrate popup even though libhb happily ignores any bitrate input from
- * the gui. We do this for better user feedback in the audio tab as well as the queue for the most part
- */
- if ([[mixdownPopUp selectedItem] tag] == HB_ACODEC_AC3 || [[mixdownPopUp selectedItem] tag] == HB_ACODEC_DCA)
- {
-
- /* lets also set the bitrate popup to the input bitrate as thats what passthru will use */
- [bitratePopUp removeAllItems];
- NSMenuItem *menuItem = [[bitratePopUp menu] addItemWithTitle:
- [NSString stringWithFormat:@"%d", inputbitrate]
- action: NULL keyEquivalent: @""];
- [menuItem setTag: inputbitrate];
- /* For ac3 passthru we disable the sample rate and bitrate popups as well as the drc slider*/
- [bitratePopUp setEnabled: NO];
- [sampleratePopUp setEnabled: NO];
-
- [drcSlider setFloatValue: 0.00];
- [self audioDRCSliderChanged: drcSlider];
- [drcSlider setEnabled: NO];
- [drcField setEnabled: NO];
- }
- else
- {
- [sampleratePopUp setEnabled: YES];
- [bitratePopUp setEnabled: YES];
- [drcSlider setEnabled: YES];
- [drcField setEnabled: YES];
- }
-[self calculateBitrate:nil];
-}
-
-- (IBAction) audioDRCSliderChanged: (id) sender
-{
- NSSlider * drcSlider;
- NSTextField * drcField;
- if (sender == fAudTrack1DrcSlider)
- {
- drcSlider = fAudTrack1DrcSlider;
- drcField = fAudTrack1DrcField;
- }
- else if (sender == fAudTrack2DrcSlider)
- {
- drcSlider = fAudTrack2DrcSlider;
- drcField = fAudTrack2DrcField;
- }
- else if (sender == fAudTrack3DrcSlider)
- {
- drcSlider = fAudTrack3DrcSlider;
- drcField = fAudTrack3DrcField;
- }
- else
- {
- drcSlider = fAudTrack4DrcSlider;
- drcField = fAudTrack4DrcField;
- }
-
- /* If we are between 0.0 and 1.0 on the slider, snap it to 1.0 */
- if ([drcSlider floatValue] > 0.0 && [drcSlider floatValue] < 1.0)
- {
- [drcSlider setFloatValue:1.0];
- }
-
-
- [drcField setStringValue: [NSString stringWithFormat: @"%.2f", [drcSlider floatValue]]];
- /* For now, do not call this until we have an intelligent way to determine audio track selections
- * compared to presets
- */
- //[self customSettingUsed: sender];
-}
-
-#pragma mark -
-
-- (IBAction) browseImportSrtFile: (id) sender
-{
-
- NSOpenPanel * panel;
-
- panel = [NSOpenPanel openPanel];
- [panel setAllowsMultipleSelection: NO];
- [panel setCanChooseFiles: YES];
- [panel setCanChooseDirectories: NO ];
- NSString * sourceDirectory;
- if ([[NSUserDefaults standardUserDefaults] stringForKey:@"LastSrtImportDirectory"])
- {
- sourceDirectory = [[NSUserDefaults standardUserDefaults] stringForKey:@"LastSrtImportDirectory"];
- }
- else
- {
- sourceDirectory = @"~/Desktop";
- sourceDirectory = [sourceDirectory stringByExpandingTildeInPath];
- }
- /* we open up the browse srt sheet here and call for browseImportSrtFileDone after the sheet is closed */
- NSArray *fileTypes = [NSArray arrayWithObjects:@"plist", @"srt", nil];
- [panel beginSheetForDirectory: sourceDirectory file: nil types: fileTypes
- modalForWindow: fWindow modalDelegate: self
- didEndSelector: @selector( browseImportSrtFileDone:returnCode:contextInfo: )
- contextInfo: sender];
-}
-
-- (void) browseImportSrtFileDone: (NSSavePanel *) sheet
- returnCode: (int) returnCode contextInfo: (void *) contextInfo
-{
- if( returnCode == NSOKButton )