OSDN Git Service

MacGui: Presets now utilize Audio Mixdowns Thanks maurj!
authordynaflash <dynaflash@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Thu, 12 Apr 2007 18:38:40 +0000 (18:38 +0000)
committerdynaflash <dynaflash@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Thu, 12 Apr 2007 18:38:40 +0000 (18:38 +0000)
- Added second audio track support in presets
- Mixdowns regress gracefully depending on current dvd source
- Source Track 2 sets to "None" if one is specified that doesn't exist in current dvd.

Note: in initial testing, second track using 6 channel kills encode performance and yields a track with no sound. Needs to be tested and verified. Main track works flawlessly in initial testing.

git-svn-id: svn://localhost/HandBrake/trunk@499 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/common.c
libhb/common.h
macosx/Controller.h
macosx/Controller.mm
macosx/English.lproj/MainMenu.nib/info.nib
macosx/English.lproj/MainMenu.nib/keyedobjects.nib

index e7bc6db..d1c4cb3 100644 (file)
@@ -45,6 +45,32 @@ hb_mixdown_t hb_audio_mixdowns[] =
 int hb_audio_mixdowns_count = sizeof( hb_audio_mixdowns ) /
                               sizeof( hb_mixdown_t );
 
+int hb_mixdown_get_mixdown_from_short_name( const char * short_name )
+{
+    int i;
+    for (i = 0; i < hb_audio_mixdowns_count; i++)
+    {
+        if (strcmp(hb_audio_mixdowns[i].short_name, short_name) == 0)
+        {
+            return hb_audio_mixdowns[i].amixdown;
+        }
+    }
+    return 0;
+}
+
+const char * hb_mixdown_get_short_name_from_mixdown( int amixdown )
+{
+    int i;
+    for (i = 0; i < hb_audio_mixdowns_count; i++)
+    {
+        if (hb_audio_mixdowns[i].amixdown == amixdown)
+        {
+            return hb_audio_mixdowns[i].short_name;
+        }
+    }
+    return "";
+}
+
 /**********************************************************************
  * hb_reduce
  **********************************************************************
index 3ed8f77..20de051 100644 (file)
@@ -92,6 +92,8 @@ extern int          hb_audio_bitrates_count;
 extern int          hb_audio_bitrates_default;
 extern hb_mixdown_t hb_audio_mixdowns[];
 extern int          hb_audio_mixdowns_count;
+int hb_mixdown_get_mixdown_from_short_name( const char * short_name );
+const char * hb_mixdown_get_short_name_from_mixdown( int amixdown );
 
 /******************************************************************************
  * hb_job_t: settings to be filled by the UI
index 8537718..dd366dd 100644 (file)
 - (IBAction) EncoderPopUpChanged: (id) sender;
 - (IBAction) SetEnabledStateOfAudioMixdownControls: (id) sender;
 - (IBAction) AudioTrackPopUpChanged: (id) sender;
+- (IBAction) AudioTrackPopUpChanged: (id) sender mixdownToUse: (int) mixdownToUse;
 
 - (IBAction) BrowseFile: (id) sender;
 - (void)     BrowseFileDone: (NSSavePanel *) sheet
index 0cbc20f..20c7b87 100644 (file)
@@ -1170,8 +1170,8 @@ static int FormatSettings[3][4] =
 
        /* changing the title may have changed the audio channels on offer, */
        /* so call AudioTrackPopUpChanged for both audio tracks to update the mixdown popups */
-       [self AudioTrackPopUpChanged: fAudLang1PopUp];
-       [self AudioTrackPopUpChanged: fAudLang2PopUp];
+       [self AudioTrackPopUpChanged: fAudLang1PopUp mixdownToUse: 0];
+       [self AudioTrackPopUpChanged: fAudLang2PopUp mixdownToUse: 0];
 
 }
 
@@ -1269,8 +1269,8 @@ static int FormatSettings[3][4] =
 
        /* changing the format may mean that we can / can't offer mono or 6ch, */
        /* so call AudioTrackPopUpChanged for both audio tracks to update the mixdown popups */
