OSDN Git Service

BuildSystem: darwin
[handbrake-jp/handbrake-jp-git.git] / macosx / Controller.mm
index cf5ad30..1239ef7 100644 (file)
@@ -9,6 +9,8 @@
 #import "HBPreferencesController.h"
 #import "HBDVDDetector.h"
 #import "HBPresets.h"
+#import "HBPreviewController.h"
+#import "HBFilterController.h"
 
 #define DragDropSimplePboardType       @"MyCustomOutlineViewPboardType"
 
@@ -61,6 +63,7 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
     }                                                            
     outputPanel = [[HBOutputPanelController alloc] init];
     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
@@ -70,7 +73,7 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
     fPresetsBuiltin = [[HBPresets alloc] init];
     fPreferencesController = [[HBPreferencesController alloc] init];
     /* Lets report the HandBrake version number here to the activity log and text log file */
-    NSString *versionStringFull = [[NSString stringWithFormat: @"Handbrake Version: %@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleGetInfoString"]] stringByAppendingString: [NSString stringWithFormat: @" (%@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]]];
+    NSString *versionStringFull = [[NSString stringWithFormat: @"Handbrake Version: %@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]] stringByAppendingString: [NSString stringWithFormat: @" (%@)", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]]];
     [self writeToActivityLog: "%s", [versionStringFull UTF8String]];    
     
     return self;
@@ -90,6 +93,10 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
     /* Init others controllers */
     [fPictureController SetHandle: fHandle];
     [fPictureController   setHBController: self];
+    /* fPictureController */
+    [fPictureFilterController SetHandle: fHandle];
+    [fPictureFilterController   setHBController: self];
+    
     [fQueueController   setHandle: fQueueEncodeLibhb];
     [fQueueController   setHBController: self];
 
@@ -97,6 +104,11 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
     [fChapterTable setDataSource:fChapterTitlesDelegate];
     [fChapterTable setDelegate:fChapterTitlesDelegate];
 
+    [fPresetsOutlineView setAutosaveName:@"Presets View"];
+    [fPresetsOutlineView setAutosaveExpandedItems:YES];
+    
+    dockIconProgress = 0;
+
     /* Call UpdateUI every 1/2 sec */
     [[NSRunLoop currentRunLoop] addTimer:[NSTimer
                                           scheduledTimerWithTimeInterval:0.5 target:self
@@ -198,8 +210,16 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
 
 - (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication *) app
 {
+    /* if we are in preview full screen mode, we need to go to
+     * windowed mode and release the display before we terminate.
+     * We do it here (instead of applicationWillTerminate) so we 
+     * release the displays and can then see the alerts below.
+     */
+    if ([fPictureController previewFullScreenMode] == YES)
+    {
+        [fPictureController previewGoWindowed:nil];
+    }
     
-    // Warn if encoding a movie
     hb_state_t s;
     hb_get_state( fQueueEncodeLibhb, &s );
     
@@ -237,10 +257,14 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
 
 - (void)applicationWillTerminate:(NSNotification *)aNotification
 {
-       [browsedSourceDisplayName release];
+    
+    [browsedSourceDisplayName release];
     [outputPanel release];
        [fQueueController release];
+    [fPreviewController release];
     [fPictureController release];
+    [fPictureFilterController release];
+    
        hb_close(&fHandle);
     hb_close(&fQueueEncodeLibhb);
 }
@@ -272,13 +296,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];
@@ -397,13 +424,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,
@@ -413,16 +439,12 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
         fAudTrack1BitratePopUp, fAudTrack2BitratePopUp, fAudTrack3BitratePopUp, fAudTrack4BitratePopUp,
         fAudDrcLabel, fAudTrack1DrcSlider, fAudTrack1DrcField, fAudTrack2DrcSlider,
         fAudTrack2DrcField, fAudTrack3DrcSlider, fAudTrack3DrcField, fAudTrack4DrcSlider,fAudTrack4DrcField,
-        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,fVidQualityRFField,fVidQualityRFLabel};
+    
     for( unsigned i = 0;
-         i < sizeof( controls ) / sizeof( NSControl * ); i++ )
+        i < sizeof( controls ) / sizeof( NSControl * ); i++ )
     {
         if( [[controls[i] className] isEqualToString: @"NSTextField"] )
         {
@@ -430,28 +452,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];
-
+        
        } else {
-
+        
                [fPresetsOutlineView setEnabled: NO];
-
+        
        }
-
+    
     [self videoMatrixChanged:nil];
     [fAdvancedOptions enableUI:b];
 }
@@ -575,7 +597,7 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
                                             NSLocalizedString( @"Scanning title %d of %d...", @"" ),
                                             p.title_cur, p.title_count]];
             [fScanIndicator setHidden: NO];
