diff options
author | Damiano Galassi <[email protected]> | 2016-03-11 13:41:32 +0100 |
---|---|---|
committer | John Stebbins <[email protected]> | 2016-03-12 09:04:01 -0700 |
commit | 44171658dac08810acd38f5691dede164dff508f (patch) | |
tree | f09b5195fb706d589d9e89643a43e12b6adba24f | |
parent | 9462d299389417bb00d5fdd07e0b5fc9e4811ec9 (diff) |
MacGui: add interlace detection filter.
-rw-r--r-- | macosx/English.lproj/HBPictureViewController.xib | 77 | ||||
-rw-r--r-- | macosx/HBFilters+UIAdditions.h | 9 | ||||
-rw-r--r-- | macosx/HBFilters+UIAdditions.m | 34 | ||||
-rw-r--r-- | macosx/HBFilters.h | 3 | ||||
-rw-r--r-- | macosx/HBFilters.m | 61 | ||||
-rw-r--r-- | macosx/HBJob+HBJobConversion.m | 13 |
6 files changed, 193 insertions, 4 deletions
diff --git a/macosx/English.lproj/HBPictureViewController.xib b/macosx/English.lproj/HBPictureViewController.xib index 1f6315a0d..9d12a5738 100644 --- a/macosx/English.lproj/HBPictureViewController.xib +++ b/macosx/English.lproj/HBPictureViewController.xib @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="15E27e" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none"> +<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10115" systemVersion="15E61b" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none"> <dependencies> <deployment identifier="macosx"/> <development version="6300" identifier="xcode"/> - <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/> + <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10115"/> </dependencies> <objects> <customObject id="-2" userLabel="File's Owner" customClass="HBPictureViewController"> @@ -1151,6 +1151,79 @@ Frames that are not interlaced will suffer some quality degradation.</string> <binding destination="-2" name="value" keyPath="self.filters.flip" id="xdh-96-5s5"/> </connections> </button> + <textField verticalHuggingPriority="750" id="Mg1-Yq-F9S"> + <rect key="frame" x="200" y="52" width="108" height="14"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> + <textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Interlace Detection:" id="xHD-vC-ePQ"> + <font key="font" metaFont="smallSystem"/> + <color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/> + <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> + </textFieldCell> + <connections> + <binding destination="-2" name="textColor" keyPath="self.labelColor" id="eKb-Bh-OkE"/> + </connections> + </textField> + <textField verticalHuggingPriority="750" id="RZE-gp-SB7"> + <rect key="frame" x="237" y="26" width="71" height="14"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> + <textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Custom:" id="Da7-pY-5vu"> + <font key="font" metaFont="smallSystem"/> + <color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/> + <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> + </textFieldCell> + <connections> + <binding destination="-2" name="hidden" keyPath="self.filters.customCombDetectionSelected" id="x5q-SE-Xds"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> + <binding destination="-2" name="textColor" keyPath="self.labelColor" id="s78-d3-GZY"/> + </connections> + </textField> + <popUpButton verticalHuggingPriority="750" id="IQG-Nn-HTb"> + <rect key="frame" x="311" y="47" width="114" height="22"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> + <string key="toolTip">This filter detects interlaced frames. +If a deinterlace filter is enabled, only frames that this filter finds to be interlaced will be deinterlaced.</string> + <popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" controlSize="small" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" inset="2" arrowPosition="arrowAtCenter" preferredEdge="maxY" id="nfb-CJ-1J3"> + <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> + <font key="font" metaFont="smallSystem"/> + <menu key="menu" title="OtherViews" id="Qz4-EY-GFO"/> + </popUpButtonCell> + <connections> + <accessibilityConnection property="title" destination="Mg1-Yq-F9S" id="nhI-oN-u5h"/> + <binding destination="-2" name="contentValues" keyPath="self.filters.combDetectionSettings" id="lKn-uj-nGl"/> + <binding destination="-2" name="selectedValue" keyPath="self.filters.combDetection" previousBinding="lKn-uj-nGl" id="XIZ-dC-cLu"> + <dictionary key="options"> + <string key="NSValueTransformerName">HBCombDetectionTransformer</string> + </dictionary> + </binding> + <binding destination="-2" name="enabled" keyPath="self.filters" id="mJ8-zq-tQ8"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSIsNotNil</string> + </dictionary> + </binding> + <outlet property="nextKeyView" destination="rPg-F2-gtl" id="46r-ZD-dTe"/> + </connections> + </popUpButton> + <textField verticalHuggingPriority="750" id="rPg-F2-gtl"> + <rect key="frame" x="314" y="23" width="108" height="19"/> + <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/> + <textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="4YG-Q6-1tM"> + <font key="font" metaFont="smallSystem"/> + <color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/> + <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> + </textFieldCell> + <accessibility description="Custom interlace detection settings."/> + <connections> + <binding destination="-2" name="hidden" keyPath="self.filters.customCombDetectionSelected" id="avq-Zl-5gA"> + <dictionary key="options"> + <string key="NSValueTransformerName">NSNegateBoolean</string> + </dictionary> + </binding> + <binding destination="-2" name="value" keyPath="self.filters.combDetectionCustomString" id="pTK-PZ-3ZE"/> + </connections> + </textField> </subviews> <point key="canvasLocation" x="403.5" y="86.5"/> </customView> diff --git a/macosx/HBFilters+UIAdditions.h b/macosx/HBFilters+UIAdditions.h index 71ca839bc..6600e7930 100644 --- a/macosx/HBFilters+UIAdditions.h +++ b/macosx/HBFilters+UIAdditions.h @@ -14,6 +14,8 @@ */ + (NSDictionary *)detelecinePresetsDict; ++ (NSDictionary *)combDetectionPresetsDict; + + (NSDictionary *)deinterlaceTypesDict; + (NSDictionary *)decombPresetsDict; + (NSDictionary *)deinterlacePresetsDict; @@ -24,6 +26,8 @@ - (BOOL)customDetelecineSelected; +@property (nonatomic, readonly) BOOL customCombDetectionSelected; + - (BOOL)deinterlaceEnabled; - (BOOL)customDeinterlaceSelected; @@ -35,6 +39,8 @@ @property (nonatomic, readonly) NSArray *detelecineSettings; +@property (nonatomic, readonly) NSArray *combDetectionSettings; + @property (nonatomic, readonly) NSArray *deinterlaceTypes; @property (nonatomic, readonly) NSArray *deinterlacePresets; @@ -61,6 +67,9 @@ @interface HBDetelecineTransformer : HBGenericDictionaryTransformer @end +@interface HBCombDetectionTransformer : HBGenericDictionaryTransformer +@end + @interface HBDeinterlaceTransformer : HBGenericDictionaryTransformer @end diff --git a/macosx/HBFilters+UIAdditions.m b/macosx/HBFilters+UIAdditions.m index 62fcda372..8141881cc 100644 --- a/macosx/HBFilters+UIAdditions.m +++ b/macosx/HBFilters+UIAdditions.m @@ -79,6 +79,18 @@ static NSDictionary * filterParamsToNamesDict(hb_filter_param_t * (f)(int), int @end +@implementation HBCombDetectionTransformer + +- (instancetype)init +{ + if (self = [super init]) + self.dict = [HBFilters combDetectionPresetsDict]; + + return self; +} + +@end + @implementation HBDeinterlaceTransformer - (instancetype)init @@ -167,6 +179,8 @@ static NSDictionary * filterParamsToNamesDict(hb_filter_param_t * (f)(int), int static NSDictionary *detelecinePresetsDict = nil; +static NSDictionary *combDetectionPresetsDict = nil; + static NSDictionary *deinterlaceTypesDict = nil; static NSDictionary *decombPresetsDict = nil; static NSDictionary *deinterlacePresetsDict = nil; @@ -188,6 +202,16 @@ static NSDictionary *denoiseTypesDict = nil; return detelecinePresetsDict; } ++ (NSDictionary *)combDetectionPresetsDict +{ + if (!combDetectionPresetsDict) + { + combDetectionPresetsDict = filterParamsToNamesDict(hb_filter_param_get_presets, HB_FILTER_COMB_DETECT); + } + return combDetectionPresetsDict; +} + + + (NSDictionary *)deinterlaceTypesDict { if (!deinterlaceTypesDict) @@ -256,6 +280,11 @@ static NSDictionary *denoiseTypesDict = nil; return filterParamsToNamesArray(hb_filter_param_get_presets, HB_FILTER_DETELECINE); } +- (NSArray *)combDetectionSettings +{ + return filterParamsToNamesArray(hb_filter_param_get_presets, HB_FILTER_COMB_DETECT); +} + - (NSArray *)deinterlacePresets { if ([self.deinterlace isEqualToString:@"deinterlace"]) @@ -288,6 +317,11 @@ static NSDictionary *denoiseTypesDict = nil; return [self.detelecine isEqualToString:@"custom"] ? YES : NO; } +- (BOOL)customCombDetectionSelected +{ + return [self.combDetection isEqualToString:@"custom"] ? YES : NO; +} + - (BOOL)customDeinterlaceSelected { return [self.deinterlacePreset isEqualToString:@"custom"] && [self deinterlaceEnabled]; diff --git a/macosx/HBFilters.h b/macosx/HBFilters.h index e173e3630..37416697d 100644 --- a/macosx/HBFilters.h +++ b/macosx/HBFilters.h @@ -19,6 +19,9 @@ extern NSString * const HBFiltersChangedNotification; @property (nonatomic, readwrite, copy) NSString *detelecine; @property (nonatomic, readwrite, copy) NSString *detelecineCustomString; +@property (nonatomic, readwrite, copy) NSString *combDetection; +@property (nonatomic, readwrite, copy) NSString *combDetectionCustomString; + @property (nonatomic, readwrite, copy) NSString *deinterlace; @property (nonatomic, readwrite, copy) NSString *deinterlacePreset; @property (nonatomic, readwrite, copy) NSString *deinterlaceCustomString; diff --git a/macosx/HBFilters.m b/macosx/HBFilters.m index 7df571b8d..910c4186d 100644 --- a/macosx/HBFilters.m +++ b/macosx/HBFilters.m @@ -28,6 +28,8 @@ NSString * const HBFiltersChangedNotification = @"HBFiltersChangedNotification"; { _detelecine = @"off"; _detelecineCustomString = @""; + _combDetection = @"off"; + _combDetectionCustomString = @""; _deinterlace = @"off"; _deinterlaceCustomString = @""; _deinterlacePreset = @"default"; @@ -89,6 +91,41 @@ NSString * const HBFiltersChangedNotification = @"HBFiltersChangedNotification"; [self postChangedNotification]; } +- (void)setCombDetection:(NSString *)combDetection +{ + if (![combDetection isEqualToString:_combDetection]) + { + [[self.undo prepareWithInvocationTarget:self] setCombDetection:_combDetection]; + } + if (combDetection) + { + _combDetection = [combDetection copy]; + } + else + { + _combDetection = @"off"; + } + [self postChangedNotification]; +} + +- (void)setCombDetectionCustomString:(NSString *)combDetectionCustomString +{ + if (![combDetectionCustomString isEqualToString:_combDetectionCustomString]) + { + [[self.undo prepareWithInvocationTarget:self] setCombDetectionCustomString:_combDetectionCustomString]; + } + if (combDetectionCustomString) + { + _combDetectionCustomString = [combDetectionCustomString copy]; + } + else + { + _combDetectionCustomString = @""; + } + + [self postChangedNotification]; +} + - (void)setDeinterlace:(NSString *)deinterlace { if (![deinterlace isEqualToString:_deinterlace]) @@ -286,8 +323,12 @@ NSString * const HBFiltersChangedNotification = @"HBFiltersChangedNotification"; { retval = [NSSet setWithObjects:@"detelecine", nil]; } + else if ([key isEqualToString:@"customCombDetectionSelected"]) + { + retval = [NSSet setWithObjects:@"combDetection", nil]; + } else if ([key isEqualToString:@"denoiseTunesAvailable"] || - [key isEqualToString:@"customDenoiseSelected"]) + [key isEqualToString:@"customDenoiseSelected"]) { retval = [NSSet setWithObjects:@"denoise", @"denoisePreset", nil]; } @@ -300,7 +341,7 @@ NSString * const HBFiltersChangedNotification = @"HBFiltersChangedNotification"; retval = [NSSet setWithObject:@"deinterlace"]; } else if ([key isEqualToString:@"customDeinterlaceSelected"] || - [key isEqualToString:@"deinterlacePresets"]) + [key isEqualToString:@"deinterlacePresets"]) { retval = [NSSet setWithObjects:@"deinterlace", @"deinterlacePreset", nil]; } @@ -328,6 +369,9 @@ NSString * const HBFiltersChangedNotification = @"HBFiltersChangedNotification"; copy->_detelecine = [_detelecine copy]; copy->_detelecineCustomString = [_detelecineCustomString copy]; + copy->_combDetection = [_combDetection copy]; + copy->_combDetectionCustomString = [_combDetectionCustomString copy]; + copy->_deinterlace = [_deinterlace copy]; copy->_deinterlacePreset = [_deinterlacePreset copy]; copy->_deinterlaceCustomString = [_deinterlaceCustomString copy]; @@ -360,6 +404,9 @@ NSString * const HBFiltersChangedNotification = @"HBFiltersChangedNotification"; encodeObject(_detelecine); encodeObject(_detelecineCustomString); + encodeObject(_combDetection); + encodeObject(_combDetectionCustomString); + encodeObject(_deinterlace); encodeObject(_deinterlacePreset); encodeObject(_deinterlaceCustomString); @@ -382,6 +429,9 @@ NSString * const HBFiltersChangedNotification = @"HBFiltersChangedNotification"; decodeObject(_detelecine, NSString); decodeObject(_detelecineCustomString, NSString); + decodeObject(_combDetection, NSString); + decodeObject(_combDetectionCustomString, NSString); + decodeObject(_deinterlace, NSString); decodeObject(_deinterlacePreset, NSString) decodeObject(_deinterlaceCustomString, NSString); @@ -409,6 +459,9 @@ NSString * const HBFiltersChangedNotification = @"HBFiltersChangedNotification"; preset[@"PictureDeinterlacePreset"] = self.deinterlacePreset; preset[@"PictureDeinterlaceCustom"] = self.deinterlaceCustomString; + preset[@"PictureCombDetectPreset"] = self.combDetection; + preset[@"PictureCombDetectCustom"] = self.combDetectionCustomString; + preset[@"PictureDetelecine"] = self.detelecine; preset[@"PictureDetelecineCustom"] = self.detelecineCustomString; @@ -434,6 +487,10 @@ NSString * const HBFiltersChangedNotification = @"HBFiltersChangedNotification"; self.deinterlacePreset = preset[@"PictureDeinterlacePreset"]; self.deinterlaceCustomString = preset[@"PictureDeinterlaceCustom"]; + // Comb detection + self.combDetection = preset[@"PictureCombDetectPreset"]; + self.combDetectionCustomString = preset[@"PictureCombDetectCustom"]; + // Detelecine self.detelecine = preset[@"PictureDetelecine"]; self.detelecineCustomString = preset[@"PictureDetelecineCustom"]; diff --git a/macosx/HBJob+HBJobConversion.m b/macosx/HBJob+HBJobConversion.m index aa109971f..8914b34d4 100644 --- a/macosx/HBJob+HBJobConversion.m +++ b/macosx/HBJob+HBJobConversion.m @@ -411,6 +411,19 @@ hb_value_free(&filter_dict); } + // Comb Detection + if (![self.filters.combDetection isEqualToString:@"off"]) + { + int filter_id = HB_FILTER_COMB_DETECT; + hb_dict_t *filter_dict = hb_generate_filter_settings(filter_id, + self.filters.combDetection.UTF8String, + NULL, + self.filters.combDetectionCustomString.UTF8String); + filter = hb_filter_init(filter_id); + hb_add_filter_dict(job, filter, filter_dict); + hb_value_free(&filter_dict); + } + // Deinterlace if (![self.filters.deinterlace isEqualToString:@"off"]) { |