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

Mark Thompson sw at jkqxz.net
Sat Aug 1 18:50:12 EEST 2020


On 01/08/2020 16:25, Wang Chuan wrote:
> 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)
> 

Can you explain why?

Looking at the code, it seems like the main consequence of this is to allow decoders to be created which have not been given the extradata header, and that isn't obviously a positive change.  (Does 
decoding a stream with a global header still work if this path is taken?)

- Mark


More information about the ffmpeg-devel mailing list