OSDN Git Service

MacGui: Adds a popup menu item for Hadamard-transformed exhaustive motion estimation...
[handbrake-jp/handbrake-jp-git.git] / macosx / Controller.mm
index 0e43904..7ab9aac 100644 (file)
@@ -9,6 +9,8 @@
 #import "HBPreferencesController.h"
 #import "HBDVDDetector.h"
 #import "HBPresets.h"
+#import "HBPreviewController.h"
+#import "HBFilterController.h"
 
 #define DragDropSimplePboardType       @"MyCustomOutlineViewPboardType"
 
@@ -18,6 +20,7 @@ static NSString *        StartEncodingIdentifier            = @"Start Encoding I
 static NSString *        PauseEncodingIdentifier            = @"Pause Encoding Item Identifier";
 static NSString *        ShowQueueIdentifier                = @"Show Queue Item Identifier";
 static NSString *        AddToQueueIdentifier               = @"Add to Queue Item Identifier";
+static NSString *        ShowPictureIdentifier             = @"Show Picture Window Item Identifier";
 static NSString *        ShowActivityIdentifier             = @"Debug Output Item Identifier";
 static NSString *        ChooseSourceIdentifier             = @"Choose Source Item Identifier";
 
@@ -34,7 +37,7 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
     {
         return nil;
     }
-
+    
     [HBPreferencesController registerUserDefaults];
     fHandle = NULL;
     fQueueEncodeLibhb = NULL;
@@ -42,24 +45,31 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
      * outputPanel needs it right away, as may other future methods
      */
     NSString *libraryDir = [NSSearchPathForDirectoriesInDomains( NSLibraryDirectory,
-                                                                 NSUserDomainMask,
-                                                                 YES ) objectAtIndex:0];
+                                                                NSUserDomainMask,
+                                                                YES ) objectAtIndex:0];
     AppSupportDirectory = [[libraryDir stringByAppendingPathComponent:@"Application Support"]
-                                       stringByAppendingPathComponent:@"HandBrake"];
+                           stringByAppendingPathComponent:@"HandBrake"];
     if( ![[NSFileManager defaultManager] fileExistsAtPath:AppSupportDirectory] )
     {
         [[NSFileManager defaultManager] createDirectoryAtPath:AppSupportDirectory
                                                    attributes:nil];
     }
-
+    /* Check for and create the App Support Preview directory if necessary */
+    NSString *PreviewDirectory = [AppSupportDirectory stringByAppendingPathComponent:@"Previews"];
+    if( ![[NSFileManager defaultManager] fileExistsAtPath:PreviewDirectory] )
+    {
+        [[NSFileManager defaultManager] createDirectoryAtPath:PreviewDirectory
+                                                   attributes:nil];
+    }                                                            
     outputPanel = [[HBOutputPanelController alloc] init];
-    fPictureController = [[PictureController alloc] initWithDelegate:self];
+    fPictureController = [[PictureController alloc] init];
+    fPictureFilterController = [[PictureFilterController alloc] init];
     fQueueController = [[HBQueueController alloc] init];
     fAdvancedOptions = [[HBAdvancedController alloc] init];
     /* we init the HBPresets class which currently is only used
-    * for updating built in presets, may move more functionality
-    * there in the future
-    */
+     * for updating built in presets, may move more functionality
+     * there in the future
+     */
     fPresetsBuiltin = [[HBPresets alloc] init];
     fPreferencesController = [[HBPreferencesController alloc] init];
     /* Lets report the HandBrake version number here to the activity log and text log file */
@@ -73,14 +83,20 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
 - (void) applicationDidFinishLaunching: (NSNotification *) notification
 {
     /* Init libhb with check for updates libhb style set to "0" so its ignored and lets sparkle take care of it */
-    fHandle = hb_init(HB_DEBUG_ALL, 0);
+    int loggingLevel = [[[NSUserDefaults standardUserDefaults] objectForKey:@"LoggingLevel"] intValue];
+    fHandle = hb_init(loggingLevel, 0);
     /* Init a separate instance of libhb for user scanning and setting up jobs */
-    fQueueEncodeLibhb = hb_init(HB_DEBUG_ALL, 0);
+    fQueueEncodeLibhb = hb_init(loggingLevel, 0);
     
        // Set the Growl Delegate
     [GrowlApplicationBridge setGrowlDelegate: self];
     /* Init others controllers */
     [fPictureController SetHandle: fHandle];
+    [fPictureController   setHBController: self];
+    /* fPictureController */
+    [fPictureFilterController SetHandle: fHandle];
+    [fPictureFilterController   setHBController: self];
+    
     [fQueueController   setHandle: fQueueEncodeLibhb];
     [fQueueController   setHBController: self];
 
@@ -88,6 +104,9 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
     [fChapterTable setDataSource:fChapterTitlesDelegate];
     [fChapterTable setDelegate:fChapterTitlesDelegate];
 
+    [fPresetsOutlineView setAutosaveName:@"Presets View"];
+    [fPresetsOutlineView setAutosaveExpandedItems:YES];
+
     /* Call UpdateUI every 1/2 sec */
     [[NSRunLoop currentRunLoop] addTimer:[NSTimer
                                           scheduledTimerWithTimeInterval:0.5 target:self
@@ -151,10 +170,16 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
     }
     else
     {
+        /* We show whichever open source window specified in LaunchSourceBehavior preference key */
+        if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"LaunchSourceBehavior"] isEqualToString: @"Open Source"])
+        {
+            [self browseSources:nil];
+        }
         
-        /* Show Browse Sources Window ASAP */
-        [self performSelectorOnMainThread:@selector(browseSources:)
-                               withObject:nil waitUntilDone:NO];
+        if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"LaunchSourceBehavior"] isEqualToString: @"Open Source (Title Specific)"])
+        {
+            [self browseSources:(id)fOpenSourceTitleMMenu];
+        }
     }
 }
 
@@ -163,8 +188,16 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
     if (returnCode == NSAlertOtherReturn)
     {
         [self clearQueueAllItems];
-        [self performSelectorOnMainThread:@selector(browseSources:)
-                           withObject:nil waitUntilDone:NO];
+        /* We show whichever open source window specified in LaunchSourceBehavior preference key */
+        if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"LaunchSourceBehavior"] isEqualToString: @"Open Source"])
+        {
+            [self browseSources:nil];
+        }
+        
+        if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"LaunchSourceBehavior"] isEqualToString: @"Open Source (Title Specific)"])
+        {
+            [self browseSources:(id)fOpenSourceTitleMMenu];
+        }
     }
     else
     {
@@ -175,20 +208,23 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
 
 - (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication *) app
 {
-    // Warn if encoding a movie
+    if ([fPreviewController fullScreen] == YES)
+    {
+        [fPreviewController goWindowedScreen:nil];
+    }
+    
     hb_state_t s;
-    hb_get_state( fHandle, &s );
+    hb_get_state( fQueueEncodeLibhb, &s );
     
     if ( s.state != HB_STATE_IDLE )
     {
         int result = NSRunCriticalAlertPanel(
-                NSLocalizedString(@"Are you sure you want to quit HandBrake?", nil),
-                NSLocalizedString(@"If you quit HandBrake, your movie will be lost. Do you want to quit anyway?", nil),
-                NSLocalizedString(@"Quit", nil), NSLocalizedString(@"Don't Quit", nil), nil, @"A movie" );
+                                             NSLocalizedString(@"Are you sure you want to quit HandBrake?", nil),
+                                             NSLocalizedString(@"If you quit HandBrake your current encode will be reloaded into your queue at next launch. Do you want to quit anyway?", nil),
+                                             NSLocalizedString(@"Quit", nil), NSLocalizedString(@"Don't Quit", nil), nil, @"A movie" );
         
         if (result == NSAlertDefaultReturn)
         {
-            [self doCancelCurrentJob];
             return NSTerminateNow;
         }
         else
@@ -196,12 +232,12 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
     }
     
     // Warn if items still in the queue
-    else if ( hb_count( fHandle ) > 0 )
+    else if ( fPendingCount > 0 )
     {
         int result = NSRunCriticalAlertPanel(
-                NSLocalizedString(@"Are you sure you want to quit HandBrake?", nil),
-                NSLocalizedString(@"One or more encodes are queued for encoding. Do you want to quit anyway?", nil),
-                NSLocalizedString(@"Quit", nil), NSLocalizedString(@"Don't Quit", nil), nil);
+                                             NSLocalizedString(@"Are you sure you want to quit HandBrake?", nil),
+                                             NSLocalizedString(@"There are pending encodes in your queue. Do you want to quit anyway?",nil),
+                                             NSLocalizedString(@"Quit", nil), NSLocalizedString(@"Don't Quit", nil), nil);
         
         if ( result == NSAlertDefaultReturn )
             return NSTerminateNow;
@@ -217,6 +253,10 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
        [browsedSourceDisplayName release];
     [outputPanel release];
        [fQueueController release];
+    [fPictureController release];
+    [fPictureFilterController release];
+    
+    [fPreviewController release];
        hb_close(&fHandle);
     hb_close(&fQueueEncodeLibhb);
 }
@@ -248,13 +288,16 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
 
        /* Show/Dont Show Presets drawer upon launch based
                on user preference DefaultPresetsDrawerShow*/
-       if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultPresetsDrawerShow"] > 0)
+       if( [[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultPresetsDrawerShow"] > 0 )
        {
+        [fPresetDrawer setDelegate:self];
+        NSSize drawerSize = NSSizeFromString( [[NSUserDefaults standardUserDefaults] 
+                                              stringForKey:@"Drawer Size"] );
+        if( drawerSize.width )
+            [fPresetDrawer setContentSize: drawerSize];
                [fPresetDrawer open];
        }
-       
-       
-    
+
     /* Destination box*/
     NSMenuItem *menuItem;
     [fDstFormatPopUp removeAllItems];
@@ -373,13 +416,12 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
 - (void) enableUI: (bool) b
 {
     NSControl * controls[] =
-      { fSrcTitleField, fSrcTitlePopUp,
+    { fSrcTitleField, fSrcTitlePopUp,
         fSrcChapterField, fSrcChapterStartPopUp, fSrcChapterToField,
         fSrcChapterEndPopUp, fSrcDuration1Field, fSrcDuration2Field,
         fDstFormatField, fDstFormatPopUp, fDstFile1Field, fDstFile2Field,
-        fDstBrowseButton, fVidRateField, fVidRatePopUp,
-        fVidEncoderField, fVidEncoderPopUp, fVidQualityField,
-        fVidQualityMatrix, fVidGrayscaleCheck, fSubField, fSubPopUp,
+        fDstBrowseButton, fVidRateField, fVidRatePopUp,fVidEncoderField, fVidEncoderPopUp, fVidQualityField,
+        fPictureSizeField,fPictureCroppingField, fVideoFiltersField,fVidQualityMatrix, fSubField, fSubPopUp,
         fAudSourceLabel, fAudCodecLabel, fAudMixdownLabel, fAudSamplerateLabel, fAudBitrateLabel,
         fAudTrack1Label, fAudTrack2Label, fAudTrack3Label, fAudTrack4Label,
         fAudLang1PopUp, fAudLang2PopUp, fAudLang3PopUp, fAudLang4PopUp,
@@ -389,16 +431,12 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
         fAudTrack1BitratePopUp, fAudTrack2BitratePopUp, fAudTrack3BitratePopUp, fAudTrack4BitratePopUp,
         fAudDrcLabel, fAudTrack1DrcSlider, fAudTrack1DrcField, fAudTrack2DrcSlider,
         fAudTrack2DrcField, fAudTrack3DrcSlider, fAudTrack3DrcField, fAudTrack4DrcSlider,fAudTrack4DrcField,
-        fPictureButton,fQueueStatus,fPicSettingARkeep, fPicSettingDeinterlace,fPicLabelSettings,fPicLabelSrc,
-        fPicLabelOutp,fPicSettingsSrc,fPicSettingsOutp,fPicSettingsAnamorphic,
-               fPicLabelAr,fPicLabelDeinterlace,fPicSettingPAR,fPicLabelAnamorphic,fPresetsAdd,fPresetsDelete,
-               fCreateChapterMarkers,fVidTurboPassCheck,fDstMp4LargeFileCheck,fPicLabelAutoCrop,
-               fPicSettingAutoCrop,fPicSettingDetelecine,fPicLabelDetelecine,fPicLabelDenoise,fPicSettingDenoise,
-        fSubForcedCheck,fPicSettingDeblock,fPicLabelDeblock,fPicLabelDecomb,fPicSettingDecomb,fPresetsOutlineView,
-        fAudDrcLabel,fDstMp4HttpOptFileCheck,fDstMp4iPodFileCheck};
-
+        fQueueStatus,fPresetsAdd,fPresetsDelete,
+               fCreateChapterMarkers,fVidTurboPassCheck,fDstMp4LargeFileCheck,fSubForcedCheck,fPresetsOutlineView,
+    fAudDrcLabel,fDstMp4HttpOptFileCheck,fDstMp4iPodFileCheck};
+    
     for( unsigned i = 0;
-         i < sizeof( controls ) / sizeof( NSControl * ); i++ )
+        i < sizeof( controls ) / sizeof( NSControl * ); i++ )
     {
         if( [[controls[i] className] isEqualToString: @"NSTextField"] )
         {
@@ -406,29 +444,28 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
             if( ![tf isBezeled] )
             {
                 [tf setTextColor: b ? [NSColor controlTextColor] :
-                    [NSColor disabledControlTextColor]];
+                 [NSColor disabledControlTextColor]];
                 continue;
             }
         }
         [controls[i] setEnabled: b];
-
+        
     }
-
+    
        if (b) {
-
+        
         /* if we're enabling the interface, check if the audio mixdown controls need to be enabled or not */
         /* these will have been enabled by the mass control enablement above anyway, so we're sense-checking it here */
         [self setEnabledStateOfAudioMixdownControls:nil];
         /* we also call calculatePictureSizing here to sense check if we already have vfr selected */
         [self calculatePictureSizing:nil];
-        [self shouldEnableHttpMp4CheckBox: nil];
-
+        
        } else {
-
+        
                [fPresetsOutlineView setEnabled: NO];
-
+        
        }
-
+    
     [self videoMatrixChanged:nil];
     [fAdvancedOptions enableUI:b];
 }
@@ -747,8 +784,11 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
                 [fWindow setFrame:frame display:YES animate:YES];
                                fRipIndicatorShown = NO;
                        }
-            
-                       /* Check to see if the encode state has not been cancelled
+            /* Since we are done with this encode, tell output to stop writing to the
+             * individual encode log
+             */
+                       [outputPanel endEncodeLog];
+            /* Check to see if the encode state has not been cancelled
              to determine if we should check for encode done notifications */
                        if( fEncodeState != 2 )
             {
@@ -901,7 +941,17 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
         [item setTarget: self];
         [item setAction: @selector(Pause:)];
     }
-    else if ([itemIdent isEqualToString: ShowActivityIdentifier]) {
+    else if ([itemIdent isEqualToString: ShowPictureIdentifier])
+    {
+        [item setLabel: @"Picture Settings"];
+        [item setPaletteLabel: @"Show Picture Settings"];
+        [item setToolTip: @"Show Picture Settings"];
+        [item setImage: [NSImage imageNamed: @"pref-picture"]];
+        [item setTarget: self];
+        [item setAction: @selector(showPicturePanel:)];
+    }
+    else if ([itemIdent isEqualToString: ShowActivityIdentifier]) 
+    {
         [item setLabel: @"Activity Window"];
         [item setPaletteLabel: @"Show Activity Window"];
         [item setToolTip: @"Show Activity Window"];
@@ -931,13 +981,13 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
 {
     return [NSArray arrayWithObjects: ChooseSourceIdentifier, NSToolbarSeparatorItemIdentifier, StartEncodingIdentifier,
         PauseEncodingIdentifier, AddToQueueIdentifier, ShowQueueIdentifier, NSToolbarFlexibleSpaceItemIdentifier, 
-               NSToolbarSpaceItemIdentifier, ShowActivityIdentifier, ToggleDrawerIdentifier, nil];
+               NSToolbarSpaceItemIdentifier, ShowPictureIdentifier, ShowActivityIdentifier, ToggleDrawerIdentifier, nil];
 }
 
 - (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar
 {
     return [NSArray arrayWithObjects:  StartEncodingIdentifier, PauseEncodingIdentifier, AddToQueueIdentifier,
-        ChooseSourceIdentifier, ShowQueueIdentifier, ShowActivityIdentifier, ToggleDrawerIdentifier,
+        ChooseSourceIdentifier, ShowQueueIdentifier, ShowPictureIdentifier, ShowActivityIdentifier, ToggleDrawerIdentifier,
         NSToolbarCustomizeToolbarItemIdentifier, NSToolbarFlexibleSpaceItemIdentifier,
         NSToolbarSpaceItemIdentifier, NSToolbarSeparatorItemIdentifier, nil];
 }
@@ -970,8 +1020,12 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
                 return YES;
             }
             if (SuccessfulScan)
+            {
                 if ([ident isEqualToString: AddToQueueIdentifier])
                     return YES;
+                if ([ident isEqualToString: ShowPictureIdentifier])
+                    return YES;
+            }
         }
         else if (s.state == HB_STATE_PAUSED)
         {
@@ -987,6 +1041,8 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
                 return YES;
             if ([ident isEqualToString: AddToQueueIdentifier])
                 return YES;
+            if ([ident isEqualToString: ShowPictureIdentifier])
+                return YES;
         }
         else if (s.state == HB_STATE_SCANNING)
             return NO;
@@ -1005,6 +1061,8 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
             }
             if ([ident isEqualToString: AddToQueueIdentifier])
                 return YES;
+            if ([ident isEqualToString: ShowPictureIdentifier])
+                return YES;
         }
 
     }
@@ -1345,7 +1403,7 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
         [self writeToActivityLog: "trying to open a physical dvd at: %s", [scanPath UTF8String]];
 
         /* lets check for vlc here to make sure we have a dylib available to use for decrypting */
-        NSString *vlcPath = @"/Applications/VLC.app";
+        NSString *vlcPath = @"/Applications/VLC.app/Contents/MacOS/lib/libdvdcss.2.dylib";
         NSFileManager * fileManager = [NSFileManager defaultManager];
            if ([fileManager fileExistsAtPath:vlcPath] == 0) 
            {
@@ -1353,7 +1411,7 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
             cancelScanDecrypt = 1;
             [self writeToActivityLog: "VLC app not found for decrypting physical dvd"];
             int status;
-            status = NSRunAlertPanel(@"HandBrake could not find VLC.",@"Please download and install VLC media player in your /Applications folder if you wish to read encrypted DVDs.", @"Get VLC", @"Cancel Scan", @"Attempt Scan Anyway");
+            status = NSRunAlertPanel(@"HandBrake could not find VLC or your VLC is out of date.",@"Please download and install VLC media player in your /Applications folder if you wish to read encrypted DVDs.", @"Get VLC", @"Cancel Scan", @"Attempt Scan Anyway");
             [NSApp requestUserAttention:NSCriticalRequest];
             
             if (status == NSAlertDefaultReturn)
@@ -1395,8 +1453,9 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
         {
             [self writeToActivityLog: "scanning specifically for title: %d", scanTitleNum];
         }
-
-        hb_scan( fHandle, [path UTF8String], scanTitleNum );
+        /* We use our advance pref to determine how many previews to scan */
+        int hb_num_previews = [[[NSUserDefaults standardUserDefaults] objectForKey:@"PreviewsNumber"] intValue];
+        hb_scan( fHandle, [path UTF8String], scanTitleNum, hb_num_previews, 1 );
         [fSrcDVD2Field setStringValue:@"Scanning new source ..."];
     }
 }
@@ -1475,18 +1534,25 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
             SuccessfulScan = YES;
             [self enableUI: YES];
 
-                /* if its the initial successful scan after awakeFromNib */
-                if (currentSuccessfulScanCount == 1)
-                {
-                    [self selectDefaultPreset:nil];
-                    /* initially set deinterlace to 0, will be overridden reset by the default preset anyway */
-                    //[fPictureController setDeinterlace:0];
-                    
-                    /* lets set Denoise to index 0 or "None" since this is the first scan */
-                    //[fPictureController setDenoise:0];
-                    
-                    [fPictureController setInitialPictureFilters];
-                }
+            /* if its the initial successful scan after awakeFromNib */
+            if (currentSuccessfulScanCount == 1)
+            {
+                [self selectDefaultPreset:nil];
+                
+                [fPictureFilterController setInitialPictureFilters];
+                
+                // Open preview window now if it was visible when HB was closed
+                if ([[NSUserDefaults standardUserDefaults] boolForKey:@"PreviewWindowIsOpen"])
+                    [self showPreviewWindow:nil];
+                
+                // Open picture sizing window now if it was visible when HB was closed
+                if ([[NSUserDefaults standardUserDefaults] boolForKey:@"PictureSizeWindowIsOpen"])
+                    [self showPicturePanel:nil];
+                
+                // Open filters window now if it was visible when HB was closed
+                if ([[NSUserDefaults standardUserDefaults] boolForKey:@"PictureFiltersWindowIsOpen"])
+                    [self showFiltersPanel:nil];
+            }
 
             
         }
@@ -1509,11 +1575,14 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
 }
 
 - (void) browseFileDone: (NSSavePanel *) sheet
-    returnCode: (int) returnCode contextInfo: (void *) contextInfo
+             returnCode: (int) returnCode contextInfo: (void *) contextInfo
 {
     if( returnCode == NSOKButton )
     {
         [fDstFile2Field setStringValue: [sheet filename]];
+        /* Save this path to the prefs so that on next browse destination window it opens there */
+        NSString *destinationDirectory = [[fDstFile2Field stringValue] stringByDeletingLastPathComponent];
+        [[NSUserDefaults standardUserDefaults] setObject:destinationDirectory forKey:@"LastDestinationDirectory"];   
     }
 }
 
@@ -1542,6 +1611,10 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
     return NO;
 }
 
+- (NSSize) drawerWillResizeContents:(NSDrawer *) drawer toSize:(NSSize) contentSize {
+       [[NSUserDefaults standardUserDefaults] setObject:NSStringFromSize( contentSize ) forKey:@"Drawer Size"];
+       return contentSize;
+}
 
 #pragma mark -
 #pragma mark Queue File
@@ -1793,7 +1866,7 @@ fWorkingCount = 0;
         hb_chapter_t *chapter = (hb_chapter_t *) hb_list_item( fTitle->list_chapter, i );
         if( chapter != NULL )
         {
-         [ChapterNamesArray addObject:[NSString stringWithFormat:@"%s",chapter->title]];
+          [ChapterNamesArray addObject:[NSString stringWithCString:chapter->title encoding:NSUTF8StringEncoding]];
         }
     }
     [queueFileJob setObject:[NSMutableArray arrayWithArray: ChapterNamesArray] forKey:@"ChapterNames"];
@@ -1819,8 +1892,6 @@ fWorkingCount = 0;
     /* Framerate */
     [queueFileJob setObject:[fVidRatePopUp titleOfSelectedItem] forKey:@"VideoFramerate"];
     
-    /* GrayScale */
-       [queueFileJob setObject:[NSNumber numberWithInt:[fVidGrayscaleCheck state]] forKey:@"VideoGrayScale"];
        /* 2 Pass Encoding */
        [queueFileJob setObject:[NSNumber numberWithInt:[fVidTwoPassCheck state]] forKey:@"VideoTwoPass"];
        /* Turbo 2 pass Encoding fVidTurboPassCheck*/
@@ -1832,12 +1903,9 @@ fWorkingCount = 0;
        [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->width] forKey:@"PictureWidth"];
        [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->height] forKey:@"PictureHeight"];
        [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->keep_ratio] forKey:@"PictureKeepRatio"];
