diff options
author | Damiano Galassi <[email protected]> | 2018-11-15 13:56:16 +0100 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2018-11-15 13:56:16 +0100 |
commit | 5c127e80911b92a8a47b08a51e8dfb52e67fc206 (patch) | |
tree | 563ef7ebb98d787281f6d4196e6aad59724e78ab /macosx | |
parent | ba7d33db36abe423aadbd36e91bccdabf25709aa (diff) |
Add VideoToolbox hardware encoding thru FFmpeg.
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/Base.lproj/Video.xib | 26 | ||||
-rw-r--r-- | macosx/HBVideo+UIAdditions.h | 2 | ||||
-rw-r--r-- | macosx/HBVideo+UIAdditions.m | 21 | ||||
-rw-r--r-- | macosx/HBVideo.m | 34 | ||||
-rw-r--r-- | macosx/HandBrake.xcodeproj/project.pbxproj | 16 |
5 files changed, 98 insertions, 1 deletions
diff --git a/macosx/Base.lproj/Video.xib b/macosx/Base.lproj/Video.xib index 8f69b26bb..8bd3cd262 100644 --- a/macosx/Base.lproj/Video.xib +++ b/macosx/Base.lproj/Video.xib @@ -86,6 +86,7 @@ </textFieldCell> <connections> <binding destination="-2" name="textColor" keyPath="self.labelColor" id="EsL-F5-tAO"/> + <binding destination="-2" name="enabled" keyPath="self.video.isConstantQualitySupported" id="vfD-XL-S4P"/> <binding destination="-2" name="value" keyPath="self.video.quality" id="tMZ-Xb-TuF"/> </connections> </textField> @@ -124,6 +125,14 @@ <font key="font" metaFont="smallSystem"/> </buttonCell> <connections> + <binding destination="-2" name="enabled3" keyPath="self.video.twoPassSupported" previousBinding="c4g-dz-q05" id="rwS-GN-5Dd"> + <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="enabled2" keyPath="self.video" previousBinding="7aV-7j-MzB" id="c4g-dz-q05"> <dictionary key="options"> <integer key="NSMultipleValuesPlaceholder" value="-1"/> @@ -253,6 +262,14 @@ x264 is lossless at RF 0.</string> <string key="NSValueTransformerName">NSIsNotNil</string> </dictionary> </binding> + <binding destination="-2" name="enabled3" keyPath="self.video.isConstantQualitySupported" previousBinding="ywk-WQ-GNY" id="riO-a0-Jfa"> + <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> @@ -273,6 +290,7 @@ x264 is lossless at RF 0.</string> <connections> <binding destination="-2" name="textColor" keyPath="self.labelColor" id="S90-zY-jeW"/> <binding destination="-2" name="value" keyPath="self.video.constantQualityLabel" id="ri5-aE-FP5"/> + <binding destination="-2" name="enabled" keyPath="self.video.isConstantQualitySupported" id="6YN-nu-K6b"/> </connections> </textField> <box autoresizesSubviews="NO" boxType="custom" borderType="none" title="x264 Presets" titlePosition="noTitle" transparent="YES" translatesAutoresizingMaskIntoConstraints="NO" id="A4U-3F-pYq"> @@ -289,6 +307,14 @@ x264 is lossless at RF 0.</string> <font key="font" metaFont="smallSystem"/> </buttonCell> <connections> + <binding destination="-2" name="enabled2" keyPath="self.video.isConstantQualitySupported" previousBinding="Ewd-OO-T3Z" id="cEw-6S-gon"> + <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" id="Ewd-OO-T3Z"> <dictionary key="options"> <string key="NSValueTransformerName">NSIsNotNil</string> diff --git a/macosx/HBVideo+UIAdditions.h b/macosx/HBVideo+UIAdditions.h index 5ce7648a7..236096916 100644 --- a/macosx/HBVideo+UIAdditions.h +++ b/macosx/HBVideo+UIAdditions.h @@ -21,6 +21,7 @@ @property (nonatomic, readonly) NSArray *levels; @property (nonatomic, readonly) BOOL fastDecodeSupported; +@property (nonatomic, readonly) BOOL twoPassSupported; @property (nonatomic, readonly) BOOL turboTwoPassSupported; @property (nonatomic, readonly) NSString *unparseOptions; @@ -29,6 +30,7 @@ @property (nonatomic, readonly) double qualityMinValue; @property (nonatomic, readonly) double qualityMaxValue; +@property (nonatomic, readonly) BOOL isConstantQualitySupported; @end diff --git a/macosx/HBVideo+UIAdditions.m b/macosx/HBVideo+UIAdditions.m index e23c1ab72..d7cbc0eda 100644 --- a/macosx/HBVideo+UIAdditions.m +++ b/macosx/HBVideo+UIAdditions.m @@ -104,6 +104,17 @@ (self.encoder & HB_VCODEC_X265_MASK)); } ++ (NSSet<NSString *> *)keyPathsForValuesAffectingTwoPassSupported +{ + return [NSSet setWithObjects:@"encoder", nil]; +} + +- (BOOL)twoPassSupported +{ + return !((self.encoder & HB_VCODEC_FFMPEG_VT_H264) || + (self.encoder & HB_VCODEC_FFMPEG_VT_H265)); +} + + (NSSet<NSString *> *)keyPathsForValuesAffectingConstantQualityLabel { return [NSSet setWithObjects:@"encoder", nil]; @@ -114,6 +125,16 @@ return @(hb_video_quality_get_name(self.encoder)); } ++ (NSSet<NSString *> *)keyPathsForValuesAffectingIsConstantQualitySupported +{ + return [NSSet setWithObjects:@"encoder", nil]; +} + +- (BOOL)isConstantQualitySupported +{ + return (self.qualityMaxValue == 0 && self.qualityMinValue == 0) == NO; +} + + (NSSet<NSString *> *)keyPathsForValuesAffectingUnparseOptions { return [NSSet setWithObjects:@"encoder", @"preset", @"tune", @"profile", @"level", diff --git a/macosx/HBVideo.m b/macosx/HBVideo.m index 15c2f67ae..1119aaa5c 100644 --- a/macosx/HBVideo.m +++ b/macosx/HBVideo.m @@ -105,6 +105,7 @@ NSString * const HBVideoChangedNotification = @"HBVideoChangedNotification"; if (!(self.undo.isUndoing || self.undo.isRedoing)) { + [self validateQualityType]; [self validatePresetsSettings]; [self validateVideoOptionExtra:previousEncoder]; } @@ -281,11 +282,42 @@ NSString * const HBVideoChangedNotification = @"HBVideoChangedNotification"; [self postChangedNotification]; } +- (void)validateQualityType +{ + if (self.qualityType != 0) + { + int direction; + float minValue, maxValue, granularity; + hb_video_quality_get_limits(self.encoder, + &minValue, &maxValue, &granularity, &direction); + + if (minValue == 0 && maxValue == 0) + { + self.qualityType = 0; + } + } + else + { + if ((self.encoder & HB_VCODEC_FFMPEG_VT_H264) || + (self.encoder & HB_VCODEC_FFMPEG_VT_H265)) + { + self.twoPass = NO; + } + } +} + - (void)validatePresetsSettings { NSArray *presets = self.presets; if (presets.count && ![presets containsObject:self.preset]) { - self.preset = presets[self.mediumPresetIndex]; + if (presets.count > self.mediumPresetIndex) + { + self.preset = presets[self.mediumPresetIndex]; + } + else + { + self.preset = presets.firstObject; + } } NSArray *tunes = self.tunes; diff --git a/macosx/HandBrake.xcodeproj/project.pbxproj b/macosx/HandBrake.xcodeproj/project.pbxproj index 586fcae64..f0ad8c6d2 100644 --- a/macosx/HandBrake.xcodeproj/project.pbxproj +++ b/macosx/HandBrake.xcodeproj/project.pbxproj @@ -225,6 +225,8 @@ A9906B2C1A710920001D82D5 /* HBQueueController.m in Sources */ = {isa = PBXBuildFile; fileRef = A9906B2B1A710920001D82D5 /* HBQueueController.m */; }; A99F40CF1B624E7E00750170 /* HBPictureViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A99F40CD1B624E7E00750170 /* HBPictureViewController.m */; }; A9A0CBE81CCEA3670045B3DF /* HBPlayerTrack.m in Sources */ = {isa = PBXBuildFile; fileRef = A9A0CBE61CCEA1D10045B3DF /* HBPlayerTrack.m */; }; + A9A25D9C21182741005A8A0F /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9A25D9B21182741005A8A0F /* CoreMedia.framework */; }; + A9A25D9D21182753005A8A0F /* CoreMedia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9A25D9B21182741005A8A0F /* CoreMedia.framework */; }; A9A7E27C1FE2A0B5006BE79F /* HBPreviewViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A9A7E27A1FE2A0B5006BE79F /* HBPreviewViewController.m */; }; A9A96B8220CAD2C200A39AFB /* HBPictureHUDController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9A96B8420CAD2C200A39AFB /* HBPictureHUDController.xib */; }; A9A96B8520CAD2CC00A39AFB /* HBEncodingProgressHUDController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9A96B8720CAD2CC00A39AFB /* HBEncodingProgressHUDController.xib */; }; @@ -247,6 +249,9 @@ A9A96BDD20CAD66000A39AFB /* OutputPanel.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9A96BDB20CAD66000A39AFB /* OutputPanel.xib */; }; A9A96BE020CAD66500A39AFB /* Preferences.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9A96BDE20CAD66500A39AFB /* Preferences.xib */; }; A9A96BE320CAD6CD00A39AFB /* HBPreviewViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A9A96BE120CAD6CD00A39AFB /* HBPreviewViewController.xib */; }; + A9AB9AA5211819A500BB3C7E /* VideoToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9AB9AA4211819A500BB3C7E /* VideoToolbox.framework */; }; + A9AB9AA621181CA900BB3C7E /* VideoToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9AB9AA4211819A500BB3C7E /* VideoToolbox.framework */; }; + A9AB9AA821181CC700BB3C7E /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9AB9AA721181CC700BB3C7E /* CoreVideo.framework */; }; A9ABD1A61E2A0F0700EC8B65 /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9ABD1A51E2A0F0700EC8B65 /* CoreText.framework */; }; A9ABD1A71E2A0F7500EC8B65 /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9ABD1A51E2A0F0700EC8B65 /* CoreText.framework */; }; A9ABD1A91E2A0F8200EC8B65 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9ABD1A81E2A0F8200EC8B65 /* CoreGraphics.framework */; }; @@ -579,6 +584,7 @@ A99F40CD1B624E7E00750170 /* HBPictureViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBPictureViewController.m; sourceTree = "<group>"; }; A9A0CBE51CCEA1D10045B3DF /* HBPlayerTrack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HBPlayerTrack.h; sourceTree = "<group>"; }; A9A0CBE61CCEA1D10045B3DF /* HBPlayerTrack.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HBPlayerTrack.m; sourceTree = "<group>"; }; + A9A25D9B21182741005A8A0F /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; }; A9A7E2791FE2A0B5006BE79F /* HBPreviewViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HBPreviewViewController.h; sourceTree = "<group>"; }; A9A7E27A1FE2A0B5006BE79F /* HBPreviewViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HBPreviewViewController.m; sourceTree = "<group>"; }; A9A96B8320CAD2C200A39AFB /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/HBPictureHUDController.xib; sourceTree = "<group>"; }; @@ -610,6 +616,8 @@ A9AA447B1970724D00D7DEFC /* HBAdvancedController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HBAdvancedController.h; sourceTree = "<group>"; }; A9AA447C1970726500D7DEFC /* HBQueueController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HBQueueController.h; sourceTree = "<group>"; }; A9AA447D1970729300D7DEFC /* HBPreviewGenerator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HBPreviewGenerator.h; sourceTree = "<group>"; }; + A9AB9AA4211819A500BB3C7E /* VideoToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = VideoToolbox.framework; path = System/Library/Frameworks/VideoToolbox.framework; sourceTree = SDKROOT; }; + A9AB9AA721181CC700BB3C7E /* CoreVideo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreVideo.framework; path = System/Library/Frameworks/CoreVideo.framework; sourceTree = SDKROOT; }; A9ABD1A51E2A0F0700EC8B65 /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = System/Library/Frameworks/CoreText.framework; sourceTree = SDKROOT; }; A9ABD1A81E2A0F8200EC8B65 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; A9B34D74197696FE00871B7D /* DiskArbitration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DiskArbitration.framework; path = System/Library/Frameworks/DiskArbitration.framework; sourceTree = SDKROOT; }; @@ -676,6 +684,9 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + A9A25D9C21182741005A8A0F /* CoreMedia.framework in Frameworks */, + A9AB9AA821181CC700BB3C7E /* CoreVideo.framework in Frameworks */, + A9AB9AA621181CA900BB3C7E /* VideoToolbox.framework in Frameworks */, A9ABD1A91E2A0F8200EC8B65 /* CoreGraphics.framework in Frameworks */, A9ABD1A71E2A0F7500EC8B65 /* CoreText.framework in Frameworks */, A9E165521C523016003EF30E /* libavfilter.a in Frameworks */, @@ -731,6 +742,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + A9A25D9D21182753005A8A0F /* CoreMedia.framework in Frameworks */, + A9AB9AA5211819A500BB3C7E /* VideoToolbox.framework in Frameworks */, A9ABD1AA1E2A0F8F00EC8B65 /* CoreGraphics.framework in Frameworks */, A9ABD1A61E2A0F0700EC8B65 /* CoreText.framework in Frameworks */, A91119A31C7DD591001C463C /* IOKit.framework in Frameworks */, @@ -868,6 +881,9 @@ 273F203414ADBAC30021BE6D /* Frameworks */ = { isa = PBXGroup; children = ( + A9A25D9B21182741005A8A0F /* CoreMedia.framework */, + A9AB9AA721181CC700BB3C7E /* CoreVideo.framework */, + A9AB9AA4211819A500BB3C7E /* VideoToolbox.framework */, A9ABD1A81E2A0F8200EC8B65 /* CoreGraphics.framework */, A9ABD1A51E2A0F0700EC8B65 /* CoreText.framework */, A91CE2D31C7DABE40068F46F /* libiconv.tbd */, |