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

Michael Niedermayer michaelni
Tue Jan 5 00:18:50 CET 2010


On Mon, Jan 04, 2010 at 01:54:24AM +0100, Stefano Sabatini wrote:
> Hi, as in subject.
> 
> Depends on the already posted patch:
> "Make lsws expose supported formats".
> 
> Regards.
> -- 
> FFmpeg = Freak & Frenzy Meaningful Problematic Exuberant Gadget

>  vf_scale.c |   36 +++++++++++++++++++++++++++++++-----
>  1 file changed, 31 insertions(+), 5 deletions(-)
> 0394116cc822d6289f45e4e8cef28d7aa9dc6d43  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-04 01:32:21.000000000 +0100
> +++ libavfilter-soc/ffmpeg/libavfilter/vf_scale.c	2010-01-04 01:50:42.000000000 +0100
> @@ -68,18 +68,44 @@
>  
>  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]) {

why do we need this check?


> -        formats = avfilter_all_colorspaces();
> -        avfilter_formats_ref(formats, &ctx->inputs[0]->out_formats);


> +        if (!(in_formats  = av_mallocz(sizeof(AVFilterFormats)))) {
> +            ret = AVERROR(ENOMEM);
> +            goto fail;
> +        }
> +
> +        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)
> +                    goto fail;

this design is inconvenient, the first avfilter_add_colorspace() could
allocate in_formats. Well heres your ** back :)


> +        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


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100105/bfdc73f3/attachment.pgp>



More information about the ffmpeg-devel mailing list