-       [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->pixel_ratio] forKey:@"PicturePAR"];
+       [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->anamorphic.mode] forKey:@"PicturePAR"];
     NSString * pictureSummary;
-    pictureSummary = [NSString stringWithFormat:@"Source: %@ Output: %@ Anamorphic: %@", 
-                     [fPicSettingsSrc stringValue], 
-                     [fPicSettingsOutp stringValue], 
-                     [fPicSettingsAnamorphic stringValue]];
+    pictureSummary = [fPictureSizeField stringValue];
     [queueFileJob setObject:pictureSummary forKey:@"PictureSizingSummary"];                 
     /* Set crop settings here */
        [queueFileJob setObject:[NSNumber numberWithInt:[fPictureController autoCrop]] forKey:@"PictureAutoCrop"];
@@ -1847,11 +1915,22 @@ fWorkingCount = 0;
        [queueFileJob setObject:[NSNumber numberWithInt:job->crop[3]] forKey:@"PictureRightCrop"];
     
     /* Picture Filters */
-    [queueFileJob setObject:[NSNumber numberWithInt:[fPictureController deinterlace]] forKey:@"PictureDeinterlace"];
-       [queueFileJob setObject:[NSNumber numberWithInt:[fPictureController detelecine]] forKey:@"PictureDetelecine"];
-    [queueFileJob setObject:[NSNumber numberWithInt:[fPictureController denoise]] forKey:@"PictureDenoise"];
-    [queueFileJob setObject:[NSString stringWithFormat:@"%d",[fPictureController deblock]] forKey:@"PictureDeblock"]; 
-    [queueFileJob setObject:[NSNumber numberWithInt:[fPictureController decomb]] forKey:@"PictureDecomb"];
+    [queueFileJob setObject:[NSNumber numberWithInt:[fPictureFilterController detelecine]] forKey:@"PictureDetelecine"];
+    [queueFileJob setObject:[fPictureFilterController detelecineCustomString] forKey:@"PictureDetelecineCustom"];
+    
+    [queueFileJob setObject:[NSNumber numberWithInt:[fPictureFilterController useDecomb]] forKey:@"PictureDecombDeinterlace"];
+    [queueFileJob setObject:[NSNumber numberWithInt:[fPictureFilterController decomb]] forKey:@"PictureDecomb"];
+    [queueFileJob setObject:[fPictureFilterController decombCustomString] forKey:@"PictureDecombCustom"];
+    
+    [queueFileJob setObject:[NSNumber numberWithInt:[fPictureFilterController deinterlace]] forKey:@"PictureDeinterlace"];
+    [queueFileJob setObject:[fPictureFilterController deinterlaceCustomString] forKey:@"PictureDeinterlaceCustom"];
+    
+    [queueFileJob setObject:[NSNumber numberWithInt:[fPictureFilterController denoise]] forKey:@"PictureDenoise"];
+    [queueFileJob setObject:[fPictureFilterController denoiseCustomString] forKey:@"PictureDenoiseCustom"];
+    
+    [queueFileJob setObject:[NSString stringWithFormat:@"%d",[fPictureFilterController deblock]] forKey:@"PictureDeblock"];
+    
+    [queueFileJob setObject:[NSNumber numberWithInt:[fPictureFilterController grayscale]] forKey:@"VideoGrayScale"];
     
     /*Audio*/
     if ([fAudLang1PopUp indexOfSelectedItem] > 0)
@@ -1911,36 +1990,23 @@ fWorkingCount = 0;
     
     
     [queueFileJob setObject:[NSNumber numberWithInt:[[fDstFormatPopUp selectedItem] tag]] forKey:@"JobFileFormatMux"];
-       /* Chapter Markers fCreateChapterMarkers*/
-       //[queueFileJob setObject:[NSNumber numberWithInt:[fCreateChapterMarkers state]] forKey:@"ChapterMarkers"];
-       /* Allow Mpeg4 64 bit formatting +4GB file sizes */
-       //[queueFileJob setObject:[NSNumber numberWithInt:[fDstMp4LargeFileCheck state]] forKey:@"Mp4LargeFile"];
-    /* Mux mp4 with http optimization */
-    //[queueFileJob setObject:[NSNumber numberWithInt:[fDstMp4HttpOptFileCheck state]] forKey:@"Mp4HttpOptimize"];
-    /* Add iPod uuid atom */
-    //[queueFileJob setObject:[NSNumber numberWithInt:[fDstMp4iPodFileCheck state]] forKey:@"Mp4iPodCompatible"];
     
     /* Codecs */
        /* Video encoder */
        [queueFileJob setObject:[NSNumber numberWithInt:[[fVidEncoderPopUp selectedItem] tag]] forKey:@"JobVideoEncoderVcodec"];
-       /* x264 Option String */
-       //[queueFileJob setObject:[fAdvancedOptions optionsString] forKey:@"x264Option"];
-
-       //[queueFileJob setObject:[NSNumber numberWithInt:[fVidQualityMatrix selectedRow]] forKey:@"VideoQualityType"];
-       //[queueFileJob setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
-       //[queueFileJob setObject:[fVidBitrateField stringValue] forKey:@"VideoAvgBitrate"];
-       //[queueFileJob setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
+       
     /* Framerate */
     [queueFileJob setObject:[NSNumber numberWithInt:[fVidRatePopUp indexOfSelectedItem]] forKey:@"JobIndexVideoFramerate"];
     [queueFileJob setObject:[NSNumber numberWithInt:title->rate] forKey:@"JobVrate"];
     [queueFileJob setObject:[NSNumber numberWithInt:title->rate_base] forKey:@"JobVrateBase"];
-       /* Picture Sizing */
+       
+    /* Picture Sizing */
        /* Use Max Picture settings for whatever the dvd is.*/
        [queueFileJob setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
        [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->width] forKey:@"PictureWidth"];
        [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->height] forKey:@"PictureHeight"];
        [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->keep_ratio] forKey:@"PictureKeepRatio"];
-       [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->pixel_ratio] forKey:@"PicturePAR"];
+       [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->anamorphic.mode] forKey:@"PicturePAR"];
     
     /* Set crop settings here */
        [queueFileJob setObject:[NSNumber numberWithInt:[fPictureController autoCrop]] forKey:@"PictureAutoCrop"];
@@ -1950,7 +2016,7 @@ fWorkingCount = 0;
        [queueFileJob setObject:[NSNumber numberWithInt:job->crop[3]] forKey:@"PictureRightCrop"];
     
     /* Picture Filters */
-    [queueFileJob setObject:[fPicSettingDecomb stringValue] forKey:@"JobPictureDecomb"];
+    //[queueFileJob setObject:[fPicSettingDecomb stringValue] forKey:@"JobPictureDecomb"];
     
     /*Audio*/
     if ([fAudLang1PopUp indexOfSelectedItem] > 0)
@@ -2066,8 +2132,10 @@ fWorkingCount = 0;
 /* Here we actually tell hb_scan to perform the source scan, using the path to source and title number*/
 - (void) performNewQueueScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum
 {
-   //NSRunAlertPanel(@"Hello!", @"We are now performing a new queue scan!", @"OK", nil, nil);
-
+   /* Tell HB to output a new activity log file for this encode */
+    [outputPanel startEncodeLog:[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"DestinationPath"]];
+    
+    
      /* use a bool to determine whether or not we can decrypt using vlc */
     BOOL cancelScanDecrypt = 0;
     /* set the bool so that showNewScan knows to apply the appropriate queue
@@ -2082,12 +2150,6 @@ fWorkingCount = 0;
         //status = NSRunAlertPanel(@"HandBrake is now loading up a new queue item...",@"Would You Like to wait until you add another encode?", @"Cancel", @"Okay", nil);
         //[NSApp requestUserAttention:NSCriticalRequest];
 
-    // Notify ChapterTitles that there's no title
-    [fChapterTitlesDelegate resetWithTitle:nil];
-    [fChapterTable reloadData];
-
-    //[self enableUI: NO];
-
     if( [detector isVideoDVD] )
     {
         // The chosen path was actually on a DVD, so use the raw block
@@ -2146,8 +2208,11 @@ fWorkingCount = 0;
         {
             [self writeToActivityLog: "scanning specifically for title: %d", scanTitleNum];
         }
+        
         [self writeToActivityLog: "performNewQueueScan currentQueueEncodeIndex is: %d", currentQueueEncodeIndex];
-        hb_scan( fQueueEncodeLibhb, [path UTF8String], scanTitleNum );
+        /* We use our advance pref to determine how many previews to scan */
+        int hb_num_previews = [[[NSUserDefaults standardUserDefaults] objectForKey:@"PreviewsNumber"] intValue];
+        hb_scan( fQueueEncodeLibhb, [path UTF8String], scanTitleNum, hb_num_previews, 0 );
     }
 }
 
@@ -2214,9 +2279,6 @@ fWorkingCount = 0;
         [fVidRatePopUp selectItemWithTitle:[queueToApply objectForKey:@"VideoFramerate"]];
     }
     
-    /* GrayScale */
-    [fVidGrayscaleCheck setState:[[queueToApply objectForKey:@"VideoGrayScale"] intValue]];
-    
     /* 2 Pass Encoding */
     [fVidTwoPassCheck setState:[[queueToApply objectForKey:@"VideoTwoPass"] intValue]];
     [self twoPassCheckboxChanged:nil];
@@ -2355,7 +2417,7 @@ fWorkingCount = 0;
             hb_fix_aspect( job, HB_KEEP_HEIGHT );
         }
     }
-    job->pixel_ratio = [[queueToApply objectForKey:@"PicturePAR"]  intValue];
+    job->anamorphic.mode = [[queueToApply objectForKey:@"PicturePAR"]  intValue];
     
     
     /* If Cropping is set to custom, then recall all four crop values from
@@ -2384,16 +2446,18 @@ fWorkingCount = 0;
     
     /* Filters */
     /* Deinterlace */
-    [fPictureController setDeinterlace:[[queueToApply objectForKey:@"PictureDeinterlace"] intValue]];
+    [fPictureFilterController setDeinterlace:[[queueToApply objectForKey:@"PictureDeinterlace"] intValue]];
     
     /* Detelecine */
-    [fPictureController setDetelecine:[[queueToApply objectForKey:@"PictureDetelecine"] intValue]];
+    [fPictureFilterController setDetelecine:[[queueToApply objectForKey:@"PictureDetelecine"] intValue]];
     /* Denoise */
-    [fPictureController setDenoise:[[queueToApply objectForKey:@"PictureDenoise"] intValue]];
+    [fPictureFilterController setDenoise:[[queueToApply objectForKey:@"PictureDenoise"] intValue]];
     /* Deblock */
-    [fPictureController setDeblock:[[queueToApply objectForKey:@"PictureDeblock"] intValue]];
+    [fPictureFilterController setDeblock:[[queueToApply objectForKey:@"PictureDeblock"] intValue]];
     /* Decomb */
-    [fPictureController setDecomb:[[queueToApply objectForKey:@"PictureDecomb"] intValue]];
+    [fPictureFilterController setDecomb:[[queueToApply objectForKey:@"PictureDecomb"] intValue]];
+    /* Grayscale */
+    [fPictureFilterController setGrayscale:[[queueToApply objectForKey:@"VideoGrayScale"] intValue]];
     
     [self calculatePictureSizing:nil];
     
@@ -2449,12 +2513,11 @@ fWorkingCount = 0;
     }
     
     NSMutableDictionary * queueToApply = [QueueFileArray objectAtIndex:currentQueueEncodeIndex];
-    [self writeToActivityLog: "processNewQueueEncode currentQueueEncodeIndex is: %d", currentQueueEncodeIndex];
+    [self writeToActivityLog: "Preset: %s", [[queueToApply objectForKey:@"PresetName"] UTF8String]];
     [self writeToActivityLog: "processNewQueueEncode number of passes expected is: %d", ([[queueToApply objectForKey:@"VideoTwoPass"] intValue] + 1)];
     job->file = [[queueToApply objectForKey:@"DestinationPath"] UTF8String];
-    [self writeToActivityLog: "processNewQueueEncode sending to prepareJob"];
+    //[self writeToActivityLog: "processNewQueueEncode sending to prepareJob"];
     [self prepareJob];
-    [self writeToActivityLog: "processNewQueueEncode back from prepareJob"];
     if( [[queueToApply objectForKey:@"SubtitlesForced"] intValue] == 1 )
         job->subtitle_force = 1;
     else
@@ -2538,159 +2601,58 @@ fWorkingCount = 0;
     [self doRip];
 }
 
-
 #pragma mark -
