[FFmpeg-devel] [PATCH v2 1/1] avfilter/frames: Ensure frames are writable when processing in-place

Soft Works softworkz at hotmail.com
Wed Sep 29 02:05:11 EEST 2021



> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> On Behalf Of
> James Almer
> Sent: Wednesday, 29 September 2021 00:27
> To: ffmpeg-devel at ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v2 1/1] avfilter/frames: Ensure
> frames are writable when processing in-place
> 
> On 9/28/2021 4:54 PM, Soft Works wrote:
> > Signed-off-by: softworkz <softworkz at hotmail.com>
> > ---
> > v2: Reduced to cases without AVFILTERPAD_FLAG_NEEDS_WRITABLE
> >
> >   libavfilter/vf_cover_rect.c | 7 +++++--
> >   libavfilter/vf_floodfill.c  | 5 +++++
> >   libavfilter/vf_vflip.c      | 7 ++++++-
> >   3 files changed, 16 insertions(+), 3 deletions(-)
> >
> > diff --git a/libavfilter/vf_cover_rect.c
> b/libavfilter/vf_cover_rect.c
> > index 0a8c10e06d..2367afb4b3 100644
> > --- a/libavfilter/vf_cover_rect.c
> > +++ b/libavfilter/vf_cover_rect.c
> > @@ -136,7 +136,7 @@ static int filter_frame(AVFilterLink *inlink,
> AVFrame *in)
> >       AVFilterContext *ctx = inlink->dst;
> >       CoverContext *cover = ctx->priv;
> >       AVDictionaryEntry *ex, *ey, *ew, *eh;
> > -    int x = -1, y = -1, w = -1, h = -1;
> > +    int x = -1, y = -1, w = -1, h = -1, ret;
> >       char *xendptr = NULL, *yendptr = NULL, *wendptr = NULL,
> *hendptr = NULL;
> >
> >       ex = av_dict_get(in->metadata, "lavfi.rect.x", NULL,
> AV_DICT_MATCH_CASE);
> > @@ -181,7 +181,10 @@ static int filter_frame(AVFilterLink *inlink,
> AVFrame *in)
> >       x = av_clip(x, 0, in->width  - w);
> >       y = av_clip(y, 0, in->height - h);
> >
> > -    av_frame_make_writable(in);
> > +    if ((ret = av_frame_make_writable(in)) < 0) {
> > +        av_frame_free(&in);
> > +        return ret;
> > +    }
> >
> >       if (cover->mode == MODE_BLUR) {
> >           blur (cover, in, x, y);
> > diff --git a/libavfilter/vf_floodfill.c
> b/libavfilter/vf_floodfill.c
> > index 21741cdb4f..292b27505e 100644
> > --- a/libavfilter/vf_floodfill.c
> > +++ b/libavfilter/vf_floodfill.c
> > @@ -294,6 +294,11 @@ static int filter_frame(AVFilterLink *link,
> AVFrame *frame)
> >       const int h = frame->height;
> >       int i, ret;
> >
> > +    if ((ret = av_frame_make_writable(frame)) < 0) {
> 
> Is this one even needed? s->pick_pixel() does not change the frame,
> and
> an av_frame_make_writable() call is already in place before any
> s->set_pixel() call in this same function.

Yes, you're right in this case. In fact I missed the existing 
av_frame_make_writable() call.

Thanks,
softworkz



More information about the ffmpeg-devel mailing list