diff options
author | Paul B Mahol <onemda@gmail.com> | 2018-12-29 10:46:25 +0100 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2018-12-29 10:46:25 +0100 |
commit | 3c3eb4930eb49b3eee76a3ff6f127a78af886345 (patch) | |
tree | 0d9b31bf77014d52df6209d64c3613d26abe4161 /libavfilter/af_afir.c | |
parent | 31c9d693aa708ffdcbd51ed1d3eab35645a20c92 (diff) | |
download | ffmpeg-3c3eb4930eb49b3eee76a3ff6f127a78af886345.tar.gz |
avfilter/af_afir: make part_index values per channel
Diffstat (limited to 'libavfilter/af_afir.c')
-rw-r--r-- | libavfilter/af_afir.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c index 8733b76ebe..0d626063b5 100644 --- a/libavfilter/af_afir.c +++ b/libavfilter/af_afir.c @@ -67,7 +67,7 @@ static int fir_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs) int n, i, j; memset(sum, 0, sizeof(*sum) * seg->fft_length); - block = (float *)seg->block->extended_data[ch] + seg->part_index * seg->block_size; + block = (float *)seg->block->extended_data[ch] + seg->part_index[ch] * seg->block_size; memset(block, 0, sizeof(*block) * seg->fft_length); s->fdsp->vector_fmul_scalar(block, src, s->dry_gain, FFALIGN(out->nb_samples, 4)); @@ -77,7 +77,7 @@ static int fir_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs) block[2 * seg->part_size] = block[1]; block[1] = 0; - j = seg->part_index; + j = seg->part_index[ch]; for (i = 0; i < seg->nb_partitions; i++) { const int coffset = i * seg->coeff_size; @@ -106,6 +106,8 @@ static int fir_channel(AVFilterContext *ctx, void *arg, int ch, int nb_jobs) dst = (float *)seg->buffer->extended_data[ch]; memcpy(dst, sum + seg->part_size, seg->part_size * sizeof(*dst)); + seg->part_index[ch] = (seg->part_index[ch] + 1) % seg->nb_partitions; + return 0; } @@ -125,12 +127,6 @@ static int fir_frame(AudioFIRContext *s, AVFrame *in, AVFilterLink *outlink) s->in[0] = in; ctx->internal->execute(ctx, fir_channel, out, NULL, outlink->channels); - for (int segment = 0; segment < s->nb_segments; segment++) { - AudioFIRSegment *seg = &s->seg[segment]; - - seg->part_index = (seg->part_index + 1) % seg->nb_partitions; - } - out->pts = s->pts; if (s->pts != AV_NOPTS_VALUE) s->pts += av_rescale_q(out->nb_samples, (AVRational){1, outlink->sample_rate}, outlink->time_base); @@ -300,6 +296,10 @@ static int init_segment(AVFilterContext *ctx, AudioFIRSegment *seg, int nb_parti return AVERROR(ENOMEM); } + seg->part_index = av_calloc(ctx->inputs[0]->channels, sizeof(*seg->part_index)); + if (!seg->part_index) + return AVERROR(ENOMEM); + seg->sum = ff_get_audio_buffer(ctx->inputs[0], seg->fft_length); seg->block = ff_get_audio_buffer(ctx->inputs[0], seg->nb_partitions * seg->block_size); seg->buffer = ff_get_audio_buffer(ctx->inputs[0], seg->part_size); @@ -622,6 +622,8 @@ static void uninit_segment(AVFilterContext *ctx, AudioFIRSegment *seg) } av_freep(&seg->irdft); + av_freep(&seg->part_index); + av_frame_free(&seg->block); av_frame_free(&seg->sum); av_frame_free(&seg->buffer); |