Unified · Split
| @@ -236,7 +236,7 @@ static double min_gain(AVFilterContext *ctx, ChannelContext *cc, int max_size) · 235 unmodified lines | |||
| 236 | return min_gain; | 236 | return min_gain; |
| 237 | } | 237 | } |
| 238 | 238 | ||
| 239 | #define ANALYZE_CHANNEL(name, ptype, zero) \ | 239 | #define ANALYZE_CHANNEL(name, ptype, zero, min_peak) \ |
| 240 | static void analyze_channel_## name (AVFilterContext *ctx, ChannelContext *cc, \ | 240 | static void analyze_channel_## name (AVFilterContext *ctx, ChannelContext *cc, \ |
| 241 | const uint8_t *srcp, int nb_samples) \ | 241 | const uint8_t *srcp, int nb_samples) \ |
| 242 | { \ | 242 | { \ |
| @@ -250,11 +250,11 @@ static void analyze_channel_## name (AVFilterContext *ctx, ChannelContext *cc, · 7 unmodified lines | |||
| 250 | while (n < nb_samples) { \ | 250 | while (n < nb_samples) { \ |
| 251 | if ((cc->state != (src[n] >= zero)) || \ | 251 | if ((cc->state != (src[n] >= zero)) || \ |
| 252 | (cc->pi[cc->pi_end].size > s->max_period)) { \ | 252 | (cc->pi[cc->pi_end].size > s->max_period)) { \ |
| 253 | double max_peak = cc->pi[cc->pi_end].max_peak; \ | 253 | ptype max_peak = cc->pi[cc->pi_end].max_peak; \ |
| 254 | int state = cc->state; \ | 254 | int state = cc->state; \ |
| 255 | cc->state = src[n] >= zero; \ | 255 | cc->state = src[n] >= zero; \ |
| 256 | av_assert0(cc->pi[cc->pi_end].size > 0); \ | 256 | av_assert0(cc->pi[cc->pi_end].size > 0); \ |
| 257 | if (cc->pi[cc->pi_end].max_peak >= MIN_PEAK || \ | 257 | if (max_peak >= min_peak || \ |
| 258 | cc->pi[cc->pi_end].size > s->max_period) { \ | 258 | cc->pi[cc->pi_end].size > s->max_period) { \ |
| 259 | cc->pi[cc->pi_end].type = 1; \ | 259 | cc->pi[cc->pi_end].type = 1; \ |
| 260 | cc->pi_end++; \ | 260 | cc->pi_end++; \ |
| @@ -290,8 +290,8 @@ static void analyze_channel_## name (AVFilterContext *ctx, ChannelContext *cc, · 29 unmodified lines | |||
| 290 | } \ | 290 | } \ |
| 291 | } | 291 | } |
| 292 | 292 | ||
| 293 | ANALYZE_CHANNEL(dbl, double, 0.0) | 293 | ANALYZE_CHANNEL(dbl, double, 0.0, MIN_PEAK) |
| 294 | ANALYZE_CHANNEL(flt, float, 0.f) | 294 | ANALYZE_CHANNEL(flt, float, 0.f, (float)MIN_PEAK) |
| 295 | 295 | ||
| 296 | #define FILTER_CHANNELS(name, ptype) \ | 296 | #define FILTER_CHANNELS(name, ptype) \ |
| 297 | static void filter_channels_## name (AVFilterContext *ctx, \ | 297 | static void filter_channels_## name (AVFilterContext *ctx, \ |
| @@ -325,12 +325,17 @@ static void filter_channels_## name (AVFilterContext *ctx, · 27 unmodified lines | |||
| 325 | FILTER_CHANNELS(dbl, double) | 325 | FILTER_CHANNELS(dbl, double) |
| 326 | FILTER_CHANNELS(flt, float) | 326 | FILTER_CHANNELS(flt, float) |
| 327 | 327 | ||
| 328 | static double lerp(double min, double max, double mix) | 328 | static double dlerp(double min, double max, double mix) |
| 329 | { | 329 | { |
| 330 | return min + (max - min) * mix; | 330 | return min + (max - min) * mix; |
| 331 | } | 331 | } |
| 332 | 332 | ||
| 333 | #define FILTER_LINK_CHANNELS(name, ptype) \ | 333 | static float flerp(float min, float max, float mix) |
| 334 | { | ||
| 335 | return min + (max - min) * mix; | ||
| 336 | } | ||
| 337 | |||
| 338 | #define FILTER_LINK_CHANNELS(name, ptype, tlerp) \ | ||
| 334 | static void filter_link_channels_## name (AVFilterContext *ctx, \ | 339 | static void filter_link_channels_## name (AVFilterContext *ctx, \ |
| 335 | AVFrame *in, int nb_samples) \ | 340 | AVFrame *in, int nb_samples) \ |
| 336 | { \ | 341 | { \ |
| @@ -371,7 +376,7 @@ static void filter_link_channels_## name (AVFilterContext *ctx, · 34 unmodified lines | |||
| 371 | continue; \ | 376 | continue; \ |
| 372 | \ | 377 | \ |
| 373 | for (int i = n; i < n + min_size; i++) { \ | 378 | for (int i = n; i < n + min_size; i++) { \ |
| 374 | ptype g = lerp(s->prev_gain, gain, (i - n) / (double)min_size); \ | 379 | ptype g = tlerp(s->prev_gain, gain, (i - n) / (ptype)min_size); \ |
| 375 | dst[i] *= g; \ | 380 | dst[i] *= g; \ |
| 376 | } \ | 381 | } \ |
| 377 | } \ | 382 | } \ |
| @@ -381,8 +386,8 @@ static void filter_link_channels_## name (AVFilterContext *ctx, · 3 unmodified lines | |||
| 381 | } \ | 386 | } \ |
| 382 | } | 387 | } |
| 383 | 388 | ||
| 384 | FILTER_LINK_CHANNELS(dbl, double) | 389 | FILTER_LINK_CHANNELS(dbl, double, dlerp) |
| 385 | FILTER_LINK_CHANNELS(flt, float) | 390 | FILTER_LINK_CHANNELS(flt, float, flerp) |
| 386 | 391 | ||
| 387 | static int filter_frame(AVFilterContext *ctx) | 392 | static int filter_frame(AVFilterContext *ctx) |
| 388 | { | 393 | { |