[FFmpeg-devel] [PATCH] Add scale filter

Michael Niedermayer michaelni
Sat Oct 31 00:46:31 CET 2009


On Fri, Oct 30, 2009 at 11:44:13AM +0100, Stefano Sabatini wrote:
> On date Wednesday 2009-10-28 00:42:43 +0100, Stefano Sabatini encoded:
> > On date Tuesday 2009-10-27 13:34:06 +0100, Michael Niedermayer encoded:
> [...]
> > > this can overflow and it should use av_reduce()
> > 
> > Changed to:
> > 
> >     out->outpic->pts = picref->pts;
> > 
> >     av_reduce(&out->outpic->pixel_aspect.num, &out->outpic->pixel_aspect.den,
> >               (int64_t)picref->pixel_aspect.num * out->h * link->w,
> >               (int64_t)picref->pixel_aspect.den * out->w * link->h,
> >               INT_MAX);
> > 
> > But there is still the possibility to get an overflow in
> > the expressions:
> > (int64_t)picref->pixel_aspect.num * out->h * link->w
> > (int64_t)picref->pixel_aspect.den * out->w * link->h, 
> > 
> > I could check for example for:
> > (int64_t)out->h * link->w < MAX_INT
> > (int64_t)out->w * link->h < MAX_INT
> > 
> > in config_props() and then eventually fail, but maybe you can suggest
> > some more clever way to check it.
> 
> Done like this, fixed another possible overflow in config_props() by
> using av_rescale(), and applied some variable renames for making the
> code more clear.
[..]
> +static av_cold void uninit(AVFilterContext *ctx)
> +{
> +    ScaleContext *scale = ctx->priv;
> +    if (scale->sws)
> +        sws_freeContext(scale->sws);

sws should be set to NULL to avoid double frees
and the check should not be needed sws_freeContext should have a check
added if it needs one


[...]
> +static void draw_slice(AVFilterLink *link, int y, int h)
> +{
> +    ScaleContext *scale = link->dst->priv;
> +    int out_h;
> +    AVFilterPicRef *cur_pic = link->cur_pic;
> +    uint8_t *data[4];
> +
> +    if (!scale->slice_dir) {
> +        if (y != 0 && y + h != link->h) {
> +            av_log(scale, AV_LOG_ERROR, "Slices start in the middle!\n");
> +            return;
> +        }
> +        scale->slice_dir = y ?                       -1 : 1;
> +        scale->slice_y   = y ? link->dst->outputs[0]->h : y;
> +    }
> +
> +    data[0] = cur_pic->data[0] +  y               * cur_pic->linesize[0];

> +    data[1] = link->format == PIX_FMT_PAL8 ?
> +              cur_pic->data[1] :
> +              cur_pic->data[1] + (y>>scale->vsub) * cur_pic->linesize[1];

the PAL8 check is insufficient, other 8bit formats can also have a fixed
palette in there


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

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA
-------------- 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/20091031/4a8287f4/attachment.pgp>



More information about the ffmpeg-devel mailing list