-            [fScanIndicator setDoubleValue: 100.0 * ( p.title_cur - 1 ) / p.title_count];
+            [fScanIndicator setDoubleValue: 100.0 * ((double)( p.title_cur - 1 ) / p.title_count)];
             break;
                }
 #undef p
@@ -652,9 +674,6 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
             [fQueueController setQueueStatusString: [NSString stringWithFormat:
                                                      NSLocalizedString( @"Queue Scanning title %d of %d...", @"" ),
                                                      p.title_cur, p.title_count]];
-            
-            [fRipIndicator setHidden: NO];
-            [fRipIndicator setDoubleValue: 100.0 * ( p.title_cur - 1 ) / p.title_count];
             break;
                }
 #undef p
@@ -662,9 +681,6 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
 #define p s.param.scandone
         case HB_STATE_SCANDONE:
         {
-            [fRipIndicator setIndeterminate: NO];
-            [fRipIndicator setDoubleValue: 0.0];
-            
                        [self writeToActivityLog:"ScanDone state received from fQueueEncodeLibhb"];
             [self processNewQueueEncode];
             [[fWindow toolbar] validateVisibleItems];
@@ -676,7 +692,6 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
 #define p s.param.working
         case HB_STATE_WORKING:
         {
-            float progress_total;
             NSMutableString * string;
                        /* Update text field */
                        string = [NSMutableString stringWithFormat: NSLocalizedString( @"Encoding: pass %d of %d, %.2f %%", @"" ), p.job_cur, p.job_count, 100.0 * p.progress];
@@ -692,9 +707,9 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
             /* Set the status string in fQueueController as well */
             [fQueueController setQueueStatusString: string];
             /* Update slider */
-                       progress_total = ( p.progress + p.job_cur - 1 ) / p.job_count;
+            double progress_total = ( p.progress + p.job_cur - 1 ) / p.job_count;
             [fRipIndicator setIndeterminate: NO];
-            [fRipIndicator setDoubleValue: 100.0 * progress_total];
+            [fRipIndicator setDoubleValue:100.0 * progress_total];
             
             // If progress bar hasn't been revealed at the bottom of the window, do
             // that now. This code used to be in doRip. I moved it to here to handle
@@ -711,10 +726,14 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
                 fRipIndicatorShown = YES;
                 
             }
-            
+
             /* Update dock icon */
-            [self UpdateDockIcon: progress_total];
-            
+            if( dockIconProgress < 100.0 * progress_total )
+            {
+                [self UpdateDockIcon: progress_total];
+                dockIconProgress += 5;
+            }
+
             break;
         }
 #undef p
@@ -754,11 +773,13 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
             /* Set the status string in fQueueController as well */
             [fQueueController setQueueStatusString: NSLocalizedString( @"Encode Finished.", @"" )];
             [fRipIndicator setIndeterminate: NO];
+            [fRipIndicator stopAnimation: nil];
             [fRipIndicator setDoubleValue: 0.0];
             [[fWindow toolbar] validateVisibleItems];
             
             /* Restore dock icon */
             [self UpdateDockIcon: -1.0];
+            dockIconProgress = 0;
             
             if( fRipIndicatorShown )
             {
@@ -842,7 +863,7 @@ static NSString *        ChooseSourceIdentifier             = @"Choose Source It
 }
 
 /* We use this to write messages to stderr from the macgui which show up in the activity window and log*/
