[FFmpeg-devel] [PATCH] lavu/videotoolbox: add support for memory mapping frames

Anton Khirnov anton at khirnov.net
Sun Jan 9 11:24:51 EET 2022


Quoting Cameron Gutman (2022-01-03 01:33:19)
> Signed-off-by: Cameron Gutman <aicommander at gmail.com>
> ---
>  libavutil/hwcontext_videotoolbox.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/libavutil/hwcontext_videotoolbox.c b/libavutil/hwcontext_videotoolbox.c
> index 0a8dbe9f33..026127d412 100644
> --- a/libavutil/hwcontext_videotoolbox.c
> +++ b/libavutil/hwcontext_videotoolbox.c
> @@ -711,6 +711,30 @@ fail:
>      return err;
>  }
>  
> +static int vt_map_from(AVHWFramesContext *hwfc, AVFrame *dst,
> +                       const AVFrame *src, int flags)
> +{
> +    int err;
> +
> +    if (dst->format == AV_PIX_FMT_NONE)
> +        dst->format = hwfc->sw_format;
> +    else if (dst->format != hwfc->sw_format)
> +        return AVERROR(ENOSYS);
> +
> +    err = vt_map_frame(hwfc, dst, src, flags);
> +    if (err)
> +        return err;
> +
> +    dst->width  = src->width;
> +    dst->height = src->height;
> +
> +    err = av_frame_copy_props(dst, src);
> +    if (err)
> +        return err;

Don't you need to unmap the frame in this error path?

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list