[FFmpeg-devel] [PATCH] Make the scale filter only declare the supported formats
Stefano Sabatini
stefano.sabatini-lala
Fri Jan 8 00:41:20 CET 2010
On date Thursday 2010-01-07 00:14:54 +0100, Michael Niedermayer encoded:
> On Wed, Jan 06, 2010 at 11:33:38PM +0100, Stefano Sabatini wrote:
> > On date Wednesday 2010-01-06 21:56:30 +0100, Stefano Sabatini encoded:
> > > Index: libavfilter-soc/ffmpeg/libavfilter/vf_scale.c
> > > ===================================================================
> > > --- libavfilter-soc.orig/ffmpeg/libavfilter/vf_scale.c 2010-01-06 21:53:47.000000000 +0100
> > > +++ libavfilter-soc/ffmpeg/libavfilter/vf_scale.c 2010-01-06 21:55:39.000000000 +0100
> > > @@ -68,15 +68,24 @@
> > >
> > > static int query_formats(AVFilterContext *ctx)
> > > {
> > > - AVFilterFormats *formats;
> > > + AVFilterFormats *in_formats = NULL;
> > > + AVFilterFormats *out_formats = NULL;
> > > + enum PixelFormat pix_fmt;
> > > + int ret;
> > >
> > > if (ctx->inputs[0]) {
> > > - formats = avfilter_all_colorspaces();
> > > - avfilter_formats_ref(formats, &ctx->inputs[0]->out_formats);
> > > + for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++)
> > > + if (sws_isSupportedInput(pix_fmt))
> > > + if ((ret = avfilter_add_colorspace(&in_formats, pix_fmt)) < 0)
> > > + return ret;
> > > + 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);
> > > + 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)
> > > + return ret;
> > > + avfilter_formats_ref(out_formats, &ctx->outputs[0]->in_formats);
> > > }
> > >
> > > return 0;
> >
> > Fixed memleak and simplified.
> > --
> > FFmpeg = Freak and Fundamental Minimalistic Purposeless Ecumenical Governor
>
> > vf_scale.c | 19 +++++++++++++++++--
> > 1 file changed, 17 insertions(+), 2 deletions(-)
> > 1a1195338d7422211ad54b5c5c8363077c26ca6b make-scale-filter-declare-managed-fmts.patch
> > Index: libavfilter-soc/ffmpeg/libavfilter/vf_scale.c
> > ===================================================================
> > --- libavfilter-soc.orig/ffmpeg/libavfilter/vf_scale.c 2010-01-06 21:53:47.000000000 +0100
> > +++ libavfilter-soc/ffmpeg/libavfilter/vf_scale.c 2010-01-06 23:29:11.000000000 +0100
> > @@ -69,17 +69,32 @@
> > static int query_formats(AVFilterContext *ctx)
> > {
> > AVFilterFormats *formats;
> > + enum PixelFormat pix_fmt;
> > + int ret;
> >
> > if (ctx->inputs[0]) {
> > - formats = avfilter_all_colorspaces();
> > + formats = NULL;
> > + for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++)
> > + if ( sws_isSupportedInput(pix_fmt)
> > + && (ret = avfilter_add_colorspace(&formats, pix_fmt)) < 0)
> > + goto fail;
> > avfilter_formats_ref(formats, &ctx->inputs[0]->out_formats);
> > }
> > if (ctx->outputs[0]) {
> > - formats = avfilter_all_colorspaces();
> > + formats = NULL;
> > + for (pix_fmt = 0; pix_fmt < PIX_FMT_NB; pix_fmt++)
> > + if ( sws_isSupportedOutput(pix_fmt)
> > + && (ret = avfilter_add_colorspace(&formats, pix_fmt)) < 0)
> > + goto fail;
> > avfilter_formats_ref(formats, &ctx->outputs[0]->in_formats);
> > }
> >
> > return 0;
> > +
> > +fail:
> > + if (formats)
> > + avfilter_formats_unref(&formats);
>
> do we need the if() ?
> in general functions not needing explicit NULL checks are nicer IMHO
Updated.
Regards.
--
FFmpeg = Furious Fostering Meaningful Patchable Enigmatic Genius
-------------- next part --------------
A non-text attachment was scrubbed...
Name: make-scale-filter-declare-managed-fmts.patch
Type: text/x-diff
Size: 1371 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100108/e4dc508b/attachment.patch>
More information about the ffmpeg-devel
mailing list