-- (void) writeToActivityLog:(char *) format, ...
+- (void) writeToActivityLog:(const char *) format, ...
 {
     va_list args;
     va_start(args, format);
@@ -1389,7 +1410,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) 
            {
@@ -1397,7 +1418,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)
@@ -1520,18 +1541,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];
+            }
 
             
         }
@@ -1590,6 +1618,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
@@ -1863,12 +1895,10 @@ fWorkingCount = 0;
        [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"];
+       [queueFileJob setObject:[NSNumber numberWithFloat:[fVidQualityRFField floatValue]] forKey:@"VideoQualitySlider"];
     /* 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*/
@@ -1880,12 +1910,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"];
@@ -1895,11 +1922,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)
@@ -1975,7 +2013,7 @@ 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"];
     
     /* Set crop settings here */
        [queueFileJob setObject:[NSNumber numberWithInt:[fPictureController autoCrop]] forKey:@"PictureAutoCrop"];
@@ -1985,7 +2023,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)
@@ -2032,33 +2070,32 @@ fWorkingCount = 0;
 }
 
 /* this is actually called from the queue controller to modify the queue array and return it back to the queue controller */
-- (void)moveObjectsInQueueArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(unsigned)insertIndex
+- (void)moveObjectsInQueueArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex
 {
-    unsigned index = [indexSet lastIndex];
-    unsigned aboveInsertIndexCount = 0;
+    NSUInteger index = [indexSet lastIndex];
+    NSUInteger aboveInsertIndexCount = 0;
     
-    while (index != NSNotFound)
-    {
-        unsigned removeIndex;
-        
-        if (index >= insertIndex)
-        {
-            removeIndex = index + aboveInsertIndexCount;
-            aboveInsertIndexCount++;
-        }
-        else
-        {
-            removeIndex = index;
-            insertIndex--;
-        }
-        
-        id object = [[QueueFileArray objectAtIndex:removeIndex] retain];
-        [QueueFileArray removeObjectAtIndex:removeIndex];
-        [QueueFileArray insertObject:object atIndex:insertIndex];
-        [object release];
+    
+    NSUInteger removeIndex;
         
-        index = [indexSet indexLessThanIndex:index];
+    if (index >= insertIndex)
+    {
+        removeIndex = index + aboveInsertIndexCount;
+        aboveInsertIndexCount++;
     }
+    else
+    {
+        removeIndex = index;
+        insertIndex--;
+    }
+
+    id object = [[QueueFileArray objectAtIndex:removeIndex] retain];
+    [QueueFileArray removeObjectAtIndex:removeIndex];
+    [QueueFileArray insertObject:object atIndex:insertIndex];
+    [object release];
+        
+    index = [indexSet indexLessThanIndex:index];
+
    /* We save all of the Queue data here 
     * and it also gets sent back to the queue controller*/
     [self saveQueueFileItem]; 
@@ -2119,12 +2156,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
@@ -2254,9 +2285,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];
@@ -2395,7 +2423,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
@@ -2424,16 +2452,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];
     
@@ -2599,56 +2629,10 @@ fWorkingCount = 0;
     job->mux = [[fDstFormatPopUp selectedItem] tag];
     job->vcodec = [[fVidEncoderPopUp selectedItem] tag];
 
-
-    /* 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( [fDstMp4LargeFileCheck state] == NSOnState )
-               {
-                       job->largeFileSize = 1;
-               }
-               else
-               {
-                       job->largeFileSize = 0;
-               }
-        /* We set http optimized mp4 here */
-        if( [fDstMp4HttpOptFileCheck state] == NSOnState && [fDstMp4HttpOptFileCheck isEnabled] )
-               {
-        job->mp4_optimize = 1;
-        }
-        else
-        {
-        job->mp4_optimize = 0;
-        }
-    }
-       if( [fDstFormatPopUp indexOfSelectedItem] == 0 || [fDstFormatPopUp indexOfSelectedItem] == 1 )
-       {
-         /* We set the chapter marker extraction here based on the format being
-               mpeg4 or mkv and the checkbox being checked */
-               if ([fCreateChapterMarkers state] == NSOnState)
-               {
-                       job->chapter_markers = 1;
-               }
-               else
-               {
-                       job->chapter_markers = 0;
-               }
-       }
-       
-    if( job->vcodec & HB_VCODEC_X264 )
+    job->chapter_markers = 0;
+    
+       if( job->vcodec & HB_VCODEC_X264 )
     {
-               if ([fDstMp4iPodFileCheck state] == NSOnState)
-           {
-            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 && [fVidQualityMatrix selectedRow] == 2)
@@ -2691,7 +2675,7 @@ fWorkingCount = 0;
         /* If we are same as source and we have detelecine on, we need to turn on
          * job->vfr
          */
-        if ([fPictureController detelecine] == 1)
+        if ([fPictureFilterController detelecine] == 1)
         {
             job->vfr = 1;
         }
@@ -2708,13 +2692,11 @@ fWorkingCount = 0;
             job->vbitrate = [fVidBitrateField intValue];
             break;
         case 2:
-            job->vquality = [fVidQualitySlider floatValue];
+            job->vquality = [fVidQualityRFField floatValue];
             job->vbitrate = 0;
             break;
     }
 