-       [self AudioTrackPopUpChanged: fAudLang1PopUp];
-       [self AudioTrackPopUpChanged: fAudLang2PopUp];
+       [self AudioTrackPopUpChanged: fAudLang1PopUp mixdownToUse: 0];
+       [self AudioTrackPopUpChanged: fAudLang2PopUp mixdownToUse: 0];
 
        /* We call method method to change UI to reflect whether a preset is used or not*/
        [self CustomSettingUsed: sender];       
@@ -1315,8 +1315,8 @@ static int FormatSettings[3][4] =
 
        /* changing the codecs on offer may mean that we can / can't offer mono or 6ch, */
        /* so call AudioTrackPopUpChanged for both audio tracks to update the mixdown popups */
-       [self AudioTrackPopUpChanged: fAudLang1PopUp];
-       [self AudioTrackPopUpChanged: fAudLang2PopUp];
+       [self AudioTrackPopUpChanged: fAudLang1PopUp mixdownToUse: 0];
+       [self AudioTrackPopUpChanged: fAudLang2PopUp mixdownToUse: 0];
 
     [self CalculateBitrate: sender];
     /* We call method method to change UI to reflect whether a preset is used or not*/
@@ -1371,6 +1371,11 @@ static int FormatSettings[3][4] =
 
 - (IBAction) AudioTrackPopUpChanged: (id) sender
 {
+    [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;
@@ -1517,16 +1522,26 @@ static int FormatSettings[3][4] =
                 
                 /* for now, this is hard-coded to a "best" mixdown of HB_AMIXDOWN_DOLBYPLII */
                 /* ultimately this should be a prefs option */
-                int prefsMixdown = HB_AMIXDOWN_DOLBYPLII;
+                int useMixdown;
                 
-                /* if prefsMixdown > maxMixdownUsed, then use maxMixdownUsed */
-                if (prefsMixdown > maxMixdownUsed) prefsMixdown = maxMixdownUsed;
+                /* 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 prefsMixdown < minMixdownUsed, then use minMixdownUsed */
-                if (prefsMixdown < minMixdownUsed) prefsMixdown = minMixdownUsed;
+                /* if useMixdown < minMixdownUsed, then use minMixdownUsed */
+                if (useMixdown < minMixdownUsed) useMixdown = minMixdownUsed;
 
                 /* select the (possibly-amended) preferred mixdown */
-                [mixdownPopUp selectItemWithTag: prefsMixdown];
+                [mixdownPopUp selectItemWithTag: useMixdown];
             
             }
 
@@ -1832,8 +1847,24 @@ the user is using "Custom" settings by determining the sender*/
        /*Audio*/
        /* Audio Language One*/
        [preset setObject:[fAudLang1PopUp titleOfSelectedItem] forKey:@"AudioLang1"];
-       /* Audio Language One Surround Sound Checkbox*/
-//     [preset setObject:[NSNumber numberWithInt:[fAudLang1SurroundCheck state]] forKey:@"AudioLang1Surround"];
+       /* Audio Track one mixdown */
+    if ([fAudLang1PopUp indexOfSelectedItem] > 0) {
+        [preset setObject:[NSString stringWithCString:hb_mixdown_get_short_name_from_mixdown([[fAudTrack1MixPopUp selectedItem] tag])] forKey:@"AudioLang1Mixdown"];
+    }
+    else
+    {
+        [preset setObject:[NSString stringWithCString:""] forKey:@"AudioLang1Mixdown"];
+    }
+       /* Audio Language Two*/
+       [preset setObject:[fAudLang2PopUp titleOfSelectedItem] forKey:@"AudioLang2"];
+       /* Audio Track Two mixdown */
+    if ([fAudLang2PopUp indexOfSelectedItem] > 0) {
+        [preset setObject:[NSString stringWithCString:hb_mixdown_get_short_name_from_mixdown([[fAudTrack2MixPopUp selectedItem] tag])] forKey:@"AudioLang2Mixdown"];
+    }
+    else
+    {
+        [preset setObject:[NSString stringWithCString:""] forKey:@"AudioLang2Mixdown"];
+    }
        /* Audio Sample Rate*/
        [preset setObject:[fAudRatePopUp titleOfSelectedItem] forKey:@"AudioSampleRate"];
        /* Audio Bitrate Rate*/
@@ -2120,7 +2151,6 @@ the user is using "Custom" settings by determining the sender*/
                [fDisplayX264Options setStringValue: [NSString stringWithFormat:[chosenPreset valueForKey:@"x264Option"]]];
                /* Lets run through the following functions to get variables set there */
                [self EncoderPopUpChanged: NULL];
-               [self AudioTrackPopUpChanged: NULL];
                [self CalculateBitrate: NULL];
                
                /* Video quality */
@@ -2145,9 +2175,45 @@ the user is using "Custom" settings by determining the sender*/
                /*Audio*/
                /* Audio Language One*/
                [fAudLang1PopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"AudioLang1"]]];
