| @@ -63,7 +63,28 @@ static int fir_channel(AVFilterContext *ctx, AVFrame *out, int ch) · 62 unmodified lines |
| 63 | for (int offset = 0; offset < out->nb_samples; offset += min_part_size) { | 63 | for (int offset = 0; offset < out->nb_samples; offset += min_part_size) { |
| 64 | switch (s->format) { | 64 | switch (s->format) { |
| 65 | case AV_SAMPLE_FMT_FLTP: | 65 | case AV_SAMPLE_FMT_FLTP: |
| 66 | if (prev_selir != selir && s->loading[ch] != 0) { | 66 | if (ctx->is_disabled || s->prev_is_disabled) { |
| | 67 | const float *in = (const float *)s->in->extended_data[ch] + offset; |
| | 68 | const float *xfade0 = (const float *)s->xfade[0]->extended_data[ch]; |
| | 69 | const float *xfade1 = (const float *)s->xfade[1]->extended_data[ch]; |
| | 70 | float *src0 = (float *)s->fadein[0]->extended_data[ch]; |
| | 71 | float *src1 = (float *)s->fadein[1]->extended_data[ch]; |
| | 72 | float *dst = ((float *)out->extended_data[ch]) + offset; |
| | 73 | |
| | 74 | if (ctx->is_disabled && !s->prev_is_disabled) { |
| | 75 | memset(src0, 0, min_part_size * sizeof(float)); |
| | 76 | fir_quantum_float(ctx, s->fadein[0], ch, offset, 0, selir); |
| | 77 | for (int n = 0; n < min_part_size; n++) |
| | 78 | dst[n] = xfade1[n] * src0[n] + xfade0[n] * in[n]; |
| | 79 | } else if (!ctx->is_disabled && s->prev_is_disabled) { |
| | 80 | memset(src1, 0, min_part_size * sizeof(float)); |
| | 81 | fir_quantum_float(ctx, s->fadein[1], ch, offset, 0, selir); |
| | 82 | for (int n = 0; n < min_part_size; n++) |
| | 83 | dst[n] = xfade1[n] * in[n] + xfade0[n] * src1[n]; |
| | 84 | } else { |
| | 85 | memcpy(dst, in, sizeof(float) * min_part_size); |
| | 86 | } |
| | 87 | } else if (prev_selir != selir && s->loading[ch] != 0) { |
| 67 | const float *xfade0 = (const float *)s->xfade[0]->extended_data[ch]; | 88 | const float *xfade0 = (const float *)s->xfade[0]->extended_data[ch]; |
| 68 | const float *xfade1 = (const float *)s->xfade[1]->extended_data[ch]; | 89 | const float *xfade1 = (const float *)s->xfade[1]->extended_data[ch]; |
| 69 | float *src0 = (float *)s->fadein[0]->extended_data[ch]; | 90 | float *src0 = (float *)s->fadein[0]->extended_data[ch]; |
| @@ -88,7 +109,28 @@ static int fir_channel(AVFilterContext *ctx, AVFrame *out, int ch) · 18 unmodified lines |
| 88 | } | 109 | } |
| 89 | break; | 110 | break; |
| 90 | case AV_SAMPLE_FMT_DBLP: | 111 | case AV_SAMPLE_FMT_DBLP: |
| 91 | if (prev_selir != selir && s->loading[ch] != 0) { | 112 | if (ctx->is_disabled || s->prev_is_disabled) { |
| | 113 | const double *in = (const double *)s->in->extended_data[ch] + offset; |
| | 114 | const double *xfade0 = (const double *)s->xfade[0]->extended_data[ch]; |
| | 115 | const double *xfade1 = (const double *)s->xfade[1]->extended_data[ch]; |
| | 116 | double *src0 = (double *)s->fadein[0]->extended_data[ch]; |
| | 117 | double *src1 = (double *)s->fadein[1]->extended_data[ch]; |
| | 118 | double *dst = ((double *)out->extended_data[ch]) + offset; |
| | 119 | |
| | 120 | if (ctx->is_disabled && !s->prev_is_disabled) { |
| | 121 | memset(src0, 0, min_part_size * sizeof(double)); |
| | 122 | fir_quantum_double(ctx, s->fadein[0], ch, offset, 0, selir); |
| | 123 | for (int n = 0; n < min_part_size; n++) |
| | 124 | dst[n] = xfade1[n] * src0[n] + xfade0[n] * in[n]; |
| | 125 | } else if (!ctx->is_disabled && s->prev_is_disabled) { |
| | 126 | memset(src1, 0, min_part_size * sizeof(double)); |
| | 127 | fir_quantum_double(ctx, s->fadein[1], ch, offset, 0, selir); |
| | 128 | for (int n = 0; n < min_part_size; n++) |
| | 129 | dst[n] = xfade1[n] * in[n] + xfade0[n] * src1[n]; |
| | 130 | } else { |
| | 131 | memcpy(dst, in, sizeof(double) * min_part_size); |
| | 132 | } |
| | 133 | } else if (prev_selir != selir && s->loading[ch] != 0) { |
| 92 | const double *xfade0 = (const double *)s->xfade[0]->extended_data[ch]; | 134 | const double *xfade0 = (const double *)s->xfade[0]->extended_data[ch]; |
| 93 | const double *xfade1 = (const double *)s->xfade[1]->extended_data[ch]; | 135 | const double *xfade1 = (const double *)s->xfade[1]->extended_data[ch]; |
| 94 | double *src0 = (double *)s->fadein[0]->extended_data[ch]; | 136 | double *src0 = (double *)s->fadein[0]->extended_data[ch]; |
| @@ -149,6 +191,7 @@ static int fir_frame(AudioFIRContext *s, AVFrame *in, AVFilterLink *outlink) · 54 unmodified lines |
| 149 | s->in = in; | 191 | s->in = in; |
| 150 | ff_filter_execute(ctx, fir_channels, out, NULL, | 192 | ff_filter_execute(ctx, fir_channels, out, NULL, |
| 151 | FFMIN(outlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx))); | 193 | FFMIN(outlink->ch_layout.nb_channels, ff_filter_get_nb_threads(ctx))); |
| | 194 | s->prev_is_disabled = ctx->is_disabled; |
| 152 | | 195 | |
| 153 | av_frame_free(&in); | 196 | av_frame_free(&in); |
| 154 | s->in = NULL; | 197 | s->in = NULL; |
| @@ -762,5 +805,6 @@ const AVFilter ff_af_afir = { · 607 unmodified lines |
| 762 | .process_command = process_command, | 805 | .process_command = process_command, |
| 763 | .flags = AVFILTER_FLAG_DYNAMIC_INPUTS | | 806 | .flags = AVFILTER_FLAG_DYNAMIC_INPUTS | |
| 764 | AVFILTER_FLAG_DYNAMIC_OUTPUTS | | 807 | AVFILTER_FLAG_DYNAMIC_OUTPUTS | |
| | 808 | AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | |
| 765 | AVFILTER_FLAG_SLICE_THREADS, | 809 | AVFILTER_FLAG_SLICE_THREADS, |
| 766 | }; | 810 | }; |