[FFmpeg-devel] [PATCH] libavcodec/videotoolbox: let VideoToolbox choose a decoder for us

Wang Chuan ouchuanm at outlook.com
Sat Aug 1 18:25:50 EEST 2020


If we fail to create a decoder specified by ourself, then try to
let VideoToolbox pick a proper one for us.

Signed-off-by: Wang Chuan <ouchuanm at outlook.com>
---
 libavcodec/videotoolbox.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index 8773de3393..9077647e25 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -837,6 +837,10 @@ static int videotoolbox_start(AVCodecContext *avctx)
                                           &decoder_cb,               // outputCallback
                                           &videotoolbox->session);   // decompressionSessionOut
 
+    // if we cannot create a decode session specified by ourself, then that videotoolbox pick one for us
+    if (status == kVTVideoDecoderNotAvailableNowErr)
+        status = VTDecompressionSessionCreate(NULL, videotoolbox->cm_fmt_desc, NULL, buf_attr, &decoder_cb, &videotoolbox->session);
+
     if (decoder_spec)
         CFRelease(decoder_spec);
     if (buf_attr)
-- 
2.27.0



More information about the ffmpeg-devel mailing list