-    job->grayscale = ( [fVidGrayscaleCheck state] == NSOnState );
-
     /* Subtitle settings */
     job->subtitle = [fSubPopUp indexOfSelectedItem] - 2;
 
@@ -2799,7 +2781,22 @@ fWorkingCount = 0;
 
     
     
-    /* Filters */ 
+    /* 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.
@@ -2807,67 +2804,94 @@ fWorkingCount = 0;
     */
     
        /* Detelecine */
-    if ([fPictureController detelecine])
+    if ([fPictureFilterController detelecine] == 1)
     {
         hb_list_add( job->filters, &hb_filter_detelecine );
     }
-    
-    /* Decomb */
-    if ([fPictureController decomb] > 0)
-    {
-        /* Run old deinterlacer fd by default */
-        //fPicSettingDecomb
-        hb_filter_decomb.settings = (char *) [[fPicSettingDecomb stringValue] UTF8String];
-        //hb_filter_decomb.settings = "4:10:15:9:10:35:9"; // <-- jbrjakes recommended parameters as of 5/23/08
-        hb_list_add( job->filters, &hb_filter_decomb );
-    }
-
-    
-    /* Deinterlace */
-    if ([fPictureController deinterlace] == 1)
+    if ([fPictureFilterController detelecine] == 2)
     {
-        /* Run old deinterlacer fd by default */
-        hb_filter_deinterlace.settings = "-1"; 
-        hb_list_add( job->filters, &hb_filter_deinterlace );
+        /* use a custom detelecine string */
+        hb_filter_detelecine.settings = (char *) [[fPictureFilterController detelecineCustomString] UTF8String];
+        hb_list_add( job->filters, &hb_filter_detelecine );
     }
-    else if ([fPictureController deinterlace] == 2)
+    if ([fPictureFilterController useDecomb] == 1)
     {
-        /* Yadif mode 0 (without spatial deinterlacing.) */
-        hb_filter_deinterlace.settings = "2"; 
-        hb_list_add( job->filters, &hb_filter_deinterlace );            
+        /* 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 if ([fPictureController deinterlace] == 3)
+    else
     {
-        /* Yadif (with spatial deinterlacing) */
-        hb_filter_deinterlace.settings = "0"; 
-        hb_list_add( job->filters, &hb_filter_deinterlace );            
-    }
-       
+        
+        /* 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 ([fPictureController denoise] == 1) // Weak in popup
+       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 ([fPictureController denoise] == 2) // Medium in popup
+       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 ([fPictureController denoise] == 3) // Strong in popup
+       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 ([fPictureController deblock] != 0)
+    if ([fPictureFilterController deblock] != 0)
     {
-        NSString *deblockStringValue = [NSString stringWithFormat: @"%d",[fPictureController deblock]];
+        NSString *deblockStringValue = [NSString stringWithFormat: @"%d",[fPictureFilterController deblock]];
         hb_filter_deblock.settings = (char *) [deblockStringValue UTF8String];
         hb_list_add( job->filters, &hb_filter_deblock );
     }
@@ -2999,7 +3023,7 @@ fWorkingCount = 0;
     job->height = [[queueToApply objectForKey:@"PictureHeight"]  intValue];
     
     job->keep_ratio = [[queueToApply objectForKey:@"PictureKeepRatio"]  intValue];
-    job->pixel_ratio = [[queueToApply objectForKey:@"PicturePAR"]  intValue];
+    job->anamorphic.mode = [[queueToApply objectForKey:@"PicturePAR"]  intValue];
     
     
     /* Here we use the crop values saved at the time the preset was saved */
