summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2020-10-25 08:40:47 +0100
committerDamiano Galassi <[email protected]>2020-10-25 08:40:47 +0100
commitec30eef6a8a54ebdbcba30c69a9329a2fceafa85 (patch)
treeec06d7e09db60d82392699784f3ab816ab408c73 /libhb
parent523f011bf52980a374158d883cebe8b22d34b97b (diff)
vt: cache the hardware encoders availability state.
Diffstat (limited to 'libhb')
-rw-r--r--libhb/platform/macosx/vt_common.m43
1 files changed, 36 insertions, 7 deletions
diff --git a/libhb/platform/macosx/vt_common.m b/libhb/platform/macosx/vt_common.m
index a51189b73..1cbf544b3 100644
--- a/libhb/platform/macosx/vt_common.m
+++ b/libhb/platform/macosx/vt_common.m
@@ -52,7 +52,8 @@ static OSStatus encoder_properties(CMVideoCodecType codecType, CFStringRef *enco
static int hb_vt_is_hardware_encoder_available(CMVideoCodecType codecType)
{
- if (@available (macOS 10.15, *))
+#if defined(__MAC_11_0)
+ if (@available (macOS 11, *))
{
CFStringRef encoderIDOut;
CFDictionaryRef supportedPropertiesOut;
@@ -68,6 +69,7 @@ static int hb_vt_is_hardware_encoder_available(CMVideoCodecType codecType)
}
else
{
+#endif
CFStringRef encoder_id;
switch (codecType) {
@@ -82,12 +84,15 @@ static int hb_vt_is_hardware_encoder_available(CMVideoCodecType codecType)
}
return encvt_available(encoder_id);
+#if defined(__MAC_11_0)
}
+#endif
}
static int hb_vt_is_constant_quality_available(CMVideoCodecType codecType)
{
- if (@available (macOS 10.15, *))
+#if defined(__MAC_11_0)
+ if (@available (macOS 11, *))
{
CFStringRef encoderIDOut;
CFDictionaryRef supportedPropertiesOut;
@@ -109,26 +114,50 @@ static int hb_vt_is_constant_quality_available(CMVideoCodecType codecType)
}
}
}
-
+#endif
return 0;
}
+static int vt_h264_available;
+
int hb_vt_h264_is_available()
{
- return hb_vt_is_hardware_encoder_available(kCMVideoCodecType_H264);
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ vt_h264_available = hb_vt_is_hardware_encoder_available(kCMVideoCodecType_H264);
+ });
+ return vt_h264_available;
}
+static int vt_h265_available;
+
int hb_vt_h265_is_available()
{
- return hb_vt_is_hardware_encoder_available(kCMVideoCodecType_HEVC);
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ vt_h265_available = hb_vt_is_hardware_encoder_available(kCMVideoCodecType_HEVC);
+ });
+ return vt_h265_available;
}
+static int vt_h264_constant_quality;
+
int hb_vt_h264_is_constant_quality_available()
{
- return hb_vt_is_constant_quality_available(kCMVideoCodecType_H264);
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ vt_h264_constant_quality = hb_vt_is_constant_quality_available(kCMVideoCodecType_H264);
+ });
+ return vt_h264_constant_quality;
}
+static int vt_h265_constant_quality;
+
int hb_vt_h265_is_constant_quality_available()
{
- return hb_vt_is_constant_quality_available(kCMVideoCodecType_HEVC);
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ vt_h265_constant_quality = hb_vt_is_constant_quality_available(kCMVideoCodecType_HEVC);
+ });
+ return vt_h265_constant_quality;
}