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

Stefano Sabatini stefasab at gmail.com
Sun Dec 11 00:26:37 CET 2011


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.

> +    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.

Looks good otherwise.
-- 
FFmpeg = Funny Fast Mastodontic Portable Ecumenical Glue


More information about the ffmpeg-devel mailing list