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 /libhb/platform/macosx | |
parent | ba7d33db36abe423aadbd36e91bccdabf25709aa (diff) |
Add VideoToolbox hardware encoding thru FFmpeg.
Diffstat (limited to 'libhb/platform/macosx')
-rw-r--r-- | libhb/platform/macosx/vt_common.c | 63 | ||||
-rw-r--r-- | libhb/platform/macosx/vt_common.h | 16 |
2 files changed, 79 insertions, 0 deletions
diff --git a/libhb/platform/macosx/vt_common.c b/libhb/platform/macosx/vt_common.c new file mode 100644 index 000000000..be75018ea --- /dev/null +++ b/libhb/platform/macosx/vt_common.c @@ -0,0 +1,63 @@ +/* vt_common.c + + Copyright (c) 2003-2018 HandBrake Team + This file is part of the HandBrake source code + Homepage: <http://handbrake.fr/>. + It may be used under the terms of the GNU General Public License v2. + For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html + */ + +#include "hb.h" +#include "vt_common.h" + +#include <VideoToolbox/VideoToolbox.h> +#include <CoreMedia/CoreMedia.h> +#include <CoreVideo/CoreVideo.h> + +//#define VT_STATS + +#ifdef VT_STATS +static void toggle_vt_gva_stats(bool state) +{ + CFPropertyListRef cf_state = state ? kCFBooleanTrue : kCFBooleanFalse; + CFPreferencesSetValue(CFSTR("gvaEncoderPerf"), cf_state, CFSTR("com.apple.GVAEncoder"), kCFPreferencesCurrentUser, kCFPreferencesCurrentHost); + CFPreferencesSetValue(CFSTR("gvaEncoderPSNR"), cf_state, CFSTR("com.apple.GVAEncoder"), kCFPreferencesCurrentUser, kCFPreferencesCurrentHost); + CFPreferencesSetValue(CFSTR("gvaEncoderSSIM"), cf_state, CFSTR("com.apple.GVAEncoder"), kCFPreferencesCurrentUser, kCFPreferencesCurrentHost); + + //CFPreferencesSetValue(CFSTR("gvaEncoderStats"), cf_state, CFSTR("com.apple.GVAEncoder"), kCFPreferencesCurrentUser, kCFPreferencesCurrentHost); + //CFPreferencesSetValue(CFSTR("gvaDebug"), cf_state, CFSTR("com.apple.AppleGVA"), kCFPreferencesCurrentUser, kCFPreferencesCurrentHost); +} +#endif + +static const CFStringRef encoder_id_h264 = CFSTR("com.apple.videotoolbox.videoencoder.h264.gva"); +static const CFStringRef encoder_id_h265 = CFSTR("com.apple.videotoolbox.videoencoder.hevc.gva"); + +int encvt_available(CFStringRef encoder) +{ + CFArrayRef encoder_list; + VTCopyVideoEncoderList(NULL, &encoder_list); + CFIndex size = CFArrayGetCount(encoder_list); + + for (CFIndex i = 0; i < size; i++ ) + { + CFDictionaryRef encoder_dict = CFArrayGetValueAtIndex(encoder_list, i); + CFStringRef encoder_id = CFDictionaryGetValue(encoder_dict, kVTVideoEncoderSpecification_EncoderID); + if (CFEqual(encoder_id, encoder)) + { + CFRelease(encoder_list); + return 1; + } + } + CFRelease(encoder_list); + return 0; +} + +int hb_vt_h264_is_available() +{ + return encvt_available(encoder_id_h264); +} + +int hb_vt_h265_is_available() +{ + return encvt_available(encoder_id_h265); +} diff --git a/libhb/platform/macosx/vt_common.h b/libhb/platform/macosx/vt_common.h new file mode 100644 index 000000000..22187d0cc --- /dev/null +++ b/libhb/platform/macosx/vt_common.h @@ -0,0 +1,16 @@ +/* vt_common.h + + Copyright (c) 2003-2018 HandBrake Team + This file is part of the HandBrake source code + Homepage: <http://handbrake.fr/>. + It may be used under the terms of the GNU General Public License v2. + For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html + */ + +int hb_vt_h264_is_available(); +int hb_vt_h265_is_available(); + +static const char * const hb_vt_h265_level_names[] = +{ + "auto", NULL, +}; |