Hi,

On Wed, Apr 20, 2011 at 7:45 PM, Anton Khirnov <[email protected]> wrote:
> From: Michael Niedermayer <[email protected]>
>
> Fixes issue2632 if interl=1 is used or the automatic interlace detection is 
> enabled
> and works. This has the advantage compared to the patch in issue2632 that it 
> causes
> no speed loss and it also works when scaling is used. The disadvantage is that
> interlacing autodetection does not yet work very well it seems.
> This is the same method mplayer uses
>
> Signed-off-by: Michael Niedermayer <[email protected]>
> Signed-off-by: Anton Khirnov <[email protected]>
> ---
>  libavfilter/vf_scale.c |   59 ++++++++++++++++++++++++++++++++++++++---------
>  1 files changed, 47 insertions(+), 12 deletions(-)

Unfortunately, this patch is not fine. Poor Stefano's pet project is
indeed being uglified by an idiot that refuses patch review.

>     struct SwsContext *sws;     ///< software scaler context
> +    struct SwsContext *isws[2]; ///< software scaler context for interlaced 
> material

Why 2? Why doesn't non-interlaced sws not just use isws[0]?

> +        if(strstr(args,"interl=1")){
> +            scale->interlaced=1;
> +        }else if(strstr(args,"interl=-1"))
> +            scale->interlaced=-1;

These checks are insufficient and underdocumented. The -1 is
supposedly autodetect but is unimplemented.

>     sws_freeContext(scale->sws);
> +    sws_freeContext(scale->isws[0]);
> +    sws_freeContext(scale->isws[1]);
>     scale->sws = NULL;

Missing =NULLs.

>     scale->sws = sws_getContext(inlink ->w, inlink ->h, inlink ->format,
>                                 outlink->w, outlink->h, outlink->format,
>                                 scale->flags, NULL, NULL, NULL);
> +    scale->isws[0] = sws_getContext(inlink ->w, inlink ->h/2, inlink 
> ->format,
> +                                    outlink->w, outlink->h/2, 
> outlink->format,
> +                                    scale->flags, NULL, NULL, NULL);
> +    scale->isws[1] = sws_getContext(inlink ->w, inlink ->h/2, inlink 
> ->format,
> +                                    outlink->w, outlink->h/2, 
> outlink->format,
> +                                    scale->flags, NULL, NULL, NULL);
>     if (!scale->sws)
>         return AVERROR(EINVAL);

|| !isws[0/1]

> +    if(scale->interlaced>0 || (scale->interlaced<0 && 
> link->cur_buf->video->interlaced)){
> +        av_assert0(y%4 == 0);
> +        out_h = scale_slice(link, scale->isws[0], y, (h+1)/2, 2, 0);
> +        out_h+= scale_slice(link, scale->isws[1], y,  h   /2, 2, 1);
> +    }else{

This assert is wrong and allows crashing libavfilter.

Please drop the patch, hopefully Stefano will fix it up so we can
integrate a squashed version into libav, or just leave it out.

Ronald
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to