-#pragma mark Job Handling
-
-
-- (void) prepareJob
+#pragma mark Live Preview
+/* Note,this is much like prepareJob, but directly sets the job vars so Picture Preview
+ * can encode to its temp preview directory and playback. This is *not* used for any actual user
+ * encodes
+ */
+- (void) prepareJobForPreview
 {
-    
-    NSMutableDictionary * queueToApply = [QueueFileArray objectAtIndex:currentQueueEncodeIndex];
-    hb_list_t  * list  = hb_get_titles( fQueueEncodeLibhb );
-    hb_title_t * title = (hb_title_t *) hb_list_item( list,0 ); // is always zero since now its a single title scan
+    hb_list_t  * list  = hb_get_titles( fHandle );
+    hb_title_t * title = (hb_title_t *) hb_list_item( list,
+            [fSrcTitlePopUp indexOfSelectedItem] );
     hb_job_t * job = title->job;
     hb_audio_config_t * audio;
-    [self writeToActivityLog: "prepareJob reached"];
+
     /* Chapter selection */
-    job->chapter_start = [[queueToApply objectForKey:@"JobChapterStart"] intValue];
-    job->chapter_end   = [[queueToApply objectForKey:@"JobChapterEnd"] intValue];
+    job->chapter_start = [fSrcChapterStartPopUp indexOfSelectedItem] + 1;
+    job->chapter_end   = [fSrcChapterEndPopUp   indexOfSelectedItem] + 1;
        
     /* Format (Muxer) and Video Encoder */
-    job->mux = [[queueToApply objectForKey:@"JobFileFormatMux"] intValue];
-    job->vcodec = [[queueToApply objectForKey:@"JobVideoEncoderVcodec"] intValue];
-    
-    
-    /* If mpeg-4, then set mpeg-4 specific options like chapters and > 4gb file sizes */
-       //if( [fDstFormatPopUp indexOfSelectedItem] == 0 )
-       //{
-    /* We set the largeFileSize (64 bit formatting) variable here to allow for > 4gb files based on the format being
-     mpeg4 and the checkbox being checked 
-     *Note: this will break compatibility with some target devices like iPod, etc.!!!!*/
-    if( [[queueToApply objectForKey:@"Mp4LargeFile"] intValue] == 1)
-    {
-        job->largeFileSize = 1;
-    }
-    else
-    {
-        job->largeFileSize = 0;
-    }
-    /* We set http optimized mp4 here */
-    if( [[queueToApply objectForKey:@"Mp4HttpOptimize"] intValue] == 1 )
-    {
-        job->mp4_optimize = 1;
-    }
-    else
-    {
-        job->mp4_optimize = 0;
-    }
-    
-    //}
-       
-    /* We set the chapter marker extraction here based on the format being
-     mpeg4 or mkv and the checkbox being checked */
-    if ([[queueToApply objectForKey:@"ChapterMarkers"] intValue] == 1)
-    {
-        job->chapter_markers = 1;
-        
-        /* now lets get our saved chapter names out the array in the queue file
-         * and insert them back into the title chapter list. We have it here,
-         * because unless we are inserting chapter markers there is no need to
-         * spend the overhead of iterating through the chapter names array imo
-         * Also, note that if for some reason we don't apply chapter names, the
-         * chapters just come out 001, 002, etc. etc.
-         */
-         
-        NSMutableArray *ChapterNamesArray = [queueToApply objectForKey:@"ChapterNames"];
-        int i = 0;
-        NSEnumerator *enumerator = [ChapterNamesArray objectEnumerator];
-        id tempObject;
-        while (tempObject = [enumerator nextObject])
-        {
-            hb_chapter_t *chapter = (hb_chapter_t *) hb_list_item( title->list_chapter, i );
-            if( chapter != NULL )
-            {
-                strncpy( chapter->title, [tempObject UTF8String], 1023);
-                chapter->title[1023] = '\0';
-            }
-            i++;
-        }
-    }
-    else
-    {
-        job->chapter_markers = 0;
-    }
-    
+    job->mux = [[fDstFormatPopUp selectedItem] tag];
+    job->vcodec = [[fVidEncoderPopUp selectedItem] tag];
 
+    job->chapter_markers = 0;
     
-    
-    
-    if( job->vcodec & HB_VCODEC_X264 )
+       if( job->vcodec & HB_VCODEC_X264 )
     {
-               if ([[queueToApply objectForKey:@"Mp4iPodCompatible"] intValue] == 1)
-           {
-            job->ipod_atom = 1;
-               }
-        else
-        {
-            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)
+               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!*/
                job->x264opts = (char *)calloc(1024, 1); /* Fixme, this just leaks */
-               /* Turbo first pass if two pass and Turbo First pass is selected */
-               if( [[queueToApply objectForKey:@"VideoTwoPass"] intValue] == 1 && [[queueToApply objectForKey:@"VideoTurboTwoPass"] intValue] == 1 )
-               {
-                       /* pass the "Turbo" string to be appended to the existing x264 opts string into a variable for the first pass */
-                       NSString *firstPassOptStringTurbo = @":ref=1:subme=1:me=dia:analyse=none:trellis=0:no-fast-pskip=0:8x8dct=0:weightb=0";
-                       /* append the "Turbo" string variable to the existing opts string.
-             Note: the "Turbo" string must be appended, not prepended to work properly*/
-                       NSString *firstPassOptStringCombined = [[queueToApply objectForKey:@"x264Option"] stringByAppendingString:firstPassOptStringTurbo];
-                       strcpy(job->x264opts, [firstPassOptStringCombined UTF8String]);
-               }
-               else
-               {
-                       strcpy(job->x264opts, [[queueToApply objectForKey:@"x264Option"] UTF8String]);
-               }
+               /* For previews we ignore the turbo option for the first pass of two since we only use 1 pass */
+               strcpy(job->x264opts, [[fAdvancedOptions optionsString] UTF8String]);
+
         
     }
-    
-    
-    [self writeToActivityLog: "prepareJob reached Picture Settings"];
-    /* Picture Size Settings */
-    job->width = [[queueToApply objectForKey:@"PictureWidth"]  intValue];
-    job->height = [[queueToApply objectForKey:@"PictureHeight"]  intValue];
-    
-    job->keep_ratio = [[queueToApply objectForKey:@"PictureKeepRatio"]  intValue];
-    job->pixel_ratio = [[queueToApply objectForKey:@"PicturePAR"]  intValue];
-    
-    
-    /* Here we use the crop values saved at the time the preset was saved */
-    job->crop[0] = [[queueToApply objectForKey:@"PictureTopCrop"]  intValue];
-    job->crop[1] = [[queueToApply objectForKey:@"PictureBottomCrop"]  intValue];
-    job->crop[2] = [[queueToApply objectForKey:@"PictureLeftCrop"]  intValue];
-    job->crop[3] = [[queueToApply objectForKey:@"PictureRightCrop"]  intValue];
-    
+
     /* Video settings */
-    [self writeToActivityLog: "prepareJob reached Frame Rate"];
-    /* Framerate */
-    
-    /* Set vfr to 0 as it's only on if using same as source in the framerate popup
+   /* Set vfr to 0 as it's only on if using same as source in the framerate popup
      * and detelecine is on, so we handle that in the logic below
      */
     job->vfr = 0;
-    if( [[queueToApply objectForKey:@"JobIndexVideoFramerate"] intValue] > 0 )
+    if( [fVidRatePopUp indexOfSelectedItem] > 0 )
     {
         /* a specific framerate has been chosen */
         job->vrate      = 27000000;
-        job->vrate_base = hb_video_rates[[[queueToApply objectForKey:@"JobIndexVideoFramerate"] intValue]-1].rate;
+        job->vrate_base = hb_video_rates[[fVidRatePopUp indexOfSelectedItem]-1].rate;
         /* We are not same as source so we set job->cfr to 1 
          * to enable constant frame rate since user has specified
          * a specific framerate*/
@@ -2699,43 +2661,39 @@ fWorkingCount = 0;
     else
     {
         /* We are same as source (variable) */
-        job->vrate      = [[queueToApply objectForKey:@"JobVrate"] intValue];
-        job->vrate_base = [[queueToApply objectForKey:@"JobVrateBase"] intValue];
+        job->vrate      = title->rate;
+        job->vrate_base = title->rate_base;
         /* We are same as source so we set job->cfr to 0 
          * to enable true same as source framerate */
         job->cfr = 0;
         /* If we are same as source and we have detelecine on, we need to turn on
          * job->vfr
          */
-        if ([[queueToApply objectForKey:@"PictureDetelecine"] intValue] == 1)
+        if ([fPictureFilterController detelecine] == 1)
         {
             job->vfr = 1;
         }
     }
-    [self writeToActivityLog: "prepareJob reached Bitrate Video Quality"];
-    if ( [[queueToApply objectForKey:@"VideoQualityType"] intValue] == 0 )
-    {
-        /* Target size.
-         Bitrate should already have been calculated and displayed
-         in fVidBitrateField, so let's just use it */
-    }
-    if ( [[queueToApply objectForKey:@"VideoQualityType"] intValue] == 1 )
-    {
-        job->vquality = -1.0;
-        job->vbitrate = [[queueToApply objectForKey:@"VideoAvgBitrate"] intValue];
-    }
-    if ( [[queueToApply objectForKey:@"VideoQualityType"] intValue] == 2 )
+
+    switch( [fVidQualityMatrix selectedRow] )
     {
-        job->vquality = [[queueToApply objectForKey:@"VideoQualitySlider"] floatValue];
-        job->vbitrate = 0;
-        
+        case 0:
+            /* Target size.
+               Bitrate should already have been calculated and displayed
+               in fVidBitrateField, so let's just use it */
+        case 1:
+            job->vquality = -1.0;
+            job->vbitrate = [fVidBitrateField intValue];
+            break;
+        case 2:
+            job->vquality = [fVidQualitySlider floatValue];
+            job->vbitrate = 0;
+            break;
     }
-    
-    job->grayscale = [[queueToApply objectForKey:@"VideoGrayScale"] intValue];
+
     /* Subtitle settings */
-    job->subtitle = [[queueToApply objectForKey:@"JobSubtitlesIndex"] intValue] - 2;
-    
-    [self writeToActivityLog: "prepareJob reached Audio"];
+    job->subtitle = [fSubPopUp indexOfSelectedItem] - 2;
+
     /* Audio tracks and mixdowns */
     /* Lets make sure there arent any erroneous audio tracks in the job list, so lets make sure its empty*/
     int audiotrack_count = hb_list_count(job->list_audio);
@@ -2745,16 +2703,401 @@ fWorkingCount = 0;
         hb_list_rem(job->list_audio, temp_audio);
     }
     /* Now lets add our new tracks to the audio list here */
-    if ([[queueToApply objectForKey:@"Audio1Track"] intValue] > 0)
+    if ([fAudLang1PopUp indexOfSelectedItem] > 0)
     {
         audio = (hb_audio_config_t *) calloc(1, sizeof(*audio));
         hb_audio_config_init(audio);
-        audio->in.track = [[queueToApply objectForKey:@"Audio1Track"] intValue] - 1;
+        audio->in.track = [fAudLang1PopUp indexOfSelectedItem] - 1;
         /* We go ahead and assign values to our audio->out.<properties> */
-        audio->out.track = [[queueToApply objectForKey:@"Audio1Track"] intValue] - 1;
-        audio->out.codec = [[queueToApply objectForKey:@"JobAudio1Encoder"] intValue];
-        audio->out.mixdown = [[queueToApply objectForKey:@"JobAudio1Mixdown"] intValue];
-        audio->out.bitrate = [[queueToApply objectForKey:@"JobAudio1Bitrate"] intValue];
+        audio->out.track = [fAudLang1PopUp indexOfSelectedItem] - 1;
+        audio->out.codec = [[fAudTrack1CodecPopUp selectedItem] tag];
+        audio->out.mixdown = [[fAudTrack1MixPopUp selectedItem] tag];
+        audio->out.bitrate = [[fAudTrack1BitratePopUp selectedItem] tag];
+        audio->out.samplerate = [[fAudTrack1RatePopUp selectedItem] tag];
+        audio->out.dynamic_range_compression = [fAudTrack1DrcField floatValue];
+        
+        hb_audio_add( job, audio );
+        free(audio);
+    }  
+    if ([fAudLang2PopUp indexOfSelectedItem] > 0)
+    {
+        audio = (hb_audio_config_t *) calloc(1, sizeof(*audio));
+        hb_audio_config_init(audio);
+        audio->in.track = [fAudLang2PopUp indexOfSelectedItem] - 1;
+        /* We go ahead and assign values to our audio->out.<properties> */
+        audio->out.track = [fAudLang2PopUp indexOfSelectedItem] - 1;
+        audio->out.codec = [[fAudTrack2CodecPopUp selectedItem] tag];
+        audio->out.mixdown = [[fAudTrack2MixPopUp selectedItem] tag];
+        audio->out.bitrate = [[fAudTrack2BitratePopUp selectedItem] tag];
+        audio->out.samplerate = [[fAudTrack2RatePopUp selectedItem] tag];
+        audio->out.dynamic_range_compression = [fAudTrack2DrcField floatValue];
+        
+        hb_audio_add( job, audio );
+        free(audio);
+        
+    }
+    
+    if ([fAudLang3PopUp indexOfSelectedItem] > 0)
+    {
+        audio = (hb_audio_config_t *) calloc(1, sizeof(*audio));
+        hb_audio_config_init(audio);
+        audio->in.track = [fAudLang3PopUp indexOfSelectedItem] - 1;
+        /* We go ahead and assign values to our audio->out.<properties> */
+        audio->out.track = [fAudLang3PopUp indexOfSelectedItem] - 1;
+        audio->out.codec = [[fAudTrack3CodecPopUp selectedItem] tag];
+        audio->out.mixdown = [[fAudTrack3MixPopUp selectedItem] tag];
+        audio->out.bitrate = [[fAudTrack3BitratePopUp selectedItem] tag];
+        audio->out.samplerate = [[fAudTrack3RatePopUp selectedItem] tag];
+        audio->out.dynamic_range_compression = [fAudTrack3DrcField floatValue];
+        
+        hb_audio_add( job, audio );
+        free(audio);
+        
+    }
+
+    if ([fAudLang4PopUp indexOfSelectedItem] > 0)
+    {
+        audio = (hb_audio_config_t *) calloc(1, sizeof(*audio));
+        hb_audio_config_init(audio);
+        audio->in.track = [fAudLang4PopUp indexOfSelectedItem] - 1;
+        /* We go ahead and assign values to our audio->out.<properties> */
+        audio->out.track = [fAudLang4PopUp indexOfSelectedItem] - 1;
+        audio->out.codec = [[fAudTrack4CodecPopUp selectedItem] tag];
+        audio->out.mixdown = [[fAudTrack4MixPopUp selectedItem] tag];
+        audio->out.bitrate = [[fAudTrack4BitratePopUp selectedItem] tag];
+        audio->out.samplerate = [[fAudTrack4RatePopUp selectedItem] tag];
+        audio->out.dynamic_range_compression = [fAudTrack4DrcField floatValue];
+        
+        hb_audio_add( job, audio );
+        free(audio);
+        
+    }
+
+    
+    
+    /* Filters */
+    
+    /* Though Grayscale is not really a filter, per se
+     * we put it here since its in the filters panel
+     */
+     
+    if ([fPictureFilterController grayscale])
+    {
+        job->grayscale = 1;
+    }
+    else
+    {
+        job->grayscale = 0;
+    }
+    
+    /* Initialize the filters list */
+    job->filters = hb_list_init();
+    
+    /* Now lets call the filters if applicable.
+    * The order of the filters is critical
+    */
+    
+       /* Detelecine */
+    if ([fPictureFilterController detelecine] == 1)
+    {
+        hb_list_add( job->filters, &hb_filter_detelecine );
+    }
+    if ([fPictureFilterController detelecine] == 2)
+    {
+        /* use a custom detelecine string */
+        hb_filter_detelecine.settings = (char *) [[fPictureFilterController detelecineCustomString] UTF8String];
+        hb_list_add( job->filters, &hb_filter_detelecine );
+    }
+    if ([fPictureFilterController useDecomb] == 1)
+    {
+        /* Decomb */
+        if ([fPictureFilterController decomb] == 1)
+        {
+            /* Run old deinterlacer fd by default */
+            //hb_filter_decomb.settings = (char *) [[fPicSettingDecomb stringValue] UTF8String];
+            hb_list_add( job->filters, &hb_filter_decomb );
+        }
+        /* we add the custom string if present */
+        if ([fPictureFilterController decomb] == 2)
+        {
+            /* use a custom decomb string */
+            hb_filter_decomb.settings = (char *) [[fPictureFilterController decombCustomString] UTF8String];
+            hb_list_add( job->filters, &hb_filter_decomb );
+        }
+    }
+    else
+    {
+        
+        /* Deinterlace */
+        if ([fPictureFilterController deinterlace] == 1)
+        {
+            /* Run old deinterlacer fd by default */
+            hb_filter_deinterlace.settings = "-1"; 
+            hb_list_add( job->filters, &hb_filter_deinterlace );
+        }
+        else if ([fPictureFilterController deinterlace] == 2)
+        {
+            /* Yadif mode 0 (without spatial deinterlacing.) */
+            hb_filter_deinterlace.settings = "2"; 
+            hb_list_add( job->filters, &hb_filter_deinterlace );            
+        }
+        else if ([fPictureFilterController deinterlace] == 3)
+        {
+            /* Yadif (with spatial deinterlacing) */
+            hb_filter_deinterlace.settings = "0"; 
+            hb_list_add( job->filters, &hb_filter_deinterlace );            
+        }
+        else if ([fPictureFilterController deinterlace] == 4)
+        {
+            /* we add the custom string if present */
+            hb_filter_deinterlace.settings = (char *) [[fPictureFilterController deinterlaceCustomString] UTF8String];
+            hb_list_add( job->filters, &hb_filter_deinterlace );            
+        }
+       }
+    
+    /* Denoise */
+       if ([fPictureFilterController denoise] == 1) // Weak in popup
+       {
+               hb_filter_denoise.settings = "2:1:2:3"; 
+        hb_list_add( job->filters, &hb_filter_denoise );       
+       }
+       else if ([fPictureFilterController denoise] == 2) // Medium in popup
+       {
+               hb_filter_denoise.settings = "3:2:2:3"; 
+        hb_list_add( job->filters, &hb_filter_denoise );       
+       }
+       else if ([fPictureFilterController denoise] == 3) // Strong in popup
+       {
+               hb_filter_denoise.settings = "7:7:5:5"; 
+        hb_list_add( job->filters, &hb_filter_denoise );       
+       }
+    else if ([fPictureFilterController denoise] == 4) // custom in popup
+       {
+               /* we add the custom string if present */
+        hb_filter_denoise.settings = (char *) [[fPictureFilterController denoiseCustomString] UTF8String]; 
+        hb_list_add( job->filters, &hb_filter_denoise );       
+       }
+    
+    /* Deblock  (uses pp7 default) */
+    /* NOTE: even though there is a valid deblock setting of 0 for the filter, for 
+     * the macgui's purposes a value of 0 actually means to not even use the filter
+     * current hb_filter_deblock.settings valid ranges are from 5 - 15 
+     */
+    if ([fPictureFilterController deblock] != 0)
+    {
+        NSString *deblockStringValue = [NSString stringWithFormat: @"%d",[fPictureFilterController deblock]];
+        hb_filter_deblock.settings = (char *) [deblockStringValue UTF8String];
+        hb_list_add( job->filters, &hb_filter_deblock );
+    }
+
+}
+
+
+#pragma mark -
+#pragma mark Job Handling
+
+
+- (void) prepareJob
+{
+    
+    NSMutableDictionary * queueToApply = [QueueFileArray objectAtIndex:currentQueueEncodeIndex];
+    hb_list_t  * list  = hb_get_titles( fQueueEncodeLibhb );
+    hb_title_t * title = (hb_title_t *) hb_list_item( list,0 ); // is always zero since now its a single title scan
+    hb_job_t * job = title->job;
+    hb_audio_config_t * audio;
+    /* Chapter selection */
+    job->chapter_start = [[queueToApply objectForKey:@"JobChapterStart"] intValue];
+    job->chapter_end   = [[queueToApply objectForKey:@"JobChapterEnd"] intValue];
+       
+    /* Format (Muxer) and Video Encoder */
+    job->mux = [[queueToApply objectForKey:@"JobFileFormatMux"] intValue];
+    job->vcodec = [[queueToApply objectForKey:@"JobVideoEncoderVcodec"] intValue];
+    
+    
+    /* If mpeg-4, then set mpeg-4 specific options like chapters and > 4gb file sizes */
+       //if( [fDstFormatPopUp indexOfSelectedItem] == 0 )
+       //{
+    /* We set the largeFileSize (64 bit formatting) variable here to allow for > 4gb files based on the format being
+     mpeg4 and the checkbox being checked 
+     *Note: this will break compatibility with some target devices like iPod, etc.!!!!*/
+    if( [[queueToApply objectForKey:@"Mp4LargeFile"] intValue] == 1)
+    {
+        job->largeFileSize = 1;
+    }
+    else
+    {
+        job->largeFileSize = 0;
+    }
+    /* We set http optimized mp4 here */
+    if( [[queueToApply objectForKey:@"Mp4HttpOptimize"] intValue] == 1 )
+    {
+        job->mp4_optimize = 1;
+    }
+    else
+    {
+        job->mp4_optimize = 0;
+    }
+    
+    //}
+       
+    /* We set the chapter marker extraction here based on the format being
+     mpeg4 or mkv and the checkbox being checked */
+    if ([[queueToApply objectForKey:@"ChapterMarkers"] intValue] == 1)
+    {
+        job->chapter_markers = 1;
+        
+        /* now lets get our saved chapter names out the array in the queue file
+         * and insert them back into the title chapter list. We have it here,
+         * because unless we are inserting chapter markers there is no need to
+         * spend the overhead of iterating through the chapter names array imo
+         * Also, note that if for some reason we don't apply chapter names, the
+         * chapters just come out 001, 002, etc. etc.
+         */
+         
+        NSMutableArray *ChapterNamesArray = [queueToApply objectForKey:@"ChapterNames"];
+        int i = 0;
+        NSEnumerator *enumerator = [ChapterNamesArray objectEnumerator];
+        id tempObject;
+        while (tempObject = [enumerator nextObject])
+        {
+            hb_chapter_t *chapter = (hb_chapter_t *) hb_list_item( title->list_chapter, i );
+            if( chapter != NULL )
+            {
+                strncpy( chapter->title, [tempObject UTF8String], 1023);
+                chapter->title[1023] = '\0';
+            }
+            i++;
+        }
+    }
+    else
+    {
+        job->chapter_markers = 0;
+    }
+    
+    if( job->vcodec & HB_VCODEC_X264 )
+    {
+               if ([[queueToApply objectForKey:@"Mp4iPodCompatible"] intValue] == 1)
+           {
+            job->ipod_atom = 1;
+               }
+        else
+        {
+            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 */
+               /* Turbo first pass if two pass and Turbo First pass is selected */
+               if( [[queueToApply objectForKey:@"VideoTwoPass"] intValue] == 1 && [[queueToApply objectForKey:@"VideoTurboTwoPass"] intValue] == 1 )
+               {
+                       /* pass the "Turbo" string to be appended to the existing x264 opts string into a variable for the first pass */
+                       NSString *firstPassOptStringTurbo = @":ref=1:subme=1:me=dia:analyse=none:trellis=0:no-fast-pskip=0:8x8dct=0:weightb=0";
+                       /* append the "Turbo" string variable to the existing opts string.
+             Note: the "Turbo" string must be appended, not prepended to work properly*/
+                       NSString *firstPassOptStringCombined = [[queueToApply objectForKey:@"x264Option"] stringByAppendingString:firstPassOptStringTurbo];
+                       strcpy(job->x264opts, [firstPassOptStringCombined UTF8String]);
+               }
+               else
+               {
+                       strcpy(job->x264opts, [[queueToApply objectForKey:@"x264Option"] UTF8String]);
+               }
+        
+    }
+    
+    
+    /* Picture Size Settings */
+    job->width = [[queueToApply objectForKey:@"PictureWidth"]  intValue];
+    job->height = [[queueToApply objectForKey:@"PictureHeight"]  intValue];
+    
+    job->keep_ratio = [[queueToApply objectForKey:@"PictureKeepRatio"]  intValue];
+    job->anamorphic.mode = [[queueToApply objectForKey:@"PicturePAR"]  intValue];
+    
+    
+    /* Here we use the crop values saved at the time the preset was saved */
+    job->crop[0] = [[queueToApply objectForKey:@"PictureTopCrop"]  intValue];
+    job->crop[1] = [[queueToApply objectForKey:@"PictureBottomCrop"]  intValue];
+    job->crop[2] = [[queueToApply objectForKey:@"PictureLeftCrop"]  intValue];
+    job->crop[3] = [[queueToApply objectForKey:@"PictureRightCrop"]  intValue];
+    
+    /* Video settings */
+    /* Framerate */
+    
+    /* Set vfr to 0 as it's only on if using same as source in the framerate popup
+     * and detelecine is on, so we handle that in the logic below
+     */
+    job->vfr = 0;
+    if( [[queueToApply objectForKey:@"JobIndexVideoFramerate"] intValue] > 0 )
+    {
+        /* a specific framerate has been chosen */
+        job->vrate      = 27000000;
+        job->vrate_base = hb_video_rates[[[queueToApply objectForKey:@"JobIndexVideoFramerate"] intValue]-1].rate;
+        /* We are not same as source so we set job->cfr to 1 
+         * to enable constant frame rate since user has specified
+         * a specific framerate*/
+        job->cfr = 1;
+    }
+    else
+    {
+        /* We are same as source (variable) */
+        job->vrate      = [[queueToApply objectForKey:@"JobVrate"] intValue];
+        job->vrate_base = [[queueToApply objectForKey:@"JobVrateBase"] intValue];
+        /* We are same as source so we set job->cfr to 0 
+         * to enable true same as source framerate */
+        job->cfr = 0;
+        /* If we are same as source and we have detelecine on, we need to turn on
+         * job->vfr
+         */
+        if ([[queueToApply objectForKey:@"PictureDetelecine"] intValue] == 1)
+        {
+            job->vfr = 1;
+        }
+    }
+    
+    if ( [[queueToApply objectForKey:@"VideoQualityType"] intValue] != 2 )
+    {
+        /* Target size.
+         Bitrate should already have been calculated and displayed
+         in fVidBitrateField, so let's just use it same as abr*/
+        job->vquality = -1.0;
+        job->vbitrate = [[queueToApply objectForKey:@"VideoAvgBitrate"] intValue];
+    }
+    if ( [[queueToApply objectForKey:@"VideoQualityType"] intValue] == 2 )
+    {
+        job->vquality = [[queueToApply objectForKey:@"VideoQualitySlider"] floatValue];
+        job->vbitrate = 0;
+        
+    }
+    
+    job->grayscale = [[queueToApply objectForKey:@"VideoGrayScale"] intValue];
+    /* Subtitle settings */
+    job->subtitle = [[queueToApply objectForKey:@"JobSubtitlesIndex"] intValue] - 2;
+    
+    /* Audio tracks and mixdowns */
+    /* Lets make sure there arent any erroneous audio tracks in the job list, so lets make sure its empty*/
+    int audiotrack_count = hb_list_count(job->list_audio);
+    for( int i = 0; i < audiotrack_count;i++)
+    {
+        hb_audio_t * temp_audio = (hb_audio_t*) hb_list_item( job->list_audio, 0 );
+        hb_list_rem(job->list_audio, temp_audio);
+    }
+    /* Now lets add our new tracks to the audio list here */
+    if ([[queueToApply objectForKey:@"Audio1Track"] intValue] > 0)
+    {
+        audio = (hb_audio_config_t *) calloc(1, sizeof(*audio));
+        hb_audio_config_init(audio);
+        audio->in.track = [[queueToApply objectForKey:@"Audio1Track"] intValue] - 1;
+        /* We go ahead and assign values to our audio->out.<properties> */
+        audio->out.track = [[queueToApply objectForKey:@"Audio1Track"] intValue] - 1;
+        audio->out.codec = [[queueToApply objectForKey:@"JobAudio1Encoder"] intValue];
+        audio->out.mixdown = [[queueToApply objectForKey:@"JobAudio1Mixdown"] intValue];
+        audio->out.bitrate = [[queueToApply objectForKey:@"JobAudio1Bitrate"] intValue];
         audio->out.samplerate = [[queueToApply objectForKey:@"JobAudio1Samplerate"] intValue];
         audio->out.dynamic_range_compression = [[queueToApply objectForKey:@"Audio1TrackDRCSlider"] floatValue];
         
@@ -2808,14 +3151,13 @@ fWorkingCount = 0;
         audio->out.mixdown = [[queueToApply objectForKey:@"JobAudio4Mixdown"] intValue];
         audio->out.bitrate = [[queueToApply objectForKey:@"JobAudio4Bitrate"] intValue];
         audio->out.samplerate = [[queueToApply objectForKey:@"JobAudio4Samplerate"] intValue];
-        audio->out.dynamic_range_compression = [[queueToApply objectForKey:@"Audio3TrackDRCSlider"] floatValue];
+        audio->out.dynamic_range_compression = [[queueToApply objectForKey:@"Audio4TrackDRCSlider"] floatValue];
         
         hb_audio_add( job, audio );
         free(audio);
     }
     
-    [self writeToActivityLog: "prepareJob reached Filters"];
-     /* Filters */ 
+    /* Filters */ 
     job->filters = hb_list_init();
     
     /* Now lets call the filters if applicable.
@@ -2824,37 +3166,64 @@ fWorkingCount = 0;
     /* Detelecine */
     if ([[queueToApply objectForKey:@"PictureDetelecine"] intValue] == 1)
     {
+        //if ([queueToApply objectForKey:@"PictureDetelecineCustom"])
         hb_list_add( job->filters, &hb_filter_detelecine );
     }
-    
-    /* Decomb */
-    if ([[queueToApply objectForKey:@"PictureDecomb"] intValue] == 1)
+    if ([[queueToApply objectForKey:@"PictureDetelecine"] intValue] == 2)
     {
-        /* Run old deinterlacer fd by default */
-        hb_filter_decomb.settings = (char *) [[queueToApply objectForKey:@"JobPictureDecomb"] UTF8String];
-        hb_list_add( job->filters, &hb_filter_decomb );
+        /* use a custom detelecine string */
+        hb_filter_detelecine.settings = (char *) [[queueToApply objectForKey:@"PictureDetelecineCustom"] UTF8String];
+        hb_list_add( job->filters, &hb_filter_detelecine );
     }
     
-    /* Deinterlace */
-    if ([[queueToApply objectForKey:@"PictureDeinterlace"] intValue] == 1)
-    {
-        /* Run old deinterlacer fd by default */
-        hb_filter_deinterlace.settings = "-1"; 
-        hb_list_add( job->filters, &hb_filter_deinterlace );
-    }
-    else if ([[queueToApply objectForKey:@"PictureDeinterlace"] intValue] == 2)
+    if ([[queueToApply objectForKey:@"PictureDecombDeinterlace"] intValue] == 1)
     {
-        /* Yadif mode 0 (without spatial deinterlacing.) */
-        hb_filter_deinterlace.settings = "2"; 
-        hb_list_add( job->filters, &hb_filter_deinterlace );            
+        /* Decomb */
+        if ([[queueToApply objectForKey:@"PictureDecomb"] intValue] == 1)
+        {
+            /* Run old deinterlacer fd by default */
+            hb_list_add( job->filters, &hb_filter_decomb );
+        }
+        /* we add the custom string if present */
+        if ([[queueToApply objectForKey:@"PictureDecomb"] intValue] == 2)
+        {
+            /* use a custom decomb string */
+            hb_filter_decomb.settings = (char *) [[queueToApply objectForKey:@"PictureDecombCustom"] UTF8String];
+            hb_list_add( job->filters, &hb_filter_decomb );
+        }
+        
     }
-    else if ([[queueToApply objectForKey:@"PictureDeinterlace"] intValue] == 3)
+    else
     {
-        /* Yadif (with spatial deinterlacing) */
-        hb_filter_deinterlace.settings = "0"; 
-        hb_list_add( job->filters, &hb_filter_deinterlace );            
+        
+        /* Deinterlace */
+        if ([[queueToApply objectForKey:@"PictureDeinterlace"] intValue] == 1)
+        {
+            /* Run old deinterlacer fd by default */
+            hb_filter_deinterlace.settings = "-1"; 
+            hb_list_add( job->filters, &hb_filter_deinterlace );
+        }
+        else if ([[queueToApply objectForKey:@"PictureDeinterlace"] intValue] == 2)
+        {
+            /* Yadif mode 0 (without spatial deinterlacing.) */
+            hb_filter_deinterlace.settings = "2"; 
+            hb_list_add( job->filters, &hb_filter_deinterlace );            
+        }
+        else if ([[queueToApply objectForKey:@"PictureDeinterlace"] intValue] == 3)
+        {
+            /* Yadif (with spatial deinterlacing) */
+            hb_filter_deinterlace.settings = "0"; 
+            hb_list_add( job->filters, &hb_filter_deinterlace );            
+        }
+        else if ([[queueToApply objectForKey:@"PictureDeinterlace"] intValue] == 4)
+        {
+            /* we add the custom string if present */
+            hb_filter_deinterlace.settings = (char *) [[queueToApply objectForKey:@"PictureDeinterlaceCustom"] UTF8String];
+            hb_list_add( job->filters, &hb_filter_deinterlace );            
+        }
+        
+        
     }
-       
     /* Denoise */
        if ([[queueToApply objectForKey:@"PictureDenoise"] intValue] == 1) // Weak in popup
        {
@@ -2871,6 +3240,12 @@ fWorkingCount = 0;
                hb_filter_denoise.settings = "7:7:5:5"; 
         hb_list_add( job->filters, &hb_filter_denoise );       
        }
+    else if ([[queueToApply objectForKey:@"PictureDenoise"] intValue] == 4) // Custom in popup
+       {
+               /* we add the custom string if present */
+        hb_filter_denoise.settings = (char *) [[queueToApply objectForKey:@"PictureDenoiseCustom"] UTF8String];
+        hb_list_add( job->filters, &hb_filter_denoise );       
+       }
     
     /* Deblock  (uses pp7 default) */
     /* NOTE: even though there is a valid deblock setting of 0 for the filter, for 
@@ -2896,21 +3271,54 @@ fWorkingCount = 0;
        /* We check for a valid destination here */
        if ([[NSFileManager defaultManager] fileExistsAtPath:destinationDirectory] == 0) 
        {
-               NSRunAlertPanel(@"Warning!", @"This is not a valid destination directory!", @"OK", nil, nil);
-        return;
+               NSRunAlertPanel(@"Warning!", @"This is not a valid destination directory!", @"OK", nil, nil);
+        return;
+       }
+    
+    BOOL fileExists;
+    fileExists = NO;
+    
+    BOOL fileExistsInQueue;
+    fileExistsInQueue = NO;
+    
+    /* We check for and existing file here */
+    if([[NSFileManager defaultManager] fileExistsAtPath: [fDstFile2Field stringValue]])
+    {
+        fileExists = YES;
+    }
+    
+    /* We now run through the queue and make sure we are not overwriting an exisiting queue item */
+    int i = 0;
+    NSEnumerator *enumerator = [QueueFileArray objectEnumerator];
+       id tempObject;
+       while (tempObject = [enumerator nextObject])
+       {
+               NSDictionary *thisQueueDict = tempObject;
+               if ([[thisQueueDict objectForKey:@"DestinationPath"] isEqualToString: [fDstFile2Field stringValue]])
+               {
+                       fileExistsInQueue = YES;        
+               }
+        i++;
        }
-
-    /* We check for duplicate name here */
-       if( [[NSFileManager defaultManager] fileExistsAtPath:
-            [fDstFile2Field stringValue]] )
+    
+    
+       if(fileExists == YES)
     {
-        NSBeginCriticalAlertSheet( NSLocalizedString( @"File already exists", @"" ),
-            NSLocalizedString( @"Cancel", @"" ), NSLocalizedString( @"Overwrite", @"" ), nil, fWindow, self,
-            @selector( overwriteAddToQueueAlertDone:returnCode:contextInfo: ),
-            NULL, NULL, [NSString stringWithFormat:
-            NSLocalizedString( @"Do you want to overwrite %@?", @"" ),
-            [fDstFile2Field stringValue]] );
-        // overwriteAddToQueueAlertDone: will be called when the alert is dismissed.
+        NSBeginCriticalAlertSheet( NSLocalizedString( @"File already exists.", @"" ),
+                                  NSLocalizedString( @"Cancel", @"" ), NSLocalizedString( @"Overwrite", @"" ), nil, fWindow, self,
+                                  @selector( overwriteAddToQueueAlertDone:returnCode:contextInfo: ),
+                                  NULL, NULL, [NSString stringWithFormat:
+                                               NSLocalizedString( @"Do you want to overwrite %@?", @"" ),
+                                               [fDstFile2Field stringValue]] );
+    }
+    else if (fileExistsInQueue == YES)
+    {
+    NSBeginCriticalAlertSheet( NSLocalizedString( @"There is already a queue item for this destination.", @"" ),
+                                  NSLocalizedString( @"Cancel", @"" ), NSLocalizedString( @"Overwrite", @"" ), nil, fWindow, self,
+                                  @selector( overwriteAddToQueueAlertDone:returnCode:contextInfo: ),
+                                  NULL, NULL, [NSString stringWithFormat:
+                                               NSLocalizedString( @"Do you want to overwrite %@?", @"" ),
+                                               [fDstFile2Field stringValue]] );
     }
     else
     {
@@ -2990,15 +3398,13 @@ fWorkingCount = 0;
          otherwise, just rip the queue */
         if(fPendingCount == 0)
         {
-         [self writeToActivityLog: "Rip: No pending jobs, so sending this one to doAddToQueue"];
-               [self doAddToQueue];
+            [self writeToActivityLog: "Rip: No pending jobs, so sending this one to doAddToQueue"];
+            [self doAddToQueue];
         }
         
-        NSString *destinationDirectory = [[fDstFile2Field stringValue] stringByDeletingLastPathComponent];
-        [[NSUserDefaults standardUserDefaults] setObject:destinationDirectory forKey:@"LastDestinationDirectory"];
         /* go right to processing the new queue encode */
-       [self writeToActivityLog: "Rip: Going right to performNewQueueScan"];
-         [self performNewQueueScan:[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"SourcePath"] scanTitleNum:[[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"TitleNumber"]intValue]]; 
+        [self writeToActivityLog: "Rip: Going right to performNewQueueScan"];
+        [self performNewQueueScan:[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"SourcePath"] scanTitleNum:[[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"TitleNumber"]intValue]]; 
         
     }
 }
@@ -3065,46 +3471,6 @@ fWorkingCount = 0;
 
 
 //------------------------------------------------------------------------------------
-// Cancels and deletes the current job and stops libhb from processing the remaining
-// encodes.
-//------------------------------------------------------------------------------------
-- (void) doCancelCurrentJob
-{
-    // Stop the current job. hb_stop will only cancel the current pass and then set
-    // its state to HB_STATE_WORKDONE. It also does this asynchronously. So when we
-    // see the state has changed to HB_STATE_WORKDONE (in updateUI), we'll delete the
-    // remaining passes of the job and then start the queue back up if there are any
-    // remaining jobs.
-     
-    
-    hb_stop( fQueueEncodeLibhb );
-    fEncodeState = 2;   // don't alert at end of processing since this was a cancel
-    
-    // now that we've stopped the currently encoding job, lets mark it as cancelled
-    [[QueueFileArray objectAtIndex:currentQueueEncodeIndex] setObject:[NSNumber numberWithInt:3] forKey:@"Status"];
-    // and as always, save it in the queue .plist...
-    /* We save all of the Queue data here */
-    [self saveQueueFileItem];
-    // so now lets move to 
-    currentQueueEncodeIndex++ ;
-    // ... and see if there are more items left in our queue
-    int queueItems = [QueueFileArray count];
-    /* If we still have more items in our queue, lets go to the next one */
-    if (currentQueueEncodeIndex < queueItems)
-    {
-    [self writeToActivityLog: "doCancelCurrentJob currentQueueEncodeIndex is incremented to: %d", currentQueueEncodeIndex];
-    [self writeToActivityLog: "doCancelCurrentJob moving to the next job"];
-    
-    [self performNewQueueScan:[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"SourcePath"] scanTitleNum:[[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"TitleNumber"]intValue]];
-    }
-    else
-    {
-        [self writeToActivityLog: "doCancelCurrentJob the item queue is complete"];
-    }
-
-}
-
-//------------------------------------------------------------------------------------
 // Displays an alert asking user if the want to cancel encoding of current job.
 // Cancel: returns immediately after posting the alert. Later, when the user
 // acknowledges the alert, doCancelCurrentJob is called.
@@ -3148,9 +3514,62 @@ fWorkingCount = 0;
     }
 }
 
