[FFmpeg-devel] [PATCH 09/14] videotoolbox: allow software implementation

wbsecg1 at gmail.com wbsecg1 at gmail.com
Fri Dec 15 09:04:23 EET 2017


From: wang-bin <wbsecg1 at 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(-)

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index e66cd23451..9d2f0afa20 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -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;
-- 
2.15.1



More information about the ffmpeg-devel mailing list