[FFmpeg-devel] [PATCH] Port gradfun to libavfilter (GCI)

Alexander Strange astrange
Mon Nov 29 17:02:20 CET 2010


On Nov 29, 2010, at 7:18 AM, Nolan L wrote:

> As part of a GCI task, I've ported the gradfun debanding filter from mplayer
> to libavfilter.
> 
> The patch includes changes to the build system to account for CPU
> optimizations that weren't present previously.
> 
> There is a SSE2 method that remains unported due to lack of SSE2 detection
> in the configure script that I wasn't quite sure how to add.
> <gradfun.patch>

> --- /dev/null
> +++ b/libavfilter/gradfun.h
> @@ -0,0 +1,62 @@
> +/*
> + * This file is part of FFmpeg.
> + *

Might as well put the same author name there. 

Ask pengvado to relicense it under LGPL, otherwise you'll have to add the GPL dependency in the Makefile.

> +static const uint16_t __attribute__((aligned(16))) pw_7f[8] = {127,127,127,127,127,127,127,127};
> +static const uint16_t __attribute__((aligned(16))) pw_ff[8] = {255,255,255,255,255,255,255,255};

I think you can merge the three files in x86/ into one; then this will only be used in one file and you can move it there.

> +static const uint16_t __attribute__((aligned(16))) dither[8][8] = {
> +    {  0, 96, 24,120,  6,102, 30,126 },
> +    { 64, 32, 88, 56, 70, 38, 94, 62 },
> +    { 16,112,  8,104, 22,118, 14,110 },
> +    { 80, 48, 72, 40, 86, 54, 78, 46 },
> +    {  4,100, 28,124,  2, 98, 26,122 },
> +    { 68, 36, 92, 60, 66, 34, 90, 58 },
> +    { 20,116, 12,108, 18,114, 10,106 },
> +    { 84, 52, 76, 44, 82, 50, 74, 42 },
> +};

This is only used in vf_gradfun.c.

> +void filter_line_c(uint8_t *dst, uint8_t *src, uint16_t *dc, int width, int thresh, const uint16_t *dithers);
> +void blur_line_c(uint16_t *dc, uint16_t *buf, uint16_t *buf1, uint8_t *src, int sstride, int width);
> +
> +void filter_line_mmx2(uint8_t *dst, uint8_t *src, uint16_t *dc,
> +                             int width, int thresh, const uint16_t *dithers);
> +
> +void filter_line_ssse3(uint8_t *dst, uint8_t *src, uint16_t *dc,
> +                              int width, int thresh, const uint16_t *dithers);
> +
> +void blur_line_sse2(uint16_t *dc, uint16_t *buf, uint16_t *buf1,
> +                           uint8_t *src, int sstride, int width);

Functions not 'static' need at least an ff_ prefix (because we don't have visibility set up), although here it should be ff_gradfun_.

> +static void filter(GradFunContext *ctx, uint8_t *dst, uint8_t *src, int width, int height, int dstride, int sstride, int r)
> +{
> +    int bstride = ((width + 15) & ~15) / 2;

FFALIGN(width, 16) / 2;

> +    gf->buf = av_mallocz((((inlink->w + 15) & ~15) * (gf->radius + 1) / 2 + 32) * sizeof(uint16_t));

Same thing here.



More information about the ffmpeg-devel mailing list