@@ -40,6 +40,9 @@
#ifndef kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder
# define kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder CFSTR("RequireHardwareAcceleratedVideoDecoder")
#endif
+#ifndef kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder
+# define kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder CFSTR("EnableHardwareAcceleratedVideoDecoder")
+#endif
#if !HAVE_KCMVIDEOCODECTYPE_HEVC
enum { kCMVideoCodecType_HEVC = 'hvc1' };
@@ -684,7 +687,9 @@ static CFDictionaryRef videotoolbox_decoder_config_create(CMVideoCodecType codec
&kCFTypeDictionaryValueCallBacks);
CFDictionarySetValue(config_info,
- kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder,
+ (avctx->hwaccel_flags & AV_HWACCEL_FLAG_ALLOW_SOFTWARE)
+ ? kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder
+ : kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder,
kCFBooleanTrue);
CFMutableDictionaryRef avc_info;
From: wang-bin <wbsecg1@gmail.com> hevc is supported on macOS 10.12+ and iOS11+. sw implementaion is provided for old devices. vt sw decoder is more energy effecient than ffmpeg sw decoder. the sum of program and vt service cpu usage is about 50% lower than ffmpeg. decoding speed is faster sometimes(if opengl compatiblility attribute is disabled) --- libavcodec/videotoolbox.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)