diff options
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/Controller.m | 61 | ||||
-rw-r--r-- | macosx/English.lproj/Video.xib | 293 | ||||
-rw-r--r-- | macosx/HBAdvancedController.h | 67 | ||||
-rw-r--r-- | macosx/HBAdvancedController.m | 98 | ||||
-rw-r--r-- | macosx/HBAudioController.m | 14 | ||||
-rw-r--r-- | macosx/HBChapterTitlesController.m | 12 | ||||
-rw-r--r-- | macosx/HBPresetsViewController.m | 11 | ||||
-rw-r--r-- | macosx/HBSubtitlesController.m | 16 | ||||
-rw-r--r-- | macosx/HBUtilities.h | 4 | ||||
-rw-r--r-- | macosx/HBUtilities.m | 8 | ||||
-rw-r--r-- | macosx/HBVideo.m | 48 | ||||
-rw-r--r-- | macosx/HBVideoController.h | 35 | ||||
-rw-r--r-- | macosx/HBVideoController.m | 1464 | ||||
-rw-r--r-- | macosx/HBViewValidation.h | 2 |
14 files changed, 560 insertions, 1573 deletions
diff --git a/macosx/Controller.m b/macosx/Controller.m index f7a291e6d..ec3c6b46c 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -21,6 +21,8 @@ #import "HBAudioDefaults.h" #import "HBSubtitlesDefaults.h" +#import "HBJob.h" + #import "HBCore.h" NSString *HBContainerChangedNotification = @"HBContainerChangedNotification"; @@ -33,6 +35,8 @@ NSString *keyTitleTag = @"keyTitleTag"; @interface HBController () <HBPresetsViewControllerDelegate> +@property (nonatomic, retain) HBJob *job; + // The current selected preset. @property (nonatomic, retain) HBPreset *selectedPreset; @property (nonatomic) BOOL customPreset; @@ -597,9 +601,7 @@ NSString *keyTitleTag = @"keyTitleTag"; [fAdvancedTab setView:[fAdvancedOptions view]]; // setup the video view controller - fVideoController = [[HBVideoController alloc] init]; - fVideoController.fAdvancedOptions = fAdvancedOptions; - fVideoController.fHBController = self; + fVideoController = [[HBVideoController alloc] initWithAdvancedController:fAdvancedOptions]; [fVideoTab setView:[fVideoController view]]; [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self @@ -668,11 +670,11 @@ NSString *keyTitleTag = @"keyTitleTag"; [controls[i] setEnabled: b]; } - [fPresetsView setUIEnabled:b]; - [fVideoController setUIEnabled:b]; - [fAudioController setUIEnabled:b]; - [fSubtitlesViewController setUIEnabled:b]; - [fChapterTitlesController setUIEnabled:b]; + fPresetsView.enabled = b; + fVideoController.enabled = b; + fAudioController.enabled = b; + fSubtitlesViewController.enabled = b; + fChapterTitlesController.enabled = b; } /** @@ -1650,14 +1652,13 @@ NSString *keyTitleTag = @"keyTitleTag"; SuccessfulScan = YES; + [self enableUI:YES]; [self titlePopUpChanged:nil]; titleLoaded = YES; [self encodeStartStopPopUpChanged:nil]; - [self enableUI: YES]; - // Open preview window now if it was visible when HB was closed if ([[NSUserDefaults standardUserDefaults] boolForKey:@"PreviewWindowIsOpen"]) [self showPreviewWindow:nil]; @@ -2083,7 +2084,7 @@ static void queueFSEventStreamCallback( /* Codecs */ /* Video encoder */ - [fVideoController prepareVideoForQueueFileJob:queueFileJob]; + [fVideoController.video prepareVideoForQueueFileJob:queueFileJob]; /* Picture Sizing */ [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->width] forKey:@"PictureWidth"]; @@ -2399,7 +2400,7 @@ static void queueFSEventStreamCallback( [fDstMp4iPodFileCheck setState:[[queueToApply objectForKey:@"Mp4iPodCompatible"] intValue]]; /* video encoder */ - [fVideoController applyVideoSettingsFromQueue:queueToApply]; + [fVideoController.video applyVideoSettingsFromQueue:queueToApply]; /* Audio Defaults */ [fAudioController.settings applySettingsFromPreset:queueToApply[@"AudioDefaults"]]; @@ -2557,7 +2558,7 @@ static void queueFSEventStreamCallback( job->mux = (int)[[fDstFormatPopUp selectedItem] tag]; /* Video Encoder */ - [fVideoController prepareVideoForJobPreview:job andTitle:title]; + [fVideoController.video prepareVideoForJobPreview:job andTitle:title]; /* Subtitle settings */ BOOL one_burned = NO; @@ -3645,11 +3646,7 @@ static void queueFSEventStreamCallback( //------------------------------------------------------------------------------------ - (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. + // Stop the current job. [self.queueCore stop]; @@ -3784,9 +3781,9 @@ static void queueFSEventStreamCallback( NSString *fileName = [HBUtilities automaticNameForSource:sourceName title:title->index chapters:NSMakeRange([fSrcChapterStartPopUp indexOfSelectedItem] + 1, [fSrcChapterEndPopUp indexOfSelectedItem] + 1) - quality:fVideoController.qualityType ? fVideoController.selectedQuality : 0 - bitrate:!fVideoController.qualityType ? fVideoController.selectedBitrate : 0 - videoCodec:fVideoController.codec]; + quality:fVideoController.video.qualityType ? fVideoController.video.quality : 0 + bitrate:!fVideoController.video.qualityType ? fVideoController.video.avgBitrate : 0 + videoCodec:fVideoController.video.encoder]; // Swap the old one with the new one [fDstFile2Field setStringValue: [NSString stringWithFormat:@"%@/%@.%@", @@ -4061,7 +4058,7 @@ static void queueFSEventStreamCallback( - (void)updateMp4Checkboxes:(NSNotification *)notification { - if (fVideoController.codec != HB_VCODEC_X264) + if (fVideoController.video.encoder != HB_VCODEC_X264) { /* We set the iPod atom checkbox to disabled and uncheck it as its only for x264 in the mp4 * container. Format is taken care of in formatPopUpChanged method by hiding and unchecking @@ -4106,16 +4103,14 @@ the user is using "Custom" settings by determining the sender*/ - (void)pictureSettingsDidChange { // align picture settings and video filters in the UI using tabs - fVideoController.pictureSettingsField = [self pictureSettingsSummary]; - fVideoController.pictureFiltersField = fPictureController.filters.summary; + fVideoController.pictureSettings = [self pictureSettingsSummary]; + fVideoController.pictureFilters = fPictureController.filters.summary; /* Store storage resolution for unparse */ if (fTitle) { - fVideoController.fPresetsWidthForUnparse = fTitle->job->width; - fVideoController.fPresetsHeightForUnparse = fTitle->job->height; - // width or height may have changed, unparse - [fVideoController x264PresetsChangedDisplayExpandedOptions:nil]; + fVideoController.video.widthForUnparse = fTitle->job->width; + fVideoController.video.heightForUnparse = fTitle->job->height; } } @@ -4249,11 +4244,11 @@ the user is using "Custom" settings by determining the sender*/ - (void)applyPreset:(HBPreset *)preset { - self.selectedPreset = preset; - self.customPreset = NO; - if (preset != nil && SuccessfulScan) { + self.selectedPreset = preset; + self.customPreset = NO; + hb_job_t * job = fTitle->job; NSDictionary *chosenPreset = preset.content; @@ -4283,7 +4278,7 @@ the user is using "Custom" settings by determining the sender*/ [fDstMp4HttpOptFileCheck setState:[[chosenPreset objectForKey:@"Mp4HttpOptimize"] intValue]]; /* Video encoder */ - [fVideoController applySettingsFromPreset:chosenPreset]; + [fVideoController.video applySettingsFromPreset:chosenPreset]; /* Lets run through the following functions to get variables set there */ /* Set the state of ipod compatible with Mp4iPodCompatible. Only for x264*/ @@ -4501,7 +4496,7 @@ the user is using "Custom" settings by determining the sender*/ preset[@"Mp4iPodCompatible"] = @(fDstMp4iPodFileCheck.state); // Video encoder - [fVideoController prepareVideoForPreset:preset]; + [fVideoController.video prepareVideoForPreset:preset]; // Picture Sizing preset[@"PictureWidth"] = currentPreset[@"PictureWidth"]; diff --git a/macosx/English.lproj/Video.xib b/macosx/English.lproj/Video.xib index 9890b4c40..1f74ea8fa 100644 --- a/macosx/English.lproj/Video.xib +++ b/macosx/English.lproj/Video.xib @@ -1,52 +1,22 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6250" systemVersion="14A389" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none"> +<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6254" systemVersion="14C81f" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none"> <dependencies> <deployment version="1060" identifier="macosx"/> <development version="5100" identifier="xcode"/> - <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6250"/> + <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/> </dependencies> <objects> <customObject id="-2" userLabel="File's Owner" customClass="HBVideoController"> <connections> - <outlet property="fDisplayPresetsAdditonalOptionsLabel" destination="ijg-ux-uvb" id="Zhw-D7-xOs"/> - <outlet property="fDisplayPresetsAdditonalOptionsTextField" destination="oJk-ur-wgc" id="TUr-Lt-UHQ"/> <outlet property="fDisplayX264PresetsUnparseTextField" destination="wk1-2U-z4i" id="aIk-h1-bOP"/> <outlet property="fDividerLine" destination="g5v-MD-kdo" id="jZS-ae-kGM"/> <outlet property="fEncoderOptionsLabel" destination="mkM-81-g3d" id="eWq-95-kTO"/> - <outlet property="fFastDecodeCheck" destination="z7F-H2-Vfr" id="usU-aE-DUt"/> - <outlet property="fFramerateCfrCell" destination="ZRE-Ig-mhJ" id="vqQ-Pd-63o"/> - <outlet property="fFramerateMatrix" destination="Xe2-d5-nEH" id="GCQ-qu-zBk"/> <outlet property="fFramerateVfrPfrCell" destination="DD4-13-4gw" id="Cwu-GV-AKd"/> - <outlet property="fLavcOptionsLabel" destination="26w-dz-St2" id="R7C-nz-BBZ"/> - <outlet property="fLavcOptionsTextField" destination="mL3-yC-hUj" id="DHu-CV-Emx"/> - <outlet property="fLevelPopUp" destination="P7c-Zk-G99" id="dHU-91-P9m"/> - <outlet property="fLevelPopUpLabel" destination="BY1-IG-JvI" id="kmr-tF-K73"/> - <outlet property="fPictureFiltersField" destination="gPF-Jh-4d0" id="6AQ-Ee-tFl"/> - <outlet property="fPictureSettingsField" destination="9L5-i4-5eu" id="elr-IU-9BI"/> - <outlet property="fPresetSelectedTextField" destination="gvn-wG-crj" id="vzQ-yp-EBS"/> - <outlet property="fPresetSliderLabel" destination="0sa-ep-yfr" id="DVa-aK-Cq4"/> <outlet property="fPresetView" destination="2dX-Hf-Hxl" id="OEP-rM-gGp"/> <outlet property="fPresetsBox" destination="A4U-3F-pYq" id="m5l-h9-Ak8"/> - <outlet property="fPresetsSlider" destination="Biw-5K-pPD" id="ixn-dK-MaZ"/> - <outlet property="fProfilePopUp" destination="CPP-lh-FbN" id="rch-3L-jwi"/> - <outlet property="fProfilePopUpLabel" destination="dY9-5D-mXX" id="Lno-BZ-ZMH"/> + <outlet property="fPresetsSlider" destination="Biw-5K-pPD" id="so9-VX-eit"/> <outlet property="fSimplePresetView" destination="aRi-vN-oR0" id="e0P-NK-oHv"/> - <outlet property="fTunePopUp" destination="A7d-wM-Xmp" id="J1a-PP-NEr"/> - <outlet property="fTunePopUpLabel" destination="gzq-SL-YVY" id="uCk-oz-Mow"/> - <outlet property="fVidBitrateCell" destination="6tI-Qz-3bJ" id="oWy-lK-5aZ"/> - <outlet property="fVidBitrateField" destination="A3o-Zx-OfM" id="IzD-XM-sDC"/> - <outlet property="fVidConstantCell" destination="au3-pU-KX6" id="M31-Xr-Rsv"/> - <outlet property="fVidEncoderField" destination="rOd-nt-22T" id="SRE-gy-wx1"/> - <outlet property="fVidEncoderPopUp" destination="xwK-Yu-a1e" id="9tr-GG-Nmf"/> - <outlet property="fVidQualityField" destination="gfa-Hb-cDP" id="7ps-7F-2H7"/> - <outlet property="fVidQualityMatrix" destination="lsD-0N-H8k" id="4hj-lZ-N2T"/> - <outlet property="fVidQualityRFField" destination="Pai-3Q-Gs3" id="t8C-Nj-EIy"/> - <outlet property="fVidQualityRFLabel" destination="1au-ZO-l1i" id="UsV-Jy-dwJ"/> <outlet property="fVidQualitySlider" destination="GPu-Ht-bKg" id="faR-df-PGL"/> - <outlet property="fVidRateField" destination="bAn-iZ-ieF" id="yiZ-OW-nxA"/> - <outlet property="fVidRatePopUp" destination="9tc-EO-QMd" id="O1B-x4-qfm"/> - <outlet property="fVidTurboPassCheck" destination="olm-zg-k9Y" id="r9Y-Ym-R0Y"/> - <outlet property="fVidTwoPassCheck" destination="bnV-aE-FVh" id="yPb-4E-8CL"/> <outlet property="fX264UseAdvancedOptionsCheck" destination="Zs7-1Y-50A" id="WWx-OC-tor"/> <outlet property="view" destination="wAC-5p-nXb" id="i3V-vv-tDn"/> </connections> @@ -65,6 +35,9 @@ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> + <connections> + <binding destination="-2" name="textColor" keyPath="self.labelColor" id="pD7-5v-U6l"/> + </connections> </textField> <textField verticalHuggingPriority="750" id="A3o-Zx-OfM"> <rect key="frame" x="507" y="241" width="78" height="19"/> @@ -75,19 +48,32 @@ <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> </textFieldCell> <connections> - <action selector="bitrateFieldChanged:" target="-2" id="zC1-Yc-rrz"/> + <binding destination="-2" name="enabled2" keyPath="self.enabled" previousBinding="mjs-X8-KV8" id="Gpe-Tm-7wn"> + <dictionary key="options"> + <integer key="NSMultipleValuesPlaceholder" value="-1"/> + <integer key="NSNoSelectionPlaceholder" value="-1"/> + <integer key="NSNotApplicablePlaceholder" value="-1"/> + <integer key="NSNullPlaceholder" value="-1"/> + </dictionary> + </binding> + <binding destination="-2" name="value" keyPath="self.video.avgBitrate" id="7eN-5J-5WV"/> + <binding destination="-2" name="enabled" keyPath="self.video.qualityType" id="mjs-X8-KV8"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> </connections> </textField> <textField verticalHuggingPriority="750" id="9L5-i4-5eu"> - <rect key="frame" x="18" y="25" width="884" height="14"/> - <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> + <rect key="frame" x="18" y="25" width="98" height="14"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="left" title="Picture Settings:" id="UWU-31-FxR"> <font key="font" metaFont="smallSystem"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> <connections> - <binding destination="-2" name="value" keyPath="pictureSettingsField" id="DEV-9e-Gv2"/> + <binding destination="-2" name="textColor" keyPath="self.labelColor" id="c5E-CM-8iJ"/> </connections> </textField> <textField verticalHuggingPriority="750" id="Pai-3Q-Gs3"> @@ -99,17 +85,21 @@ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> + <connections> + <binding destination="-2" name="value" keyPath="self.video.quality" id="tMZ-Xb-TuF"/> + <binding destination="-2" name="textColor" keyPath="self.labelColor" id="EsL-F5-tAO"/> + </connections> </textField> <textField verticalHuggingPriority="750" id="gPF-Jh-4d0"> - <rect key="frame" x="18" y="9" width="884" height="14"/> - <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> + <rect key="frame" x="18" y="9" width="81" height="14"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="left" title="Picture Filters:" id="l1l-8S-ttm"> <font key="font" metaFont="smallSystem"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> <connections> - <binding destination="-2" name="value" keyPath="pictureFiltersField" id="SoL-dS-2OQ"/> + <binding destination="-2" name="textColor" keyPath="self.labelColor" id="hyA-9e-U73"/> </connections> </textField> <popUpButton verticalHuggingPriority="750" id="9tc-EO-QMd"> @@ -125,7 +115,14 @@ </menu> </popUpButtonCell> <connections> - <action selector="videoFrameRateChanged:" target="-2" id="cxw-2p-JT9"/> + <binding destination="-2" name="enabled" keyPath="self.enabled" id="mpI-26-Ajl"/> + <binding destination="-2" name="selectedValue" keyPath="self.video.frameRate" previousBinding="Heu-SS-Uwq" id="XC7-GV-Uae"> + <dictionary key="options"> + <bool key="NSAllowsEditingMultipleValuesSelection" value="NO"/> + <string key="NSValueTransformerName">HBFrameRateTransformer</string> + </dictionary> + </binding> + <binding destination="-2" name="content" keyPath="self.video.frameRates" id="Heu-SS-Uwq"/> </connections> </popUpButton> <button id="bnV-aE-FVh"> @@ -136,7 +133,20 @@ <font key="font" metaFont="smallSystem"/> </buttonCell> <connections> - <action selector="twoPassCheckboxChanged:" target="-2" id="W4m-Bw-R57"/> + <binding destination="-2" name="enabled2" keyPath="self.enabled" previousBinding="7aV-7j-MzB" id="GSP-bg-aKw"> + <dictionary key="options"> + <integer key="NSMultipleValuesPlaceholder" value="-1"/> + <integer key="NSNoSelectionPlaceholder" value="-1"/> + <integer key="NSNotApplicablePlaceholder" value="-1"/> + <integer key="NSNullPlaceholder" value="-1"/> + </dictionary> + </binding> + <binding destination="-2" name="enabled" keyPath="self.video.qualityType" id="7aV-7j-MzB"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> + <binding destination="-2" name="value" keyPath="self.video.twoPass" id="mOJ-b3-YKx"/> </connections> </button> <button id="olm-zg-k9Y"> @@ -146,6 +156,27 @@ <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> <font key="font" metaFont="smallSystem"/> </buttonCell> + <connections> + <binding destination="-2" name="enabled2" keyPath="self.enabled" previousBinding="iZE-er-OQN" id="DQs-Z1-77T"> + <dictionary key="options"> + <integer key="NSMultipleValuesPlaceholder" value="-1"/> + <integer key="NSNoSelectionPlaceholder" value="-1"/> + <integer key="NSNotApplicablePlaceholder" value="-1"/> + <integer key="NSNullPlaceholder" value="-1"/> + </dictionary> + </binding> + <binding destination="-2" name="enabled" keyPath="self.video.qualityType" id="iZE-er-OQN"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> + <binding destination="-2" name="value" keyPath="self.video.turboTwoPass" id="4A4-hg-qhy"/> + <binding destination="-2" name="hidden" keyPath="self.video.twoPass" previousBinding="DQs-Z1-77T" id="sfq-sw-XJu"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> + </connections> </button> <popUpButton verticalHuggingPriority="750" id="xwK-Yu-a1e"> <rect key="frame" x="110" y="284" width="149" height="22"/> @@ -160,8 +191,14 @@ </menu> </popUpButtonCell> <connections> - <action selector="videoEncoderPopUpChanged:" target="-2" id="ojB-Jd-Au6"/> - <binding destination="-2" name="selectedTag" keyPath="self.codec" id="CvW-H4-Tco"/> + <binding destination="-2" name="enabled" keyPath="self.enabled" id="kKW-qz-38E"/> + <binding destination="-2" name="selectedValue" keyPath="self.video.encoder" previousBinding="PbS-nr-Hjk" id="h1y-Vg-Gyg"> + <dictionary key="options"> + <bool key="NSAllowsEditingMultipleValuesSelection" value="NO"/> + <string key="NSValueTransformerName">HBVideoEncoderTransformer</string> + </dictionary> + </binding> + <binding destination="-2" name="content" keyPath="self.video.encoders" id="PbS-nr-Hjk"/> </connections> </popUpButton> <textField verticalHuggingPriority="750" id="bAn-iZ-ieF"> @@ -172,6 +209,9 @@ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> + <connections> + <binding destination="-2" name="textColor" keyPath="self.labelColor" id="FB8-Bt-u3y"/> + </connections> </textField> <textField verticalHuggingPriority="750" id="rOd-nt-22T"> <rect key="frame" x="6" y="289" width="101" height="14"/> @@ -181,6 +221,9 @@ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> + <connections> + <binding destination="-2" name="textColor" keyPath="self.labelColor" id="2Sr-Kw-dnE"/> + </connections> </textField> <matrix verticalHuggingPriority="750" allowsEmptySelection="NO" autosizesCells="NO" id="lsD-0N-H8k"> <rect key="frame" x="354" y="234" width="145" height="70"/> @@ -205,8 +248,8 @@ </column> </cells> <connections> - <action selector="videoMatrixChanged:" target="-2" id="rGb-Wc-eBW"/> - <binding destination="-2" name="selectedTag" keyPath="self.qualityType" id="JkP-GB-eWw"/> + <binding destination="-2" name="enabled" keyPath="self.enabled" id="RaB-VA-rgV"/> + <binding destination="-2" name="selectedTag" keyPath="self.video.qualityType" id="Bpj-MC-Zf7"/> </connections> </matrix> <matrix verticalHuggingPriority="750" allowsEmptySelection="NO" id="Xe2-d5-nEH"> @@ -231,6 +274,10 @@ </buttonCell> </column> </cells> + <connections> + <binding destination="-2" name="enabled" keyPath="self.enabled" id="7Cn-NH-MAP"/> + <binding destination="-2" name="selectedIndex" keyPath="self.video.frameRateMode" id="tJr-26-Y2P"/> + </connections> </matrix> <box autoresizesSubviews="NO" title="x264 Presets" borderType="none" titlePosition="noTitle" id="A4U-3F-pYq"> <rect key="frame" x="0.0" y="63" width="923" height="134"/> @@ -249,7 +296,22 @@ <font key="font" metaFont="miniSystem"/> </sliderCell> <connections> - <action selector="qualitySliderChanged:" target="-2" id="nSh-RA-OCo"/> + <binding destination="-2" name="enabled2" keyPath="self.enabled" previousBinding="wCA-ag-GHJ" id="EOE-Cw-D0K"> + <dictionary key="options"> + <integer key="NSMultipleValuesPlaceholder" value="-1"/> + <integer key="NSNoSelectionPlaceholder" value="-1"/> + <integer key="NSNotApplicablePlaceholder" value="-1"/> + <integer key="NSNullPlaceholder" value="-1"/> + </dictionary> + </binding> + <binding destination="-2" name="value" keyPath="self.video.quality" previousBinding="nAO-gB-Jbd" id="C3d-pR-fJ2"> + <dictionary key="options"> + <string key="NSValueTransformerName">HBQualityTransformer</string> + </dictionary> + </binding> + <binding destination="-2" name="maxValue" keyPath="self.video.qualityMaxValue" id="FrR-GV-xnx"/> + <binding destination="-2" name="minValue" keyPath="self.video.qualityMinValue" previousBinding="FrR-GV-xnx" id="nAO-gB-Jbd"/> + <binding destination="-2" name="enabled" keyPath="self.video.qualityType" id="wCA-ag-GHJ"/> </connections> </slider> <textField verticalHuggingPriority="750" id="1au-ZO-l1i"> @@ -260,6 +322,9 @@ <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> + <connections> + <binding destination="-2" name="textColor" keyPath="self.labelColor" id="S90-zY-jeW"/> + </connections> </textField> <box verticalHuggingPriority="750" title="Box" boxType="separator" titlePosition="noTitle" id="aeW-F6-jrd"> <rect key="frame" x="20" y="45" width="880" height="5"/> @@ -268,8 +333,36 @@ <color key="fillColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> <font key="titleFont" metaFont="system"/> </box> + <textField verticalHuggingPriority="750" id="BI1-oA-GQA"> + <rect key="frame" x="111" y="25" width="791" height="14"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> + <textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="left" id="Kk2-3e-Iau"> + <font key="font" metaFont="smallSystem"/> + <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> + <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> + </textFieldCell> + <connections> + <binding destination="-2" name="value" keyPath="pictureSettings" id="hem-VY-3fR"/> + <binding destination="-2" name="enabled" keyPath="self.enabled" id="uv0-Gi-gXH"/> + <binding destination="-2" name="textColor" keyPath="self.labelColor" id="aVY-g8-jGq"/> + </connections> + </textField> + <textField verticalHuggingPriority="750" id="PW6-gP-Dyj"> + <rect key="frame" x="99" y="9" width="803" height="14"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> + <textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="left" id="gJf-jo-gdK"> + <font key="font" metaFont="smallSystem"/> + <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> + <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> + </textFieldCell> + <connections> + <binding destination="-2" name="value" keyPath="pictureFilters" id="Sr7-JI-M4y"/> + <binding destination="-2" name="enabled" keyPath="self.enabled" id="Joa-BW-Ekr"/> + <binding destination="-2" name="textColor" keyPath="self.labelColor" id="FtS-pM-hKz"/> + </connections> + </textField> </subviews> - <point key="canvasLocation" x="185" y="286.5"/> + <point key="canvasLocation" x="265" y="409.5"/> </view> <customView id="2dX-Hf-Hxl" userLabel="x264/x264 presets view"> <rect key="frame" x="0.0" y="0.0" width="920" height="134"/> @@ -284,7 +377,7 @@ This estabilishes your default encoder settings. Tunes, profiles, levels and adv You should generally set this option to the slowest you can bear since slower settings will result in better quality or smaller files.</string> <sliderCell key="cell" controlSize="mini" continuous="YES" state="on" alignment="left" maxValue="5" tickMarkPosition="above" numberOfTickMarks="2" allowsTickMarkValuesOnly="YES" sliderType="linear" id="suZ-F3-AGy"/> <connections> - <action selector="presetsSliderChanged:" target="-2" id="bKH-cB-TyO"/> + <binding destination="-2" name="enabled" keyPath="self.presetViewEnabled" id="exe-6L-bUd"/> </connections> </slider> <textField verticalHuggingPriority="750" id="0sa-ep-yfr"> @@ -295,6 +388,9 @@ You should generally set this option to the slowest you can bear since slower se <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> + <connections> + <binding destination="-2" name="textColor" keyPath="self.labelColor" id="jwX-Os-rhB"/> + </connections> </textField> <textField verticalHuggingPriority="750" id="gzq-SL-YVY"> <rect key="frame" x="35" y="78" width="79" height="14"/> @@ -304,6 +400,9 @@ You should generally set this option to the slowest you can bear since slower se <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> + <connections> + <binding destination="-2" name="textColor" keyPath="self.labelColor" id="wpX-b9-mYI"/> + </connections> </textField> <textField verticalHuggingPriority="750" id="dY9-5D-mXX"> <rect key="frame" x="35" y="57" width="79" height="14"/> @@ -313,6 +412,9 @@ You should generally set this option to the slowest you can bear since slower se <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> + <connections> + <binding destination="-2" name="textColor" keyPath="self.labelColor" id="nkv-vu-agJ"/> + </connections> </textField> <textField verticalHuggingPriority="750" id="BY1-IG-JvI"> <rect key="frame" x="35" y="36" width="79" height="14"/> @@ -322,6 +424,9 @@ You should generally set this option to the slowest you can bear since slower se <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> + <connections> + <binding destination="-2" name="textColor" keyPath="self.labelColor" id="0LN-xF-Kg6"/> + </connections> </textField> <popUpButton verticalHuggingPriority="750" id="A7d-wM-Xmp"> <rect key="frame" x="119" y="77" width="126" height="15"/> @@ -329,19 +434,19 @@ You should generally set this option to the slowest you can bear since slower se <string key="toolTip">Tune settings to optimize for common scenarios. This can improve efficiency for particular source characteristics or set characteristics of the output file. Changes will be applied after the preset but before all other parameters.</string> - <popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" arrowPosition="arrowAtCenter" preferredEdge="maxY" selectedItem="rl3-yb-lhe" id="dy8-w4-ycN"> + <popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" arrowPosition="arrowAtCenter" preferredEdge="maxY" id="dy8-w4-ycN"> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <font key="font" metaFont="miniSystem"/> - <menu key="menu" title="OtherViews" id="c4N-uO-iVC"> - <items> - <menuItem title="Item 1" state="on" id="rl3-yb-lhe"/> - <menuItem title="Item 2" id="Oh1-Pi-VOR"/> - <menuItem title="Item 3" id="8PG-Nw-5ky"/> - </items> - </menu> + <menu key="menu" title="OtherViews" id="c4N-uO-iVC"/> </popUpButtonCell> <connections> - <action selector="x264PresetsChangedDisplayExpandedOptions:" target="-2" id="NXN-UM-juC"/> + <binding destination="-2" name="enabled" keyPath="self.presetViewEnabled" id="jwX-If-Tz7"/> + <binding destination="-2" name="selectedValue" keyPath="self.video.tune" previousBinding="ziN-5r-CNJ" id="gu5-Qw-6oi"> + <dictionary key="options"> + <string key="NSNullPlaceholder">none</string> + </dictionary> + </binding> + <binding destination="-2" name="content" keyPath="self.video.tunes" id="ziN-5r-CNJ"/> </connections> </popUpButton> <popUpButton verticalHuggingPriority="750" id="CPP-lh-FbN"> @@ -349,37 +454,37 @@ This can improve efficiency for particular source characteristics or set charact <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> <string key="toolTip">Sets and ensures compliance with the specified profile. Overrides all other settings.</string> - <popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" arrowPosition="arrowAtCenter" preferredEdge="maxY" selectedItem="mmg-zN-rCB" id="oOm-hC-AoS"> + <popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" arrowPosition="arrowAtCenter" preferredEdge="maxY" id="oOm-hC-AoS"> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <font key="font" metaFont="miniSystem"/> - <menu key="menu" title="OtherViews" id="7CG-ga-88H"> - <items> - <menuItem title="Item 1" state="on" id="mmg-zN-rCB"/> - <menuItem title="Item 2" id="got-Ie-NJ2"/> - <menuItem title="Item 3" id="Dgy-rE-2Tr"/> - </items> - </menu> + <menu key="menu" title="OtherViews" id="7CG-ga-88H"/> </popUpButtonCell> <connections> - <action selector="x264PresetsChangedDisplayExpandedOptions:" target="-2" id="WDW-WH-NRA"/> + <binding destination="-2" name="enabled" keyPath="self.presetViewEnabled" id="daB-50-blQ"/> + <binding destination="-2" name="selectedValue" keyPath="self.video.profile" previousBinding="Njf-bs-Nub" id="ioS-p7-9Ri"> + <dictionary key="options"> + <string key="NSNullPlaceholder">auto</string> + </dictionary> + </binding> + <binding destination="-2" name="content" keyPath="self.video.profiles" id="Njf-bs-Nub"/> </connections> </popUpButton> <popUpButton toolTip="Sets and ensures compliance with the specified level.
Overrides all other settings." verticalHuggingPriority="750" id="P7c-Zk-G99"> <rect key="frame" x="119" y="35" width="126" height="15"/> <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> - <popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" arrowPosition="arrowAtCenter" preferredEdge="maxY" selectedItem="kAg-9O-5hF" id="PhX-Wa-Vhs"> + <popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" controlSize="mini" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" arrowPosition="arrowAtCenter" preferredEdge="maxY" id="PhX-Wa-Vhs"> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <font key="font" metaFont="miniSystem"/> - <menu key="menu" title="OtherViews" id="pPu-oR-2R8"> - <items> - <menuItem title="Item 1" state="on" id="kAg-9O-5hF"/> - <menuItem title="Item 2" id="D7y-fr-REA"/> - <menuItem title="Item 3" id="b0U-ow-7Mq"/> - </items> - </menu> + <menu key="menu" title="OtherViews" id="pPu-oR-2R8"/> </popUpButtonCell> <connections> - <action selector="x264PresetsChangedDisplayExpandedOptions:" target="-2" id="vbv-LQ-CX5"/> + <binding destination="-2" name="enabled" keyPath="self.presetViewEnabled" id="gyc-y2-3XD"/> + <binding destination="-2" name="selectedValue" keyPath="self.video.level" previousBinding="MXA-St-eVu" id="v8q-ly-ZVP"> + <dictionary key="options"> + <string key="NSNullPlaceholder">auto</string> + </dictionary> + </binding> + <binding destination="-2" name="content" keyPath="self.video.levels" id="MXA-St-eVu"/> </connections> </popUpButton> <button id="z7F-H2-Vfr"> @@ -392,7 +497,13 @@ Set this if your device is struggling to play the output (dropped frames).</stri <font key="font" metaFont="smallSystem"/> </buttonCell> <connections> - <action selector="x264PresetsChangedDisplayExpandedOptions:" target="-2" id="UYm-bq-oxP"/> + <binding destination="-2" name="enabled" keyPath="self.presetViewEnabled" id="JTS-dn-Hyg"/> + <binding destination="-2" name="value" keyPath="self.video.fastDecode" id="3I9-0k-Ixu"/> + <binding destination="-2" name="hidden" keyPath="self.video.fastDecodeSupported" previousBinding="JTS-dn-Hyg" id="IVa-dm-KVJ"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> </connections> </button> <textField verticalHuggingPriority="750" id="ijg-ux-uvb"> @@ -403,6 +514,9 @@ Set this if your device is struggling to play the output (dropped frames).</stri <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> + <connections> + <binding destination="-2" name="textColor" keyPath="self.labelColor" id="g1c-DV-iaX"/> + </connections> </textField> <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="oJk-ur-wgc"> <rect key="frame" x="377" y="35" width="523" height="37"/> @@ -413,7 +527,8 @@ Set this if your device is struggling to play the output (dropped frames).</stri <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> </textFieldCell> <connections> - <action selector="x264PresetsChangedDisplayExpandedOptions:" target="-2" id="wJH-X4-1oP"/> + <binding destination="-2" name="enabled" keyPath="self.presetViewEnabled" id="wBW-sS-Bk8"/> + <binding destination="-2" name="value" keyPath="self.video.videoOptionExtra" id="OfI-jr-h9v"/> </connections> </textField> <textField verticalHuggingPriority="750" id="gvn-wG-crj"> @@ -424,6 +539,10 @@ Set this if your device is struggling to play the output (dropped frames).</stri <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> + <connections> + <binding destination="-2" name="value" keyPath="self.video.preset" id="yix-Fd-Qfi"/> + <binding destination="-2" name="textColor" keyPath="self.labelColor" id="Dpc-uO-tKp"/> + </connections> </textField> <button toolTip="Use Advanced Options tab for x264 settings. Use at your own risk!" id="Zs7-1Y-50A"> <rect key="frame" x="117" y="118" width="209" height="18"/> @@ -433,17 +552,21 @@ Set this if your device is struggling to play the output (dropped frames).</stri <font key="font" metaFont="smallSystem"/> </buttonCell> <connections> - <action selector="updateEncoderOptionsWidgets:" target="-2" id="kT9-0X-dVp"/> + <binding destination="-2" name="enabled" keyPath="self.enabled" id="eDg-nl-sf5"/> + <binding destination="-2" name="value" keyPath="self.video.advancedOptions" id="sQg-ab-NdN"/> </connections> </button> - <textField verticalHuggingPriority="750" id="wk1-2U-z4i"> + <textField verticalHuggingPriority="750" setsMaxLayoutWidthAtFirstLayout="YES" id="wk1-2U-z4i"> <rect key="frame" x="18" y="0.0" width="883" height="29"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> - <textFieldCell key="cell" selectable="YES" sendsActionOnEndEditing="YES" alignment="left" title="Unparse:" id="G8P-IF-mpl"> + <textFieldCell key="cell" lineBreakMode="charWrapping" selectable="YES" sendsActionOnEndEditing="YES" alignment="left" title="Unparse:" id="G8P-IF-mpl"> <font key="font" metaFont="smallSystem"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> + <connections> + <binding destination="-2" name="textColor" keyPath="self.labelColor" id="ewb-Ig-EKG"/> + </connections> </textField> <textField verticalHuggingPriority="750" id="mkM-81-g3d"> <rect key="frame" x="-2" y="120" width="116" height="14"/> @@ -453,6 +576,9 @@ Set this if your device is struggling to play the output (dropped frames).</stri <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> </textFieldCell> + <connections> + <binding destination="-2" name="textColor" keyPath="self.labelColor" id="Qg2-rj-XNj"/> + </connections> </textField> <box verticalHuggingPriority="750" title="Box" boxType="separator" titlePosition="noTitle" id="g5v-MD-kdo"> <rect key="frame" x="120" y="124" width="780" height="5"/> @@ -462,7 +588,7 @@ Set this if your device is struggling to play the output (dropped frames).</stri <font key="titleFont" metaFont="system"/> </box> </subviews> - <point key="canvasLocation" x="185" y="576"/> + <point key="canvasLocation" x="265" y="700"/> </customView> <customView id="aRi-vN-oR0" userLabel="ffmpeg presets view"> <rect key="frame" x="0.0" y="0.0" width="920" height="34"/> @@ -476,6 +602,9 @@ Set this if your device is struggling to play the output (dropped frames).</stri <color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> </textFieldCell> + <connections> + <binding destination="-2" name="value" keyPath="self.video.videoOptionExtra" id="HNx-Oj-zHh"/> + </connections> </textField> <textField verticalHuggingPriority="750" id="26w-dz-St2"> <rect key="frame" x="6" y="20" width="108" height="14"/> diff --git a/macosx/HBAdvancedController.h b/macosx/HBAdvancedController.h index e7267cfe0..526b71c13 100644 --- a/macosx/HBAdvancedController.h +++ b/macosx/HBAdvancedController.h @@ -7,73 +7,14 @@ #import <Cocoa/Cocoa.h> #import "HBViewValidation.h" +@class HBVideo; + /** * HBAdvancedController */ @interface HBAdvancedController : NSViewController <HBViewValidation> -{ - /* Advanced Tab for opts fX264optView*/ - IBOutlet NSBox * fOptionsBox; - - IBOutlet NSView * fEmptyView; - - IBOutlet NSView * fX264optView; - IBOutlet NSTextField * fX264optViewTitleLabel; - IBOutlet NSTextField * fDisplayX264OptionsLabel; - IBOutlet NSTextField * fDisplayX264Options; - - IBOutlet NSTextField * fX264optBframesLabel; - IBOutlet NSPopUpButton * fX264optBframesPopUp; - IBOutlet NSTextField * fX264optRefLabel; - IBOutlet NSPopUpButton * fX264optRefPopUp; - IBOutlet NSButton * fX264optWeightPSwitch; - IBOutlet NSTextField * fX264optWeightPLabel; - IBOutlet NSTextField * fX264optNodctdcmtLabel; - IBOutlet NSButton * fX264optNodctdcmtSwitch; - IBOutlet NSTextField * fX264optSubmeLabel; - IBOutlet NSPopUpButton * fX264optSubmePopUp; - IBOutlet NSTextField * fX264optTrellisLabel; - IBOutlet NSPopUpButton * fX264optTrellisPopUp; - IBOutlet NSTextField * fX264optMotionEstLabel; - IBOutlet NSPopUpButton * fX264optMotionEstPopUp; - IBOutlet NSTextField * fX264optMERangeLabel; - IBOutlet NSPopUpButton * fX264optMERangePopUp; - IBOutlet NSTextField * fX264optBPyramidLabel; - IBOutlet NSPopUpButton * fX264optBPyramidPopUp; - IBOutlet NSTextField * fX264optDirectPredLabel; - IBOutlet NSPopUpButton * fX264optDirectPredPopUp; - IBOutlet NSTextField * fX264optDeblockLabel; - IBOutlet NSPopUpButton * fX264optAlphaDeblockPopUp; - IBOutlet NSPopUpButton * fX264optBetaDeblockPopUp; - IBOutlet NSTextField * fX264optAnalyseLabel; - IBOutlet NSPopUpButton * fX264optAnalysePopUp; - IBOutlet NSTextField * fX264opt8x8dctLabel; - IBOutlet NSButton * fX264opt8x8dctSwitch; - IBOutlet NSTextField * fX264optCabacLabel; - IBOutlet NSButton * fX264optCabacSwitch; - IBOutlet NSSlider * fX264optAqSlider; - IBOutlet NSTextField * fX264optAqLabel; - IBOutlet NSSlider * fX264optPsyRDSlider; - IBOutlet NSTextField * fX264optPsyRDLabel; - IBOutlet NSSlider * fX264optPsyTrellisSlider; - IBOutlet NSTextField * fX264optPsyTrellisLabel; - IBOutlet NSPopUpButton * fX264optBAdaptPopUp; - IBOutlet NSTextField * fX264optBAdaptLabel; -} - -// x264 Advanced Panel Methods -- (NSString *) optionsString; -- (void) setOptions: (NSString *)string; -- (void) setHidden: (BOOL) hide; -- (IBAction) X264AdvancedOptionsAnimate: (id) sender; -- (IBAction) X264AdvancedOptionsSet: (id) sender; -- (IBAction) X264AdvancedOptionsStandardizeOptString: (id) sender; -- (IBAction) X264AdvancedOptionsSetCurrentSettings: (id) sender; -- (NSString *) X264AdvancedOptionsStandardizeOptNames:(NSString *) cleanOptNameString; -- (NSString *) X264AdvancedOptionsOptIDToString: (id) sender; -- (NSString *) X264AdvancedOptionsWidgetToString: (NSString *) optName withID: (id) sender; -- (BOOL) X264AdvancedOptionsIsOpt: (NSString *) optNameToChange inString: (NSString *) currentOptString; -- (IBAction) X264AdvancedOptionsChanged: (id) sender; +@property (nonatomic, readwrite, retain) HBVideo *videoSettings; +@property (nonatomic, readwrite, getter=isHidden) BOOL hidden; @end diff --git a/macosx/HBAdvancedController.m b/macosx/HBAdvancedController.m index b5e38af06..a88cea8d1 100644 --- a/macosx/HBAdvancedController.m +++ b/macosx/HBAdvancedController.m @@ -5,9 +5,75 @@ It may be used under the terms of the GNU General Public License. */ #import "HBAdvancedController.h" +#import "HBVideo.h" + +@interface HBAdvancedController () +{ + /* Advanced Tab for opts fX264optView*/ + IBOutlet NSBox * fOptionsBox; + + IBOutlet NSView * fEmptyView; + + IBOutlet NSView * fX264optView; + IBOutlet NSTextField * fX264optViewTitleLabel; + IBOutlet NSTextField * fDisplayX264OptionsLabel; + IBOutlet NSTextField * fDisplayX264Options; + + IBOutlet NSTextField * fX264optBframesLabel; + IBOutlet NSPopUpButton * fX264optBframesPopUp; + IBOutlet NSTextField * fX264optRefLabel; + IBOutlet NSPopUpButton * fX264optRefPopUp; + IBOutlet NSButton * fX264optWeightPSwitch; + IBOutlet NSTextField * fX264optWeightPLabel; + IBOutlet NSTextField * fX264optNodctdcmtLabel; + IBOutlet NSButton * fX264optNodctdcmtSwitch; + IBOutlet NSTextField * fX264optSubmeLabel; + IBOutlet NSPopUpButton * fX264optSubmePopUp; + IBOutlet NSTextField * fX264optTrellisLabel; + IBOutlet NSPopUpButton * fX264optTrellisPopUp; + IBOutlet NSTextField * fX264optMotionEstLabel; + IBOutlet NSPopUpButton * fX264optMotionEstPopUp; + IBOutlet NSTextField * fX264optMERangeLabel; + IBOutlet NSPopUpButton * fX264optMERangePopUp; + IBOutlet NSTextField * fX264optBPyramidLabel; + IBOutlet NSPopUpButton * fX264optBPyramidPopUp; + IBOutlet NSTextField * fX264optDirectPredLabel; + IBOutlet NSPopUpButton * fX264optDirectPredPopUp; + IBOutlet NSTextField * fX264optDeblockLabel; + IBOutlet NSPopUpButton * fX264optAlphaDeblockPopUp; + IBOutlet NSPopUpButton * fX264optBetaDeblockPopUp; + IBOutlet NSTextField * fX264optAnalyseLabel; + IBOutlet NSPopUpButton * fX264optAnalysePopUp; + IBOutlet NSTextField * fX264opt8x8dctLabel; + IBOutlet NSButton * fX264opt8x8dctSwitch; + IBOutlet NSTextField * fX264optCabacLabel; + IBOutlet NSButton * fX264optCabacSwitch; + IBOutlet NSSlider * fX264optAqSlider; + IBOutlet NSTextField * fX264optAqLabel; + IBOutlet NSSlider * fX264optPsyRDSlider; + IBOutlet NSTextField * fX264optPsyRDLabel; + IBOutlet NSSlider * fX264optPsyTrellisSlider; + IBOutlet NSTextField * fX264optPsyTrellisLabel; + IBOutlet NSPopUpButton * fX264optBAdaptPopUp; + IBOutlet NSTextField * fX264optBAdaptLabel; +} + +- (IBAction) X264AdvancedOptionsAnimate: (id) sender; +- (IBAction) X264AdvancedOptionsSet: (id) sender; +- (IBAction) X264AdvancedOptionsStandardizeOptString: (id) sender; +- (IBAction) X264AdvancedOptionsSetCurrentSettings: (id) sender; +- (NSString *) X264AdvancedOptionsStandardizeOptNames:(NSString *) cleanOptNameString; +- (NSString *) X264AdvancedOptionsOptIDToString: (id) sender; +- (NSString *) X264AdvancedOptionsWidgetToString: (NSString *) optName withID: (id) sender; +- (BOOL) X264AdvancedOptionsIsOpt: (NSString *) optNameToChange inString: (NSString *) currentOptString; +- (IBAction) X264AdvancedOptionsChanged: (id) sender; + +@end @implementation HBAdvancedController +@synthesize enabled = _enabled; + - (instancetype)init { self = [super initWithNibName:@"AdvancedView" bundle:nil]; @@ -25,20 +91,25 @@ [self setHidden:NO]; } -- (NSString *) optionsString +- (void)setVideoSettings:(HBVideo *)videoSettings { - return [fDisplayX264Options stringValue]; -} + [_videoSettings autorelease]; + _videoSettings = [videoSettings retain]; -- (void) setOptions: (NSString *)string -{ - [fDisplayX264Options setStringValue:string]; + if (_videoSettings) + { + fDisplayX264Options.stringValue = _videoSettings.unparseOptions; + } + else + { + fDisplayX264Options.stringValue = @""; + } [self X264AdvancedOptionsSet:nil]; } -- (void) setHidden: (BOOL) hide +- (void)setHidden:(BOOL)hidden { - if (hide) + if (hidden) { [fOptionsBox setContentView:fEmptyView]; } @@ -46,11 +117,12 @@ { [fOptionsBox setContentView:fX264optView]; } - return; } - - (void)setUIEnabled:(BOOL)flag + - (void)setEnabled:(BOOL)flag { + _enabled = flag; + unsigned i; NSControl * controls[] = { fX264optViewTitleLabel,fDisplayX264Options,fDisplayX264OptionsLabel,fX264optBframesLabel, @@ -394,6 +466,7 @@ /* Change the option string to reflect the new standardized option string */ [fDisplayX264Options setStringValue:changedOptString]; + self.videoSettings.videoOptionExtra = changedOptString; } /** @@ -1304,7 +1377,7 @@ } /* Change the dislayed option string to reflect the new modified settings */ - [fDisplayX264Options setStringValue:changedOptString]; + [fDisplayX264Options setStringValue:changedOptString]; } else // if none exists, add it to the string { @@ -1331,7 +1404,8 @@ } /* We now need to reset the opt widgets since we changed some stuff */ - [self X264AdvancedOptionsSet:sender]; + [self X264AdvancedOptionsSet:sender]; + self.videoSettings.videoOptionExtra = fDisplayX264Options.stringValue; } @end diff --git a/macosx/HBAudioController.m b/macosx/HBAudioController.m index 374441d85..9d608a421 100644 --- a/macosx/HBAudioController.m +++ b/macosx/HBAudioController.m @@ -37,7 +37,6 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; @property (assign) IBOutlet NSPopUpButton *trackPopup; @property (assign) IBOutlet NSButton *configureDefaults; @property (assign) IBOutlet NSButton *reloadDefaults; -@property (nonatomic, readwrite) BOOL enabled; @property (nonatomic, readwrite, retain) NSArray *masterTrackArray; @property (nonatomic, retain) NSNumber *videoContainerTag; // initially is the default HB_MUX_MP4 @@ -56,6 +55,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; @synthesize masterTrackArray; @synthesize noneTrack; @synthesize videoContainerTag; +@synthesize enabled = _enabled; - (instancetype)init { @@ -95,13 +95,13 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; [self switchingTrackFromNone:nil]; } -- (void)setUIEnabled:(BOOL)flag +- (void)setEnabled:(BOOL)enabled { - self.enabled = flag; - [fTableView setEnabled:flag]; - [self.trackPopup setEnabled:flag]; - [self.configureDefaults setEnabled:flag]; - [self.reloadDefaults setEnabled:flag]; + _enabled = enabled; + [fTableView setEnabled:enabled]; + [self.trackPopup setEnabled:enabled]; + [self.configureDefaults setEnabled:enabled]; + [self.reloadDefaults setEnabled:enabled]; } - (BOOL)validateUserInterfaceItem:(id < NSValidatedUserInterfaceItem >)anItem diff --git a/macosx/HBChapterTitlesController.m b/macosx/HBChapterTitlesController.m index 6702a5d81..40adb36c9 100644 --- a/macosx/HBChapterTitlesController.m +++ b/macosx/HBChapterTitlesController.m @@ -23,6 +23,8 @@ @implementation HBChapterTitlesController +@synthesize enabled = _enabled; + - (instancetype)init { self = [super initWithNibName:@"ChaptersTitles" bundle:nil]; @@ -83,12 +85,12 @@ [fChapterTable reloadData]; } -- (void)setUIEnabled:(BOOL)flag +- (void)setEnabled:(BOOL)enabled { - [fCreateChaptersMarkers setEnabled:flag]; - [fChapterTable setEnabled:flag]; - [fLoadChaptersButton setEnabled:flag]; - [fSaveChaptersButton setEnabled:flag]; + [fCreateChaptersMarkers setEnabled:enabled]; + [fChapterTable setEnabled:enabled]; + [fLoadChaptersButton setEnabled:enabled]; + [fSaveChaptersButton setEnabled:enabled]; } - (NSArray *)chapterTitlesArray diff --git a/macosx/HBPresetsViewController.m b/macosx/HBPresetsViewController.m index a5cb8c6ad..921df6ee5 100644 --- a/macosx/HBPresetsViewController.m +++ b/macosx/HBPresetsViewController.m @@ -28,12 +28,12 @@ @property (assign) IBOutlet NSOutlineView *outlineView; -@property (nonatomic) BOOL enabled; - @end @implementation HBPresetsViewController +@synthesize enabled = _enabled; + - (instancetype)initWithPresetManager:(HBPresetsManager *)presetManager { self = [super initWithNibName:@"Presets" bundle:nil]; @@ -83,13 +83,6 @@ return YES; } -#pragma mark - HBViewValidation methods - -- (void)setUIEnabled:(BOOL)flag -{ - self.enabled = flag; -} - #pragma mark - UI Methods - (IBAction)clicked:(id)sender diff --git a/macosx/HBSubtitlesController.m b/macosx/HBSubtitlesController.m index 4882cc84b..df433fcc2 100644 --- a/macosx/HBSubtitlesController.m +++ b/macosx/HBSubtitlesController.m @@ -40,8 +40,6 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex"; @property (assign) IBOutlet NSButton *configureDefaults; @property (assign) IBOutlet NSButton *reloadDefaults; -@property (nonatomic, readwrite) BOOL enabled; - // Subtitles arrays @property (nonatomic, readonly) NSMutableArray *subtitleArray; @property (nonatomic, readonly) NSMutableArray *subtitleSourceArray; @@ -68,6 +66,8 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex"; @implementation HBSubtitlesController +@synthesize enabled = _enabled; + - (instancetype)init { self = [super initWithNibName:@"Subtitles" bundle:nil]; @@ -92,13 +92,13 @@ NSString *keySubTrackLanguageIndex = @"keySubTrackLanguageIndex"; return self; } -- (void)setUIEnabled:(BOOL)flag +- (void)setEnabled:(BOOL)enabled { - [self.trackPopUp setEnabled:flag]; - [self.configureDefaults setEnabled:flag]; - [self.reloadDefaults setEnabled:flag]; - [self.fTableView setEnabled:flag]; - self.enabled = flag; + [self.trackPopUp setEnabled:enabled]; + [self.configureDefaults setEnabled:enabled]; + [self.reloadDefaults setEnabled:enabled]; + [self.fTableView setEnabled:enabled]; + _enabled = enabled; } - (void)titleChanged:(NSNotification *)aNotification diff --git a/macosx/HBUtilities.h b/macosx/HBUtilities.h index 8669dab49..754e872ab 100644 --- a/macosx/HBUtilities.h +++ b/macosx/HBUtilities.h @@ -37,8 +37,8 @@ + (NSString *)automaticNameForSource:(NSString *)sourceName title:(NSUInteger)title chapters:(NSRange)chaptersRange - quality:(NSString *)quality - bitrate:(NSString *)bitrate + quality:(double)quality + bitrate:(int)bitrate videoCodec:(uint32_t)codec; @end diff --git a/macosx/HBUtilities.m b/macosx/HBUtilities.m index 30f403a29..7618c4263 100644 --- a/macosx/HBUtilities.m +++ b/macosx/HBUtilities.m @@ -41,8 +41,8 @@ + (NSString *)automaticNameForSource:(NSString *)sourceName title:(NSUInteger)title chapters:(NSRange)chaptersRange - quality:(NSString *)quality - bitrate:(NSString *)bitrate + quality:(double)quality + bitrate:(int)bitrate videoCodec:(uint32_t)codec { NSMutableString *name = [[[NSMutableString alloc] init] autorelease]; @@ -109,12 +109,12 @@ { // Append the right quality suffix for the selected codec (rf/qp) [name appendString:[[NSString stringWithUTF8String:hb_video_quality_get_name(codec)] lowercaseString]]; - [name appendString:quality]; + [name appendString:[NSString stringWithFormat:@"%0.2f", quality]]; } else { [name appendString:@"abr"]; - [name appendString:bitrate]; + [name appendString:[NSString stringWithFormat:@"%d", bitrate]]; } } else diff --git a/macosx/HBVideo.m b/macosx/HBVideo.m index b697dc773..4d68e93d9 100644 --- a/macosx/HBVideo.m +++ b/macosx/HBVideo.m @@ -388,23 +388,24 @@ (!preset[@"x264UseAdvancedOptions"] || [preset[@"x264UseAdvancedOptions"] intValue])) { + // preset does not use the x264 preset system, reset the widgets. + self.preset = @"medium"; + self.tune = nil; + self.profile = nil; + self.level = nil; + // x264UseAdvancedOptions is not set (legacy preset) // or set to 1 (enabled), so we use the old advanced panel. if (preset[@"x264Option"]) { // we set the advanced options string here if applicable. - self.advancedOptions = YES; self.videoOptionExtra = preset[@"x264Option"]; + self.advancedOptions = YES; } else { self.videoOptionExtra = nil; } - // preset does not use the x264 preset system, reset the widgets. - self.preset = nil; - self.tune = nil; - self.profile = nil; - self.level = nil; } else { @@ -575,11 +576,12 @@ if ([queueToApply[@"x264UseAdvancedOptions"] intValue]) { // we are using the advanced panel - self.preset = nil; + self.preset = @"medium"; self.tune = nil; - self.videoOptionExtra = queueToApply[@"x264Option"]; self.profile = nil; self.level = nil; + self.videoOptionExtra = queueToApply[@"x264Option"]; + self.advancedOptions = YES; } else if (self.encoder == HB_VCODEC_X264 || self.encoder == HB_VCODEC_X265) { @@ -858,7 +860,22 @@ const char *name = hb_video_framerate_get_name([value intValue]); if (name) { - return @(name); + if (!strcmp(name, "23.976")) + { + return @"23.976 (NTSC Film)"; + } + else if (!strcmp(name, "25")) + { + return @"25 (PAL Film/Video)"; + } + else if (!strcmp(name, "29.97")) + { + return @"29.97 (NTSC Video)"; + } + else + { + return @(name); + } } else { @@ -907,12 +924,15 @@ - (id)transformedValue:(id)value { - const char * const *presets = hb_video_encoder_get_presets(_encoder); - for (int i = 0; presets[i] != NULL; i++) + if (value) { - if (!strcasecmp(presets[i], [value UTF8String])) + const char * const *presets = hb_video_encoder_get_presets(_encoder); + for (int i = 0; presets != NULL && presets[i] != NULL; i++) { - return @(i); + if (!strcasecmp(presets[i], [value UTF8String])) + { + return @(i); + } } } @@ -927,7 +947,7 @@ - (id)reverseTransformedValue:(id)value { const char * const *presets = hb_video_encoder_get_presets(_encoder); - for (int i = 0; presets[i] != NULL; i++) + for (int i = 0; presets != NULL && presets[i] != NULL; i++) { if (i == [value intValue]) { diff --git a/macosx/HBVideoController.h b/macosx/HBVideoController.h index 6845ed703..f878879c0 100644 --- a/macosx/HBVideoController.h +++ b/macosx/HBVideoController.h @@ -12,40 +12,25 @@ @class HBController; @class HBAdvancedController; +@class HBVideo; + extern NSString *HBVideoEncoderChangedNotification; /** * HBVideoController * - * Responds to HBContainerChangedNotification and HBTitleChangedNotification notifications. + * Responds to HBContainerChangedNotification notifications. */ @interface HBVideoController : NSViewController <HBViewValidation> -// Methods to apply the settings to the controller -- (void)applyVideoSettingsFromQueue:(NSDictionary *)queueToApply; -- (void)applySettingsFromPreset:(NSDictionary *)preset; - -// Methods to get back the controller settings -- (void)prepareVideoForQueueFileJob:(NSMutableDictionary *)queueFileJob; -- (void)prepareVideoForJobPreview:(hb_job_t *)job andTitle:(hb_title_t *)title; -- (void)prepareVideoForPreset:(NSMutableDictionary *)preset; - -- (IBAction)x264PresetsChangedDisplayExpandedOptions:(id)sender; - -@property (nonatomic, copy, readwrite) NSString *pictureSettingsField; -@property (nonatomic, copy, readwrite) NSString *pictureFiltersField; +- (instancetype)initWithAdvancedController:(HBAdvancedController *)advancedController; -// Property exposed for the auto name function -@property (nonatomic, readonly) int codec; -@property (nonatomic, readonly) int qualityType; -@property (nonatomic, readonly) NSString *selectedBitrate; -@property (nonatomic, readonly) NSString *selectedQuality; - -// Property updates when the video size changes -@property (nonatomic, readwrite) NSUInteger fPresetsWidthForUnparse; -@property (nonatomic, readwrite) NSUInteger fPresetsHeightForUnparse; +/** + * Summaries of the pictures and filters settings + */ +@property (nonatomic, copy, readwrite) NSString *pictureSettings; +@property (nonatomic, copy, readwrite) NSString *pictureFilters; -@property (nonatomic, retain, readwrite) HBController *fHBController; -@property (nonatomic, retain, readwrite) HBAdvancedController *fAdvancedOptions; +@property (nonatomic, readonly) HBVideo *video; @end diff --git a/macosx/HBVideoController.m b/macosx/HBVideoController.m index 4bbd1499e..2b28f24b5 100644 --- a/macosx/HBVideoController.m +++ b/macosx/HBVideoController.m @@ -5,1454 +5,302 @@ It may be used under the terms of the GNU General Public License. */ #import "HBVideoController.h" - -#include "hb.h" - #import "Controller.h" #import "HBAdvancedController.h" +#import "HBVideo.h" + +#include "hb.h" NSString *HBVideoEncoderChangedNotification = @"HBVideoEncoderChangedNotification"; +static void *HBVideoControllerContext = &HBVideoControllerContext; @interface HBVideoController () { - /* Framerate */ - /* Radio Button Framerate Controls */ - IBOutlet NSMatrix * fFramerateMatrix; - IBOutlet NSButtonCell * fFramerateVfrPfrCell; - IBOutlet NSButtonCell * fFramerateCfrCell; - - /* Video Encoder */ - IBOutlet NSTextField * fVidRateField; - IBOutlet NSPopUpButton * fVidRatePopUp; - IBOutlet NSTextField * fVidEncoderField; - IBOutlet NSPopUpButton * fVidEncoderPopUp; - IBOutlet NSTextField * fVidQualityField; - IBOutlet NSTextField * fVidQualityRFLabel; - IBOutlet NSTextField * fVidQualityRFField; - IBOutlet NSMatrix * fVidQualityMatrix; - IBOutlet NSButtonCell * fVidBitrateCell; - IBOutlet NSTextField * fVidBitrateField; - IBOutlet NSButtonCell * fVidConstantCell; - IBOutlet NSSlider * fVidQualitySlider; - IBOutlet NSButton * fVidTwoPassCheck; - IBOutlet NSButton * fVidTurboPassCheck; + // Framerate Radio Button Framerate Controls + IBOutlet NSButtonCell *fFramerateVfrPfrCell; - /* Status read out fields for picture settings and video filters */ - IBOutlet NSTextField * fPictureSettingsField; - IBOutlet NSTextField * fPictureFiltersField; + // Video Encoder + IBOutlet NSSlider *fVidQualitySlider; + // Encoder options views + IBOutlet NSView *fPresetView; + IBOutlet NSView *fSimplePresetView; - /* Encoder options views */ - IBOutlet NSView *fPresetView; - IBOutlet NSView *fSimplePresetView; + IBOutlet NSTextField *fEncoderOptionsLabel; - IBOutlet NSTextField *fEncoderOptionsLabel; + // x264/x265 Presets Box + IBOutlet NSButton *fX264UseAdvancedOptionsCheck; + IBOutlet NSBox *fDividerLine; + IBOutlet NSBox *fPresetsBox; + IBOutlet NSSlider *fPresetsSlider; - /* Simple Presets Box */ - IBOutlet NSTextField *fLavcOptionsTextField; - IBOutlet NSTextField *fLavcOptionsLabel; - - /* x264/x265 Presets Box */ - NSArray * fPresetNames; - NSUInteger fMediumPresetIndex; - IBOutlet NSButton * fX264UseAdvancedOptionsCheck; - IBOutlet NSBox * fDividerLine; - IBOutlet NSBox * fPresetsBox; - IBOutlet NSSlider * fPresetsSlider; - IBOutlet NSTextField * fPresetSliderLabel; - IBOutlet NSTextField * fPresetSelectedTextField; - IBOutlet NSPopUpButton * fTunePopUp; - IBOutlet NSTextField * fTunePopUpLabel; - IBOutlet NSPopUpButton * fProfilePopUp; - IBOutlet NSTextField * fProfilePopUpLabel; - IBOutlet NSPopUpButton * fLevelPopUp; - IBOutlet NSTextField * fLevelPopUpLabel; - IBOutlet NSButton * fFastDecodeCheck; - IBOutlet NSTextField * fDisplayPresetsAdditonalOptionsTextField; - IBOutlet NSTextField * fDisplayPresetsAdditonalOptionsLabel; // Text Field to show the expanded opts from unparse() - IBOutlet NSTextField * fDisplayX264PresetsUnparseTextField; - char * fX264PresetsUnparsedUTF8String; + IBOutlet NSTextField *fDisplayX264PresetsUnparseTextField; } -@property (nonatomic, readwrite) int codec; -@property (nonatomic, readwrite) int qualityType; +@property (nonatomic, retain, readwrite) HBAdvancedController *advancedController; + +@property (nonatomic, readwrite) HBVideo *video; +@property (nonatomic, readwrite) BOOL presetViewEnabled; + +@property (nonatomic, readwrite) NSColor *labelColor; @end @implementation HBVideoController -- (void)setPictureSettingsField:(NSString *)string -{ - if (string) - { - [_pictureSettingsField autorelease]; - _pictureSettingsField = [[NSString stringWithFormat:@"Picture Settings: %@", string] retain]; - } -} +@synthesize enabled = _enabled; -- (void)setPictureFiltersField:(NSString *)string +- (instancetype)initWithAdvancedController:(HBAdvancedController *)advancedController { - if (string) + self = [self init]; + if (self) { - [_pictureFiltersField autorelease]; - _pictureFiltersField = [[NSString stringWithFormat:@"Picture Filters: %@", string] retain]; + _advancedController = [advancedController retain]; } + return self; } -- (NSString *)selectedBitrate -{ - return [fVidBitrateField stringValue]; -} - -- (NSString *)selectedQuality -{ - return [fVidQualityRFField stringValue]; -} - - - (instancetype)init { self = [super initWithNibName:@"Video" bundle:nil]; if (self) { - /* - * initialize fX264PresetsUnparsedUTF8String as early as possible - * avoids an invalid free - */ - fX264PresetsUnparsedUTF8String = NULL; - _pictureFiltersField = @"Picture Filters:"; - _pictureSettingsField = @"Picture Settings:"; - - NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; + // Use a single HBVideo instance for now, + // will use the HBJob one in the future. + _video = [[HBVideo alloc] init]; - /* register that we are interested in changes made to the video container */ - [center addObserver:self selector: @selector(containerChanged:) name:HBContainerChangedNotification object:nil]; - [center addObserver:self selector: @selector(titleChanged:) name:HBTitleChangedNotification object:nil]; + // register that we are interested in changes made to the video container. + [[NSNotificationCenter defaultCenter] addObserver:self selector: @selector(containerChanged:) name:HBContainerChangedNotification object:nil]; - // Observe the andvanced tab preference. + // Observe the advanced tab pref shown/hided state. [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.HBShowAdvancedTab" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial - context:NULL]; - } - - return self; -} - -- (void)loadView { - [super loadView]; - - /* Video encoder */ - [fVidEncoderPopUp removeAllItems]; - [fVidEncoderPopUp addItemWithTitle:@"H.264 (x264)"]; + context:HBVideoControllerContext]; - /* setup our x264/x265 presets widgets */ - [self switchPresetViewForEncoder:HB_VCODEC_X264]; - - /* Video quality */ - [fVidBitrateField setIntValue: 1000]; - self.qualityType = 0; - - [self videoMatrixChanged:nil]; - - /* Video framerate */ - [fVidRatePopUp removeAllItems]; - NSMenuItem *menuItem = [[fVidRatePopUp menu] addItemWithTitle:@"Same as source" - action:nil - keyEquivalent:@""]; - [menuItem setTag:hb_video_framerate_get_from_name("Same as source")]; - for (const hb_rate_t *video_framerate = hb_video_framerate_get_next(NULL); - video_framerate != NULL; - video_framerate = hb_video_framerate_get_next(video_framerate)) - { - NSString *itemTitle; - if (!strcmp(video_framerate->name, "23.976")) - { - itemTitle = @"23.976 (NTSC Film)"; - } - else if (!strcmp(video_framerate->name, "25")) - { - itemTitle = @"25 (PAL Film/Video)"; - } - else if (!strcmp(video_framerate->name, "29.97")) - { - itemTitle = @"29.97 (NTSC Video)"; - } - else - { - itemTitle = @(video_framerate->name); - } - menuItem = [[fVidRatePopUp menu] addItemWithTitle:itemTitle - action:nil - keyEquivalent:@""]; - [menuItem setTag:video_framerate->rate]; - } - [fVidRatePopUp selectItemAtIndex:0]; - - /* We disable the Turbo 1st pass checkbox since we are not x264 */ - [fVidTurboPassCheck setEnabled: NO]; - [fVidTurboPassCheck setState: NSOffState]; -} - -- (void)setUIEnabled:(BOOL)flag { - NSControl *controls[] = - { - fFramerateMatrix, - fVidRateField, - fVidRatePopUp, - fVidEncoderField, - fVidEncoderPopUp, - fVidQualityField, - fVidQualityRFLabel, - fVidQualityRFField, - fVidQualityMatrix, - fVidBitrateField, - fVidQualitySlider, - fVidTwoPassCheck, - fVidTurboPassCheck, - fEncoderOptionsLabel, - fPictureSettingsField, - fPictureFiltersField - }; + // Observe the x264 slider granularity, to update the slider when the pref is changed. + [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self + forKeyPath:@"values.x264CqSliderFractional" + options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionInitial + context:HBVideoControllerContext]; - for (unsigned i = 0; i < (sizeof(controls) / sizeof(NSControl *)); i++) - { - if ([[controls[i] className] isEqualToString: @"NSTextField"]) - { - NSTextField *tf = (NSTextField *)controls[i]; - if (![tf isBezeled]) - { - [tf setTextColor: (flag ? - [NSColor controlTextColor] : - [NSColor disabledControlTextColor])]; - continue; - } - } - [controls[i] setEnabled:flag]; + // Observer a bunch of HBVideo properties to update the UI. + [self addObserver:self forKeyPath:@"video.encoder" options:NSKeyValueObservingOptionInitial context:HBVideoControllerContext]; + [self addObserver:self forKeyPath:@"video.frameRate" options:NSKeyValueObservingOptionInitial context:HBVideoControllerContext]; + [self addObserver:self forKeyPath:@"video.unparseOptions" options:NSKeyValueObservingOptionInitial context:HBVideoControllerContext]; + [self addObserver:self forKeyPath:@"video.advancedOptions" options:NSKeyValueObservingOptionInitial context:HBVideoControllerContext]; } - [self videoMatrixChanged:nil]; - [self enableEncoderOptionsWidgets:flag]; + return self; } -- (void)containerChanged:(NSNotification *)aNotification +- (void)loadView { - NSDictionary *notDict = [aNotification userInfo]; - - int videoContainer = [notDict[keyContainerTag] intValue]; - - /* lets get the tag of the currently selected item first so we might reset it later */ - int selectedVidEncoderTag = self.codec; - BOOL encoderSupported = NO; - - /* Note: we now store the video encoder int values from common.c in the tags of each popup for easy retrieval later */ - [fVidEncoderPopUp removeAllItems]; - for (const hb_encoder_t *video_encoder = hb_video_encoder_get_next(NULL); - video_encoder != NULL; - video_encoder = hb_video_encoder_get_next(video_encoder)) - { - if (video_encoder->muxers & videoContainer) - { - NSMenuItem *menuItem = [[fVidEncoderPopUp menu] addItemWithTitle:@(video_encoder->name) - action:nil - keyEquivalent:@""]; - [menuItem setTag:video_encoder->codec]; - - if (selectedVidEncoderTag == video_encoder->codec) - { - encoderSupported = YES; - } - } - } - - if (!encoderSupported) - { - self.codec = hb_video_encoder_get_default(videoContainer); - [self videoEncoderPopUpChanged:nil]; - } - else - { - self.codec = selectedVidEncoderTag; - } - - [fVidEncoderPopUp selectItemWithTag:self.codec]; - + [super loadView]; + [self switchPresetView]; } -- (void)titleChanged:(NSNotification *)aNotification +- (void)setEnabled:(BOOL)flag { - [fVidRatePopUp selectItemAtIndex: 0]; -} + _enabled = flag; -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context -{ - if (context == NULL) + if (_enabled) { - if ([keyPath isEqualToString:@"values.HBShowAdvancedTab"]) - { - [self validateAdvancedOptionsCheckBoxForEncoder:self.codec]; - } + self.labelColor = [NSColor controlTextColor]; } else { - [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; + self.labelColor = [NSColor disabledControlTextColor]; } -} -- (void)validateAdvancedOptionsCheckBoxForEncoder:(int)encoder -{ - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HBShowAdvancedTab"] && (encoder == HB_VCODEC_X264)) - { - [fX264UseAdvancedOptionsCheck setHidden:NO]; - [fDividerLine setHidden:YES]; - [fEncoderOptionsLabel setStringValue:NSLocalizedString(@"Encoder Options:", @"")]; - } - else - { - [fX264UseAdvancedOptionsCheck setHidden:YES]; - [fDividerLine setHidden:NO]; - [fEncoderOptionsLabel setStringValue:NSLocalizedString(@"Encoder Options", @"")]; - } + [self enableEncoderOptionsWidgets:flag]; } -#pragma mark - apply settings +#pragma mark - KVO -- (void)applyVideoSettingsFromQueue:(NSDictionary *)queueToApply +- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { - /* video encoder */ - self.codec = [queueToApply[@"JobVideoEncoderVcodec"] intValue]; - - /* Lets run through the following functions to get variables set there */ - [self videoEncoderPopUpChanged:nil]; - - /* advanced x264 options */ - if ([queueToApply[@"x264UseAdvancedOptions"] intValue]) - { - // we are using the advanced panel - [self.fAdvancedOptions setOptions:queueToApply[@"x264Option"]]; - // preset does not use the x264 preset system, reset the widgets - [self setPreset: nil]; - [self setTune: nil]; - [self setOptionExtra:queueToApply[@"x264Option"]]; - [self setProfile: nil]; - [self setLevel: nil]; - // enable the advanced panel and update the widgets - [fX264UseAdvancedOptionsCheck setState:NSOnState]; - [self updateEncoderOptionsWidgets:nil]; - } - else if (self.codec == HB_VCODEC_X264 || self.codec == HB_VCODEC_X265) + if (context == HBVideoControllerContext) { - // we are using the x264 preset system - [self setPreset: queueToApply[@"VideoPreset"]]; - [self setTune: queueToApply[@"VideoTune"]]; - [self setOptionExtra:queueToApply[@"VideoOptionExtra"]]; - [self setProfile: queueToApply[@"VideoProfile"]]; - [self setLevel: queueToApply[@"VideoLevel"]]; - // preset does not use the advanced panel, reset it - [self.fAdvancedOptions setOptions:@""]; - // disable the advanced panel and update the widgets - [fX264UseAdvancedOptionsCheck setState:NSOffState]; - [self updateEncoderOptionsWidgets:nil]; - } - else - { - self.lavcOptions = queueToApply[@"VideoOptionExtra"]; - } - - /* Video quality */ - self.qualityType = [queueToApply[@"VideoQualityType"] intValue] - 1; - - [fVidBitrateField setStringValue:queueToApply[@"VideoAvgBitrate"]]; - - int direction; - float minValue, maxValue, granularity; - - hb_video_quality_get_limits(self.codec, &minValue, &maxValue, &granularity, &direction); - - if (!direction) - { - [fVidQualitySlider setFloatValue:[queueToApply[@"VideoQualitySlider"] floatValue]]; - } - else - { - /* - * Since ffmpeg and x264 use an "inverted" slider (lower values - * indicate a higher quality) we invert the value on the slider - */ - [fVidQualitySlider setFloatValue:([fVidQualitySlider minValue] + - [fVidQualitySlider maxValue] - - [queueToApply[@"VideoQualitySlider"] floatValue])]; - } - - [self videoMatrixChanged:nil]; - - /* Video framerate */ - if ([queueToApply[@"VideoFramerate"] isEqualToString:@"Same as source"]) - { - /* Now set the Video Frame Rate Mode to either vfr or cfr according to the preset */ - if ([queueToApply[@"VideoFramerateMode"] isEqualToString:@"vfr"]) + if ([keyPath isEqualToString:@"video.encoder"]) { - [fFramerateMatrix selectCellAtRow:0 column:0]; // we want vfr + [self switchPresetView]; + [self setupQualitySlider]; } - else + else if ([keyPath isEqualToString:@"video.frameRate"]) { - [fFramerateMatrix selectCellAtRow:1 column:0]; // we want cfr - } - } - else - { - /* Now set the Video Frame Rate Mode to either pfr or cfr according to the preset */ - if ([queueToApply[@"VideoFramerateMode"] isEqualToString:@"pfr"]) - { - [fFramerateMatrix selectCellAtRow:0 column:0]; // we want pfr - } - else - { - [fFramerateMatrix selectCellAtRow:1 column:0]; // we want cfr - } - } - [fVidRatePopUp selectItemWithTitle:queueToApply[@"VideoFramerate"]]; - [self videoFrameRateChanged:nil]; - - /* 2 Pass Encoding */ - [fVidTwoPassCheck setState:[queueToApply[@"VideoTwoPass"] intValue]]; - [self twoPassCheckboxChanged:nil]; - /* Turbo 1st pass for 2 Pass Encoding */ - [fVidTurboPassCheck setState:[queueToApply[@"VideoTurboTwoPass"] intValue]]; -} - -- (void)applySettingsFromPreset:(NSDictionary *)preset -{ - /* map legacy encoder names via libhb */ - const char *strValue = hb_video_encoder_sanitize_name([preset[@"VideoEncoder"] UTF8String]); - - self.codec = hb_video_encoder_get_from_name(strValue); - [self videoEncoderPopUpChanged:nil]; - - if (self.codec == HB_VCODEC_X264 || self.codec == HB_VCODEC_X265) - { - if (self.codec == HB_VCODEC_X264 && - (!preset[@"x264UseAdvancedOptions"] || - [preset[@"x264UseAdvancedOptions"] intValue])) - { - /* - * x264UseAdvancedOptions is not set (legacy preset) - * or set to 1 (enabled), so we use the old advanced panel - */ - if (preset[@"x264Option"]) - { - /* we set the advanced options string here if applicable */ - [self.fAdvancedOptions setOptions:preset[@"x264Option"]]; - [self setOptionExtra:preset[@"x264Option"]]; - } - else - { - [self.fAdvancedOptions setOptions:@""]; - [self setOptionExtra:nil]; - } - /* preset does not use the x264 preset system, reset the widgets */ - [self setPreset: nil]; - [self setTune: nil]; - [self setProfile:nil]; - [self setLevel: nil]; - - /* we enable the advanced panel and update the widgets */ - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HBShowAdvancedTab"]) + // Hide and set the PFR Checkbox to OFF if we are set to Same as Source + // Depending on whether or not Same as source is selected modify the title for + // fFramerateVfrPfrCell + if (self.video.frameRate == 0) // We are Same as Source { - [fX264UseAdvancedOptionsCheck setState:NSOnState]; + [fFramerateVfrPfrCell setTitle:@"Variable Framerate"]; } else { - [fX264UseAdvancedOptionsCheck setState:NSOffState]; + [fFramerateVfrPfrCell setTitle:@"Peak Framerate (VFR)"]; } - [self updateEncoderOptionsWidgets:nil]; } - else + else if ([keyPath isEqualToString:@"video.unparseOptions"]) { - // x264UseAdvancedOptions is set to 0 (disabled), - // so we use the new preset system and - // disable the advanced panel - [self.fAdvancedOptions setOptions:@""]; - [fX264UseAdvancedOptionsCheck setState:NSOffState]; - - if (preset[@"x264Preset"]) + if (self.video.encoder == HB_VCODEC_X264) { - // Read the old x264 preset keys - [self setPreset: preset[@"x264Preset"]]; - [self setTune: preset[@"x264Tune"]]; - [self setOptionExtra:preset[@"x264OptionExtra"]]; - [self setProfile: preset[@"h264Profile"]]; - [self setLevel: preset[@"h264Level"]]; + fDisplayX264PresetsUnparseTextField.stringValue = [NSString stringWithFormat:@"x264 Unparse: %@", self.video.unparseOptions]; } else { - // Read the new preset keys (0.10) - [self setPreset: preset[@"VideoPreset"]]; - [self setTune: preset[@"VideoTune"]]; - [self setOptionExtra:preset[@"VideoOptionExtra"]]; - [self setProfile: preset[@"VideoProfile"]]; - [self setLevel: preset[@"VideoLevel"]]; + fDisplayX264PresetsUnparseTextField.stringValue = @""; } - - [self updateEncoderOptionsWidgets:nil]; } - } - else - { - if (preset[@"lavcOption"]) - { - // Load the old format - self.lavcOptions = preset[@"lavcOption"]; - } - else + else if ([keyPath isEqualToString:@"video.advancedOptions"]) { - self.lavcOptions = preset[@"VideoOptionExtra"]; - } - } - - int qualityType = [preset[@"VideoQualityType"] intValue] - 1; - /* Note since the removal of Target Size encoding, the possible values for VideoQuality type are 0 - 1. - * Therefore any preset that uses the old 2 for Constant Quality would now use 1 since there is one less index - * for the fVidQualityMatrix. It should also be noted that any preset that used the deprecated Target Size - * setting of 0 would set us to 0 or ABR since ABR is now tagged 0. Fortunately this does not affect any built-in - * presets since they all use Constant Quality or Average Bitrate.*/ - if (qualityType == -1) - { - qualityType = 0; - } - self.qualityType = qualityType; - - [fVidBitrateField setStringValue:preset[@"VideoAvgBitrate"]]; - - int direction; - float minValue, maxValue, granularity; - - hb_video_quality_get_limits(self.codec, &minValue, &maxValue, &granularity, &direction); - - if (!direction) - { - [fVidQualitySlider setFloatValue:[preset[@"VideoQualitySlider"] floatValue]]; - } - else - { - /* - * Since ffmpeg and x264 use an "inverted" slider (lower values - * indicate a higher quality) we invert the value on the slider - */ - [fVidQualitySlider setFloatValue:([fVidQualitySlider minValue] + - [fVidQualitySlider maxValue] - - [preset[@"VideoQualitySlider"] floatValue])]; - } - - [self videoMatrixChanged:nil]; - - /* Video framerate */ - if ([preset[@"VideoFramerate"] isEqualToString:@"Same as source"]) - { - /* Now set the Video Frame Rate Mode to either vfr or cfr according to the preset */ - if (!preset[@"VideoFramerateMode"] || - [preset[@"VideoFramerateMode"] isEqualToString:@"vfr"]) - { - [fFramerateMatrix selectCellAtRow:0 column:0]; // we want vfr - } - else - { - [fFramerateMatrix selectCellAtRow:1 column:0]; // we want cfr - } - } - else - { - /* Now set the Video Frame Rate Mode to either pfr or cfr according to the preset */ - if ([preset[@"VideoFramerateMode"] isEqualToString:@"pfr"] || - [preset[@"VideoFrameratePFR"] intValue] == 1) - { - [fFramerateMatrix selectCellAtRow:0 column:0]; // we want pfr - } - else - { - [fFramerateMatrix selectCellAtRow:1 column:0]; // we want cfr - } - } - /* map legacy names via libhb */ - int intValue = hb_video_framerate_get_from_name([preset[@"VideoFramerate"] UTF8String]); - [fVidRatePopUp selectItemWithTag:intValue]; - [self videoFrameRateChanged:nil]; - - /* 2 Pass Encoding */ - [fVidTwoPassCheck setState:[preset[@"VideoTwoPass"] intValue]]; - [self twoPassCheckboxChanged:nil]; - - /* Turbo 1st pass for 2 Pass Encoding */ - [fVidTurboPassCheck setState:[preset[@"VideoTurboTwoPass"] intValue]]; -} - -- (void)prepareVideoForQueueFileJob:(NSMutableDictionary *)queueFileJob -{ - queueFileJob[@"VideoEncoder"] = @(hb_video_encoder_get_name(self.codec)); - - /* x264 advanced options */ - if ([fX264UseAdvancedOptionsCheck state]) - { - // we are using the advanced panel - queueFileJob[@"x264UseAdvancedOptions"] = @1; - queueFileJob[@"x264Option"] = [self.fAdvancedOptions optionsString]; - } - else if (self.codec == HB_VCODEC_X264 || self.codec == HB_VCODEC_X265) - { - // we are using the x264/x265 preset system - queueFileJob[@"x264UseAdvancedOptions"] = @0; - queueFileJob[@"VideoPreset"] = [self preset]; - queueFileJob[@"VideoTune"] = [self tune]; - queueFileJob[@"VideoOptionExtra"] = [self optionExtra]; - queueFileJob[@"VideoProfile"] = [self profile]; - queueFileJob[@"VideoLevel"] = [self level]; - } - else - { - /* FFmpeg (lavc) Option String */ - queueFileJob[@"VideoOptionExtra"] = self.lavcOptions; - } - - queueFileJob[@"VideoQualityType"] = @(self.qualityType + 1); - queueFileJob[@"VideoAvgBitrate"] = [fVidBitrateField stringValue]; - queueFileJob[@"VideoQualitySlider"] = @([fVidQualityRFField floatValue]); - /* Framerate */ - queueFileJob[@"VideoFramerate"] = [fVidRatePopUp titleOfSelectedItem]; - /* Frame Rate Mode */ - if ([fFramerateMatrix selectedRow] == 1) // if selected we are cfr regardless of the frame rate popup - { - queueFileJob[@"VideoFramerateMode"] = @"cfr"; - } - else - { - if ([fVidRatePopUp indexOfSelectedItem] == 0) // Same as source frame rate - { - queueFileJob[@"VideoFramerateMode"] = @"vfr"; - } - else - { - queueFileJob[@"VideoFramerateMode"] = @"pfr"; - } - - } - - /* 2 Pass Encoding */ - queueFileJob[@"VideoTwoPass"] = @([fVidTwoPassCheck state]); - /* Turbo 2 pass Encoding fVidTurboPassCheck*/ - queueFileJob[@"VideoTurboTwoPass"] = @([fVidTurboPassCheck state]); - - /* Video encoder */ - queueFileJob[@"JobVideoEncoderVcodec"] = @(self.codec); - - /* Framerate */ - queueFileJob[@"JobIndexVideoFramerate"] = @([[fVidRatePopUp selectedItem] tag]); -} - -- (void)prepareVideoForJobPreview:(hb_job_t *)job andTitle:(hb_title_t *)title -{ - job->vcodec = self.codec; - job->fastfirstpass = 0; - - job->chapter_markers = 0; - - if (job->vcodec == HB_VCODEC_X264) - { - /* advanced x264 options */ - NSString *tmpString; - // translate zero-length strings to NULL for libhb - const char *encoder_preset = NULL; - const char *encoder_tune = NULL; - const char *encoder_options = NULL; - const char *encoder_profile = NULL; - const char *encoder_level = NULL; - if ([fX264UseAdvancedOptionsCheck state]) - { - // we are using the advanced panel - if ([(tmpString = [self.fAdvancedOptions optionsString]) length]) - { - encoder_options = [tmpString UTF8String]; - } - } - else - { - // we are using the x264 preset system - if ([(tmpString = [self tune]) length]) + if (self.video.advancedOptions) { - encoder_tune = [tmpString UTF8String]; + // Do not enable the advanced panel it isn't visible. + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HBShowAdvancedTab"]) + { + self.advancedController.videoSettings = self.video.advancedOptions ? self.video : nil; + } + else + { + self.video.advancedOptions = NO; + } } - if ([(tmpString = [self optionExtra]) length]) - { - encoder_options = [tmpString UTF8String]; - } - if ([(tmpString = [self profile]) length]) - { - encoder_profile = [tmpString UTF8String]; - } - if ([(tmpString = [self level]) length]) - { - encoder_level = [tmpString UTF8String]; - } - encoder_preset = [[self preset] UTF8String]; - } - hb_job_set_encoder_preset (job, encoder_preset); - hb_job_set_encoder_tune (job, encoder_tune); - hb_job_set_encoder_options(job, encoder_options); - hb_job_set_encoder_profile(job, encoder_profile); - hb_job_set_encoder_level (job, encoder_level); - } - else if (job->vcodec & HB_VCODEC_FFMPEG_MASK) - { - hb_job_set_encoder_options(job, [self.lavcOptions UTF8String]); - } + // enable/disable, populate and update the various widgets + [self enableEncoderOptionsWidgets:self.enabled]; - /* Video settings */ - int fps_mode, fps_num, fps_den; - if( [fVidRatePopUp indexOfSelectedItem] > 0 ) - { - /* a specific framerate has been chosen */ - fps_num = 27000000; - fps_den = (int)[[fVidRatePopUp selectedItem] tag]; - if ([fFramerateMatrix selectedRow] == 1) + } else if ([keyPath isEqualToString:@"values.HBShowAdvancedTab"]) { - // CFR - fps_mode = 1; + [self toggleAdvancedOptionsCheckBoxForEncoder:self.video.encoder]; } - else + else if ([keyPath isEqualToString:@"values.x264CqSliderFractional"]) { - // PFR - fps_mode = 2; + [self setupQualitySlider]; } } else { - /* same as source */ - fps_num = title->vrate.num; - fps_den = title->vrate.den; - if ([fFramerateMatrix selectedRow] == 1) - { - // CFR - fps_mode = 1; - } - else - { - // VFR - fps_mode = 0; - } - } - - switch (self.qualityType) - { - case 0: - /* ABR */ - job->vquality = -1.0; - job->vbitrate = [fVidBitrateField intValue]; - break; - case 1: - /* Constant Quality */ - job->vquality = [fVidQualityRFField floatValue]; - job->vbitrate = 0; - break; - } - - /* Add framerate shaping filter */ - hb_filter_object_t *filter = hb_filter_init(HB_FILTER_VFR); - hb_add_filter(job, filter, [[NSString stringWithFormat:@"%d:%d:%d", - fps_mode, fps_num, fps_den] UTF8String]); -} - -- (void)prepareVideoForPreset:(NSMutableDictionary *)preset -{ - preset[@"VideoEncoder"] = @(hb_video_encoder_get_name(self.codec)); - - /* x264 Options, this will either be advanced panel or the video tabs x264 presets panel with modded option string */ - if ([fX264UseAdvancedOptionsCheck state] == NSOnState) - { - /* use the old advanced panel */ - preset[@"x264UseAdvancedOptions"] = @1; - preset[@"x264Option"] = [self.fAdvancedOptions optionsString]; - } - else if (self.codec == HB_VCODEC_X264 || self.codec == HB_VCODEC_X265) - { - /* use the x264 preset system */ - preset[@"x264UseAdvancedOptions"] = @0; - preset[@"VideoPreset"] = [self preset]; - preset[@"VideoTune"] = [self tune]; - preset[@"VideoOptionExtra"] = [self optionExtra]; - preset[@"VideoProfile"] = [self profile]; - preset[@"VideoLevel"] = [self level]; - - /* - * bonus: set the unparsed options to make the preset compatible - * with old HB versions - */ - if (fX264PresetsUnparsedUTF8String != NULL) - { - preset[@"x264Option"] = @(fX264PresetsUnparsedUTF8String); - } - else - { - preset[@"x264Option"] = @""; - } - } - else - { - /* FFmpeg (lavc) Option String */ - preset[@"VideoOptionExtra"] = self.lavcOptions; - } - - /* though there are actually only 0 - 1 types available in the ui we need to map to the old 0 - 2 - * set of indexes from when we had 0 == Target , 1 == Abr and 2 == Constant Quality for presets - * to take care of any legacy presets. */ - preset[@"VideoQualityType"] = @(self.qualityType +1); - preset[@"VideoAvgBitrate"] = [fVidBitrateField stringValue]; - preset[@"VideoQualitySlider"] = @([fVidQualityRFField floatValue]); - - /* Video framerate and framerate mode */ - if ([fFramerateMatrix selectedRow] == 1) - { - preset[@"VideoFramerateMode"] = @"cfr"; - } - if ([fVidRatePopUp indexOfSelectedItem] == 0) // Same as source is selected - { - preset[@"VideoFramerate"] = @"Same as source"; - - if ([fFramerateMatrix selectedRow] == 0) - { - preset[@"VideoFramerateMode"] = @"vfr"; - } - } - else // translate the rate (selected item's tag) to the official libhb name - { - preset[@"VideoFramerate"] = [NSString stringWithFormat:@"%s", - hb_video_framerate_get_name((int)[[fVidRatePopUp selectedItem] tag])]; - - if ([fFramerateMatrix selectedRow] == 0) - { - preset[@"VideoFramerateMode"] = @"pfr"; - } + [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; } - - - - /* 2 Pass Encoding */ - preset[@"VideoTwoPass"] = @([fVidTwoPassCheck state]); - /* Turbo 2 pass Encoding fVidTurboPassCheck*/ - preset[@"VideoTurboTwoPass"] = @([fVidTurboPassCheck state]); -} - -#pragma mark - Video - -- (IBAction) videoEncoderPopUpChanged: (id) sender -{ - [self switchPresetViewForEncoder:self.codec]; - - [[NSNotificationCenter defaultCenter] postNotificationName:HBVideoEncoderChangedNotification object:self]; - - [self setupQualitySlider]; - [self twoPassCheckboxChanged: sender]; } -- (IBAction) twoPassCheckboxChanged: (id) sender +- (void)containerChanged:(NSNotification *)aNotification { - /* check to see if x264 is chosen */ - if(self.codec == HB_VCODEC_X264) - { - if( [fVidTwoPassCheck state] == NSOnState) - { - [fVidTurboPassCheck setHidden: NO]; - } - else - { - [fVidTurboPassCheck setHidden: YES]; - [fVidTurboPassCheck setState: NSOffState]; - } - /* Make sure Two Pass is checked if Turbo is checked */ - if( [fVidTurboPassCheck state] == NSOnState) - { - [fVidTwoPassCheck setState: NSOnState]; - } - } - else - { - [fVidTurboPassCheck setHidden: YES]; - [fVidTurboPassCheck setState: NSOffState]; - } - - /* We call method method to change UI to reflect whether a preset is used or not*/ - [self.fHBController customSettingUsed: sender]; + self.video.container = [[aNotification userInfo][keyContainerTag] intValue]; } -- (IBAction ) videoFrameRateChanged: (id) sender -{ - /* if no valid framerate is selected, use "Same as source" */ - if ([fVidRatePopUp selectedItem] == nil) - { - [fVidRatePopUp selectItemAtIndex:0]; - } +#pragma mark - Interface setup - /* Hide and set the PFR Checkbox to OFF if we are set to Same as Source */ - /* Depending on whether or not Same as source is selected modify the title for - * fFramerateVfrPfrCell*/ - if ([fVidRatePopUp indexOfSelectedItem] == 0) // We are Same as Source - { - [fFramerateVfrPfrCell setTitle:@"Variable Framerate"]; - } - else - { - [fFramerateVfrPfrCell setTitle:@"Peak Framerate (VFR)"]; - - - } - - /* We call method method to change UI to reflect whether a preset is used or not*/ - [self.fHBController customSettingUsed: sender]; -} - -- (IBAction) videoMatrixChanged: (id) sender; -{ - /* We use the selectedCell: tag of the fVidQualityMatrix instead of selectedRow - * so that the order of the video controls can be switched around. - * Constant quality is 1 and Average bitrate is 0 for reference. */ - bool bitrate, quality; - bitrate = quality = false; - if( [fVidQualityMatrix isEnabled] ) - { - switch(self.qualityType) - { - case 0: - bitrate = true; - break; - case 1: - quality = true; - break; - } - } - - [fVidBitrateField setEnabled: bitrate]; - [fVidQualitySlider setEnabled: quality]; - [fVidQualityRFField setEnabled: quality]; - [fVidQualityRFLabel setEnabled: quality]; - [fVidTwoPassCheck setEnabled: !quality && - [fVidQualityMatrix isEnabled]]; - if( quality ) - { - [fVidTwoPassCheck setState: NSOffState]; - [fVidTurboPassCheck setHidden: YES]; - [fVidTurboPassCheck setState: NSOffState]; - } - - [self qualitySliderChanged: sender]; - [self.fHBController customSettingUsed: sender]; -} - -/* Use this method to setup the quality slider for cq/rf values depending on +/* + * Use this method to setup the quality slider for cq/rf values depending on * the video encoder selected. */ -- (void) setupQualitySlider +- (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)); - [fVidQualityRFLabel setStringValue:[NSString stringWithFormat:@"%s", - hb_video_quality_get_name(self.codec)]]; int direction; float minValue, maxValue, granularity; - hb_video_quality_get_limits([self codec], + hb_video_quality_get_limits(self.video.encoder, &minValue, &maxValue, &granularity, &direction); if (granularity < 1.0f) { - /* - * Encoders that allow fractional CQ values often have a low granularity - * which makes the slider hard to use, so use a value from preferences. - */ + // Encoders that allow fractional CQ values often have a low granularity + // which makes the slider hard to use, so use a value from preferences. granularity = [[NSUserDefaults standardUserDefaults] floatForKey:@"x264CqSliderFractional"]; } - [fVidQualitySlider setMinValue:minValue]; - [fVidQualitySlider setMaxValue:maxValue]; [fVidQualitySlider setNumberOfTickMarks:((maxValue - minValue) * (1.0f / granularity)) + 1]; - /* check to see if we have changed slider scales */ - if (previousMaxValue != maxValue) - { - /* - * if so, convert the old setting to the new scale as close as possible - * based on percentages - */ - [fVidQualitySlider setFloatValue:((maxValue - minValue + 1.) * - (previousPercentOfSliderScale))]; - } - - [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. - */ - int direction; - float minValue, maxValue, granularity; - float inverseValue = ([fVidQualitySlider minValue] + - [fVidQualitySlider maxValue] - - [fVidQualitySlider floatValue]); - - hb_video_quality_get_limits(self.codec, &minValue, &maxValue, &granularity, &direction); - - if (!direction) - { - [fVidQualityRFField setStringValue:[NSString stringWithFormat:@"%.2f", - [fVidQualitySlider floatValue]]]; - } - else - { - [fVidQualityRFField setStringValue:[NSString stringWithFormat:@"%.2f", - inverseValue]]; - } - /* Show a warning if x264 and rf 0 which is lossless */ - if (self.codec == HB_VCODEC_X264 && inverseValue == 0.0) - { - [fVidQualityRFField setStringValue:[NSString stringWithFormat:@"%.2f (Warning: Lossless)", - inverseValue]]; - } - - [self.fHBController customSettingUsed: sender]; -} - -- (IBAction)bitrateFieldChanged:(id)sender -{ - [self.fHBController customSettingUsed: sender]; + // Replace the slider transformer with a new one, + // configured with the new max/min/direction values. + [fVidQualitySlider unbind:@"value"]; + HBQualityTransformer *transformer = [[[HBQualityTransformer alloc] initWithReversedDirection:direction min:minValue max:maxValue] autorelease]; + [fVidQualitySlider bind:@"value" toObject:self withKeyPath:@"self.video.quality" options:@{NSValueTransformerBindingOption: transformer}]; } #pragma mark - Video x264/x265 Presets -- (void)switchPresetViewForEncoder:(int)encoder +/** + * Shows/hides the right preset view for the current video encoder. + */ +- (void)switchPresetView { - [self.fAdvancedOptions setHidden:YES]; - - if (encoder == HB_VCODEC_X264 || encoder == HB_VCODEC_X265) - { - [fPresetsBox setContentView:fPresetView]; - [self setupPresetsWidgetsForEncoder:encoder]; + self.advancedController.hidden = YES; - if (encoder == HB_VCODEC_X264) - { - [self.fAdvancedOptions setHidden:NO]; - } - } - else if (encoder & HB_VCODEC_FFMPEG_MASK) + if (self.video.encoder == HB_VCODEC_X264 || self.video.encoder == HB_VCODEC_X265) { - [fPresetsBox setContentView:fSimplePresetView]; - } - else - { - [fPresetsBox setContentView:nil]; - } -} + [self toggleAdvancedOptionsCheckBoxForEncoder:self.video.encoder]; -- (void) setupPresetsWidgetsForEncoder:(int)encoder -{ - [self validateAdvancedOptionsCheckBoxForEncoder:(int)encoder]; + fPresetsBox.contentView = fPresetView; + [self setupPresetsSlider]; - if (encoder == HB_VCODEC_X264) - { - [fFastDecodeCheck setHidden:NO]; - } - else - { - [fFastDecodeCheck setHidden:YES]; - } - - NSUInteger i; - // populate the preset system widgets via hb_video_encoder_get_* functions. - // store preset names - const char* const *presets = hb_video_encoder_get_presets(encoder); - NSMutableArray *tmp_array = [[NSMutableArray alloc] init]; - for (i = 0; presets[i] != NULL; i++) - { - [tmp_array addObject:@(presets[i])]; - if (!strcasecmp(presets[i], "medium")) - { - fMediumPresetIndex = i; - } - } - [fPresetNames autorelease]; - fPresetNames = [[NSArray alloc] initWithArray:tmp_array]; - [tmp_array release]; - // setup the preset slider - [fPresetsSlider setMinValue:0]; - [fPresetsSlider setMaxValue:[fPresetNames count]-1]; - [fPresetsSlider setNumberOfTickMarks:[fPresetNames count]]; - [fPresetsSlider setIntegerValue:fMediumPresetIndex]; - [fPresetsSlider setTickMarkPosition:NSTickMarkAbove]; - [fPresetsSlider setAllowsTickMarkValuesOnly:YES]; - [self presetsSliderChanged: nil]; - // setup the tune popup - [fTunePopUp removeAllItems]; - [fTunePopUp addItemWithTitle: @"none"]; - const char* const *tunes = hb_video_encoder_get_tunes(encoder); - for (int i = 0; tunes[i] != NULL; i++) - { - // we filter out "fastdecode" as we have a dedicated checkbox for it - if (strcasecmp(tunes[i], "fastdecode") != 0) + if (self.video.encoder == HB_VCODEC_X264) { - [fTunePopUp addItemWithTitle: @(tunes[i])]; + self.advancedController.hidden = NO; } } - // the fastdecode checkbox is off by default - [fFastDecodeCheck setState: NSOffState]; - // setup the h264 profile popup - [fProfilePopUp removeAllItems]; - const char* const *profiles = hb_video_encoder_get_profiles(encoder); - for (int i = 0; profiles[i] != NULL; i++) + else if (self.video.encoder & HB_VCODEC_FFMPEG_MASK) { - [fProfilePopUp addItemWithTitle: @(profiles[i])]; + fPresetsBox.contentView = fSimplePresetView; } - // setup the level popup - [fLevelPopUp removeAllItems]; - const char* const *levels = hb_video_encoder_get_levels(encoder); - for (int i = 0; levels != NULL && levels[i] != NULL; i++) - { - [fLevelPopUp addItemWithTitle: @(levels[i])]; - } - if ([[fLevelPopUp itemArray] count] == 0) + else { - [fLevelPopUp addItemWithTitle:@"auto"]; + fPresetsBox.contentView = nil; } - // clear the additional x264 options - [fDisplayPresetsAdditonalOptionsTextField setStringValue:@""]; } -- (void) enableEncoderOptionsWidgets: (BOOL) enable +/** + * Enables/disables the advanced panel and the preset panel. + */ +- (void)enableEncoderOptionsWidgets:(BOOL)enable { - NSControl *controls[] = - { - fPresetsSlider, fPresetSliderLabel, fPresetSelectedTextField, - fTunePopUp, fTunePopUpLabel, fFastDecodeCheck, - fDisplayPresetsAdditonalOptionsTextField, fDisplayPresetsAdditonalOptionsLabel, - fProfilePopUp, fProfilePopUpLabel, - fLevelPopUp, fLevelPopUpLabel, - fDisplayX264PresetsUnparseTextField, - }; - // check whether the x264 preset system and the advanced panel should be enabled - BOOL enable_x264_controls = (enable && [fX264UseAdvancedOptionsCheck state] == NSOffState); - BOOL enable_advanced_panel = (enable && [fX264UseAdvancedOptionsCheck state] == NSOnState); + BOOL enable_x264_controls = (enable && !self.video.advancedOptions); + BOOL enable_advanced_panel = (enable && self.video.advancedOptions); // enable/disable the checkbox and advanced panel - [fX264UseAdvancedOptionsCheck setEnabled:enable]; - [self.fAdvancedOptions setUIEnabled:enable_advanced_panel]; - - // enable/disable the x264 preset system controls - for (unsigned i = 0; i < (sizeof(controls) / sizeof(NSControl*)); i++) - { - if ([[controls[i] className] isEqualToString: @"NSTextField"]) - { - NSTextField *tf = (NSTextField*)controls[i]; - if (![tf isBezeled]) - { - [tf setTextColor:(enable_x264_controls ? - [NSColor controlTextColor] : - [NSColor disabledControlTextColor])]; - continue; - } - } - [controls[i] setEnabled:enable_x264_controls]; - } -} - -- (IBAction) updateEncoderOptionsWidgets: (id) sender -{ - if ([fX264UseAdvancedOptionsCheck state] == NSOnState) - { - /* - * we are using or switching to the advanced panel - * - * if triggered by selectPreset or applyQueueSettingToMainWindow, - * the options string will have been specified explicitly - leave it. - * - * if triggered by the advanced panel on/off checkbox, set the options - * string to the value of the unparsed x264 preset system string. - */ - if (sender == fX264UseAdvancedOptionsCheck) - { - if (fX264PresetsUnparsedUTF8String != NULL) - { - [self.fAdvancedOptions setOptions:@(fX264PresetsUnparsedUTF8String)]; - } - else - { - [self.fAdvancedOptions setOptions:@""]; - } - } - } - // enable/disable, populate and update the various widgets - [self enableEncoderOptionsWidgets: YES]; - [self presetsSliderChanged:nil]; - [self.fAdvancedOptions X264AdvancedOptionsSet: nil]; + self.presetViewEnabled = enable_x264_controls; + self.advancedController.enabled = enable_advanced_panel; } -#pragma mark - Lavc presets - -- (void) setLavcOptions: (NSString *)optionExtra -{ - if (!optionExtra) - { - [fLavcOptionsTextField setStringValue:@""]; - return; - } - [fLavcOptionsTextField setStringValue:optionExtra]; -} - -- (NSString *) lavcOptions -{ - return [fLavcOptionsTextField stringValue]; -} - -#pragma mark - -#pragma mark x264/x265 preset system - -- (NSString *) preset -{ - return (NSString *)fPresetNames[[fPresetsSlider intValue]]; -} - -- (NSString *) tune -{ - NSString *tune = @""; - if ([fTunePopUp indexOfSelectedItem]) - { - tune = [tune stringByAppendingString: - [fTunePopUp titleOfSelectedItem]]; - } - if ([fFastDecodeCheck state]) - { - if ([tune length]) - { - tune = [tune stringByAppendingString: @","]; - } - tune = [tune stringByAppendingString: @"fastdecode"]; - } - return tune; -} - -- (NSString *) optionExtra -{ - return [fDisplayPresetsAdditonalOptionsTextField stringValue]; -} - -- (NSString *) profile -{ - if ([fProfilePopUp indexOfSelectedItem]) - { - return [fProfilePopUp titleOfSelectedItem]; - } - return @""; -} - -- (NSString *) level -{ - if ([fLevelPopUp indexOfSelectedItem]) - { - return [fLevelPopUp titleOfSelectedItem]; - } - return @""; -} - -- (void) setPreset: (NSString *)preset -{ - if (preset) - { - for (NSString *name in fPresetNames) - { - if ([name isEqualToString:preset]) - { - [fPresetsSlider setIntegerValue: - [fPresetNames indexOfObject:name]]; - return; - } - } - } - [fPresetsSlider setIntegerValue:fMediumPresetIndex]; -} - -- (void) setTune: (NSString *)tune -{ - if (!tune) - { - [fTunePopUp selectItemAtIndex:0]; - [fFastDecodeCheck setState:NSOffState]; - return; - } - // handle fastdecode - if ([tune rangeOfString:@"fastdecode"].location != NSNotFound) - { - [fFastDecodeCheck setState:NSOnState]; - } - else - { - [fFastDecodeCheck setState:NSOffState]; - } - // filter out fastdecode - tune = [tune stringByReplacingOccurrencesOfString:@"," - withString:@""]; - tune = [tune stringByReplacingOccurrencesOfString:@"fastdecode" - withString:@""]; - // set the tune - [fTunePopUp selectItemWithTitle:tune]; - // fallback - if ([fTunePopUp indexOfSelectedItem] == -1) - { - [fTunePopUp selectItemAtIndex:0]; - } -} - -- (void) setOptionExtra: (NSString *)optionExtra -{ - if (!optionExtra) - { - [fDisplayPresetsAdditonalOptionsTextField setStringValue:@""]; - return; - } - [fDisplayPresetsAdditonalOptionsTextField setStringValue:optionExtra]; -} - -- (void) setProfile: (NSString *)profile -{ - if (!profile) - { - [fProfilePopUp selectItemAtIndex:0]; - return; - } - // set the profile - [fProfilePopUp selectItemWithTitle:profile]; - // fallback - if ([fProfilePopUp indexOfSelectedItem] == -1) - { - [fProfilePopUp selectItemAtIndex:0]; - } -} - -- (void) setLevel: (NSString *)level -{ - if (!level) - { - [fLevelPopUp selectItemAtIndex:0]; - return; - } - // set the level - [fLevelPopUp selectItemWithTitle:level]; - // fallback - if ([fLevelPopUp indexOfSelectedItem] == -1) - { - [fLevelPopUp selectItemAtIndex:0]; - } -} - -- (IBAction) presetsSliderChanged: (id) sender +/** + * Shows/Hides the advanced options checkbox + * + * @param encoder the current encoder + */ +- (void)toggleAdvancedOptionsCheckBoxForEncoder:(int)encoder { - // we assume the preset names and slider were setup properly - [fPresetSelectedTextField setStringValue: [self preset]]; - - if (self.codec == HB_VCODEC_X264) + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"HBShowAdvancedTab"] && (encoder == HB_VCODEC_X264)) { - [self x264PresetsChangedDisplayExpandedOptions:nil]; - [fDisplayX264PresetsUnparseTextField setHidden:NO]; + fX264UseAdvancedOptionsCheck.hidden = NO; + fDividerLine.hidden = YES; + fEncoderOptionsLabel.stringValue = NSLocalizedString(@"Encoder Options:", @""); } else { - [fDisplayX264PresetsUnparseTextField setHidden:YES]; + fX264UseAdvancedOptionsCheck.hidden =YES; + fDividerLine.hidden = NO; + fEncoderOptionsLabel.stringValue = NSLocalizedString(@"Encoder Options", @""); + self.video.advancedOptions = NO; } - } -/* This is called everytime a x264 widget in the video tab is changed to - display the expanded options in a text field via outlet fDisplayX264PresetsUnparseTextField +/** + * Setup the presets slider with the right + * number of ticks. */ -- (IBAction) x264PresetsChangedDisplayExpandedOptions: (id) sender - +- (void)setupPresetsSlider { - if (self.codec != HB_VCODEC_X264) - { - return; - } + // Bind the slider value to a custom value transformer, + // done here because it can't be done in IB. + [fPresetsSlider unbind:@"value"]; + HBPresetsTransformer *transformer = [[[HBPresetsTransformer alloc] initWithEncoder:self.video.encoder] autorelease]; + [fPresetsSlider bind:@"value" toObject:self withKeyPath:@"self.video.preset" options:@{NSValueTransformerBindingOption: transformer}]; - /* API reference: - * - * char * hb_x264_param_unparse(const char *x264_preset, - * const char *x264_tune, - * const char *x264_encopts, - * const char *h264_profile, - * const char *h264_level, - * int width, int height); - */ - NSString *tmpString; - const char *x264_preset = [[self preset] UTF8String]; - const char *x264_tune = NULL; - const char *advanced_opts = NULL; - const char *h264_profile = NULL; - const char *h264_level = NULL; - int width = 1; - int height = 1; - // prepare the tune, advanced options, profile and level - if ([(tmpString = [self tune]) length]) - { - x264_tune = [tmpString UTF8String]; - } - if ([(tmpString = [self optionExtra]) length]) - { - advanced_opts = [tmpString UTF8String]; - } - if ([(tmpString = [self profile]) length]) - { - h264_profile = [tmpString UTF8String]; - } - if ([(tmpString = [self level]) length]) - { - h264_level = [tmpString UTF8String]; - } - // width and height must be non-zero - if (_fPresetsWidthForUnparse && _fPresetsHeightForUnparse) - { - width = (int)_fPresetsWidthForUnparse; - height = (int)_fPresetsHeightForUnparse; - } - // free the previous unparsed string - free(fX264PresetsUnparsedUTF8String); - // now, unparse - fX264PresetsUnparsedUTF8String = hb_x264_param_unparse(x264_preset, - x264_tune, - advanced_opts, - h264_profile, - h264_level, - width, height); - // update the text field - if (fX264PresetsUnparsedUTF8String != NULL) - { - [fDisplayX264PresetsUnparseTextField setStringValue: - [NSString stringWithFormat:@"x264 Unparse: %s", - fX264PresetsUnparsedUTF8String]]; - } - else - { - [fDisplayX264PresetsUnparseTextField setStringValue:@"x264 Unparse:"]; - } + // setup the preset slider + [fPresetsSlider setMaxValue:self.video.presets.count - 1]; + [fPresetsSlider setNumberOfTickMarks:self.video.presets.count]; } + @end diff --git a/macosx/HBViewValidation.h b/macosx/HBViewValidation.h index 779208cd4..205c748fb 100644 --- a/macosx/HBViewValidation.h +++ b/macosx/HBViewValidation.h @@ -10,6 +10,6 @@ @protocol HBViewValidation <NSObject> -- (void)setUIEnabled:(BOOL)flag; +@property (nonatomic, readwrite, getter=isEnabled) BOOL enabled; @end |