[FFmpeg-devel] [PATCH] vf_framestep: add blend parameter for motion blur effect

Nicolas George george at nsup.org
Thu Apr 6 10:42:19 EEST 2017


Le sextidi 16 germinal, an CCXXV, Matthias C. M. Troffaes a écrit :
> +#define DEFINE_BLEND(NAME, TYPE, DECL, EXPR)                                   \
> +static void blend_##NAME##_##TYPE(AVFilterContext *ctx, AVFrame *in, int plane)\
> +{                                                                              \
> +    FrameStepContext *s = ctx->priv;                                           \
> +    DECL                                                                       \
> +    const int height = s->planeheight[plane];                                  \
> +    const int width  = s->planewidth[plane];                                   \
> +    const int stride = in->linesize[plane] / sizeof(TYPE);                     \
> +    TYPE *src = (TYPE *)in->data[plane];                                       \
> +    uint32_t *dst = s->data[plane];                                            \
> +    int y, x;                                                                  \
> +                                                                               \
> +    for (y = 0; y < height; y++) {                                             \
> +        for (x = 0; x < width; x++) {                                          \
> +            EXPR;                                                              \
> +        }                                                                      \
> +        src += stride;                                                         \
> +    }                                                                          \
> +}
> +
> +#define SET_DECL
> +#define SET_EXPR *dst++ = src[x]
> +#define ADD_DECL
> +#define ADD_EXPR *dst++ += src[x]
> +#define DIV_DECL const int frame_blend = s->frame_blend;
> +#define DIV_EXPR src[x] = *dst++ / frame_blend
> +
> +DEFINE_BLEND(set, uint8_t,  SET_DECL, SET_EXPR)
> +DEFINE_BLEND(set, uint16_t, SET_DECL, SET_EXPR)
> +DEFINE_BLEND(add, uint8_t,  ADD_DECL, ADD_EXPR)
> +DEFINE_BLEND(add, uint16_t, ADD_DECL, ADD_EXPR)
> +DEFINE_BLEND(div, uint8_t,  DIV_DECL, DIV_EXPR)
> +DEFINE_BLEND(div, uint16_t, DIV_DECL, DIV_EXPR)

There is already blending code in vf_framerate and vf_overlay, I think
we should not add new similar code without sharing it as much as
possible.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170406/dade89fe/attachment.sig>


More information about the ffmpeg-devel mailing list