[FFmpeg-devel] [PATCH] avfilter: Add blue and violet noise generation filters

Moritz Barsnick barsnick at gmx.net
Wed Jul 19 14:39:37 EEST 2017


On Wed, Jul 19, 2017 at 07:59:33 +0200, george at spotify.com wrote:
> For the blue and violet noise, I took the pink and brown noise
> respectively and subtracted the offsets instead of adding them. When I

Cool.

> -    { "color",        "set noise color",  OFFSET(color),        AV_OPT_TYPE_INT,       {.i64 =  1},      0,  2,          FLAGS, "color" },
> -    { "colour",       "set noise color",  OFFSET(color),        AV_OPT_TYPE_INT,       {.i64 =  1},      0,  2,          FLAGS, "color" },
> -    { "c",            "set noise color",  OFFSET(color),        AV_OPT_TYPE_INT,       {.i64 =  0},      0,  2,          FLAGS, "color" },
> +    { "color",        "set noise color",  OFFSET(color),        AV_OPT_TYPE_INT,       {.i64 =  1},      0,  4,          FLAGS, "color" },
> +    { "colour",       "set noise color",  OFFSET(color),        AV_OPT_TYPE_INT,       {.i64 =  1},      0,  4,          FLAGS, "color" },
> +    { "c",            "set noise color",  OFFSET(color),        AV_OPT_TYPE_INT,       {.i64 =  0},      0,  4,          FLAGS, "color" },

At this point, it's probably worth adding an enum.

enum NoiseMode {
    NM_WHITE,
    NM_PINK,
[...]
    NM_NB
};

and setting the option's max to "NM_NB-1" instead of "4".

>      switch (s->color) {
> -    case 0: s->filter = white_filter; break;
> -    case 1: s->filter = pink_filter;  break;
> -    case 2: s->filter = brown_filter; break;
> +    case 0: s->filter = white_filter;  break;
> +    case 1: s->filter = pink_filter;   break;
> +    case 2: s->filter = brown_filter;  break;
> +    case 3: s->filter = blue_filter;   break;
> +    case 4: s->filter = violet_filter; break;

And use the enums here.

Just a suggestion...

Cheers,
Moritz


More information about the ffmpeg-devel mailing list