[FFmpeg-devel] [PATCH] Add negate filter.

Stefano Sabatini stefano.sabatini-lala
Mon Nov 29 11:02:53 CET 2010


On date Monday 2010-11-29 03:21:22 +0100, Michael Niedermayer encoded:
> On Sun, Nov 28, 2010 at 12:30:09PM +0100, Stefano Sabatini wrote:
[...]
> > +static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
> > +{
> > +    NegContext *neg = inlink->dst->priv;
> > +    AVFilterLink *outlink = inlink->dst->outputs[0];
> > +    AVFilterBufferRef *inpic  = inlink ->cur_buf;
> > +    AVFilterBufferRef *outpic = outlink->out_buf;
> > +    uint8_t *inrow, *outrow;
> > +    int i, j, plane;
> > +
> > +    for (plane = 0; inpic->data[plane]; plane++) {
> > +        int vsub = plane == 1 || plane == 2 ? neg->vsub : 0;
> > +        int hsub = plane == 1 || plane == 2 ? neg->hsub : 0;
> > +
> > +        inrow  = inpic ->data[plane] + (y>>vsub) * inpic ->linesize[plane];
> > +        outrow = outpic->data[plane] + (y>>vsub) * outpic->linesize[plane];
> > +
> > +        if (neg->plane_neg[plane]) {
> > +            if (inlink->format == PIX_FMT_MONOWHITE || inlink->format == PIX_FMT_MONOBLACK) {
> > +                for (i = 0; i < inlink->h; i++) {
> > +                    for (j = 0; j < inlink->w >> 3; j++)
> > +                        outrow[j] = ~inrow[j];
> > +                    inrow  += inpic ->linesize[0];
> > +                    outrow += outpic->linesize[0];
> > +                }
> > +            } else {
> > +                for (i = 0; i < (h>>vsub); i ++) {
> > +                    for (j = 0; j < (inlink->w>>hsub); j++)
> > +                        outrow[j] = 255 - inrow[j] + neg->plane_off[plane];
> 
> can overflow and others likely too

Fixed by clipping out-of-range values.

Also relevant:
http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/94136/focus=94154
-- 
FFmpeg = Faithful & Fascinating Murdering Pacific Ecumenical God



More information about the ffmpeg-devel mailing list