@@ -3148,37 +3172,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
        {
@@ -3195,6 +3246,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 
@@ -3584,10 +3641,7 @@ fWorkingCount = 0;
        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
@@ -3599,9 +3653,9 @@ fWorkingCount = 0;
        AutoCropLeft = job->crop[2];
        AutoCropRight = job->crop[3];
 
-       /* Reset the new title in fPictureController */
+       /* Reset the new title in fPictureController &&  fPreviewController*/
     [fPictureController SetTitle:title];
-
+    //[fPictureFilterController SetTitle:title];
     /* Update subtitle popups */
     hb_subtitle_t * subtitle;
     [fSubPopUp removeAllItems];
@@ -3703,6 +3757,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;
@@ -3765,7 +3823,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];
@@ -3865,9 +3931,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
@@ -3882,7 +3948,7 @@ the user is using "Custom" settings by determining the sender*/
         [fPictureController setAllowLooseAnamorphic:YES];
         [fDstMp4iPodFileCheck setEnabled: YES];
     }
-    
+    [self setupQualitySlider];
        [self calculatePictureSizing: sender];
        [self twoPassCheckboxChanged: sender];
 }
@@ -3949,6 +4015,8 @@ the user is using "Custom" settings by determining the sender*/
     [fVidTargetSizeField  setEnabled: target];
     [fVidBitrateField     setEnabled: bitrate];
     [fVidQualitySlider    setEnabled: quality];
+    [fVidQualityRFField   setEnabled: quality];
+    [fVidQualityRFLabel    setEnabled: quality];
     [fVidTwoPassCheck     setEnabled: !quality &&
         [fVidQualityMatrix isEnabled]];
     if( quality )
@@ -3963,12 +4031,88 @@ the user is using "Custom" settings by determining the sender*/
        [self customSettingUsed: sender];
 }
 