+//------------------------------------------------------------------------------------
+// Cancels and deletes the current job and stops libhb from processing the remaining
+// encodes.
+//------------------------------------------------------------------------------------
+- (void) doCancelCurrentJob
+{
+    // Stop the current job. hb_stop will only cancel the current pass and then set
+    // its state to HB_STATE_WORKDONE. It also does this asynchronously. So when we
+    // see the state has changed to HB_STATE_WORKDONE (in updateUI), we'll delete the
+    // remaining passes of the job and then start the queue back up if there are any
+    // remaining jobs.
+     
+    
+    hb_stop( fQueueEncodeLibhb );
+    
+    // Delete all remaining jobs since libhb doesn't do this on its own.
+            hb_job_t * job;
+            while( ( job = hb_job(fQueueEncodeLibhb, 0) ) )
+                hb_rem( fQueueEncodeLibhb, job );
+                
+    fEncodeState = 2;   // don't alert at end of processing since this was a cancel
+    
+    // now that we've stopped the currently encoding job, lets mark it as cancelled
+    [[QueueFileArray objectAtIndex:currentQueueEncodeIndex] setObject:[NSNumber numberWithInt:3] forKey:@"Status"];
+    // and as always, save it in the queue .plist...
+    /* We save all of the Queue data here */
+    [self saveQueueFileItem];
+    // so now lets move to 
+    currentQueueEncodeIndex++ ;
+    // ... and see if there are more items left in our queue
+    int queueItems = [QueueFileArray count];
+    /* If we still have more items in our queue, lets go to the next one */
+    if (currentQueueEncodeIndex < queueItems)
+    {
+    [self writeToActivityLog: "doCancelCurrentJob currentQueueEncodeIndex is incremented to: %d", currentQueueEncodeIndex];
+    [self writeToActivityLog: "doCancelCurrentJob moving to the next job"];
+    
+    [self performNewQueueScan:[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"SourcePath"] scanTitleNum:[[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"TitleNumber"]intValue]];
+    }
+    else
+    {
+        [self writeToActivityLog: "doCancelCurrentJob the item queue is complete"];
+    }
+
+}
+
 - (void) doCancelCurrentJobAndStop
 {
     hb_stop( fQueueEncodeLibhb );
+    
+    // Delete all remaining jobs since libhb doesn't do this on its own.
+            hb_job_t * job;
+            while( ( job = hb_job(fQueueEncodeLibhb, 0) ) )
+                hb_rem( fQueueEncodeLibhb, job );
+                
+                
     fEncodeState = 2;   // don't alert at end of processing since this was a cancel
     
     // now that we've stopped the currently encoding job, lets mark it as cancelled
@@ -3215,11 +3634,8 @@ fWorkingCount = 0;
     /* Start Get and set the initial pic size for display */
        hb_job_t * job = title->job;
        fTitle = title;
-
-       /*Set Source Size Field Here */
-    [fPicSettingsSrc setStringValue: [NSString stringWithFormat: @"%d x %d", fTitle->width, fTitle->height]];
-       
-       /* Set Auto Crop to on upon selecting a new title */
+    
+    /* Set Auto Crop to on upon selecting a new title  */
     [fPictureController setAutoCrop:YES];
     
        /* We get the originial output picture width and height and put them
@@ -3231,11 +3647,9 @@ fWorkingCount = 0;
        AutoCropLeft = job->crop[2];
        AutoCropRight = job->crop[3];
 
-       /* Run Through encoderPopUpChanged to see if there
-               needs to be any pic value modifications based on encoder settings */
-       //[self encoderPopUpChanged: NULL];
-       /* END Get and set the initial pic size for display */ 
-
+       /* Reset the new title in fPictureController &&  fPreviewController*/
+    [fPictureController SetTitle:title];
+    //[fPictureFilterController SetTitle:title];
     /* Update subtitle popups */
     hb_subtitle_t * subtitle;
     [fSubPopUp removeAllItems];
@@ -3337,6 +3751,10 @@ fWorkingCount = 0;
     [fDstMp4iPodFileCheck setHidden: YES];
     
     /* Update the Video Codec PopUp */
+    /* lets get the tag of the currently selected item first so we might reset it later */
+    int selectedVidEncoderTag;
+    selectedVidEncoderTag = [[fVidEncoderPopUp selectedItem] tag];
+    
     /* Note: we now store the video encoder int values from common.c in the tags of each popup for easy retrieval later */
     [fVidEncoderPopUp removeAllItems];
     NSMenuItem *menuItem;
@@ -3399,7 +3817,15 @@ fWorkingCount = 0;
                        [fCreateChapterMarkers setState: NSOffState];
                        break;
     }
-    [fVidEncoderPopUp selectItemAtIndex: 0];
+    /* if we have a previously selected vid encoder tag, then try to select it */
+    if (selectedVidEncoderTag)
+    {
+        [fVidEncoderPopUp selectItemWithTag: selectedVidEncoderTag];
+    }
+    else
+    {
+        [fVidEncoderPopUp selectItemAtIndex: 0];
+    }
 
     [self audioAddAudioTrackCodecs: fAudTrack1CodecPopUp];
     [self audioAddAudioTrackCodecs: fAudTrack2CodecPopUp];
@@ -3459,16 +3885,6 @@ fWorkingCount = 0;
                                     [[fDstFile2Field stringValue] stringByDeletingPathExtension], extension]];
 }
 
-- (void) shouldEnableHttpMp4CheckBox: (id) sender
-{
-    if( [[fAudTrack1CodecPopUp selectedItem] tag] == HB_ACODEC_AC3 || [[fAudTrack2CodecPopUp selectedItem] tag] == HB_ACODEC_AC3 ||
-                                                        [[fAudTrack3CodecPopUp selectedItem] tag] == HB_ACODEC_AC3 ||
-                                                        [[fAudTrack4CodecPopUp selectedItem] tag] == HB_ACODEC_AC3 )
-        [fDstMp4HttpOptFileCheck setEnabled: NO];
-    else
-        [fDstMp4HttpOptFileCheck setEnabled: YES];
-}
-        
 /* Method to determine if we should change the UI
 To reflect whether or not a Preset is being used or if
 the user is using "Custom" settings by determining the sender*/
@@ -3483,6 +3899,7 @@ the user is using "Custom" settings by determining the sender*/
 
                curUserPresetChosenNum = nil;
        }
+[self calculateBitrate:nil];
 }
 
 
@@ -3508,9 +3925,9 @@ the user is using "Custom" settings by determining the sender*/
     to use the index itself but this is easier */
     if (videoEncoder == HB_VCODEC_FFMPEG)
     {
-        if (job->pixel_ratio == 2)
+        if (job->anamorphic.mode == 2)
         {
-            job->pixel_ratio = 0;
+            job->anamorphic.mode = 0;
         }
         [fPictureController setAllowLooseAnamorphic:NO];
         /* We set the iPod atom checkbox to disabled and uncheck it as its only for x264 in the mp4
@@ -3630,9 +4047,98 @@ the user is using "Custom" settings by determining the sender*/
     hb_title_t * title = (hb_title_t *) hb_list_item( list,
             [fSrcTitlePopUp indexOfSelectedItem] );
     hb_job_t * job = title->job;
-     
-    [fVidBitrateField setIntValue: hb_calc_bitrate( job,
-            [fVidTargetSizeField intValue] )];
+    hb_audio_config_t * audio;
+    /* For  hb_calc_bitrate in addition to the Target Size in MB out of the
+     * Target Size Field, we also need the job info for the Muxer, the Chapters
+     * as well as all of the audio track info.
+     * This used to be accomplished by simply calling prepareJob here, however
+     * since the resilient queue sets the queue array values instead of the job
+     * values directly, we duplicate the old prepareJob code here for the variables
+     * needed
+     */
+    job->chapter_start = [fSrcChapterStartPopUp indexOfSelectedItem] + 1;
+    job->chapter_end = [fSrcChapterEndPopUp indexOfSelectedItem] + 1; 
+    job->mux = [[fDstFormatPopUp selectedItem] tag];
+    
+    /* Audio goes here */
+    int audiotrack_count = hb_list_count(job->list_audio);
+    for( int i = 0; i < audiotrack_count;i++)
+    {
+        hb_audio_t * temp_audio = (hb_audio_t*) hb_list_item( job->list_audio, 0 );
+        hb_list_rem(job->list_audio, temp_audio);
+    }
+    /* Now we need our audio info here for each track if applicable */
+    if ([fAudLang1PopUp indexOfSelectedItem] > 0)
+    {
+        audio = (hb_audio_config_t *) calloc(1, sizeof(*audio));
+        hb_audio_config_init(audio);
+        audio->in.track = [fAudLang1PopUp indexOfSelectedItem] - 1;
+        /* We go ahead and assign values to our audio->out.<properties> */
+        audio->out.track = [fAudLang1PopUp indexOfSelectedItem] - 1;
+        audio->out.codec = [[fAudTrack1CodecPopUp selectedItem] tag];
+        audio->out.mixdown = [[fAudTrack1MixPopUp selectedItem] tag];
+        audio->out.bitrate = [[fAudTrack1BitratePopUp selectedItem] tag];
+        audio->out.samplerate = [[fAudTrack1RatePopUp selectedItem] tag];
+        audio->out.dynamic_range_compression = [fAudTrack1DrcField floatValue];
+        
+        hb_audio_add( job, audio );
+        free(audio);
+    }  
+    if ([fAudLang2PopUp indexOfSelectedItem] > 0)
+    {
+        audio = (hb_audio_config_t *) calloc(1, sizeof(*audio));
+        hb_audio_config_init(audio);
+        audio->in.track = [fAudLang2PopUp indexOfSelectedItem] - 1;
+        /* We go ahead and assign values to our audio->out.<properties> */
+        audio->out.track = [fAudLang2PopUp indexOfSelectedItem] - 1;
+        audio->out.codec = [[fAudTrack2CodecPopUp selectedItem] tag];
+        audio->out.mixdown = [[fAudTrack2MixPopUp selectedItem] tag];
+        audio->out.bitrate = [[fAudTrack2BitratePopUp selectedItem] tag];
+        audio->out.samplerate = [[fAudTrack2RatePopUp selectedItem] tag];
+        audio->out.dynamic_range_compression = [fAudTrack2DrcField floatValue];
+        
+        hb_audio_add( job, audio );
+        free(audio);
+        
+    }
+    
+    if ([fAudLang3PopUp indexOfSelectedItem] > 0)
+    {
+        audio = (hb_audio_config_t *) calloc(1, sizeof(*audio));
+        hb_audio_config_init(audio);
+        audio->in.track = [fAudLang3PopUp indexOfSelectedItem] - 1;
+        /* We go ahead and assign values to our audio->out.<properties> */
+        audio->out.track = [fAudLang3PopUp indexOfSelectedItem] - 1;
+        audio->out.codec = [[fAudTrack3CodecPopUp selectedItem] tag];
+        audio->out.mixdown = [[fAudTrack3MixPopUp selectedItem] tag];
+        audio->out.bitrate = [[fAudTrack3BitratePopUp selectedItem] tag];
+        audio->out.samplerate = [[fAudTrack3RatePopUp selectedItem] tag];
+        audio->out.dynamic_range_compression = [fAudTrack3DrcField floatValue];
+        
+        hb_audio_add( job, audio );
+        free(audio);
+        
+    }
+
+    if ([fAudLang4PopUp indexOfSelectedItem] > 0)
+    {
+        audio = (hb_audio_config_t *) calloc(1, sizeof(*audio));
+        hb_audio_config_init(audio);
+        audio->in.track = [fAudLang4PopUp indexOfSelectedItem] - 1;
+        /* We go ahead and assign values to our audio->out.<properties> */
+        audio->out.track = [fAudLang4PopUp indexOfSelectedItem] - 1;
+        audio->out.codec = [[fAudTrack4CodecPopUp selectedItem] tag];
+        audio->out.mixdown = [[fAudTrack4MixPopUp selectedItem] tag];
+        audio->out.bitrate = [[fAudTrack4BitratePopUp selectedItem] tag];
+        audio->out.samplerate = [[fAudTrack4RatePopUp selectedItem] tag];
+        audio->out.dynamic_range_compression = [fAudTrack4DrcField floatValue];
+        
+        hb_audio_add( job, audio );
+        free(audio);
+        
+    }
+       
+[fVidBitrateField setIntValue: hb_calc_bitrate( job, [fVidTargetSizeField intValue] )];
 }
 
 #pragma mark -
@@ -3645,18 +4151,9 @@ the user is using "Custom" settings by determining the sender*/
 - (IBAction) revertPictureSizeToMax: (id) sender
 {
        hb_job_t * job = fTitle->job;
-       /* We use the output picture width and height
-     as calculated from libhb right after title is set
-     in TitlePopUpChanged */
-       job->width = PicOrigOutputWidth;
-       job->height = PicOrigOutputHeight;
-    [fPictureController setAutoCrop:YES];
-       /* Here we use the auto crop values determined right after scan */
-       job->crop[0] = AutoCropTop;
-       job->crop[1] = AutoCropBottom;
-       job->crop[2] = AutoCropLeft;
-       job->crop[3] = AutoCropRight;
-    
+       /* Here we apply the title source and height */
+    job->width = fTitle->width;
+    job->height = fTitle->height;
     
     [self calculatePictureSizing: sender];
     /* We call method to change UI to reflect whether a preset is used or not*/    
@@ -3667,145 +4164,123 @@ the user is using "Custom" settings by determining the sender*/
  * Registers changes made in the Picture Settings Window.
  */
 
-- (void)pictureSettingsDidChange {
+- (void)pictureSettingsDidChange 
+{
        [self calculatePictureSizing:nil];
 }
 
 /* Get and Display Current Pic Settings in main window */
 - (IBAction) calculatePictureSizing: (id) sender
 {
-       [fPicSettingsOutp setStringValue: [NSString stringWithFormat:@"%d x %d", fTitle->job->width, fTitle->job->height]];
-       
-    if (fTitle->job->pixel_ratio == 1)
+       if (fTitle->job->anamorphic.mode > 0)
        {
-        int titlewidth = fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3];
-        int arpwidth = fTitle->job->pixel_aspect_width;
-        int arpheight = fTitle->job->pixel_aspect_height;
-        int displayparwidth = titlewidth * arpwidth / arpheight;
-        int displayparheight = fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1];
-        [fPicSettingsOutp setStringValue: [NSString stringWithFormat:@"%d x %d", titlewidth, displayparheight]];
-        [fPicSettingsAnamorphic setStringValue: [NSString stringWithFormat:@"%d x %d Strict", displayparwidth, displayparheight]];
-        fTitle->job->keep_ratio = 0;
-       }
-    else if (fTitle->job->pixel_ratio == 2)
-    {
-        hb_job_t * job = fTitle->job;
-        int output_width, output_height, output_par_width, output_par_height;
-        hb_set_anamorphic_size(job, &output_width, &output_height, &output_par_width, &output_par_height);
-        int display_width;
-        display_width = output_width * output_par_width / output_par_height;
-
-        [fPicSettingsOutp setStringValue: [NSString stringWithFormat:@"%d x %d", output_width, output_height]];
-        [fPicSettingsAnamorphic setStringValue: [NSString stringWithFormat:@"%d x %d Loose", display_width, output_height]];
-
         fTitle->job->keep_ratio = 0;
-    }
-       else
-       {
-        [fPicSettingsAnamorphic setStringValue:@"Off"];
        }
-
-       /* Set ON/Off values for the deinterlace/keep aspect ratio according to boolean */
-       if (fTitle->job->keep_ratio > 0)
+    
+    [fPictureSizeField setStringValue: [NSString stringWithFormat:@"Picture Size: %@", [fPictureController getPictureSizeInfoString]]];
+    
+    NSString *picCropping;
+    /* Set the display field for crop as per boolean */
+       if (![fPictureController autoCrop])
        {
-               [fPicSettingARkeep setStringValue: @"On"];
+        picCropping =  @"Custom";
        }
        else
        {
-               [fPicSettingARkeep setStringValue: @"Off"];
-       }       
+               picCropping =  @"Auto";
+       }
+    picCropping = [picCropping stringByAppendingString:[NSString stringWithFormat:@" %d/%d/%d/%d",fTitle->job->crop[0],fTitle->job->crop[1],fTitle->job->crop[2],fTitle->job->crop[3]]];
+    
+    [fPictureCroppingField setStringValue: [NSString stringWithFormat:@"Picture Cropping: %@",picCropping]];
     
+    NSString *videoFilters;
+    videoFilters = @"";
     /* Detelecine */
