[FFmpeg-devel] [PATCH] avfilter/fade: add color option.

Lukasz M lukasz.m.luki at gmail.com
Sat Nov 9 00:48:38 CET 2013


On 9 November 2013 00:08, Clément Bœsch <u at pkh.me> wrote:

> Fixes Ticket #1822.
> ---
>  doc/filters.texi      | 13 +++++++++----
>  libavfilter/vf_fade.c | 50
> ++++++++++++++++++++++++++++++++++++++++++++++++--
>  2 files changed, 57 insertions(+), 6 deletions(-)
>
> +static int filter_slice_rgb(AVFilterContext *ctx, void *arg, int jobnr,
> +                            int nb_jobs)
> +{
> +    FadeContext *s = ctx->priv;
> +    AVFrame *frame = arg;
> +    int slice_start = (frame->height *  jobnr   ) / nb_jobs;
> +    int slice_end   = (frame->height * (jobnr+1)) / nb_jobs;
> +    int i, j;
> +
> +    const uint8_t r  = s->rgba_map[R];
> +    const uint8_t g  = s->rgba_map[G];
> +    const uint8_t b  = s->rgba_map[B];
> +    const uint8_t a  = s->rgba_map[A];
> +    const uint8_t *c = s->color_rgba;
> +
> +    for (i = slice_start; i < slice_end; i++) {
> +        uint8_t *p = frame->data[0] + i * frame->linesize[0];
> +        for (j = 0; j < frame->width; j++) {
> +#define INTERP(layer, value) av_clip_uint8(((c[value]<<16) +
> ((int)p[layer] - (int)c[value]) * s->factor + (1<<15)) >> 16)
> +            p[r] = INTERP(r, 0);
> +            p[g] = INTERP(g, 1);
> +            p[b] = INTERP(b, 2);
> +            if (s->alpha)
>

This check is done a lot of times with the same result. Maybe move it
outside inner loop and implement loop twice: for 3 and 4 bytes per pixel


> +                p[a] = INTERP(a, 3);
> +            p += s->bpp;
>

I previous remark applied than can be constant +3/+4 maybe


> +        }
> +    }
> +
> +    return 0;
> +}
> +


More information about the ffmpeg-devel mailing list