+/* Use this method to setup the quality slider for cq/rf values depending on
+ * the video encoder selected.
+ */
+- (void) setupQualitySlider
+{
+    /* Get the current slider maxValue to check for a change in slider scale later
+     * so that we can choose a new similar value on the new slider scale */
+    float previousMaxValue = [fVidQualitySlider maxValue];
+    float previousPercentOfSliderScale = [fVidQualitySlider floatValue] / ([fVidQualitySlider maxValue] - [fVidQualitySlider minValue] + 1);
+    NSString * qpRFLabelString = @"QP:";
+    /* x264 0-51 */
+    if ([[fVidEncoderPopUp selectedItem] tag] == HB_VCODEC_X264)
+    {
+        [fVidQualitySlider setMinValue:0.0];
+        [fVidQualitySlider setMaxValue:51.0];
+        /* As x264 allows for qp/rf values that are fractional, we get the value from the preferences */
+        int fractionalGranularity = 1 / [[NSUserDefaults standardUserDefaults] floatForKey:@"x264CqSliderFractional"];
+        [fVidQualitySlider setNumberOfTickMarks:(([fVidQualitySlider maxValue] - [fVidQualitySlider minValue]) * fractionalGranularity) + 1];
+        if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultCrf"] > 0)
+        {
+            qpRFLabelString = @"RF:";
+        }
+    }
+    /* ffmpeg and xvid 1-31 */
+    if ([[fVidEncoderPopUp selectedItem] tag] == HB_VCODEC_FFMPEG || [[fVidEncoderPopUp selectedItem] tag] == HB_VCODEC_XVID)
+    {
+        [fVidQualitySlider setMinValue:1.0];
+        [fVidQualitySlider setMaxValue:31.0];
+        [fVidQualitySlider setNumberOfTickMarks:31];
+    }
+    /* Theora 0-63 */
+    if ([[fVidEncoderPopUp selectedItem] tag] == HB_VCODEC_THEORA)
+    {
+        [fVidQualitySlider setMinValue:0.0];
+        [fVidQualitySlider setMaxValue:63.0];
+        [fVidQualitySlider setNumberOfTickMarks:64];
+    }
+    [fVidQualityRFLabel setStringValue:qpRFLabelString];
+    
+    /* check to see if we have changed slider scales */
+    if (previousMaxValue != [fVidQualitySlider maxValue])
+    {
+        /* if so, convert the old setting to the new scale as close as possible based on percentages */
+        float rf =  ([fVidQualitySlider maxValue] - [fVidQualitySlider minValue] + 1) * previousPercentOfSliderScale;
+        [fVidQualitySlider setFloatValue:rf];
+    }
+    
+    [self qualitySliderChanged:nil];
+}
+
 - (IBAction) qualitySliderChanged: (id) sender
 {
+    /* Our constant quality slider is in a range based
+     * on each encoders qp/rf values. The range depends
+     * on the encoder. Also, the range is inverse of quality
+     * for all of the encoders *except* for theora
+     * (ie. as the "quality" goes up, the cq or rf value
+     * actually goes down). Since the IB sliders always set
+     * their max value at the right end of the slider, we
+     * will calculate the inverse, so as the slider floatValue
+     * goes up, we will show the inverse in the rf field
+     * so, the floatValue at the right for x264 would be 51
+     * and our rf field needs to show 0 and vice versa.
+     */
+    
+    float sliderRfInverse = ([fVidQualitySlider maxValue] - [fVidQualitySlider floatValue]) + [fVidQualitySlider minValue];
+    /* If the encoder is theora, use the float, otherwise use the inverse float*/
+    float sliderRfToPercent;
+    if ([[fVidEncoderPopUp selectedItem] tag] == HB_VCODEC_THEORA)
+    {
+        [fVidQualityRFField setStringValue: [NSString stringWithFormat: @"%.2f", [fVidQualitySlider floatValue]]];
+        sliderRfToPercent = [fVidQualityRFField floatValue] / ([fVidQualitySlider maxValue] - [fVidQualitySlider minValue]);   
+    }
+    else
+    {
+        [fVidQualityRFField setStringValue: [NSString stringWithFormat: @"%.2f", sliderRfInverse]];
+        sliderRfToPercent = ( ([fVidQualitySlider maxValue] - [fVidQualitySlider minValue])  - ([fVidQualityRFField floatValue] - [fVidQualitySlider minValue])) / ([fVidQualitySlider maxValue] - [fVidQualitySlider minValue]);
+    }
     [fVidConstantCell setTitle: [NSString stringWithFormat:
-        NSLocalizedString( @"Constant quality: %.0f %%", @"" ), 100.0 *
-        [fVidQualitySlider floatValue]]];
-               [self customSettingUsed: sender];
+                                 NSLocalizedString( @"Constant quality: %.2f %%", @"" ), 100 * sliderRfToPercent]];
+    
+    [self customSettingUsed: sender];
 }
 
 - (void) controlTextDidChange: (NSNotification *) notification
@@ -4112,136 +4256,115 @@ the user is using "Custom" settings by determining the sender*/
 /* 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]
+    if ([fPictureFilterController detelecine] == 1
     {
-        [fPicSettingDetelecine setStringValue: @"Yes"];
+        videoFilters = [videoFilters stringByAppendingString:@" - Detelecine (Default)"];
     }
-    else 
+    else if ([fPictureFilterController detelecine] == 2) 
     {
-        [fPicSettingDetelecine setStringValue: @"Off"];
+        videoFilters = [videoFilters stringByAppendingString:[NSString stringWithFormat:@" - Detelecine (%@)",[fPictureFilterController detelecineCustomString]]];
     }
     
-    /* Decomb */
-       if ([fPictureController decomb])
-       {
-               [fPicSettingDecomb setStringValue: @"1:2:6:9:80:16:16"];
-       }
-       else
-       {
-               [fPicSettingDecomb setStringValue: @"Off"];
-       }
     
