Showing the changes to libavfilter (1 of 2 files). Show all
Unified · Split
| @@ -36,7 +36,7 @@ typedef struct ANoiseSrcContext { · 35 unmodified lines | ||
| 36 | 36 | |
| 37 | 37 | int64_t pts; |
| 38 | 38 | int infinite; |
| 39 | − double (*filter)(double white, double *buf); | |
| 39 | + double (*filter)(double white, double *buf, double half_amplitude); | |
| 40 | 40 | double buf[7]; |
| 41 | 41 | AVLFG c; |
| 42 | 42 | } ANoiseSrcContext; |
| @@ -47,6 +47,7 @@ enum NoiseMode { · 4 unmodified lines | ||
| 47 | 47 | NM_BROWN, |
| 48 | 48 | NM_BLUE, |
| 49 | 49 | NM_VIOLET, |
| 50 | + NM_VELVET, | |
| 50 | 51 | NM_NB |
| 51 | 52 | }; |
| 52 | 53 | |
| @@ -68,6 +69,7 @@ static const AVOption anoisesrc_options[] = { · 15 unmodified lines | ||
| 68 | 69 | { "brown", 0, 0, AV_OPT_TYPE_CONST, {.i64 = NM_BROWN}, 0, 0, FLAGS, "color" }, |
| 69 | 70 | { "blue", 0, 0, AV_OPT_TYPE_CONST, {.i64 = NM_BLUE}, 0, 0, FLAGS, "color" }, |
| 70 | 71 | { "violet", 0, 0, AV_OPT_TYPE_CONST, {.i64 = NM_VIOLET}, 0, 0, FLAGS, "color" }, |
| 72 | + { "velvet", 0, 0, AV_OPT_TYPE_CONST, {.i64 = NM_VELVET}, 0, 0, FLAGS, "color" }, | |
| 71 | 73 | { "seed", "set random seed", OFFSET(seed), AV_OPT_TYPE_INT64, {.i64 = -1}, -1, UINT_MAX, FLAGS }, |
| 72 | 74 | { "s", "set random seed", OFFSET(seed), AV_OPT_TYPE_INT64, {.i64 = -1}, -1, UINT_MAX, FLAGS }, |
| 73 | 75 | { "nb_samples", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.i64 = 1024}, 1, INT_MAX, FLAGS }, |
| @@ -111,12 +113,12 @@ static av_cold int query_formats(AVFilterContext *ctx) · 37 unmodified lines | ||
| 111 | 113 | return ff_set_common_samplerates(ctx, formats); |
| 112 | 114 | } |
| 113 | 115 | |
| 114 | −static double white_filter(double white, double *buf) | |
| 116 | +static double white_filter(double white, double *buf, double ha) | |
| 115 | 117 | { |
| 116 | 118 | return white; |
| 117 | 119 | } |
| 118 | 120 | |
| 119 | −static double pink_filter(double white, double *buf) | |
| 121 | +static double pink_filter(double white, double *buf, double ha) | |
| 120 | 122 | { |
| 121 | 123 | double pink; |
| 122 | 124 | |
| @@ -132,7 +134,7 @@ static double pink_filter(double white, double *buf) · 9 unmodified lines | ||
| 132 | 134 | return pink * 0.11; |
| 133 | 135 | } |
| 134 | 136 | |
| 135 | −static double blue_filter(double white, double *buf) | |
| 137 | +static double blue_filter(double white, double *buf, double ha) | |
| 136 | 138 | { |
| 137 | 139 | double blue; |
| 138 | 140 | |
| @@ -148,7 +150,7 @@ static double blue_filter(double white, double *buf) · 9 unmodified lines | ||
| 148 | 150 | return blue * 0.11; |
| 149 | 151 | } |
| 150 | 152 | |
| 151 | −static double brown_filter(double white, double *buf) | |
| 153 | +static double brown_filter(double white, double *buf, double ha) | |
| 152 | 154 | { |
| 153 | 155 | double brown; |
| 154 | 156 | |
| @@ -157,7 +159,7 @@ static double brown_filter(double white, double *buf) · 2 unmodified lines | ||
| 157 | 159 | return brown * 3.5; |
| 158 | 160 | } |
| 159 | 161 | |
| 160 | −static double violet_filter(double white, double *buf) | |
| 162 | +static double violet_filter(double white, double *buf, double ha) | |
| 161 | 163 | { |
| 162 | 164 | double violet; |
| 163 | 165 | |
| @@ -166,6 +168,11 @@ static double violet_filter(double white, double *buf) · 2 unmodified lines | ||
| 166 | 168 | return violet * 3.5; |
| 167 | 169 | } |
| 168 | 170 | |
| 171 | +static double velvet_filter(double white, double *buf, double ha) | |
| 172 | +{ | |
| 173 | + return 2. * ha * ((white > ha) - (white < -ha)); | |
| 174 | +} | |
| 175 | + | |
| 169 | 176 | static av_cold int config_props(AVFilterLink *outlink) |
| 170 | 177 | { |
| 171 | 178 | AVFilterContext *ctx = outlink->src; |
| @@ -185,6 +192,7 @@ static av_cold int config_props(AVFilterLink *outlink) · 13 unmodified lines | ||
| 185 | 192 | case NM_BROWN: s->filter = brown_filter; break; |
| 186 | 193 | case NM_BLUE: s->filter = blue_filter; break; |
| 187 | 194 | case NM_VIOLET: s->filter = violet_filter; break; |
| 195 | + case NM_VELVET: s->filter = velvet_filter; break; | |
| 188 | 196 | } |
| 189 | 197 | |
| 190 | 198 | return 0; |
| @@ -213,7 +221,7 @@ static int request_frame(AVFilterLink *outlink) · 22 unmodified lines | ||
| 213 | 221 | for (i = 0; i < nb_samples; i++) { |
| 214 | 222 | double white; |
| 215 | 223 | white = s->amplitude * ((2 * ((double) av_lfg_get(&s->c) / 0xffffffff)) - 1); |
| 216 | − dst[i] = s->filter(white, s->buf); | |
| 224 | + dst[i] = s->filter(white, s->buf, s->amplitude * 0.5); | |
| 217 | 225 | } |
| 218 | 226 | |
| 219 | 227 | if (!s->infinite) |