Unified · Split
| @@ -94,7 +94,6 @@ typedef struct SilenceRemoveContext { · 93 unmodified lines | |||
| 94 | int64_t window_duration; | 94 | int64_t window_duration; |
| 95 | double sum; | 95 | double sum; |
| 96 | 96 | ||
| 97 | int threshold; | ||
| 98 | int one_period; | 97 | int one_period; |
| 99 | int restart; | 98 | int restart; |
| 100 | int64_t next_pts; | 99 | int64_t next_pts; |
| @@ -435,7 +434,6 @@ static int config_input(AVFilterLink *inlink) · 334 unmodified lines | |||
| 435 | AVFilterContext *ctx = inlink->dst; | 434 | AVFilterContext *ctx = inlink->dst; |
| 436 | SilenceRemoveContext *s = ctx->priv; | 435 | SilenceRemoveContext *s = ctx->priv; |
| 437 | 436 | ||
| 438 | s->threshold = -1; | ||
| 439 | s->next_pts = AV_NOPTS_VALUE; | 437 | s->next_pts = AV_NOPTS_VALUE; |
| 440 | s->window_duration = av_rescale(s->window_duration_opt, inlink->sample_rate, | 438 | s->window_duration = av_rescale(s->window_duration_opt, inlink->sample_rate, |
| 441 | AV_TIME_BASE); | 439 | AV_TIME_BASE); |
| @@ -629,10 +627,6 @@ silence_trim: · 187 unmodified lines | |||
| 629 | } | 627 | } |
| 630 | } | 628 | } |
| 631 | 629 | ||
| 632 | if (s->threshold >= 0) | ||
| 633 | s->one_period = s->threshold != threshold; | ||
| 634 | s->threshold = threshold; | ||
| 635 | |||
| 636 | if (threshold) { | 630 | if (threshold) { |
| 637 | for (j = 0; j < outlink->channels; j++) { | 631 | for (j = 0; j < outlink->channels; j++) { |
| 638 | s->update(s, in, j, nb_samples_read); | 632 | s->update(s, in, j, nb_samples_read); |
| @@ -646,7 +640,8 @@ silence_trim: · 7 unmodified lines | |||
| 646 | nb_samples_read++; | 640 | nb_samples_read++; |
| 647 | 641 | ||
| 648 | if (s->start_holdoff_end >= s->start_duration) { | 642 | if (s->start_holdoff_end >= s->start_duration) { |
| 649 | s->start_found_periods += s->one_period; | 643 | s->start_found_periods += s->one_period >= 1; |
| 644 | s->one_period = 0; | ||
| 650 | if (s->start_found_periods >= s->start_periods) { | 645 | if (s->start_found_periods >= s->start_periods) { |
| 651 | s->mode = SILENCE_TRIM_FLUSH; | 646 | s->mode = SILENCE_TRIM_FLUSH; |
| 652 | goto silence_trim_flush; | 647 | goto silence_trim_flush; |
| @@ -659,6 +654,7 @@ silence_trim: · 6 unmodified lines | |||
| 659 | } | 654 | } |
| 660 | } else { | 655 | } else { |
| 661 | s->start_holdoff_end = 0; | 656 | s->start_holdoff_end = 0; |
| 657 | s->one_period++; | ||
| 662 | 658 | ||
| 663 | for (j = 0; j < outlink->channels; j++) { | 659 | for (j = 0; j < outlink->channels; j++) { |
| 664 | s->update(s, in, j, nb_samples_read); | 660 | s->update(s, in, j, nb_samples_read); |
| @@ -755,13 +751,10 @@ silence_copy: · 90 unmodified lines | |||
| 755 | } | 751 | } |
| 756 | } | 752 | } |
| 757 | 753 | ||
| 758 | if (s->threshold >= 0) | ||
| 759 | s->one_period = s->threshold != threshold; | ||
| 760 | s->threshold = threshold; | ||
| 761 | |||
| 762 | if (threshold && s->stop_holdoff_end && !s->stop_silence) { | 754 | if (threshold && s->stop_holdoff_end && !s->stop_silence) { |
| 763 | s->mode = SILENCE_COPY_FLUSH; | 755 | s->mode = SILENCE_COPY_FLUSH; |
| 764 | flush(s, out, outlink, &nb_samples_written, 0); | 756 | flush(s, out, outlink, &nb_samples_written, 0); |
| 757 | s->one_period++; | ||
| 765 | goto silence_copy_flush; | 758 | goto silence_copy_flush; |
| 766 | } else if (threshold) { | 759 | } else if (threshold) { |
| 767 | for (j = 0; j < outlink->channels; j++) { | 760 | for (j = 0; j < outlink->channels; j++) { |
| @@ -774,6 +767,7 @@ silence_copy: · 6 unmodified lines | |||
| 774 | s->window_offset = 0; | 767 | s->window_offset = 0; |
| 775 | nb_samples_read++; | 768 | nb_samples_read++; |
| 776 | nb_samples_written++; | 769 | nb_samples_written++; |
| 770 | s->one_period++; | ||
| 777 | } else if (!threshold) { | 771 | } else if (!threshold) { |
| 778 | for (j = 0; j < outlink->channels; j++) { | 772 | for (j = 0; j < outlink->channels; j++) { |
| 779 | s->update(s, in, j, nb_samples_read); | 773 | s->update(s, in, j, nb_samples_read); |
| @@ -798,7 +792,8 @@ silence_copy: · 18 unmodified lines | |||
| 798 | s->stop_holdoff_end++; | 792 | s->stop_holdoff_end++; |
| 799 | 793 | ||
| 800 | if (s->stop_holdoff_end >= s->stop_duration) { | 794 | if (s->stop_holdoff_end >= s->stop_duration) { |
| 801 | s->stop_found_periods += s->one_period; | 795 | s->stop_found_periods += s->one_period >= 1; |
| 796 | s->one_period = 0; | ||
| 802 | if (s->stop_found_periods >= s->stop_periods) { | 797 | if (s->stop_found_periods >= s->stop_periods) { |
| 803 | s->stop_holdoff_offset = 0; | 798 | s->stop_holdoff_offset = 0; |
| 804 | s->stop_holdoff_end = 0; | 799 | s->stop_holdoff_end = 0; |
| @@ -826,6 +821,7 @@ silence_copy: · 21 unmodified lines | |||
| 826 | } | 821 | } |
| 827 | } | 822 | } |
| 828 | } | 823 | } |
| 824 | s->one_period++; | ||
| 829 | flush(s, out, outlink, &nb_samples_written, 0); | 825 | flush(s, out, outlink, &nb_samples_written, 0); |
| 830 | } else { | 826 | } else { |
| 831 | av_samples_copy(out->extended_data, in->extended_data, | 827 | av_samples_copy(out->extended_data, in->extended_data, |