-
-    /* VFR (Variable Frame Rate) */
+    if ([fPictureFilterController useDecomb] == 1)
+    {
+        /* Decomb */
+        if ([fPictureFilterController decomb] == 1)
+        {
+            videoFilters = [videoFilters stringByAppendingString:@" - Decomb (Default)"];
+        }
+        else if ([fPictureFilterController decomb] == 2)
+        {
+            videoFilters = [videoFilters stringByAppendingString:[NSString stringWithFormat:@" - Decomb (%@)",[fPictureFilterController decombCustomString]]];
+        }
+    }
+    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) 
+    if ([fPictureFilterController deblock] > 0) 
     {
-        [fPicSettingDeblock setStringValue: @"Off"];
+        videoFilters = [videoFilters stringByAppendingString:[NSString stringWithFormat:@" - Deblock (%d)",[fPictureFilterController deblock]]];
     }
-    else 
+       
+    /* Grayscale */
+    if ([fPictureFilterController grayscale]) 
     {
-        [fPicSettingDeblock setStringValue: [NSString stringWithFormat:@"%d",[fPictureController deblock]]];
+        videoFilters = [videoFilters stringByAppendingString:@" - Grayscale"];
     }
-       
-       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"];
-       }               
-   
+    [fVideoFiltersField setStringValue: [NSString stringWithFormat:@"Video Filters: %@", videoFilters]];
+    
+    [fPictureController reloadStillPreview]; 
 }
 
 
@@ -5066,6 +5189,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
@@ -5149,13 +5280,27 @@ 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 showPreviewPanel:sender forTitle:title];
-    [fPictureController showPictureWindow:sender];
+       [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 -
@@ -5189,7 +5334,7 @@ the user is using "Custom" settings by determining the sender*/
 }
 
 /* We use this to deterimine children of an item */
-- (id)outlineView:(NSOutlineView *)fPresetsOutlineView child:(int)index ofItem:(id)item
+- (id)outlineView:(NSOutlineView *)fPresetsOutlineView child:(NSInteger)index ofItem:(id)item
 {
     
     /* we need to return the count of the array in ChildrenArray for this folder */
@@ -5205,7 +5350,7 @@ the user is using "Custom" settings by determining the sender*/
             children = [item objectForKey:@"ChildrenArray"];
         }
     }   
-    if ((children == nil) || ([children count] <= index))
+    if ((children == nil) || ( [children count] <= (NSUInteger) index))
     {
         return nil;
     }
@@ -5284,6 +5429,15 @@ return YES;
     }
 }
 
+- (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
@@ -5399,7 +5553,7 @@ return YES;
     return YES;
 }
 
