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

Stefano Sabatini stefano.sabatini-lala
Tue Nov 30 23:22:43 CET 2010


On date Monday 2010-11-29 11:02:53 +0100, Stefano Sabatini encoded:
> 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

> From 3c16bf49c0f9f4c3c72d9eea49ae35a47d58d961 Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> Date: Fri, 26 Nov 2010 17:31:11 +0100
> Subject: [PATCH] Add negate filter.
> 
> Ported from the libavfilter-soc repo with per-component negation
> addition.
> ---
>  doc/filters.texi         |   22 ++++++
>  libavfilter/Makefile     |    1 +
>  libavfilter/allfilters.c |    1 +
>  libavfilter/vf_negate.c  |  184 ++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 208 insertions(+), 0 deletions(-)
>  create mode 100644 libavfilter/vf_negate.c

I'll apply in three days unless objections.
-- 
FFmpeg = Formidable Fostering Multipurpose Proud Energized Gorilla



More information about the ffmpeg-devel mailing list