[FFmpeg-devel] [PATCH] life: add slow_death, life_color and death_color options.

Stefano Sabatini stefasab at gmail.com
Sun Dec 11 11:38:24 CET 2011


On date Sunday 2011-12-11 00:35:26 +0100, Clément Bœsch encoded:
> On Sun, Dec 11, 2011 at 12:26:37AM +0100, Stefano Sabatini wrote:
> > On date Saturday 2011-12-10 04:11:10 +0100, Clément Bœsch encoded:
> > > On Fri, Dec 09, 2011 at 03:24:59PM +0100, Stefano Sabatini wrote:
> > [...]
> > > +static void fill_picture_rgb(AVFilterContext *ctx, AVFilterBufferRef *picref)
> > > +{
> > > +    LifeContext *life = ctx->priv;
> > > +    uint8_t *buf = life->buf[life->buf_idx];
> > 
> > > +    const uint8_t *c1 = life-> mold_color;
> > > +    const uint8_t *c2 = life->death_color;
> > 

> > nit+: you may move these temporaries to the block when they're used.

s/when/where/

> > 
> 
> Sure.
> 
> > > +    int i, j;
> > > +
> > > +    /* fill the output picture with the old grid buffer */
> > > +    for (i = 0; i < life->h; i++) {
> > > +        uint8_t *p = picref->data[0] + i * picref->linesize[0];
> > > +        for (j = 0; j < life->w; j++) {
> > > +            uint8_t v = buf[i*life->w + j];
> > > +            if (life->mold && v != ALIVE_CELL) {
> > > +                int death_age = FFMIN((0xff - v) * life->mold, 0xff);
> >  
> > > +                *p++ = ((c2[0] << 8) + ((int)c1[0] - (int)c2[0]) * death_age) >> 8;
> > > +                *p++ = ((c2[1] << 8) + ((int)c1[1] - (int)c2[1]) * death_age) >> 8;
> > > +                *p++ = ((c2[2] << 8) + ((int)c1[2] - (int)c2[2]) * death_age) >> 8;
> > 
> > then I realized this should be divided by 255, check FAST_DIV255 in
> > vf_overlay.c.
> > 
> 

> Mmh, should we move this code to some common header (in that case which
> one?) or should I just duplicate the code...

As you prefer, libavutil or libavfilter/internal.h may do, but this
looks like premature factorization, and shouldn't block the patch.

> > Looks good otherwise.
> 
> ... and commit/push it?

You can do that yourself ;-).
-- 
FFmpeg = Fancy and Formidable Multipurpose Problematic Embarassing Gymnast


More information about the ffmpeg-devel mailing list