summaryrefslogtreecommitdiff
path: root/libavcodec/videotoolbox.c
diff options
context:
space:
mode:
authorrcombs <rcombs@rcombs.me>2021-11-13 02:43:06 -0600
committerrcombs <rcombs@rcombs.me>2021-11-28 16:40:58 -0600
commita41a2efc85f8c88caec10040ee437562f9d0b947 (patch)
tree133c31e9eb66bc1a180f9da2d545b5beebcd1ad8 /libavcodec/videotoolbox.c
parente3c6cc96cf2f0b2c22dee80a53a01a5fe4fea009 (diff)
lavc/videotoolbox: add VP9 hardware acceleration
On M1 Max, this supports profiles 0 and 2, but not 1 and 3.
Diffstat (limited to 'libavcodec/videotoolbox.c')
-rw-r--r--libavcodec/videotoolbox.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index a11d494915..5f08488a6b 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -33,6 +33,7 @@
#include "hevcdec.h"
#include "mpegvideo.h"
#include <Availability.h>
+#include <AvailabilityMacros.h>
#include <TargetConditionals.h>
#ifndef kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder
@@ -46,6 +47,10 @@
enum { kCMVideoCodecType_HEVC = 'hvc1' };
#endif
+#if !HAVE_KCMVIDEOCODECTYPE_VP9
+enum { kCMVideoCodecType_VP9 = 'vp09' };
+#endif
+
#define VIDEOTOOLBOX_ESDS_EXTRADATA_PADDING 12
typedef struct VTHWFrame {
@@ -816,6 +821,11 @@ static CFDictionaryRef videotoolbox_decoder_config_create(CMVideoCodecType codec
if (data)
CFDictionarySetValue(avc_info, CFSTR("hvcC"), data);
break;
+ case kCMVideoCodecType_VP9 :
+ data = ff_videotoolbox_vpcc_extradata_create(avctx);
+ if (data)
+ CFDictionarySetValue(avc_info, CFSTR("vpcC"), data);
+ break;
default:
break;
}
@@ -863,12 +873,15 @@ static int videotoolbox_start(AVCodecContext *avctx)
case AV_CODEC_ID_MPEG4 :
videotoolbox->cm_codec_type = kCMVideoCodecType_MPEG4Video;
break;
+ case AV_CODEC_ID_VP9 :
+ videotoolbox->cm_codec_type = kCMVideoCodecType_VP9;
+ break;
default :
break;
}
-#ifdef __MAC_10_11
- if (__builtin_available(macOS 10.11, *)) {
+#if defined(MAC_OS_VERSION_11_0) && !TARGET_OS_IPHONE && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0)
+ if (__builtin_available(macOS 11.0, *)) {
VTRegisterSupplementalVideoDecoderIfAvailable(videotoolbox->cm_codec_type);
}
#endif