Showing the changes to libavfilter (2 of 2 files). Show all
Unified · Split
| @@ -94,6 +94,7 @@ typedef struct SilenceRemoveContext { · 93 unmodified lines | |||
| 94 | int *stop_back; | 94 | int *stop_back; |
| 95 | 95 | ||
| 96 | int64_t window_duration; | 96 | int64_t window_duration; |
| 97 | int cache_size; | ||
| 97 | 98 | ||
| 98 | int start_window_pos; | 99 | int start_window_pos; |
| 99 | int start_window_size; | 100 | int start_window_size; |
| @@ -224,10 +225,22 @@ static int config_output(AVFilterLink *outlink) · 124 unmodified lines | |||
| 224 | AVFilterContext *ctx = outlink->src; | 225 | AVFilterContext *ctx = outlink->src; |
| 225 | SilenceRemoveContext *s = ctx->priv; | 226 | SilenceRemoveContext *s = ctx->priv; |
| 226 | 227 | ||
| 228 | switch (s->detection) { | ||
| 229 | case D_AVG: | ||
| 230 | case D_RMS: | ||
| 231 | s->cache_size = 1; | ||
| 232 | break; | ||
| 233 | case D_MEDIAN: | ||
| 234 | case D_PEAK: | ||
| 235 | case D_PTP: | ||
| 236 | s->cache_size = s->window_duration; | ||
| 237 | break; | ||
| 238 | } | ||
| 239 | |||
| 227 | s->start_window = ff_get_audio_buffer(outlink, s->window_duration); | 240 | s->start_window = ff_get_audio_buffer(outlink, s->window_duration); |
| 228 | s->stop_window = ff_get_audio_buffer(outlink, s->window_duration); | 241 | s->stop_window = ff_get_audio_buffer(outlink, s->window_duration); |
| 229 | s->start_cache = av_calloc(outlink->ch_layout.nb_channels, s->window_duration * sizeof(*s->start_cache)); | 242 | s->start_cache = av_calloc(outlink->ch_layout.nb_channels, s->cache_size * sizeof(*s->start_cache)); |
| 230 | s->stop_cache = av_calloc(outlink->ch_layout.nb_channels, s->window_duration * sizeof(*s->stop_cache)); | 243 | s->stop_cache = av_calloc(outlink->ch_layout.nb_channels, s->cache_size * sizeof(*s->stop_cache)); |
| 231 | if (!s->start_window || !s->stop_window || !s->start_cache || !s->stop_cache) | 244 | if (!s->start_window || !s->stop_window || !s->start_cache || !s->stop_cache) |
| 232 | return AVERROR(ENOMEM); | 245 | return AVERROR(ENOMEM); |
| 233 | 246 | ||
| @@ -328,6 +328,7 @@ static void fn(filter_start)(AVFilterContext *ctx, · 327 unmodified lines | |||
| 328 | ftype *start_cache = (ftype *)s->start_cache; | 328 | ftype *start_cache = (ftype *)s->start_cache; |
| 329 | const int start_silence = s->start_silence; | 329 | const int start_silence = s->start_silence; |
| 330 | int window_size = start_window_nb_samples; | 330 | int window_size = start_window_nb_samples; |
| 331 | const int cache_size = s->cache_size; | ||
| 331 | int *front = s->start_front; | 332 | int *front = s->start_front; |
| 332 | int *back = s->start_back; | 333 | int *back = s->start_back; |
| 333 | 334 | ||
| @@ -352,7 +353,7 @@ static void fn(filter_start)(AVFilterContext *ctx, · 18 unmodified lines | |||
| 352 | ftype start_ow = startw[start_wpos + ch]; | 353 | ftype start_ow = startw[start_wpos + ch]; |
| 353 | ftype tstart; | 354 | ftype tstart; |
| 354 | 355 | ||
| 355 | tstart = fn(s->compute)(start_cache + ch * start_window_nb_samples, | 356 | tstart = fn(s->compute)(start_cache + ch * cache_size, |
| 356 | start_sample, | 357 | start_sample, |
| 357 | start_ow, | 358 | start_ow, |
| 358 | window_size, | 359 | window_size, |
| @@ -423,8 +424,9 @@ static void fn(filter_stop)(AVFilterContext *ctx, · 64 unmodified lines | |||
| 423 | const int stop_duration = s->stop_duration; | 424 | const int stop_duration = s->stop_duration; |
| 424 | ftype *stop_cache = (ftype *)s->stop_cache; | 425 | ftype *stop_cache = (ftype *)s->stop_cache; |
| 425 | const int stop_silence = s->stop_silence; | 426 | const int stop_silence = s->stop_silence; |
| 426 | const int restart = s->restart; | ||
| 427 | int window_size = stop_window_nb_samples; | 427 | int window_size = stop_window_nb_samples; |
| 428 | const int cache_size = s->cache_size; | ||
| 429 | const int restart = s->restart; | ||
| 428 | int *front = s->stop_front; | 430 | int *front = s->stop_front; |
| 429 | int *back = s->stop_back; | 431 | int *back = s->stop_back; |
| 430 | 432 | ||
| @@ -446,7 +448,7 @@ static void fn(filter_stop)(AVFilterContext *ctx, · 15 unmodified lines | |||
| 446 | ftype stop_ow = stopw[stop_wpos + ch]; | 448 | ftype stop_ow = stopw[stop_wpos + ch]; |
| 447 | ftype tstop; | 449 | ftype tstop; |
| 448 | 450 | ||
| 449 | tstop = fn(s->compute)(stop_cache + ch * stop_window_nb_samples, | 451 | tstop = fn(s->compute)(stop_cache + ch * cache_size, |
| 450 | stop_sample, | 452 | stop_sample, |
| 451 | stop_ow, | 453 | stop_ow, |
| 452 | window_size, | 454 | window_size, |