[FFmpeg-devel] [PATCH 3/3] lavu/hwcontext: clarify behavior on av_hwframe_map() failure

Anton Khirnov anton at khirnov.net
Wed Jan 19 15:47:52 EET 2022


Quoting James Almer (2022-01-19 14:45:12)
> 
> 
> On 1/19/2022 10:40 AM, Anton Khirnov wrote:
> > Clear anything that av_hwframe_map() might have done to the destination
> > frame, but leave caller-provided fields unchanged.
> > ---
> >   libavutil/hwcontext.c | 23 +++++++++++++++++++++--
> >   libavutil/hwcontext.h |  4 ++++
> >   2 files changed, 25 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
> > index 31c7840dba..ae33da1262 100644
> > --- a/libavutil/hwcontext.c
> > +++ b/libavutil/hwcontext.c
> > @@ -18,6 +18,7 @@
> >   
> >   #include "config.h"
> >   
> > +#include "avassert.h"
> >   #include "buffer.h"
> >   #include "common.h"
> >   #include "hwcontext.h"
> > @@ -788,6 +789,8 @@ fail:
> >   
> >   int av_hwframe_map(AVFrame *dst, const AVFrame *src, int flags)
> >   {
> > +    AVBufferRef    *orig_dst_frames = dst->hw_frames_ctx;
> > +    enum AVPixelFormat orig_dst_fmt = dst->format;
> >       AVHWFramesContext *src_frames, *dst_frames;
> >       HWMapDescriptor *hwmap;
> >       int ret;
> > @@ -825,7 +828,7 @@ int av_hwframe_map(AVFrame *dst, const AVFrame *src, int flags)
> >               ret = src_frames->internal->hw_type->map_from(src_frames,
> >                                                             dst, src, flags);
> >               if (ret != AVERROR(ENOSYS))
> > -                return ret;
> > +                goto fail;
> 
> What if ret is 0? Is the stuff in the fail label meant to run on success?

Critical brain failure. Will fix.

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list