[FFmpeg-devel] [PATCH] Make the scale filter only declare the supported formats

Stefano Sabatini stefano.sabatini-lala
Wed Jan 6 21:56:30 CET 2010


On date Tuesday 2010-01-05 00:18:50 +0100, Michael Niedermayer encoded:
> On Mon, Jan 04, 2010 at 01:54:24AM +0100, Stefano Sabatini wrote:
[...]
> > +        avfilter_formats_ref(in_formats, &ctx->inputs[0]->out_formats);
> >      }
> >      if (ctx->outputs[0]) {
> > -        formats = avfilter_all_colorspaces();
> > -        avfilter_formats_ref(formats, &ctx->outputs[0]->in_formats);
> > +        if (!(out_formats  = av_mallocz(sizeof(AVFilterFormats)))) {
> > +            ret = AVERROR(ENOMEM);
> > +            goto fail;
> > +        }
> > +
> > +        for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++)
> > +            if (sws_isSupportedOutput(pix_fmt))
> > +                if ((ret = avfilter_add_colorspace(out_formats, pix_fmt)) < 0)
> > +                    goto fail;
> > +        avfilter_formats_ref(out_formats, &ctx->outputs[0]->in_formats);
> >      }
> >  
> >      return 0;
> > +
> > +fail:
> 
> > +    if (in_formats)
> > +        avfilter_formats_unref(&in_formats);
> > +    if (out_formats)
> > +        avfilter_formats_unref(&out_formats);
> 
> do we need this freeing here?
> it seems more logic to let the common calling code do the cleanup

I agree (I didn't understood what you meant here with "calling code").

Note that currently all the filter formats in case of query_formats
failure got freed when calling avfilter_graph_destroy().

Also maybe is also a good idea to extend the documentation of
query_formats() like in the attached patch.

Regards.
-- 
FFmpeg = Fundamentalist and Fantastic Minimalistic Puritan Exxagerate Gem
-------------- next part --------------
A non-text attachment was scrubbed...
Name: extend-query-formats-doxy.patch
Type: text/x-diff
Size: 715 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100106/09df34cf/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: make-scale-filter-declare-managed-fmts.patch
Type: text/x-diff
Size: 1444 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100106/09df34cf/attachment-0001.patch>



More information about the ffmpeg-devel mailing list