-    if ([fPictureController detelecine]) {
-        [fPicSettingDetelecine setStringValue: @"Yes"];
+    if ([fPictureFilterController detelecine] == 1) 
+    {
+        videoFilters = [videoFilters stringByAppendingString:@" - Detelecine (Default)"];
     }
-    else {
-        [fPicSettingDetelecine setStringValue: @"No"];
+    else if ([fPictureFilterController detelecine] == 2) 
+    {
+        videoFilters = [videoFilters stringByAppendingString:[NSString stringWithFormat:@" - Detelecine (%@)",[fPictureFilterController detelecineCustomString]]];
     }
     
-    /* Decomb */
-       if ([fPictureController decomb] == 0)
-       {
-               [fPicSettingDecomb setStringValue: @"Off"];
-       }
-       else if ([fPictureController decomb] == 1)
-       {
-               [fPicSettingDecomb setStringValue: @"1:2:6:9:80:16:16"];
-       }
-    else if ([fPictureController decomb] == 2)
+    
+    if ([fPictureFilterController useDecomb] == 1)
     {
-        [fPicSettingDecomb setStringValue:[[NSUserDefaults standardUserDefaults] stringForKey:@"DecombCustomString"]];
+        /* Decomb */
+        if ([fPictureFilterController decomb] == 1)
+        {
+            videoFilters = [videoFilters stringByAppendingString:@" - Decomb (Default)"];
+        }
+        else if ([fPictureFilterController decomb] == 2)
+        {
+            videoFilters = [videoFilters stringByAppendingString:[NSString stringWithFormat:@" - Decomb (%@)",[fPictureFilterController decombCustomString]]];
+        }
     }
-
-    /* VFR (Variable Frame Rate) */
+    else
+    {
+        /* Deinterlace */
+        if ([fPictureFilterController deinterlace] > 0)
+        {
+            fTitle->job->deinterlace  = 1;
+        }
+        else
+        {
+            fTitle->job->deinterlace  = 0;
+        }
+        
+        if ([fPictureFilterController deinterlace] == 1)
+        {
+            videoFilters = [videoFilters stringByAppendingString:@" - Deinterlace (Fast)"];
+        }
+        else if ([fPictureFilterController deinterlace] == 2)
+        {
+            videoFilters = [videoFilters stringByAppendingString:@" - Deinterlace (Slow)"];
+        }
+        else if ([fPictureFilterController deinterlace] == 3)
+        {
+            videoFilters = [videoFilters stringByAppendingString:@" - Deinterlace (Slower)"];
+        }
+        else if ([fPictureFilterController deinterlace] == 4)
+        {
+            videoFilters = [videoFilters stringByAppendingString:[NSString stringWithFormat:@" - Deinterlace (%@)",[fPictureFilterController deinterlaceCustomString]]];
+        }
+       }
     
     
-       /* Deinterlace */
-       if ([fPictureController deinterlace] == 0)
-       {
-               [fPicSettingDeinterlace setStringValue: @"Off"];
-       }
-       else if ([fPictureController deinterlace] == 1)
-       {
-               [fPicSettingDeinterlace setStringValue: @"Fast"];
-       }
-       else if ([fPictureController deinterlace] == 2)
-       {
-               [fPicSettingDeinterlace setStringValue: @"Slow"];
-       }
-       else if ([fPictureController deinterlace] == 3)
-       {
-               [fPicSettingDeinterlace setStringValue: @"Slower"];
-       }
-               
     /* Denoise */
-       if ([fPictureController denoise] == 0)
+       if ([fPictureFilterController denoise] == 1)
        {
-               [fPicSettingDenoise setStringValue: @"Off"];
-       }
-       else if ([fPictureController denoise] == 1)
+               videoFilters = [videoFilters stringByAppendingString:@" - Denoise (Weak)"];
+    }
+       else if ([fPictureFilterController denoise] == 2)
        {
-               [fPicSettingDenoise setStringValue: @"Weak"];
-       }
-       else if ([fPictureController denoise] == 2)
+               videoFilters = [videoFilters stringByAppendingString:@" - Denoise (Medium)"];
+    }
+       else if ([fPictureFilterController denoise] == 3)
        {
-               [fPicSettingDenoise setStringValue: @"Medium"];
+               videoFilters = [videoFilters stringByAppendingString:@" - Denoise (Strong)"];
        }
-       else if ([fPictureController denoise] == 3)
+    else if ([fPictureFilterController denoise] == 4)
        {
-               [fPicSettingDenoise setStringValue: @"Strong"];
+               videoFilters = [videoFilters stringByAppendingString:[NSString stringWithFormat:@" - Denoise (%@)",[fPictureFilterController denoiseCustomString]]];
        }
     
     /* Deblock */
-    if ([fPictureController deblock] == 0) 
-    {
-        [fPicSettingDeblock setStringValue: @"Off"];
-    }
-    else 
+    if ([fPictureFilterController deblock] > 0) 
     {
-        [fPicSettingDeblock setStringValue: [NSString stringWithFormat:@"%d",[fPictureController deblock]]];
+        videoFilters = [videoFilters stringByAppendingString:[NSString stringWithFormat:@" - Deblock (%d)",[fPictureFilterController deblock]]];
     }
        
-       if (fTitle->job->pixel_ratio > 0)
-       {
-               [fPicSettingPAR setStringValue: @""];
-       }
-       else
-       {
-               [fPicSettingPAR setStringValue: @"Off"];
-       }
-       
-    /* Set the display field for crop as per boolean */
-       if (![fPictureController autoCrop])
-       {
-           [fPicSettingAutoCrop setStringValue: @"Custom"];
-       }
-       else
-       {
-               [fPicSettingAutoCrop setStringValue: @"Auto"];
-       }       
-       
+    /* Grayscale */
+    if ([fPictureFilterController grayscale]) 
+    {
+        videoFilters = [videoFilters stringByAppendingString:@" - Grayscale"];
+    }
+    [fVideoFiltersField setStringValue: [NSString stringWithFormat:@"Video Filters: %@", videoFilters]];
     
+    [fPictureController reloadStillPreview]; 
 }
 
 
@@ -4402,7 +4877,6 @@ the user is using "Custom" settings by determining the sender*/
     if( [fDstFormatPopUp indexOfSelectedItem] == 0 )
     {
         [self autoSetM4vExtension: sender];
-        [self shouldEnableHttpMp4CheckBox: sender];
     }
 }
 
@@ -4604,7 +5078,7 @@ the user is using "Custom" settings by determining the sender*/
         [drcSlider setEnabled: YES];
         [drcField setEnabled: YES];
     }
-    
+[self calculateBitrate:nil];    
 }
 
 - (IBAction) audioDRCSliderChanged: (id) sender
@@ -4631,6 +5105,14 @@ the user is using "Custom" settings by determining the sender*/
         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
@@ -4714,45 +5196,139 @@ the user is using "Custom" settings by determining the sender*/
 
 - (IBAction) showPicturePanel: (id) sender
 {
-       hb_list_t  * list  = hb_get_titles( fHandle );
-    hb_title_t * title = (hb_title_t *) hb_list_item( list,
-            [fSrcTitlePopUp indexOfSelectedItem] );
-    [fPictureController showPanelInWindow:fWindow forTitle:title];
+       [fPictureController showPictureWindow:sender];
+}
+
+- (void) picturePanelFullScreen
+{
+       [fPictureController setToFullScreenMode];
+}
+
+- (void) picturePanelWindowed
+{
+       [fPictureController setToWindowedMode];
+}
+
+- (IBAction) showFiltersPanel: (id) sender
+{
+       [fPictureFilterController showFilterWindow:sender];
+}
+
+- (IBAction) showPreviewWindow: (id) sender
+{
+       [fPictureController showPreviewWindow:sender];
 }
 
 #pragma mark -
 #pragma mark Preset Outline View Methods
 #pragma mark - Required
 /* These are required by the NSOutlineView Datasource Delegate */
+
+
+/* used to specify the number of levels to show for each item */
+- (int)outlineView:(NSOutlineView *)fPresetsOutlineView numberOfChildrenOfItem:(id)item
+{
+    /* currently use no levels to test outline view viability */
+    if (item == nil) // for an outline view the root level of the hierarchy is always nil
+    {
+        return [UserPresets count];
+    }
+    else
+    {
+        /* we need to return the count of the array in ChildrenArray for this folder */
+        NSArray *children = nil;
+        children = [item objectForKey:@"ChildrenArray"];
+        if ([children count] > 0)
+        {
+            return [children count];
+        }
+        else
+        {
+            return 0;
+        }
+    }
+}
+
 /* We use this to deterimine children of an item */
-- (id)outlineView:(NSOutlineView *)fPresetsOutlineView child:(NSInteger)index ofItem:(id)item
+- (id)outlineView:(NSOutlineView *)fPresetsOutlineView child:(int)index ofItem:(id)item
 {
-if (item == nil)
-        return [UserPresets objectAtIndex:index];
+    
+    /* we need to return the count of the array in ChildrenArray for this folder */
+    NSArray *children = nil;
+    if (item == nil)
+    {
+        children = UserPresets;
+    }
+    else
+    {
+        if ([item objectForKey:@"ChildrenArray"])
+        {
+            children = [item objectForKey:@"ChildrenArray"];
+        }
+    }   
+    if ((children == nil) || ([children count] <= index))
+    {
+        return nil;
+    }
+    else
+    {
+        return [children objectAtIndex:index];
+    }
+    
     
     // We are only one level deep, so we can't be asked about children
-    NSAssert (NO, @"Presets View outlineView:child:ofItem: currently can't handle nested items.");
-    return nil;
+    //NSAssert (NO, @"Presets View outlineView:child:ofItem: currently can't handle nested items.");
+    //return nil;
 }
+
 /* We use this to determine if an item should be expandable */
 - (BOOL)outlineView:(NSOutlineView *)fPresetsOutlineView isItemExpandable:(id)item
 {
-
-    /* For now, we maintain one level, so set to no
-    * when nested, we set to yes for any preset "folders"
-    */
-    return NO;
-
-}
-/* used to specify the number of levels to show for each item */
-- (int)outlineView:(NSOutlineView *)fPresetsOutlineView numberOfChildrenOfItem:(id)item
-{
-    /* currently use no levels to test outline view viability */
+    
+    /* we need to return the count of the array in ChildrenArray for this folder */
+    NSArray *children= nil;
     if (item == nil)
-        return [UserPresets count];
+    {
+        children = UserPresets;
+    }
+    else
+    {
+        if ([item objectForKey:@"ChildrenArray"])
+        {
+            children = [item objectForKey:@"ChildrenArray"];
+        }
+    }   
+    
+    /* To deterimine if an item should show a disclosure triangle
+     * we could do it by the children count as so:
+     * if ([children count] < 1)
+     * However, lets leave the triangle show even if there are no
+     * children to help indicate a folder, just like folder in the
+     * finder can show a disclosure triangle even when empty
+     */
+    
+    /* We need to determine if the item is a folder */
+   if ([[item objectForKey:@"Folder"] intValue] == 1)
+   {
+        return YES;
+    }
     else
-        return 0;
+    {
+        return NO;
+    }
+    
+}
+
+- (BOOL)outlineView:(NSOutlineView *)outlineView shouldExpandItem:(id)item
+{
+    // Our outline view has no levels, but we can still expand every item. Doing so
+    // just makes the row taller. See heightOfRowByItem below.
+//return ![(HBQueueOutlineView*)outlineView isDragging];
+
+return YES;
 }
+
+
 /* Used to tell the outline view which information is to be displayed per item */
 - (id)outlineView:(NSOutlineView *)fPresetsOutlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
 {
@@ -4764,17 +5340,26 @@ if (item == nil)
     }
     else
     {
-        return @"something";
+        //return @"";
+        return nil;
     }
 }
 
