[FFmpeg-devel] [PATCH] Add negate filter.
Stefano Sabatini
stefano.sabatini-lala
Sun Nov 28 12:30:09 CET 2010
On date Sunday 2010-11-28 03:09:35 +0100, Michael Niedermayer encoded:
> On Fri, Nov 26, 2010 at 05:32:13PM +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;
> > +
> > + if (inlink->format == PIX_FMT_MONOWHITE || inlink->format == PIX_FMT_MONOBLACK) {
> > + inrow = inpic ->data[0] + y * inpic ->linesize[0];
> > + outrow = outpic->data[0] + y * outpic->linesize[0];
> > + for (i = 0; i < h; i++) {
> > + for (j = 0; j < inlink->w >> 3; j++)
> > + outrow[j] = ~inrow[j];
> > + inrow += inpic ->linesize[0];
> > + outrow += outpic->linesize[0];
> > + }
> > + } else {
> > + /* luma plane */
> > + inrow = inpic ->data[0] + y * inpic-> linesize[0];
> > + outrow = outpic->data[0] + y * outpic->linesize[0];
> > + for (i = 0; i < h; i ++) {
> > + for(j = 0; j < inlink->w; j++)
> > + outrow[j] = 255 - inrow[j] + neg->off_y;
> > + inrow += inpic ->linesize[0];
> > + outrow += outpic->linesize[0];
> > + }
> > +
> > + /* chroma planes */
> > + for (plane = 1; plane < 3; plane++) {
> > + inrow = inpic-> data[plane] + (y >> neg->vsub) * inpic ->linesize[plane];
> > + outrow = outpic->data[plane] + (y >> neg->vsub) * outpic->linesize[plane];
> > +
> > + for (i = 0; i < h >> neg->vsub; i++) {
> > + for (j = 0; j < inlink->w >> neg->hsub; j++)
> > + outrow[j] = 255 - inrow[j] + neg->off_uv;
> > + inrow += inpic ->linesize[plane];
> > + outrow += outpic->linesize[plane];
> > + }
> > + }
>
> the user should be able to selct which planes are negated
Good idea, updated.
--
FFmpeg = Fast & Faithless Meaningful Powerful Extreme Guru
More information about the ffmpeg-devel
mailing list