-- (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(int)index
+- (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(NSInteger)index
 {
        
        // Don't allow dropping ONTO an item since they can't really contain any children.
@@ -5428,7 +5582,7 @@ return YES;
 
 
 
-- (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(int)index
+- (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(NSInteger)index
 {
     /* 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
@@ -5456,33 +5610,30 @@ return YES;
     return YES;
 }
 
-- (void)moveObjectsInPresetsArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(unsigned)insertIndex
+- (void)moveObjectsInPresetsArray:(NSMutableArray *)array fromIndexes:(NSIndexSet *)indexSet toIndex:(NSUInteger)insertIndex
 {
-    unsigned index = [indexSet lastIndex];
-    unsigned aboveInsertIndexCount = 0;
+    NSUInteger index = [indexSet lastIndex];
+    NSUInteger aboveInsertIndexCount = 0;
     
-    while (index != NSNotFound)
+    NSUInteger removeIndex;
+
+    if (index >= insertIndex)
     {
-        unsigned removeIndex;
-        
-        if (index >= insertIndex)
-        {
-            removeIndex = index + aboveInsertIndexCount;
-            aboveInsertIndexCount++;
-        }
-        else
-        {
-            removeIndex = index;
-            insertIndex--;
-        }
-        
-        id object = [[array objectAtIndex:removeIndex] retain];
-        [array removeObjectAtIndex:removeIndex];
-        [array insertObject:object atIndex:insertIndex];
-        [object release];
-        
-        index = [indexSet indexLessThanIndex:index];
+        removeIndex = index + aboveInsertIndexCount;
+        aboveInsertIndexCount++;
+    }
+    else
+    {
+        removeIndex = index;
+        insertIndex--;
     }
+
+    id object = [[array objectAtIndex:removeIndex] retain];
+    [array removeObjectAtIndex:removeIndex];
+    [array insertObject:object atIndex:insertIndex];
+    [object release];
+
+    index = [indexSet indexLessThanIndex:index];
 }
 
 
@@ -5533,7 +5684,23 @@ return YES;
         
         [fVidTargetSizeField setStringValue:[chosenPreset objectForKey:@"VideoTargetSize"]];
         [fVidBitrateField setStringValue:[chosenPreset objectForKey:@"VideoAvgBitrate"]];
-        [fVidQualitySlider setFloatValue:[[chosenPreset objectForKey:@"VideoQualitySlider"] floatValue]];
+        
+        /* Since we are now using RF Values for the slider, we detect if the preset uses an old quality float.
+         * So, check to see if the quality value is less than 1.0 which should indicate the old ".062" type
+         * quality preset. Caveat: in the case of x264, where the RF scale starts at 0, it would misinterpret
+         * a preset that uses 0.0 - 0.99 for RF as an old style preset. Not sure how to get around that one yet,
+         * though it should be a corner case since it would pretty much be a preset for lossless encoding. */
+        if ([[chosenPreset objectForKey:@"VideoQualitySlider"] floatValue] < 1.0)
+        {
+            /* For the quality slider we need to convert the old percent's to the new rf scales */
+            float rf =  (([fVidQualitySlider maxValue] - [fVidQualitySlider minValue]) * [[chosenPreset objectForKey:@"VideoQualitySlider"] floatValue]);
+            [fVidQualitySlider setFloatValue:rf];
+            
+        }
+        else
+        {
+            [fVidQualitySlider setFloatValue:([fVidQualitySlider maxValue] - [fVidQualitySlider minValue]) - [[chosenPreset objectForKey:@"VideoQualitySlider"] floatValue]];
+        }
         
         [self videoMatrixChanged:nil];
         
@@ -5549,8 +5716,6 @@ return YES;
             [fVidRatePopUp selectItemWithTitle:[chosenPreset objectForKey:@"VideoFramerate"]];
         }
         
-        /* GrayScale */
-        [fVidGrayscaleCheck setState:[[chosenPreset objectForKey:@"VideoGrayScale"] intValue]];
         
         /* 2 Pass Encoding */
         [fVidTwoPassCheck setState:[[chosenPreset objectForKey:@"VideoTwoPass"] intValue]];
@@ -5738,7 +5903,7 @@ return YES;
                         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" */
             {
@@ -5746,8 +5911,9 @@ return YES;
                 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
                 {
@@ -5765,7 +5931,7 @@ return YES;
                         hb_fix_aspect( job, HB_KEEP_HEIGHT );
                     }
                 }
-                job->pixel_ratio = [[chosenPreset objectForKey:@"PicturePAR"]  intValue];
+                job->anamorphic.mode = [[chosenPreset objectForKey:@"PicturePAR"]  intValue];
                 
             }
             
@@ -5775,66 +5941,101 @@ return YES;
         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 */
-            if ([[chosenPreset objectForKey:@"PictureDecomb"] intValue] == 1)
+            
+            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];
     }
 }
@@ -5993,7 +6194,7 @@ return YES;
         [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"];
+        [preset setObject:[NSNumber numberWithFloat:[fVidQualityRFField floatValue]] forKey:@"VideoQualitySlider"];
         
         /* Video framerate */
         if ([fVidRatePopUp indexOfSelectedItem] == 0) // Same as source is selected
@@ -6004,8 +6205,7 @@ return YES;
         {
             [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*/
@@ -6018,7 +6218,7 @@ return YES;
         [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"];
+        [preset setObject:[NSNumber numberWithInt:fTitle->job->anamorphic.mode] forKey:@"PicturePAR"];
         
         /* Set crop settings here */
         [preset setObject:[NSNumber numberWithInt:[fPictureController autoCrop]] forKey:@"PictureAutoCrop"];
@@ -6028,12 +6228,17 @@ return YES;
         [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"];
+        [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*/