+- (id)outlineView:(NSOutlineView *)outlineView itemForPersistentObject:(id)object
+{
+    return [NSKeyedUnarchiver unarchiveObjectWithData:object];
+}
+- (id)outlineView:(NSOutlineView *)outlineView persistentObjectForItem:(id)item
+{
+    return [NSKeyedArchiver archivedDataWithRootObject:item];
+}
+
 #pragma mark - Added Functionality (optional)
 /* Use to customize the font and display characteristics of the title cell */
 - (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
 {
     if ([[tableColumn identifier] isEqualToString:@"PresetName"])
     {
-        NSDictionary *userPresetDict = item;
         NSFont *txtFont;
         NSColor *fontColor;
         NSColor *shadowColor;
@@ -4788,7 +5373,7 @@ if (item == nil)
         }
         else
         {
-            if ([[userPresetDict objectForKey:@"Type"] intValue] == 0)
+            if ([[item objectForKey:@"Type"] intValue] == 0)
             {
                 fontColor = [NSColor blueColor];
             }
@@ -4796,15 +5381,21 @@ if (item == nil)
             {
                 fontColor = [NSColor blackColor];
             }
-            shadowColor = nil;
+            /* check to see if its a folder */
+            //if ([[item objectForKey:@"Folder"] intValue] == 1)
+            //{
+            //fontColor = [NSColor greenColor];
+            //}
+            
+            
         }
         /* We use Bold Text for the HB Default */
-        if ([[userPresetDict objectForKey:@"Default"] intValue] == 1)// 1 is HB default
+        if ([[item objectForKey:@"Default"] intValue] == 1)// 1 is HB default
         {
             txtFont = [NSFont boldSystemFontOfSize: [NSFont smallSystemFontSize]];
         }
         /* We use Bold Text for the User Specified Default */
-        if ([[userPresetDict objectForKey:@"Default"] intValue] == 2)// 2 is User default
+        if ([[item objectForKey:@"Default"] intValue] == 2)// 2 is User default
         {
             txtFont = [NSFont boldSystemFontOfSize: [NSFont smallSystemFontSize]];
         }
@@ -4861,7 +5452,8 @@ if (item == nil)
 - (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pboard
 {
        // Dragging is only allowed for custom presets.
-       if ([[[UserPresets objectAtIndex:[fPresetsOutlineView selectedRow]] objectForKey:@"Type"] intValue] == 0) // 0 is built in preset
+    //[[[fPresetsOutlineView itemAtRow:[fPresetsOutlineView selectedRow]] objectForKey:@"Default"] intValue] != 1
+       if ([[[fPresetsOutlineView itemAtRow:[fPresetsOutlineView selectedRow]] objectForKey:@"Type"] intValue] == 0) // 0 is built in preset
     {
         return NO;
     }
@@ -4879,16 +5471,15 @@ if (item == nil)
 
 - (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(int)index
 {
+       
        // Don't allow dropping ONTO an item since they can't really contain any children.
     
     BOOL isOnDropTypeProposal = index == NSOutlineViewDropOnItemIndex;
     if (isOnDropTypeProposal)
         return NSDragOperationNone;
     
-    
-       // Don't allow dropping INTO an item since they can't really contain any children as of yet.
-       
-    if (item != nil)
+    // Don't allow dropping INTO an item since they can't really contain any children as of yet.
+       if (item != nil)
        {
                index = [fPresetsOutlineView rowForItem: item] + 1;
                item = nil;
@@ -4899,7 +5490,7 @@ if (item == nil)
     {
         return NSDragOperationNone;
         index = MAX (index, presetCurrentBuiltInCount);
-       }
+       }    
        
     [outlineView setDropItem:item dropChildIndex:index];
     return NSDragOperationGeneric;
@@ -4909,16 +5500,27 @@ if (item == nil)
 
 - (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(int)index
 {
-    NSMutableIndexSet *moveItems = [NSMutableIndexSet indexSet];
-    
-    id obj;
-    NSEnumerator *enumerator = [fDraggedNodes objectEnumerator];
-    while (obj = [enumerator nextObject])
-    {
-        [moveItems addIndex:[UserPresets indexOfObject:obj]];
+    /* first, lets see if we are dropping into a folder */
+    if ([[fPresetsOutlineView itemAtRow:index] objectForKey:@"Folder"] && [[[fPresetsOutlineView itemAtRow:index] objectForKey:@"Folder"] intValue] == 1) // if its a folder
+       {
+    NSMutableArray *childrenArray = [[NSMutableArray alloc] init];
+    childrenArray = [[fPresetsOutlineView itemAtRow:index] objectForKey:@"ChildrenArray"];
+    [childrenArray addObject:item];
+    [[fPresetsOutlineView itemAtRow:index] setObject:[NSMutableArray arrayWithArray: childrenArray] forKey:@"ChildrenArray"];
+    [childrenArray autorelease];
+    }
+    else // We are not, so we just move the preset into the existing array 
+    {
+        NSMutableIndexSet *moveItems = [NSMutableIndexSet indexSet];
+        id obj;
+        NSEnumerator *enumerator = [fDraggedNodes objectEnumerator];
+        while (obj = [enumerator nextObject])
+        {
+            [moveItems addIndex:[UserPresets indexOfObject:obj]];
+        }
+        // Successful drop, lets rearrange the view and save it all
+        [self moveObjectsInPresetsArray:UserPresets fromIndexes:moveItems toIndex: index];
     }
-    // Successful drop, lets rearrange the view and save it all
-    [self moveObjectsInPresetsArray:UserPresets fromIndexes:moveItems toIndex: index];
     [fPresetsOutlineView reloadData];
     [self savePreset];
     return YES;
@@ -4959,12 +5561,12 @@ if (item == nil)
 
 - (IBAction)selectPreset:(id)sender
 {
-
-    if ([fPresetsOutlineView selectedRow] >= 0)
+    
+    if ([fPresetsOutlineView selectedRow] >= 0 && [[[fPresetsOutlineView itemAtRow:[fPresetsOutlineView selectedRow]] objectForKey:@"Folder"] intValue] != 1)
     {
         chosenPreset = [fPresetsOutlineView itemAtRow:[fPresetsOutlineView selectedRow]];
-        /* we set the preset display field in main window here */
         [fPresetSelectedDisplay setStringValue:[chosenPreset objectForKey:@"PresetName"]];
+        
         if ([[chosenPreset objectForKey:@"Default"] intValue] == 1)
         {
             [fPresetSelectedDisplay setStringValue:[NSString stringWithFormat:@"%@ (Default)", [chosenPreset objectForKey:@"PresetName"]]];
@@ -4973,67 +5575,38 @@ if (item == nil)
         {
             [fPresetSelectedDisplay setStringValue:[chosenPreset objectForKey:@"PresetName"]];
         }
+        
         /* File Format */
         [fDstFormatPopUp selectItemWithTitle:[chosenPreset objectForKey:@"FileFormat"]];
         [self formatPopUpChanged:nil];
-
+        
         /* Chapter Markers*/
         [fCreateChapterMarkers setState:[[chosenPreset objectForKey:@"ChapterMarkers"] intValue]];
         /* Allow Mpeg4 64 bit formatting +4GB file sizes */
         [fDstMp4LargeFileCheck setState:[[chosenPreset objectForKey:@"Mp4LargeFile"] intValue]];
         /* Mux mp4 with http optimization */
         [fDstMp4HttpOptFileCheck setState:[[chosenPreset objectForKey:@"Mp4HttpOptimize"] intValue]];
-
+        
         /* Video encoder */
+        [fVidEncoderPopUp selectItemWithTitle:[chosenPreset objectForKey:@"VideoEncoder"]];
         /* We set the advanced opt string here if applicable*/
         [fAdvancedOptions setOptions:[chosenPreset objectForKey:@"x264Option"]];
-        /* We use a conditional to account for the new x264 encoder dropdown as well as presets made using legacy x264 settings*/
-        if ([[chosenPreset objectForKey:@"VideoEncoder"] isEqualToString:@"x264 (h.264 Main)"] ||
-            [[chosenPreset objectForKey:@"VideoEncoder"] isEqualToString:@"x264 (h.264 iPod)"] ||
-            [[chosenPreset objectForKey:@"VideoEncoder"] isEqualToString:@"x264"])
-        {
-            [fVidEncoderPopUp selectItemWithTitle:@"H.264 (x264)"];
-            /* special case for legacy preset to check the new fDstMp4HttpOptFileCheck checkbox to set the ipod atom */
-            if ([[chosenPreset objectForKey:@"VideoEncoder"] isEqualToString:@"x264 (h.264 iPod)"])
-            {
-                [fDstMp4iPodFileCheck setState:NSOnState];
-                /* We also need to add "level=30:" to the advanced opts string to set the correct level for the iPod when
-                 encountering a legacy preset as it used to be handled separately from the opt string*/
-                [fAdvancedOptions setOptions:[@"level=30:" stringByAppendingString:[fAdvancedOptions optionsString]]];
-            }
-            else
-            {
-                [fDstMp4iPodFileCheck setState:NSOffState];
-            }
-        }
-        else if ([[chosenPreset objectForKey:@"VideoEncoder"] isEqualToString:@"FFmpeg"])
-        {
-            [fVidEncoderPopUp selectItemWithTitle:@"MPEG-4 (FFmpeg)"];
-        }
-        else if ([[chosenPreset objectForKey:@"VideoEncoder"] isEqualToString:@"XviD"])
-        {
-            [fVidEncoderPopUp selectItemWithTitle:@"MPEG-4 (XviD)"];
-        }
-        else
-        {
-            [fVidEncoderPopUp selectItemWithTitle:[chosenPreset objectForKey:@"VideoEncoder"]];
-        }
-
+        
         /* Lets run through the following functions to get variables set there */
         [self videoEncoderPopUpChanged:nil];
         /* Set the state of ipod compatible with Mp4iPodCompatible. Only for x264*/
         [fDstMp4iPodFileCheck setState:[[chosenPreset objectForKey:@"Mp4iPodCompatible"] intValue]];
         [self calculateBitrate:nil];
-
+        
         /* Video quality */
         [fVidQualityMatrix selectCellAtRow:[[chosenPreset objectForKey:@"VideoQualityType"] intValue] column:0];
-
+        
         [fVidTargetSizeField setStringValue:[chosenPreset objectForKey:@"VideoTargetSize"]];
         [fVidBitrateField setStringValue:[chosenPreset objectForKey:@"VideoAvgBitrate"]];
         [fVidQualitySlider setFloatValue:[[chosenPreset objectForKey:@"VideoQualitySlider"] floatValue]];
-
+        
         [self videoMatrixChanged:nil];
-
+        
         /* Video framerate */
         /* For video preset video framerate, we want to make sure that Same as source does not conflict with the
          detected framerate in the fVidRatePopUp so we use index 0*/
@@ -5045,336 +5618,179 @@ if (item == nil)
         {
             [fVidRatePopUp selectItemWithTitle:[chosenPreset objectForKey:@"VideoFramerate"]];
         }
-
-        /* GrayScale */
-        [fVidGrayscaleCheck setState:[[chosenPreset objectForKey:@"VideoGrayScale"] intValue]];
-
+        
+        
         /* 2 Pass Encoding */
         [fVidTwoPassCheck setState:[[chosenPreset objectForKey:@"VideoTwoPass"] intValue]];
         [self twoPassCheckboxChanged:nil];
+        
         /* Turbo 1st pass for 2 Pass Encoding */
         [fVidTurboPassCheck setState:[[chosenPreset objectForKey:@"VideoTurboTwoPass"] intValue]];
-
+        
         /*Audio*/
-        if ([chosenPreset objectForKey:@"FileCodecs"])
+        
+        if ([chosenPreset objectForKey:@"Audio1Track"] > 0)
         {
-            /* We need to handle the audio codec popup by determining what was chosen from the deprecated Codecs PopUp for past presets*/
-            if ([[chosenPreset objectForKey:@"FileCodecs"] isEqualToString: @"AVC/H.264 Video / AAC + AC3 Audio"])
-            {
-                /* We need to address setting languages etc. here in the new multi track audio panel */
-                /* Track One set here */
-                /*for track one though a track should be selected but lets check here anyway and use track one if its not.*/
-                if ([fAudLang1PopUp indexOfSelectedItem] == 0)
-                {
-                    [fAudLang1PopUp selectItemAtIndex: 1];
-                    [self audioTrackPopUpChanged: fAudLang1PopUp];
-                }
-                [fAudTrack1CodecPopUp selectItemWithTitle: @"AAC (faac)"];
-                [self audioTrackPopUpChanged: fAudTrack1CodecPopUp];
-                /* Track Two, set source same as track one */
-                [fAudLang2PopUp selectItemAtIndex: [fAudLang1PopUp indexOfSelectedItem]];
-                [self audioTrackPopUpChanged: fAudLang2PopUp];
-                [fAudTrack2CodecPopUp selectItemWithTitle: @"AC3 Passthru"];
-                [self audioTrackPopUpChanged: fAudTrack2CodecPopUp];
-            }
-            else if ([[chosenPreset objectForKey:@"FileCodecs"] isEqualToString:@"MPEG-4 Video / AAC Audio"] ||
-                     [[chosenPreset objectForKey:@"FileCodecs"] isEqualToString:@"AVC/H.264 Video / AAC Audio"])
+            if ([fAudLang1PopUp indexOfSelectedItem] == 0)
             {
-                if ([fAudLang1PopUp indexOfSelectedItem] > 0)
-                {
-                    [fAudTrack1CodecPopUp selectItemWithTitle: @"AAC (faac)"];
-                    [self audioTrackPopUpChanged: fAudTrack1CodecPopUp];
-                }
-                if ([fAudLang2PopUp indexOfSelectedItem] > 0)
-                {
-                    [fAudTrack2CodecPopUp selectItemWithTitle: @"AAC (faac)"];
-                    [self audioTrackPopUpChanged: fAudTrack2CodecPopUp];
-                }
-                if ([fAudLang3PopUp indexOfSelectedItem] > 0)
-                {
-                    [fAudTrack3CodecPopUp selectItemWithTitle: @"AAC (faac)"];
-                    [self audioTrackPopUpChanged: fAudTrack3CodecPopUp];
-                }
-                if ([fAudLang4PopUp indexOfSelectedItem] > 0)
-                {
-                    [fAudTrack4CodecPopUp selectItemWithTitle: @"AAC (faac)"];
-                    [self audioTrackPopUpChanged: fAudTrack4CodecPopUp];
-                }
+                [fAudLang1PopUp selectItemAtIndex: 1];
             }
-            else if ([[chosenPreset objectForKey:@"FileCodecs"] isEqualToString:@"MPEG-4 Video / AC-3 Audio"] ||
-                     [[chosenPreset objectForKey:@"FileCodecs"] isEqualToString:@"AVC/H.264 Video / AC-3 Audio"])
+            [self audioTrackPopUpChanged: fAudLang1PopUp];
+            [fAudTrack1CodecPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio1Encoder"]];
+            [self audioTrackPopUpChanged: fAudTrack1CodecPopUp];
+            [fAudTrack1MixPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio1Mixdown"]];
+            /* 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)
             {
-                if ([fAudLang1PopUp indexOfSelectedItem] > 0)
-                {
-                    [fAudTrack1CodecPopUp selectItemWithTitle: @"AC3 Passthru"];
-                    [self audioTrackPopUpChanged: fAudTrack1CodecPopUp];
-                }
-                if ([fAudLang2PopUp indexOfSelectedItem] > 0)
-                {
-                    [fAudTrack2CodecPopUp selectItemWithTitle: @"AC3 Passthru"];
-                    [self audioTrackPopUpChanged: fAudTrack2CodecPopUp];
-                }
-                if ([fAudLang3PopUp indexOfSelectedItem] > 0)
-                {
-                    [fAudTrack3CodecPopUp selectItemWithTitle: @"AC3 Passthru"];
-                    [self audioTrackPopUpChanged: fAudTrack3CodecPopUp];
-                }
-                if ([fAudLang4PopUp indexOfSelectedItem] > 0)
-                {
-                    [fAudTrack4CodecPopUp selectItemWithTitle: @"AC3 Passthru"];
-                    [self audioTrackPopUpChanged: fAudTrack4CodecPopUp];
-                }
+                [self audioTrackPopUpChanged: fAudTrack1CodecPopUp];
             }
-            else if ([[chosenPreset objectForKey:@"FileCodecs"] isEqualToString:@"MPEG-4 Video / MP3 Audio"] ||
-                     [[chosenPreset objectForKey:@"FileCodecs"] isEqualToString:@"AVC/H.264 Video / MP3 Audio"])
+            [fAudTrack1RatePopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio1Samplerate"]];
+            /* We set the presets bitrate if it is *not* an AC3 track since that uses the input bitrate */
+            if (![[chosenPreset objectForKey:@"Audio1Encoder"] isEqualToString:@"AC3 Passthru"])
             {
-                if ([fAudLang1PopUp indexOfSelectedItem] > 0)
-                {
-                    [fAudTrack1CodecPopUp selectItemWithTitle: @"MP3 (lame)"];
-                    [self audioTrackPopUpChanged: fAudTrack1CodecPopUp];
-                }
-                if ([fAudLang2PopUp indexOfSelectedItem] > 0)
-                {
-                    [fAudTrack2CodecPopUp selectItemWithTitle: @"MP3 (lame)"];
-                    [self audioTrackPopUpChanged: fAudTrack2CodecPopUp];
-                }
-                if ([fAudLang3PopUp indexOfSelectedItem] > 0)
-                {
-                    [fAudTrack3CodecPopUp selectItemWithTitle: @"MP3 (lame)"];
-                    [self audioTrackPopUpChanged: fAudTrack3CodecPopUp];
-                }
-                if ([fAudLang4PopUp indexOfSelectedItem] > 0)
-                {
-                    [fAudTrack4CodecPopUp selectItemWithTitle: @"MP3 (lame)"];
-                    [self audioTrackPopUpChanged: fAudTrack4CodecPopUp];
-                }
+                [fAudTrack1BitratePopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio1Bitrate"]];
             }
-            else if ([[chosenPreset objectForKey:@"FileCodecs"] isEqualToString:@"MPEG-4 Video / Vorbis Audio"])
+            [fAudTrack1DrcSlider setFloatValue:[[chosenPreset objectForKey:@"Audio1TrackDRCSlider"] floatValue]];
+            [self audioDRCSliderChanged: fAudTrack1DrcSlider];
+        }
+        if ([chosenPreset objectForKey:@"Audio2Track"] > 0)
+        {
+            if ([fAudLang2PopUp indexOfSelectedItem] == 0)
             {
-                if ([fAudLang1PopUp indexOfSelectedItem] > 0)
-                {
-                    [fAudTrack1CodecPopUp selectItemWithTitle: @"Vorbis (vorbis)"];
-                    [self audioTrackPopUpChanged: fAudTrack1CodecPopUp];
-                }
-                if ([fAudLang2PopUp indexOfSelectedItem] > 0)
-                {
-                    [fAudTrack2CodecPopUp selectItemWithTitle: @"Vorbis (vorbis)"];
-                    [self audioTrackPopUpChanged: fAudTrack2CodecPopUp];
-                }
-                if ([fAudLang3PopUp indexOfSelectedItem] > 0)
-                {
-                    [fAudTrack3CodecPopUp selectItemWithTitle: @"Vorbis (vorbis)"];
-                    [self audioTrackPopUpChanged: fAudTrack3CodecPopUp];
-                }
-                if ([fAudLang4PopUp indexOfSelectedItem] > 0)
-                {
-                    [fAudTrack4CodecPopUp selectItemWithTitle: @"Vorbis (vorbis)"];
-                    [self audioTrackPopUpChanged: fAudTrack4CodecPopUp];
-                }
+                [fAudLang2PopUp selectItemAtIndex: 1];
             }
-            /* We detect here if we have the old audio sample rate and if so we apply samplerate and bitrate to the existing four tracks if chosen
-            * UNLESS the CodecPopUp is AC3 in which case the preset values are ignored in favor of rates set in audioTrackMixdownChanged*/
-            if ([chosenPreset objectForKey:@"AudioSampleRate"])
+            [self audioTrackPopUpChanged: fAudLang2PopUp];
+            [fAudTrack2CodecPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio2Encoder"]];
+            [self audioTrackPopUpChanged: fAudTrack2CodecPopUp];
+            [fAudTrack2MixPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio2Mixdown"]];
+            /* 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)
             {
-                if ([fAudLang1PopUp indexOfSelectedItem] > 0 && [fAudTrack1CodecPopUp titleOfSelectedItem] != @"AC3 Passthru")
-                {
-                    [fAudTrack1RatePopUp selectItemWithTitle:[chosenPreset objectForKey:@"AudioSampleRate"]];
-                    [fAudTrack1BitratePopUp selectItemWithTitle:[chosenPreset objectForKey:@"AudioBitRate"]];
-                }
-                if ([fAudLang2PopUp indexOfSelectedItem] > 0 && [fAudTrack2CodecPopUp titleOfSelectedItem] != @"AC3 Passthru")
-                {
-                    [fAudTrack2RatePopUp selectItemWithTitle:[chosenPreset objectForKey:@"AudioSampleRate"]];
-                    [fAudTrack2BitratePopUp selectItemWithTitle:[chosenPreset objectForKey:@"AudioBitRate"]];
-                }
-                if ([fAudLang3PopUp indexOfSelectedItem] > 0 && [fAudTrack3CodecPopUp titleOfSelectedItem] != @"AC3 Passthru")
-                {
-                    [fAudTrack3RatePopUp selectItemWithTitle:[chosenPreset objectForKey:@"AudioSampleRate"]];
-                    [fAudTrack3BitratePopUp selectItemWithTitle:[chosenPreset objectForKey:@"AudioBitRate"]];
-                }
-                if ([fAudLang4PopUp indexOfSelectedItem] > 0 && [fAudTrack4CodecPopUp titleOfSelectedItem] != @"AC3 Passthru")
-                {
-                    [fAudTrack4RatePopUp selectItemWithTitle:[chosenPreset objectForKey:@"AudioSampleRate"]];
-                    [fAudTrack4BitratePopUp selectItemWithTitle:[chosenPreset objectForKey:@"AudioBitRate"]];
-                }
+                [self audioTrackPopUpChanged: fAudTrack2CodecPopUp];
             }
-            /* We detect here if we have the old DRC Slider and if so we apply it to the existing four tracks if chosen */
-            if ([chosenPreset objectForKey:@"AudioDRCSlider"])
+            [fAudTrack2RatePopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio2Samplerate"]];
+            /* We set the presets bitrate if it is *not* an AC3 track since that uses the input bitrate */
+            if (![[chosenPreset objectForKey:@"Audio2Encoder"] isEqualToString:@"AC3 Passthru"])
             {
-                if ([fAudLang1PopUp indexOfSelectedItem] > 0)
-                {
-                    [fAudTrack1DrcSlider setFloatValue:[[chosenPreset objectForKey:@"AudioDRCSlider"] floatValue]];
-                    [self audioDRCSliderChanged: fAudTrack1DrcSlider];
-                }
-                if ([fAudLang2PopUp indexOfSelectedItem] > 0)
-                {
-                    [fAudTrack2DrcSlider setFloatValue:[[chosenPreset objectForKey:@"AudioDRCSlider"] floatValue]];
-                    [self audioDRCSliderChanged: fAudTrack2DrcSlider];
-                }
-                if ([fAudLang3PopUp indexOfSelectedItem] > 0)
-                {
-                    [fAudTrack3DrcSlider setFloatValue:[[chosenPreset objectForKey:@"AudioDRCSlider"] floatValue]];
-                    [self audioDRCSliderChanged: fAudTrack3DrcSlider];
-                }
-                if ([fAudLang4PopUp indexOfSelectedItem] > 0)
-                {
-                    [fAudTrack4DrcSlider setFloatValue:[[chosenPreset objectForKey:@"AudioDRCSlider"] floatValue]];
-                    [self audioDRCSliderChanged: fAudTrack4DrcSlider];
-                }
+                [fAudTrack2BitratePopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio2Bitrate"]];
             }
+            [fAudTrack2DrcSlider setFloatValue:[[chosenPreset objectForKey:@"Audio2TrackDRCSlider"] floatValue]];
+            [self audioDRCSliderChanged: fAudTrack2DrcSlider];
         }
-        else // since there was no codecs key in the preset we know we can use new multi-audio track presets
+        if ([chosenPreset objectForKey:@"Audio3Track"] > 0)
         {
-            if ([chosenPreset objectForKey:@"Audio1Track"] > 0)
-            {
-                if ([fAudLang1PopUp indexOfSelectedItem] == 0)
-                {
-                    [fAudLang1PopUp selectItemAtIndex: 1];
-                }
-                [self audioTrackPopUpChanged: fAudLang1PopUp];
-                [fAudTrack1CodecPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio1Encoder"]];
-                [self audioTrackPopUpChanged: fAudTrack1CodecPopUp];
-                [fAudTrack1MixPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio1Mixdown"]];
-                /* 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:[chosenPreset objectForKey:@"Audio1Samplerate"]];
-                /* We set the presets bitrate if it is *not* an AC3 track since that uses the input bitrate */
-                if (![[chosenPreset objectForKey:@"Audio1Encoder"] isEqualToString:@"AC3 Passthru"])
-                {
-                    [fAudTrack1BitratePopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio1Bitrate"]];
-                }
-                [fAudTrack1DrcSlider setFloatValue:[[chosenPreset objectForKey:@"Audio1TrackDRCSlider"] floatValue]];
-                [self audioDRCSliderChanged: fAudTrack1DrcSlider];
-            }
-            if ([chosenPreset objectForKey:@"Audio2Track"] > 0)
+            if ([fAudLang3PopUp indexOfSelectedItem] == 0)
             {
-                if ([fAudLang2PopUp indexOfSelectedItem] == 0)
-                {
-                    [fAudLang2PopUp selectItemAtIndex: 1];
-                }
-                [self audioTrackPopUpChanged: fAudLang2PopUp];
-                [fAudTrack2CodecPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio2Encoder"]];
-                [self audioTrackPopUpChanged: fAudTrack2CodecPopUp];
-                [fAudTrack2MixPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio2Mixdown"]];
-                /* 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:[chosenPreset objectForKey:@"Audio2Samplerate"]];
-                /* We set the presets bitrate if it is *not* an AC3 track since that uses the input bitrate */
-                if (![[chosenPreset objectForKey:@"Audio2Encoder"] isEqualToString:@"AC3 Passthru"])
-                {
-                    [fAudTrack2BitratePopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio2Bitrate"]];
-                }
-                [fAudTrack2DrcSlider setFloatValue:[[chosenPreset objectForKey:@"Audio2TrackDRCSlider"] floatValue]];
-                [self audioDRCSliderChanged: fAudTrack2DrcSlider];
+                [fAudLang3PopUp selectItemAtIndex: 1];
             }
-            if ([chosenPreset objectForKey:@"Audio3Track"] > 0)
+            [self audioTrackPopUpChanged: fAudLang3PopUp];
+            [fAudTrack3CodecPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio3Encoder"]];
+            [self audioTrackPopUpChanged: fAudTrack3CodecPopUp];
+            [fAudTrack3MixPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio3Mixdown"]];
+            /* check to see if the selections was available, if not, rerun audioTrackPopUpChanged using the codec to just set the default
+             * mixdown*/
+            if  ([fAudTrack3MixPopUp selectedItem] == nil)
             {
-                if ([fAudLang3PopUp indexOfSelectedItem] == 0)
-                {
-                    [fAudLang3PopUp selectItemAtIndex: 1];
-                }
-                [self audioTrackPopUpChanged: fAudLang3PopUp];
-                [fAudTrack3CodecPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio3Encoder"]];
                 [self audioTrackPopUpChanged: fAudTrack3CodecPopUp];
-                [fAudTrack3MixPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio3Mixdown"]];
-                /* check to see if the selections was available, if not, rerun audioTrackPopUpChanged using the codec to just set the default
-                 * mixdown*/
-                if  ([fAudTrack3MixPopUp selectedItem] == nil)
-                {
-                    [self audioTrackPopUpChanged: fAudTrack3CodecPopUp];
-                }
-                [fAudTrack3RatePopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio3Samplerate"]];
-                /* We set the presets bitrate if it is *not* an AC3 track since that uses the input bitrate */
-                if (![[chosenPreset objectForKey:@"Audio3Encoder"] isEqualToString: @"AC3 Passthru"])
-                {
-                    [fAudTrack3BitratePopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio3Bitrate"]];
-                }
-                [fAudTrack3DrcSlider setFloatValue:[[chosenPreset objectForKey:@"Audio3TrackDRCSlider"] floatValue]];
-                [self audioDRCSliderChanged: fAudTrack3DrcSlider];
             }
-            if ([chosenPreset objectForKey:@"Audio4Track"] > 0)
+            [fAudTrack3RatePopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio3Samplerate"]];
+            /* We set the presets bitrate if it is *not* an AC3 track since that uses the input bitrate */
+            if (![[chosenPreset objectForKey:@"Audio3Encoder"] isEqualToString: @"AC3 Passthru"])
             {
-                if ([fAudLang4PopUp indexOfSelectedItem] == 0)
-                {
-                    [fAudLang4PopUp selectItemAtIndex: 1];
-                }
-                [self audioTrackPopUpChanged: fAudLang4PopUp];
-                [fAudTrack4CodecPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio4Encoder"]];
-                [self audioTrackPopUpChanged: fAudTrack4CodecPopUp];
-                [fAudTrack4MixPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio4Mixdown"]];
-                /* check to see if the selections was available, if not, rerun audioTrackPopUpChanged using the codec to just set the default
-                 * mixdown*/
-                if  ([fAudTrack4MixPopUp selectedItem] == nil)
-                {
-                    [self audioTrackPopUpChanged: fAudTrack4CodecPopUp];
-                }
-                [fAudTrack4RatePopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio4Samplerate"]];
-                /* We set the presets bitrate if it is *not* an AC3 track since that uses the input bitrate */
-                if (![[chosenPreset objectForKey:@"Audio4Encoder"] isEqualToString:@"AC3 Passthru"])
-                {
-                    [fAudTrack4BitratePopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio4Bitrate"]];
-                }
-                [fAudTrack4DrcSlider setFloatValue:[[chosenPreset objectForKey:@"Audio4TrackDRCSlider"] floatValue]];
-                [self audioDRCSliderChanged: fAudTrack4DrcSlider];
+                [fAudTrack3BitratePopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio3Bitrate"]];
             }
-
-
-        }
-
-        /* We now cleanup any extra audio tracks that may be previously set if we need to, we do it here so we don't have to
-         * duplicate any code for legacy presets.*/
-        /* First we handle the legacy Codecs crazy AVC/H.264 Video / AAC + AC3 Audio atv hybrid */
-        if ([chosenPreset objectForKey:@"FileCodecs"] && [[chosenPreset objectForKey:@"FileCodecs"] isEqualToString:@"AVC/H.264 Video / AAC + AC3 Audio"])
-        {
-            [fAudLang3PopUp selectItemAtIndex: 0];
-            [self audioTrackPopUpChanged: fAudLang3PopUp];
-            [fAudLang4PopUp selectItemAtIndex: 0];
-            [self audioTrackPopUpChanged: fAudLang4PopUp];
+            [fAudTrack3DrcSlider setFloatValue:[[chosenPreset objectForKey:@"Audio3TrackDRCSlider"] floatValue]];
+            [self audioDRCSliderChanged: fAudTrack3DrcSlider];
         }
-        else
+        if ([chosenPreset objectForKey:@"Audio4Track"] > 0)
         {
-            if (![chosenPreset objectForKey:@"Audio2Track"] || [chosenPreset objectForKey:@"Audio2Track"] == 0)
+            if ([fAudLang4PopUp indexOfSelectedItem] == 0)
             {
-                [fAudLang2PopUp selectItemAtIndex: 0];
-                [self audioTrackPopUpChanged: fAudLang2PopUp];
+                [fAudLang4PopUp selectItemAtIndex: 1];
             }
-            if (![chosenPreset objectForKey:@"Audio3Track"] || [chosenPreset objectForKey:@"Audio3Track"] > 0)
+            [self audioTrackPopUpChanged: fAudLang4PopUp];
+            [fAudTrack4CodecPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio4Encoder"]];
+            [self audioTrackPopUpChanged: fAudTrack4CodecPopUp];
+            [fAudTrack4MixPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio4Mixdown"]];
+            /* check to see if the selections was available, if not, rerun audioTrackPopUpChanged using the codec to just set the default
+             * mixdown*/
+            if  ([fAudTrack4MixPopUp selectedItem] == nil)
             {
-                [fAudLang3PopUp selectItemAtIndex: 0];
-                [self audioTrackPopUpChanged: fAudLang3PopUp];
+                [self audioTrackPopUpChanged: fAudTrack4CodecPopUp];
             }
-            if (![chosenPreset objectForKey:@"Audio4Track"] || [chosenPreset objectForKey:@"Audio4Track"] > 0)
+            [fAudTrack4RatePopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio4Samplerate"]];
+            /* We set the presets bitrate if it is *not* an AC3 track since that uses the input bitrate */
+            if (![[chosenPreset objectForKey:@"Audio4Encoder"] isEqualToString:@"AC3 Passthru"])
             {
-                [fAudLang4PopUp selectItemAtIndex: 0];
-                [self audioTrackPopUpChanged: fAudLang4PopUp];
+                [fAudTrack4BitratePopUp selectItemWithTitle:[chosenPreset objectForKey:@"Audio4Bitrate"]];
             }
+            [fAudTrack4DrcSlider setFloatValue:[[chosenPreset objectForKey:@"Audio4TrackDRCSlider"] floatValue]];
+            [self audioDRCSliderChanged: fAudTrack4DrcSlider];
+        }
+        
+        /* We now cleanup any extra audio tracks that may have been previously set if we need to */
+        
+        if (![chosenPreset objectForKey:@"Audio2Track"] || [chosenPreset objectForKey:@"Audio2Track"] == 0)
+        {
+            [fAudLang2PopUp selectItemAtIndex: 0];
+            [self audioTrackPopUpChanged: fAudLang2PopUp];
+        }
+        if (![chosenPreset objectForKey:@"Audio3Track"] || [chosenPreset objectForKey:@"Audio3Track"] > 0)
+        {
+            [fAudLang3PopUp selectItemAtIndex: 0];
+            [self audioTrackPopUpChanged: fAudLang3PopUp];
         }
-
+        if (![chosenPreset objectForKey:@"Audio4Track"] || [chosenPreset objectForKey:@"Audio4Track"] > 0)
+        {
+            [fAudLang4PopUp selectItemAtIndex: 0];
+            [self audioTrackPopUpChanged: fAudLang4PopUp];
+        }
+        
         /*Subtitles*/
         [fSubPopUp selectItemWithTitle:[chosenPreset objectForKey:@"Subtitles"]];
         /* Forced Subtitles */
         [fSubForcedCheck setState:[[chosenPreset objectForKey:@"SubtitlesForced"] intValue]];
-
+        
         /* Picture Settings */
-        /* Note: objectForKey:@"UsesPictureSettings" now refers to picture size, this encompasses:
+        /* Note: objectForKey:@"UsesPictureSettings" refers to picture size, which encompasses:
          * height, width, keep ar, anamorphic and crop settings.
-         * picture filters are now handled separately.
-         * We will be able to actually change the key names for legacy preset keys when preset file
-         * update code is done. But for now, lets hang onto the old legacy key name for backwards compatibility.
+         * picture filters are handled separately below.
          */
         /* Check to see if the objectForKey:@"UsesPictureSettings is greater than 0, as 0 means use picture sizing "None" 
-         * and the preset completely ignores any picture sizing values in the preset.
+         * ( 2 is use max for source and 1 is use exact size when the preset was created ) and the 
+         * preset completely ignores any picture sizing values in the preset.
          */
         if ([[chosenPreset objectForKey:@"UsesPictureSettings"]  intValue] > 0)
         {
             hb_job_t * job = fTitle->job;
+            
+            /* If Cropping is set to custom, then recall all four crop values from
+             when the preset was created and apply them */
+            if ([[chosenPreset objectForKey:@"PictureAutoCrop"]  intValue] == 0)
+            {
+                [fPictureController setAutoCrop:NO];
+                
+                /* Here we use the custom crop values saved at the time the preset was saved */
+                job->crop[0] = [[chosenPreset objectForKey:@"PictureTopCrop"]  intValue];
+                job->crop[1] = [[chosenPreset objectForKey:@"PictureBottomCrop"]  intValue];
+                job->crop[2] = [[chosenPreset objectForKey:@"PictureLeftCrop"]  intValue];
+                job->crop[3] = [[chosenPreset objectForKey:@"PictureRightCrop"]  intValue];
+                
+            }
+            else /* if auto crop has been saved in preset, set to auto and use post scan auto crop */
+            {
+                [fPictureController setAutoCrop:YES];
+                /* Here we use the auto crop values determined right after scan */
+                job->crop[0] = AutoCropTop;
+                job->crop[1] = AutoCropBottom;
+                job->crop[2] = AutoCropLeft;
+                job->crop[3] = AutoCropRight;
+                
+            }
+            
+            
             /* Check to see if the objectForKey:@"UsesPictureSettings is 2 which is "Use Max for the source */
             if ([[chosenPreset objectForKey:@"UsesPictureSettings"]  intValue] == 2 || [[chosenPreset objectForKey:@"UsesMaxPictureSettings"]  intValue] == 1)
             {
@@ -5390,7 +5806,7 @@ if (item == nil)
                         hb_fix_aspect( job, HB_KEEP_HEIGHT );
                     }
                 }
-                job->pixel_ratio = [[chosenPreset objectForKey:@"PicturePAR"]  intValue];
+                job->anamorphic.mode = [[chosenPreset objectForKey:@"PicturePAR"]  intValue];
             }
             else // /* If not 0 or 2 we assume objectForKey:@"UsesPictureSettings is 1 which is "Use picture sizing from when the preset was set" */
             {
@@ -5398,8 +5814,9 @@ if (item == nil)
                 if (fTitle->width < [[chosenPreset objectForKey:@"PictureWidth"]  intValue] || fTitle->height < [[chosenPreset objectForKey:@"PictureHeight"]  intValue])
                 {
                     /* if so, then we use the sources height and width to avoid scaling up */
-                    job->width = fTitle->width;
-                    job->height = fTitle->height;
+                    //job->width = fTitle->width;
+                    //job->height = fTitle->height;
+                    [self revertPictureSizeToMax:nil];
                 }
                 else // source width/height is >= the preset height/width
                 {
@@ -5417,170 +5834,111 @@ if (item == nil)
                         hb_fix_aspect( job, HB_KEEP_HEIGHT );
                     }
                 }
-                job->pixel_ratio = [[chosenPreset objectForKey:@"PicturePAR"]  intValue];
-                
+                job->anamorphic.mode = [[chosenPreset objectForKey:@"PicturePAR"]  intValue];
                 
-                /* If Cropping is set to custom, then recall all four crop values from
-                 when the preset was created and apply them */
-                if ([[chosenPreset objectForKey:@"PictureAutoCrop"]  intValue] == 0)
-                {
-                    [fPictureController setAutoCrop:NO];
-                    
-                    /* Here we use the custom crop values saved at the time the preset was saved */
-                    job->crop[0] = [[chosenPreset objectForKey:@"PictureTopCrop"]  intValue];
-                    job->crop[1] = [[chosenPreset objectForKey:@"PictureBottomCrop"]  intValue];
-                    job->crop[2] = [[chosenPreset objectForKey:@"PictureLeftCrop"]  intValue];
-                    job->crop[3] = [[chosenPreset objectForKey:@"PictureRightCrop"]  intValue];
-                    
-                }
-                else /* if auto crop has been saved in preset, set to auto and use post scan auto crop */
-                {
-                    [fPictureController setAutoCrop:YES];
-                    /* Here we use the auto crop values determined right after scan */
-                    job->crop[0] = AutoCropTop;
-                    job->crop[1] = AutoCropBottom;
-                    job->crop[2] = AutoCropLeft;
-                    job->crop[3] = AutoCropRight;
-                    
-                }
-                /* If the preset has no objectForKey:@"UsesPictureFilters", then we know it is a legacy preset
-                 * and handle the filters here as before.
-                 * NOTE: This should be removed when the update presets code is done as we can be assured that legacy
-                 * presets are updated to work properly with new keys.
-                 */
-                if (![chosenPreset objectForKey:@"UsesPictureFilters"])
-                {
-                    /* Filters */
-                    /* Deinterlace */
-                    if ([chosenPreset objectForKey:@"PictureDeinterlace"])
-                    {
-                        /* We check to see if the preset used the past fourth "Slowest" deinterlaceing and set that to "Slower
-                         * since we no longer have a fourth "Slowest" deinterlacing due to the mcdeint bug */
-                        if ([[chosenPreset objectForKey:@"PictureDeinterlace"] intValue] == 4)
-                        {
-                            [fPictureController setDeinterlace:3];
-                        }
-                        else
-                        {
-                            
-                            [fPictureController setDeinterlace:[[chosenPreset objectForKey:@"PictureDeinterlace"] intValue]];
-                        }
-                    }
-                    else
-                    {
-                        [fPictureController setDeinterlace:0];
-                    }
-                    /* VFR */
-                    if ([[chosenPreset objectForKey:@"VFR"] intValue] == 1)
-                    {
-                        // We make sure that framerate is set to Same as source variable
-                        // detelecine will take care of itself right below
-                        //[fPictureController setVFR:[[chosenPreset objectForKey:@"VFR"] intValue]];
-                    }
-                    
-                    /* Detelecine */
-                    if ([[chosenPreset objectForKey:@"PictureDetelecine"] intValue] == 1)
-                    {
-                        [fPictureController setDetelecine:[[chosenPreset objectForKey:@"PictureDetelecine"] intValue]];
-                    }
-                    else
-                    {
-                        [fPictureController setDetelecine:0];
-                    }
-                    /* Denoise */
-                    if ([chosenPreset objectForKey:@"PictureDenoise"])
-                    {
-                        [fPictureController setDenoise:[[chosenPreset objectForKey:@"PictureDenoise"] intValue]];
-                    }
-                    else
-                    {
-                        [fPictureController setDenoise:0];
-                    }   
-                    /* Deblock */
-                    if ([[chosenPreset objectForKey:@"PictureDeblock"] intValue] == 1)
-                    {
-                       /* since we used to use 1 to turn on deblock, we now use a 5 in our sliding scale */
-                         [fPictureController setDeblock:5];
-                    }
-                    else
-                    {
-                        [fPictureController setDeblock:0];
-                     
-                    }
-
-                   [self calculatePictureSizing:nil];
-                }
-
             }
-
-
+            
+            
         }
-        /* If the preset has an objectForKey:@"UsesPictureFilters", then we know it is a newer style filters preset
-         * and handle the filters here depending on whether or not the preset specifies applying the filter.
-         */
+        /* If the preset has an objectForKey:@"UsesPictureFilters", and handle the filters here */
         if ([chosenPreset objectForKey:@"UsesPictureFilters"] && [[chosenPreset objectForKey:@"UsesPictureFilters"]  intValue] > 0)
         {
             /* Filters */
-            /* Deinterlace */
-            if ([chosenPreset objectForKey:@"PictureDeinterlace"])
+            
+            /* We only allow *either* Decomb or Deinterlace. So check for the PictureDecombDeinterlace key.
+             * also, older presets may not have this key, in which case we also check to see if that preset had  PictureDecomb
+             * specified, in which case we use decomb and ignore any possible Deinterlace settings as using both was less than
+             * sane.
+             */
+            [fPictureFilterController setUseDecomb:1];
+            [fPictureFilterController setDecomb:0];
+            [fPictureFilterController setDeinterlace:0];
+            if ([[chosenPreset objectForKey:@"PictureDecombDeinterlace"] intValue] == 1 || [[chosenPreset objectForKey:@"PictureDecomb"] intValue] > 0)
             {
-                /* We check to see if the preset used the past fourth "Slowest" deinterlaceing and set that to "Slower
-                 * since we no longer have a fourth "Slowest" deinterlacing due to the mcdeint bug */
-                if ([[chosenPreset objectForKey:@"PictureDeinterlace"] intValue] == 4)
-                {
-                    [fPictureController setDeinterlace:3];
-                }
-                else
+                /* we are using decomb */
+                /* Decomb */
+                if ([[chosenPreset objectForKey:@"PictureDecomb"] intValue] > 0)
                 {
-                    [fPictureController setDeinterlace:[[chosenPreset objectForKey:@"PictureDeinterlace"] intValue]];
+                    [fPictureFilterController setDecomb:[[chosenPreset objectForKey:@"PictureDecomb"] intValue]];
+                    
+                    /* if we are using "Custom" in the decomb setting, also set the custom string*/
+                    if ([[chosenPreset objectForKey:@"PictureDecomb"] intValue] == 2)
+                    {
+                        [fPictureFilterController setDecombCustomString:[chosenPreset objectForKey:@"PictureDecombCustom"]];    
+                    }
                 }
-            }
+             }
             else
             {
-                [fPictureController setDeinterlace:0];
+                /* We are using Deinterlace */
+                /* Deinterlace */
+                if ([[chosenPreset objectForKey:@"PictureDeinterlace"] intValue] > 0)
+                {
+                    [fPictureFilterController setUseDecomb:0];
+                    [fPictureFilterController setDeinterlace:[[chosenPreset objectForKey:@"PictureDeinterlace"] intValue]];
+                    /* if we are using "Custom" in the deinterlace setting, also set the custom string*/
+                    if ([[chosenPreset objectForKey:@"PictureDeinterlace"] intValue] == 4)
+                    {
+                        [fPictureFilterController setDeinterlaceCustomString:[chosenPreset objectForKey:@"PictureDeinterlaceCustom"]];    
+                    }
+                }
             }
             
+            
             /* Detelecine */
-            if ([[chosenPreset objectForKey:@"PictureDetelecine"] intValue] == 1)
+            if ([[chosenPreset objectForKey:@"PictureDetelecine"] intValue] > 0)
             {
-                [fPictureController setDetelecine:[[chosenPreset objectForKey:@"PictureDetelecine"] intValue]];
+                [fPictureFilterController setDetelecine:[[chosenPreset objectForKey:@"PictureDetelecine"] intValue]];
+                /* if we are using "Custom" in the detelecine setting, also set the custom string*/
+                if ([[chosenPreset objectForKey:@"PictureDetelecine"] intValue] == 2)
+                {
+                    [fPictureFilterController setDetelecineCustomString:[chosenPreset objectForKey:@"PictureDetelecineCustom"]];    
+                }
             }
             else
             {
-                [fPictureController setDetelecine:0];
+                [fPictureFilterController setDetelecine:0];
             }
+            
             /* Denoise */
-            if ([chosenPreset objectForKey:@"PictureDenoise"])
+            if ([[chosenPreset objectForKey:@"PictureDenoise"] intValue] > 0)
             {
-                [fPictureController setDenoise:[[chosenPreset objectForKey:@"PictureDenoise"] intValue]];
+                [fPictureFilterController setDenoise:[[chosenPreset objectForKey:@"PictureDenoise"] intValue]];
+                /* if we are using "Custom" in the denoise setting, also set the custom string*/
+                if ([[chosenPreset objectForKey:@"PictureDenoise"] intValue] == 4)
+                {
+                    [fPictureFilterController setDenoiseCustomString:[chosenPreset objectForKey:@"PictureDenoiseCustom"]];    
+                }
             }
             else
             {
-                [fPictureController setDenoise:0];
+                [fPictureFilterController setDenoise:0];
             }   
+            
             /* Deblock */
             if ([[chosenPreset objectForKey:@"PictureDeblock"] intValue] == 1)
             {
                 /* if its a one, then its the old on/off deblock, set on to 5*/
-                [fPictureController setDeblock:5];
+                [fPictureFilterController setDeblock:5];
             }
             else
             {
                 /* use the settings intValue */
-                [fPictureController setDeblock:[[chosenPreset objectForKey:@"PictureDeblock"] intValue]];
+                [fPictureFilterController setDeblock:[[chosenPreset objectForKey:@"PictureDeblock"] intValue]];
             }
-            /* Decomb */
-            /* Even though we currently allow for a custom setting for decomb, ultimately it will only have Off and
-             * Default so we just pay attention to anything greater than 0 as 1 (Default). 0 is Off. */
-            if ([[chosenPreset objectForKey:@"PictureDecomb"] intValue] > 0)
+            
+            if ([[chosenPreset objectForKey:@"VideoGrayScale"] intValue] == 1)
             {
-                [fPictureController setDecomb:1];
+                [fPictureFilterController setGrayscale:1];
             }
             else
             {
-                [fPictureController setDecomb:0];
+                [fPictureFilterController setGrayscale:0];
             }
         }
+        /* we call SetTitle: in fPictureController so we get an instant update in the Picture Settings window */
+        [fPictureController SetTitle:fTitle];
+        [fPictureFilterController SetTitle:fTitle];
         [self calculatePictureSizing:nil];
     }
 }
@@ -5624,6 +5982,8 @@ if (item == nil)
     [fPresetNewPicSettingsPopUp selectItemAtIndex: 0]; 
     /* Uncheck the preset use filters checkbox */
     [fPresetNewPicFiltersCheck setState:NSOffState];
+    // fPresetNewFolderCheck
+    [fPresetNewFolderCheck setState:NSOffState];
     /* Erase info from the input fields*/
        [fPresetNewName setStringValue: @""];
        [fPresetNewDesc setStringValue: @""];
@@ -5695,130 +6055,145 @@ if (item == nil)
     NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
        /* Get the New Preset Name from the field in the AddPresetPanel */
     [preset setObject:[fPresetNewName stringValue] forKey:@"PresetName"];
+    /* Set whether or not this is to be a folder fPresetNewFolderCheck*/
+    [preset setObject:[NSNumber numberWithBool:[fPresetNewFolderCheck state]] forKey:@"Folder"];
        /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
        [preset setObject:[NSNumber numberWithInt:1] forKey:@"Type"];
        /*Set whether or not this is default, at creation set to 0*/
        [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
-       /*Get the whether or not to apply pic Size and Cropping (includes Anamorphic)*/
-       [preset setObject:[NSNumber numberWithInt:[fPresetNewPicSettingsPopUp indexOfSelectedItem]] forKey:@"UsesPictureSettings"];
-    /* Get whether or not to use the current Picture Filter settings for the preset */
-    [preset setObject:[NSNumber numberWithInt:[fPresetNewPicFiltersCheck state]] forKey:@"UsesPictureFilters"];
-    /* Get New Preset Description from the field in the AddPresetPanel*/
-       [preset setObject:[fPresetNewDesc stringValue] forKey:@"PresetDescription"];
-       /* File Format */
-    [preset setObject:[fDstFormatPopUp titleOfSelectedItem] forKey:@"FileFormat"];
-       /* Chapter Markers fCreateChapterMarkers*/
-       [preset setObject:[NSNumber numberWithInt:[fCreateChapterMarkers state]] forKey:@"ChapterMarkers"];
-       /* Allow Mpeg4 64 bit formatting +4GB file sizes */
-       [preset setObject:[NSNumber numberWithInt:[fDstMp4LargeFileCheck state]] forKey:@"Mp4LargeFile"];
-    /* Mux mp4 with http optimization */
-    [preset setObject:[NSNumber numberWithInt:[fDstMp4HttpOptFileCheck state]] forKey:@"Mp4HttpOptimize"];
-    /* Add iPod uuid atom */
-    [preset setObject:[NSNumber numberWithInt:[fDstMp4iPodFileCheck state]] forKey:@"Mp4iPodCompatible"];
-
-    /* Codecs */
-       /* Video encoder */
-       [preset setObject:[fVidEncoderPopUp titleOfSelectedItem] forKey:@"VideoEncoder"];
-       /* x264 Option String */
-       [preset setObject:[fAdvancedOptions optionsString] forKey:@"x264Option"];
-
-       [preset setObject:[NSNumber numberWithInt:[fVidQualityMatrix selectedRow]] forKey:@"VideoQualityType"];
-       [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
-       [preset setObject:[fVidBitrateField stringValue] forKey:@"VideoAvgBitrate"];
-       [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
-
-       /* Video framerate */
-    if ([fVidRatePopUp indexOfSelectedItem] == 0) // Same as source is selected
-       {
-        [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
-    }
-    else // we can record the actual titleOfSelectedItem
-    {
-    [preset setObject:[fVidRatePopUp titleOfSelectedItem] forKey:@"VideoFramerate"];
-    }
-       /* GrayScale */
-       [preset setObject:[NSNumber numberWithInt:[fVidGrayscaleCheck state]] forKey:@"VideoGrayScale"];
-       /* 2 Pass Encoding */
-       [preset setObject:[NSNumber numberWithInt:[fVidTwoPassCheck state]] forKey:@"VideoTwoPass"];
-       /* Turbo 2 pass Encoding fVidTurboPassCheck*/
-       [preset setObject:[NSNumber numberWithInt:[fVidTurboPassCheck state]] forKey:@"VideoTurboTwoPass"];
-       /*Picture Settings*/
-       hb_job_t * job = fTitle->job;
-       /* Picture Sizing */
-       /* Use Max Picture settings for whatever the dvd is.*/
-       [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
-       [preset setObject:[NSNumber numberWithInt:fTitle->job->width] forKey:@"PictureWidth"];
-       [preset setObject:[NSNumber numberWithInt:fTitle->job->height] forKey:@"PictureHeight"];
-       [preset setObject:[NSNumber numberWithInt:fTitle->job->keep_ratio] forKey:@"PictureKeepRatio"];
-       [preset setObject:[NSNumber numberWithInt:fTitle->job->pixel_ratio] forKey:@"PicturePAR"];
-    
-    /* Set crop settings here */
-       [preset setObject:[NSNumber numberWithInt:[fPictureController autoCrop]] forKey:@"PictureAutoCrop"];
-    [preset setObject:[NSNumber numberWithInt:job->crop[0]] forKey:@"PictureTopCrop"];
-    [preset setObject:[NSNumber numberWithInt:job->crop[1]] forKey:@"PictureBottomCrop"];
-       [preset setObject:[NSNumber numberWithInt:job->crop[2]] forKey:@"PictureLeftCrop"];
-       [preset setObject:[NSNumber numberWithInt:job->crop[3]] forKey:@"PictureRightCrop"];
-    
-    /* Picture Filters */
-    [preset setObject:[NSNumber numberWithInt:[fPictureController deinterlace]] forKey:@"PictureDeinterlace"];
-       [preset setObject:[NSNumber numberWithInt:[fPictureController detelecine]] forKey:@"PictureDetelecine"];
-    //[preset setObject:[NSNumber numberWithInt:[fPictureController vfr]] forKey:@"VFR"];
-       [preset setObject:[NSNumber numberWithInt:[fPictureController denoise]] forKey:@"PictureDenoise"];
-    [preset setObject:[NSNumber numberWithInt:[fPictureController deblock]] forKey:@"PictureDeblock"]; 
-    [preset setObject:[NSNumber numberWithInt:[fPictureController decomb]] forKey:@"PictureDecomb"];
-    
-    
-    /*Audio*/
-    if ([fAudLang1PopUp indexOfSelectedItem] > 0)
-    {
-        [preset setObject:[NSNumber numberWithInt:[fAudLang1PopUp indexOfSelectedItem]] forKey:@"Audio1Track"];
-        [preset setObject:[fAudLang1PopUp titleOfSelectedItem] forKey:@"Audio1TrackDescription"];
-        [preset setObject:[fAudTrack1CodecPopUp titleOfSelectedItem] forKey:@"Audio1Encoder"];
-        [preset setObject:[fAudTrack1MixPopUp titleOfSelectedItem] forKey:@"Audio1Mixdown"];
-        [preset setObject:[fAudTrack1RatePopUp titleOfSelectedItem] forKey:@"Audio1Samplerate"];
-        [preset setObject:[fAudTrack1BitratePopUp titleOfSelectedItem] forKey:@"Audio1Bitrate"];
-        [preset setObject:[NSNumber numberWithFloat:[fAudTrack1DrcSlider floatValue]] forKey:@"Audio1TrackDRCSlider"];
-    }
-    if ([fAudLang2PopUp indexOfSelectedItem] > 0)
-    {
-        [preset setObject:[NSNumber numberWithInt:[fAudLang2PopUp indexOfSelectedItem]] forKey:@"Audio2Track"];
-        [preset setObject:[fAudLang2PopUp titleOfSelectedItem] forKey:@"Audio2TrackDescription"];
-        [preset setObject:[fAudTrack2CodecPopUp titleOfSelectedItem] forKey:@"Audio2Encoder"];
-        [preset setObject:[fAudTrack2MixPopUp titleOfSelectedItem] forKey:@"Audio2Mixdown"];
-        [preset setObject:[fAudTrack2RatePopUp titleOfSelectedItem] forKey:@"Audio2Samplerate"];
-        [preset setObject:[fAudTrack2BitratePopUp titleOfSelectedItem] forKey:@"Audio2Bitrate"];
-        [preset setObject:[NSNumber numberWithFloat:[fAudTrack2DrcSlider floatValue]] forKey:@"Audio2TrackDRCSlider"];
-    }
-    if ([fAudLang3PopUp indexOfSelectedItem] > 0)
+    if ([fPresetNewFolderCheck state] == YES)
     {
-        [preset setObject:[NSNumber numberWithInt:[fAudLang3PopUp indexOfSelectedItem]] forKey:@"Audio3Track"];
-        [preset setObject:[fAudLang3PopUp titleOfSelectedItem] forKey:@"Audio3TrackDescription"];
-        [preset setObject:[fAudTrack3CodecPopUp titleOfSelectedItem] forKey:@"Audio3Encoder"];
-        [preset setObject:[fAudTrack3MixPopUp titleOfSelectedItem] forKey:@"Audio3Mixdown"];
-        [preset setObject:[fAudTrack3RatePopUp titleOfSelectedItem] forKey:@"Audio3Samplerate"];
-        [preset setObject:[fAudTrack3BitratePopUp titleOfSelectedItem] forKey:@"Audio3Bitrate"];
-        [preset setObject:[NSNumber numberWithFloat:[fAudTrack3DrcSlider floatValue]] forKey:@"Audio3TrackDRCSlider"];
+        /* initialize and set an empty array for children here since we are a new folder */
+        NSMutableArray *childrenArray = [[NSMutableArray alloc] init];
+        [preset setObject:[NSMutableArray arrayWithArray: childrenArray] forKey:@"ChildrenArray"];
+        [childrenArray autorelease];
     }
-    if ([fAudLang4PopUp indexOfSelectedItem] > 0)
+    else // we are not creating a preset folder, so we go ahead with the rest of the preset info
     {
-        [preset setObject:[NSNumber numberWithInt:[fAudLang4PopUp indexOfSelectedItem]] forKey:@"Audio4Track"];
-        [preset setObject:[fAudLang4PopUp titleOfSelectedItem] forKey:@"Audio4TrackDescription"];
-        [preset setObject:[fAudTrack4CodecPopUp titleOfSelectedItem] forKey:@"Audio4Encoder"];
-        [preset setObject:[fAudTrack4MixPopUp titleOfSelectedItem] forKey:@"Audio4Mixdown"];
-        [preset setObject:[fAudTrack4RatePopUp titleOfSelectedItem] forKey:@"Audio4Samplerate"];
-        [preset setObject:[fAudTrack4BitratePopUp titleOfSelectedItem] forKey:@"Audio4Bitrate"];
-        [preset setObject:[NSNumber numberWithFloat:[fAudTrack4DrcSlider floatValue]] forKey:@"Audio4TrackDRCSlider"];
+        /*Get the whether or not to apply pic Size and Cropping (includes Anamorphic)*/
+        [preset setObject:[NSNumber numberWithInt:[fPresetNewPicSettingsPopUp indexOfSelectedItem]] forKey:@"UsesPictureSettings"];
+        /* Get whether or not to use the current Picture Filter settings for the preset */
+        [preset setObject:[NSNumber numberWithInt:[fPresetNewPicFiltersCheck state]] forKey:@"UsesPictureFilters"];
+        
+        /* Get New Preset Description from the field in the AddPresetPanel*/
+        [preset setObject:[fPresetNewDesc stringValue] forKey:@"PresetDescription"];
+        /* File Format */
+        [preset setObject:[fDstFormatPopUp titleOfSelectedItem] forKey:@"FileFormat"];
+        /* Chapter Markers fCreateChapterMarkers*/
+        [preset setObject:[NSNumber numberWithInt:[fCreateChapterMarkers state]] forKey:@"ChapterMarkers"];
+        /* Allow Mpeg4 64 bit formatting +4GB file sizes */
+        [preset setObject:[NSNumber numberWithInt:[fDstMp4LargeFileCheck state]] forKey:@"Mp4LargeFile"];
+        /* Mux mp4 with http optimization */
+        [preset setObject:[NSNumber numberWithInt:[fDstMp4HttpOptFileCheck state]] forKey:@"Mp4HttpOptimize"];
+        /* Add iPod uuid atom */
+        [preset setObject:[NSNumber numberWithInt:[fDstMp4iPodFileCheck state]] forKey:@"Mp4iPodCompatible"];
+        
+        /* Codecs */
+        /* Video encoder */
+        [preset setObject:[fVidEncoderPopUp titleOfSelectedItem] forKey:@"VideoEncoder"];
+        /* x264 Option String */
+        [preset setObject:[fAdvancedOptions optionsString] forKey:@"x264Option"];
+        
+        [preset setObject:[NSNumber numberWithInt:[fVidQualityMatrix selectedRow]] forKey:@"VideoQualityType"];
+        [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
+        [preset setObject:[fVidBitrateField stringValue] forKey:@"VideoAvgBitrate"];
+        [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
+        
+        /* Video framerate */
+        if ([fVidRatePopUp indexOfSelectedItem] == 0) // Same as source is selected
+        {
+            [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
+        }
+        else // we can record the actual titleOfSelectedItem
+        {
+            [preset setObject:[fVidRatePopUp titleOfSelectedItem] forKey:@"VideoFramerate"];
+        }
+        
+        /* 2 Pass Encoding */
+        [preset setObject:[NSNumber numberWithInt:[fVidTwoPassCheck state]] forKey:@"VideoTwoPass"];
+        /* Turbo 2 pass Encoding fVidTurboPassCheck*/
+        [preset setObject:[NSNumber numberWithInt:[fVidTurboPassCheck state]] forKey:@"VideoTurboTwoPass"];
+        /*Picture Settings*/
+        hb_job_t * job = fTitle->job;
+        /* Picture Sizing */
+        /* Use Max Picture settings for whatever the dvd is.*/
+        [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
+        [preset setObject:[NSNumber numberWithInt:fTitle->job->width] forKey:@"PictureWidth"];
+        [preset setObject:[NSNumber numberWithInt:fTitle->job->height] forKey:@"PictureHeight"];
+        [preset setObject:[NSNumber numberWithInt:fTitle->job->keep_ratio] forKey:@"PictureKeepRatio"];
+        [preset setObject:[NSNumber numberWithInt:fTitle->job->anamorphic.mode] forKey:@"PicturePAR"];
+        
+        /* Set crop settings here */
+        [preset setObject:[NSNumber numberWithInt:[fPictureController autoCrop]] forKey:@"PictureAutoCrop"];
+        [preset setObject:[NSNumber numberWithInt:job->crop[0]] forKey:@"PictureTopCrop"];
+        [preset setObject:[NSNumber numberWithInt:job->crop[1]] forKey:@"PictureBottomCrop"];
+        [preset setObject:[NSNumber numberWithInt:job->crop[2]] forKey:@"PictureLeftCrop"];
+        [preset setObject:[NSNumber numberWithInt:job->crop[3]] forKey:@"PictureRightCrop"];
+        
+        /* Picture Filters */
+        [preset setObject:[NSNumber numberWithInt:[fPictureFilterController useDecomb]] forKey:@"PictureDecombDeinterlace"];
+        [preset setObject:[NSNumber numberWithInt:[fPictureFilterController deinterlace]] forKey:@"PictureDeinterlace"];
+        [preset setObject:[fPictureFilterController deinterlaceCustomString] forKey:@"PictureDeinterlaceCustom"];
+        [preset setObject:[NSNumber numberWithInt:[fPictureFilterController detelecine]] forKey:@"PictureDetelecine"];
+        [preset setObject:[fPictureFilterController detelecineCustomString] forKey:@"PictureDetelecineCustom"];
+        [preset setObject:[NSNumber numberWithInt:[fPictureFilterController denoise]] forKey:@"PictureDenoise"];
+        [preset setObject:[fPictureFilterController denoiseCustomString] forKey:@"PictureDenoiseCustom"];
+        [preset setObject:[NSNumber numberWithInt:[fPictureFilterController deblock]] forKey:@"PictureDeblock"]; 
+        [preset setObject:[NSNumber numberWithInt:[fPictureFilterController decomb]] forKey:@"PictureDecomb"];
+        [preset setObject:[fPictureFilterController decombCustomString] forKey:@"PictureDecombCustom"];
+        [preset setObject:[NSNumber numberWithInt:[fPictureFilterController grayscale]] forKey:@"VideoGrayScale"];
+        
+        
+        /*Audio*/
+        if ([fAudLang1PopUp indexOfSelectedItem] > 0)
+        {
+            [preset setObject:[NSNumber numberWithInt:[fAudLang1PopUp indexOfSelectedItem]] forKey:@"Audio1Track"];
+            [preset setObject:[fAudLang1PopUp titleOfSelectedItem] forKey:@"Audio1TrackDescription"];
+            [preset setObject:[fAudTrack1CodecPopUp titleOfSelectedItem] forKey:@"Audio1Encoder"];
+            [preset setObject:[fAudTrack1MixPopUp titleOfSelectedItem] forKey:@"Audio1Mixdown"];
+            [preset setObject:[fAudTrack1RatePopUp titleOfSelectedItem] forKey:@"Audio1Samplerate"];
+            [preset setObject:[fAudTrack1BitratePopUp titleOfSelectedItem] forKey:@"Audio1Bitrate"];
+            [preset setObject:[NSNumber numberWithFloat:[fAudTrack1DrcSlider floatValue]] forKey:@"Audio1TrackDRCSlider"];
+        }
+        if ([fAudLang2PopUp indexOfSelectedItem] > 0)
+        {
+            [preset setObject:[NSNumber numberWithInt:[fAudLang2PopUp indexOfSelectedItem]] forKey:@"Audio2Track"];
+            [preset setObject:[fAudLang2PopUp titleOfSelectedItem] forKey:@"Audio2TrackDescription"];
+            [preset setObject:[fAudTrack2CodecPopUp titleOfSelectedItem] forKey:@"Audio2Encoder"];
+            [preset setObject:[fAudTrack2MixPopUp titleOfSelectedItem] forKey:@"Audio2Mixdown"];
+            [preset setObject:[fAudTrack2RatePopUp titleOfSelectedItem] forKey:@"Audio2Samplerate"];
+            [preset setObject:[fAudTrack2BitratePopUp titleOfSelectedItem] forKey:@"Audio2Bitrate"];
+            [preset setObject:[NSNumber numberWithFloat:[fAudTrack2DrcSlider floatValue]] forKey:@"Audio2TrackDRCSlider"];
+        }
+        if ([fAudLang3PopUp indexOfSelectedItem] > 0)
+        {
+            [preset setObject:[NSNumber numberWithInt:[fAudLang3PopUp indexOfSelectedItem]] forKey:@"Audio3Track"];
+            [preset setObject:[fAudLang3PopUp titleOfSelectedItem] forKey:@"Audio3TrackDescription"];
+            [preset setObject:[fAudTrack3CodecPopUp titleOfSelectedItem] forKey:@"Audio3Encoder"];
+            [preset setObject:[fAudTrack3MixPopUp titleOfSelectedItem] forKey:@"Audio3Mixdown"];
+            [preset setObject:[fAudTrack3RatePopUp titleOfSelectedItem] forKey:@"Audio3Samplerate"];
+            [preset setObject:[fAudTrack3BitratePopUp titleOfSelectedItem] forKey:@"Audio3Bitrate"];
+            [preset setObject:[NSNumber numberWithFloat:[fAudTrack3DrcSlider floatValue]] forKey:@"Audio3TrackDRCSlider"];
+        }
+        if ([fAudLang4PopUp indexOfSelectedItem] > 0)
+        {
+            [preset setObject:[NSNumber numberWithInt:[fAudLang4PopUp indexOfSelectedItem]] forKey:@"Audio4Track"];
+            [preset setObject:[fAudLang4PopUp titleOfSelectedItem] forKey:@"Audio4TrackDescription"];
+            [preset setObject:[fAudTrack4CodecPopUp titleOfSelectedItem] forKey:@"Audio4Encoder"];
+            [preset setObject:[fAudTrack4MixPopUp titleOfSelectedItem] forKey:@"Audio4Mixdown"];
+            [preset setObject:[fAudTrack4RatePopUp titleOfSelectedItem] forKey:@"Audio4Samplerate"];
+            [preset setObject:[fAudTrack4BitratePopUp titleOfSelectedItem] forKey:@"Audio4Bitrate"];
+            [preset setObject:[NSNumber numberWithFloat:[fAudTrack4DrcSlider floatValue]] forKey:@"Audio4TrackDRCSlider"];
+        }
+        
+        /* Subtitles*/
+        [preset setObject:[fSubPopUp titleOfSelectedItem] forKey:@"Subtitles"];
+        /* Forced Subtitles */
+        [preset setObject:[NSNumber numberWithInt:[fSubForcedCheck state]] forKey:@"SubtitlesForced"];
     }
-    
-       /* Subtitles*/
-       [preset setObject:[fSubPopUp titleOfSelectedItem] forKey:@"Subtitles"];
-    /* Forced Subtitles */
-       [preset setObject:[NSNumber numberWithInt:[fSubForcedCheck state]] forKey:@"SubtitlesForced"];
-    
     [preset autorelease];
     return preset;
-
+    
 }
 
 - (void)savePreset
@@ -5831,30 +6206,49 @@ if (item == nil)
 
 - (IBAction)deletePreset:(id)sender
 {
-    int status;
-    NSEnumerator *enumerator;
-    NSNumber *index;
-    NSMutableArray *tempArray;
-    id tempObject;
+    
     
     if ( [fPresetsOutlineView numberOfSelectedRows] == 0 )
+    {
         return;
+    }
     /* Alert user before deleting preset */
-       /* Comment out for now, tie to user pref eventually */
-
-    //NSBeep();
+       int status;
     status = NSRunAlertPanel(@"Warning!", @"Are you sure that you want to delete the selected preset?", @"OK", @"Cancel", nil);
     
-    if ( status == NSAlertDefaultReturn ) {
-        enumerator = [fPresetsOutlineView selectedRowEnumerator];
+    if ( status == NSAlertDefaultReturn ) 
+    {
+        int presetToModLevel = [fPresetsOutlineView levelForItem: [fPresetsOutlineView itemAtRow:[fPresetsOutlineView selectedRow]]];
+        NSDictionary *presetToMod = [fPresetsOutlineView itemAtRow:[fPresetsOutlineView selectedRow]];
+        NSDictionary *presetToModParent = [fPresetsOutlineView parentForItem: presetToMod];
+        
+        NSEnumerator *enumerator;
+        NSMutableArray *presetsArrayToMod;
+        NSMutableArray *tempArray;
+        id tempObject;
+        /* If we are a root level preset, we are modding the UserPresets array */
+        if (presetToModLevel == 0)
+        {
+            presetsArrayToMod = UserPresets;
+        }
+        else // We have a parent preset, so we modify the chidren array object for key
+        {
+            presetsArrayToMod = [presetToModParent objectForKey:@"ChildrenArray"]; 
+        }
+        
+        enumerator = [presetsArrayToMod objectEnumerator];
         tempArray = [NSMutableArray array];
         
-        while ( (index = [enumerator nextObject]) ) {
-            tempObject = [UserPresets objectAtIndex:[index intValue]];
-            [tempArray addObject:tempObject];
+        while (tempObject = [enumerator nextObject]) 
+        {
+            NSDictionary *thisPresetDict = tempObject;
+            if (thisPresetDict == presetToMod)
+            {
+                [tempArray addObject:tempObject];
+            }
         }
         
-        [UserPresets removeObjectsInArray:tempArray];
+        [presetsArrayToMod removeObjectsInArray:tempArray];
         [fPresetsOutlineView reloadData];
         [self savePreset];   
     }
@@ -5865,72 +6259,224 @@ if (item == nil)
 
 - (IBAction)getDefaultPresets:(id)sender
 {
-       int i = 0;
+       presetHbDefault = nil;
+    presetUserDefault = nil;
+    presetUserDefaultParent = nil;
+    presetUserDefaultParentParent = nil;
+    NSMutableDictionary *presetHbDefaultParent = nil;
+    NSMutableDictionary *presetHbDefaultParentParent = nil;
+    
+    int i = 0;
+    BOOL userDefaultFound = NO;
     presetCurrentBuiltInCount = 0;
+    /* First we iterate through the root UserPresets array to check for defaults */
     NSEnumerator *enumerator = [UserPresets objectEnumerator];
        id tempObject;
        while (tempObject = [enumerator nextObject])
        {
-               NSDictionary *thisPresetDict = tempObject;
+               NSMutableDictionary *thisPresetDict = tempObject;
                if ([[thisPresetDict objectForKey:@"Default"] intValue] == 1) // 1 is HB default
                {
-                       presetHbDefault = i;    
+                       presetHbDefault = thisPresetDict;       
                }
                if ([[thisPresetDict objectForKey:@"Default"] intValue] == 2) // 2 is User specified default
                {
-                       presetUserDefault = i;  
-               }
+                       presetUserDefault = thisPresetDict;
+            userDefaultFound = YES;
+        }
         if ([[thisPresetDict objectForKey:@"Type"] intValue] == 0) // Type 0 is a built in preset              
         {
                        presetCurrentBuiltInCount++; // <--increment the current number of built in presets     
                }
                i++;
+        
+        /* if we run into a folder, go to level 1 and iterate through the children arrays for the default */
+        if ([thisPresetDict objectForKey:@"ChildrenArray"])
+        {
+            NSMutableDictionary *thisPresetDictParent = thisPresetDict;
+            NSEnumerator *enumerator = [[thisPresetDict objectForKey:@"ChildrenArray"] objectEnumerator];
+            id tempObject;
+            while (tempObject = [enumerator nextObject])
+            {
+                NSMutableDictionary *thisPresetDict = tempObject;
+                if ([[thisPresetDict objectForKey:@"Default"] intValue] == 1) // 1 is HB default
+                {
+                    presetHbDefault = thisPresetDict;
+                    presetHbDefaultParent = thisPresetDictParent;
+                }
+                if ([[thisPresetDict objectForKey:@"Default"] intValue] == 2) // 2 is User specified default
+                {
+                    presetUserDefault = thisPresetDict;
+                    presetUserDefaultParent = thisPresetDictParent;
+                    userDefaultFound = YES;
+                }
+                
+                /* if we run into a folder, go to level 2 and iterate through the children arrays for the default */
+                if ([thisPresetDict objectForKey:@"ChildrenArray"])
+                {
+                    NSMutableDictionary *thisPresetDictParentParent = thisPresetDict;
+                    NSEnumerator *enumerator = [[thisPresetDict objectForKey:@"ChildrenArray"] objectEnumerator];
+                    id tempObject;
+                    while (tempObject = [enumerator nextObject])
+                    {
+                        NSMutableDictionary *thisPresetDict = tempObject;
+                        if ([[thisPresetDict objectForKey:@"Default"] intValue] == 1) // 1 is HB default
+                        {
+                            presetHbDefault = thisPresetDict;
+                            presetHbDefaultParent = thisPresetDictParent;
+                            presetHbDefaultParentParent = thisPresetDictParentParent;  
+                        }
+                        if ([[thisPresetDict objectForKey:@"Default"] intValue] == 2) // 2 is User specified default
+                        {
+                            presetUserDefault = thisPresetDict;
+                            presetUserDefaultParent = thisPresetDictParent;
+                            presetUserDefaultParentParent = thisPresetDictParentParent;
+                            userDefaultFound = YES;    
+                        }
+                        
+                    }
+                }
+            }
+        }
+        
        }
+    /* check to see if a user specified preset was found, if not then assign the parents for
+     * the presetHbDefault so that we can open the parents for the nested presets
+     */
+    if (userDefaultFound == NO)
+    {
+        presetUserDefaultParent = presetHbDefaultParent;
+        presetUserDefaultParentParent = presetHbDefaultParentParent;
+    }
 }
 
 - (IBAction)setDefaultPreset:(id)sender
 {
+/* We need to determine if the item is a folder */
+   if ([[[fPresetsOutlineView itemAtRow:[fPresetsOutlineView selectedRow]] objectForKey:@"Folder"] intValue] == 1)
+   {
+   return;
+   }
+
     int i = 0;
     NSEnumerator *enumerator = [UserPresets objectEnumerator];
        id tempObject;
        /* First make sure the old user specified default preset is removed */
-       while (tempObject = [enumerator nextObject])
+    while (tempObject = [enumerator nextObject])
        {
-               /* make sure we are not removing the default HB preset */
-               if ([[[UserPresets objectAtIndex:i] objectForKey:@"Default"] intValue] != 1) // 1 is HB default
+               NSMutableDictionary *thisPresetDict = tempObject;
+               if ([[tempObject objectForKey:@"Default"] intValue] != 1) // if not the default HB Preset, set to 0
                {
-                       [[UserPresets objectAtIndex:i] setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
+                       [[UserPresets objectAtIndex:i] setObject:[NSNumber numberWithInt:0] forKey:@"Default"]; 
                }
-               i++;
-       }
-       /* Second, go ahead and set the appropriate user specfied preset */
-       /* we get the chosen preset from the UserPresets array */
-       if ([[[UserPresets objectAtIndex:[fPresetsOutlineView selectedRow]] objectForKey:@"Default"] intValue] != 1) // 1 is HB default
-       {
-               [[UserPresets objectAtIndex:[fPresetsOutlineView selectedRow]] setObject:[NSNumber numberWithInt:2] forKey:@"Default"];
+               
+               /* if we run into a folder, go to level 1 and iterate through the children arrays for the default */
+        if ([thisPresetDict objectForKey:@"ChildrenArray"])
+        {
+            NSEnumerator *enumerator = [[thisPresetDict objectForKey:@"ChildrenArray"] objectEnumerator];
+            id tempObject;
+            int ii = 0;
+            while (tempObject = [enumerator nextObject])
+            {
+                NSMutableDictionary *thisPresetDict1 = tempObject;
+                if ([[tempObject objectForKey:@"Default"] intValue] != 1) // if not the default HB Preset, set to 0
+                {
+                    [[[thisPresetDict objectForKey:@"ChildrenArray"] objectAtIndex:ii] setObject:[NSNumber numberWithInt:0] forKey:@"Default"];        
+                }
+                /* if we run into a folder, go to level 2 and iterate through the children arrays for the default */
+                if ([thisPresetDict1 objectForKey:@"ChildrenArray"])
+                {
+                    NSEnumerator *enumerator = [[thisPresetDict1 objectForKey:@"ChildrenArray"] objectEnumerator];
+                    id tempObject;
+                    int iii = 0;
+                    while (tempObject = [enumerator nextObject])
+                    {
+                        if ([[tempObject objectForKey:@"Default"] intValue] != 1) // if not the default HB Preset, set to 0
+                        {
+                            [[[thisPresetDict1 objectForKey:@"ChildrenArray"] objectAtIndex:iii] setObject:[NSNumber numberWithInt:0] forKey:@"Default"];      
+                        }
+                        iii++;
+                    }
+                }
+                ii++;
+            }
+            
+        }
+        i++; 
        }
-       /*FIX ME: I think we now need to use the items not rows in NSOutlineView */
-    presetUserDefault = [fPresetsOutlineView selectedRow];
-       
-       /* We save all of the preset data here */
+    
+    
+    int presetToModLevel = [fPresetsOutlineView levelForItem: [fPresetsOutlineView itemAtRow:[fPresetsOutlineView selectedRow]]];
+    NSDictionary *presetToMod = [fPresetsOutlineView itemAtRow:[fPresetsOutlineView selectedRow]];
+    NSDictionary *presetToModParent = [fPresetsOutlineView parentForItem: presetToMod];
+    
+    
+    NSMutableArray *presetsArrayToMod;
+    NSMutableArray *tempArray;
+    
+    /* If we are a root level preset, we are modding the UserPresets array */
+    if (presetToModLevel == 0)
+    {
+        presetsArrayToMod = UserPresets;
+    }
+    else // We have a parent preset, so we modify the chidren array object for key
+    {
+        presetsArrayToMod = [presetToModParent objectForKey:@"ChildrenArray"]; 
+    }
+    
+    enumerator = [presetsArrayToMod objectEnumerator];
+    tempArray = [NSMutableArray array];
+    int iiii = 0;
+    while (tempObject = [enumerator nextObject]) 
+    {
+        NSDictionary *thisPresetDict = tempObject;
+        if (thisPresetDict == presetToMod)
+        {
+            if ([[tempObject objectForKey:@"Default"] intValue] != 1) // if not the default HB Preset, set to 2
+            {
+                [[presetsArrayToMod objectAtIndex:iiii] setObject:[NSNumber numberWithInt:2] forKey:@"Default"];       
+            }
+        }
+     iiii++;
+     }
+    
+    
+    /* We save all of the preset data here */
     [self savePreset];
-       /* We Reload the New Table data for presets */
+    /* We Reload the New Table data for presets */
     [fPresetsOutlineView reloadData];
 }
 
 - (IBAction)selectDefaultPreset:(id)sender
 {
-       /* if there is a user specified default, we use it */
+       NSMutableDictionary *presetToMod;
+    /* if there is a user specified default, we use it */
        if (presetUserDefault)
        {
-       [fPresetsOutlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:presetUserDefault] byExtendingSelection:NO];
-       [self selectPreset:nil];
-       }
+        presetToMod = presetUserDefault;
+    }
        else if (presetHbDefault) //else we use the built in default presetHbDefault
        {
-       [fPresetsOutlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:presetHbDefault] byExtendingSelection:NO];
-       [self selectPreset:nil];
+        presetToMod = presetHbDefault;
        }
+    else
+    {
+    return;
+    }
+    
+    if (presetUserDefaultParent != nil)
+    {
+        [fPresetsOutlineView expandItem:presetUserDefaultParent];
+        
+    }
+    if (presetUserDefaultParentParent != nil)
+    {
+        [fPresetsOutlineView expandItem:presetUserDefaultParentParent];
+        
+    }
+    
+    [fPresetsOutlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:[fPresetsOutlineView rowForItem: presetToMod]] byExtendingSelection:NO];
+       [self selectPreset:nil];
 }
 
 
@@ -5998,7 +6544,7 @@ if (item == nil)
 
     // By default, NSTableView only drags an image of the first column. Change this to
     // drag an image of the queue's icon and PresetName columns.
-    NSArray * cols = [NSArray arrayWithObjects: [self tableColumnWithIdentifier:@"icon"], [self tableColumnWithIdentifier:@"PresetName"], nil];
+    NSArray * cols = [NSArray arrayWithObjects: [self tableColumnWithIdentifier:@"PresetName"], nil];
     return [super dragImageForRowsWithIndexes:dragRows tableColumns:cols event:dragEvent offset:dragImageOffset];
 }