-               /* Audio Language One Surround Sound Checkbox*/
-//             [fAudLang1SurroundCheck setState:[[chosenPreset objectForKey:@"AudioLang1Surround"] intValue]];
-               [self AudioTrackPopUpChanged: NULL];
+               /* We check to make sure something is selected for track 1 */
+               if ([fAudLang1PopUp indexOfSelectedItem] == -1)
+               {
+                       /* If not we choose the first source in the track 1 dropdown */
+                       [fAudLang1PopUp selectItemAtIndex: 0];
+               }
+
+        /* if the preset contains a mixdown value for track 1, then try and load it */
+        /* if the preset contains the empty string for this value, then we'll get
+           a mixdown of 0 from hb_mixdown_get_mixdown_from_short_name,
+           which will be correctly ignored by AudioTrackPopUpChanged */
+        /* if the mixdown is unavailable, AudioTrackPopUpChanged will choose the next best mixdown */
+        char cBuffer1[32];
+        NSString * short_name1 = [NSString stringWithFormat:[chosenPreset valueForKey:@"AudioLang1Mixdown"]];
+        [short_name1 getCString:cBuffer1];
+        int mixdown1 = hb_mixdown_get_mixdown_from_short_name(cBuffer1);
+        [self AudioTrackPopUpChanged: fAudLang1PopUp mixdownToUse: mixdown1];
+
+               /* Audio Language Two*/
+               [fAudLang2PopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"AudioLang2"]]];
+               /* We check to make sure something is selected for track 2 */
+               if ([fAudLang2PopUp indexOfSelectedItem] == -1)
+               {
+                       /* If not we choose "None" in the track 2 dropdown */
+                       [fAudLang2PopUp selectItemWithTitle: [NSString stringWithFormat:@"None"]];
+                       //[self SetEnabledStateOfAudioMixdownControls: sender];
+               }
+               /* if the preset contains a mixdown value for track 2, then try and load it */
+        /* if the preset contains the empty string for this value, then we'll get
+           a mixdown of 0 from hb_mixdown_get_mixdown_from_short_name,
+           which will be correctly ignored by AudioTrackPopUpChanged */
+        /* if the mixdown is unavailable, AudioTrackPopUpChanged will choose the next best mixdown */
+        char cBuffer2[32];
+        NSString * short_name2 = [NSString stringWithFormat:[chosenPreset valueForKey:@"AudioLang2Mixdown"]];
+        [short_name2 getCString:cBuffer2];
+        int mixdown2 = hb_mixdown_get_mixdown_from_short_name(cBuffer2);
+        [self AudioTrackPopUpChanged: fAudLang2PopUp mixdownToUse: mixdown2];
+       
+               
                /* Audio Sample Rate*/
                [fAudRatePopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"AudioSampleRate"]]];
                /* Audio Bitrate Rate*/
index 65baf20..1f041f6 100644 (file)
@@ -19,8 +19,8 @@
        </array>
        <key>IBOpenObjects</key>
        <array>
-               <integer>21</integer>
                <integer>29</integer>
+               <integer>21</integer>
        </array>
        <key>IBSystem Version</key>
        <string>8P2137</string>
index 0eb8c26..21448ee 100644 (file)
Binary files a/macosx/English.lproj/MainMenu.nib/keyedobjects.nib and b/macosx/English.lproj/MainMenu.nib/keyedobjects.nib differ