[FFmpeg-cvslog] avfilter/af_afir: make part_index values per channel
Paul B Mahol
git at videolan.org
Sun Dec 30 14:42:57 EET 2018
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sat Dec 29 10:46:25 2018 +0100| [3c3eb4930eb49b3eee76a3ff6f127a78af886345] | committer: Paul B Mahol
avfilter/af_afir: make part_index values per channel
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3c3eb4930eb49b3eee76a3ff6f127a78af886345
---
libavfilter/af_afir.c | 18 ++++++++++--------
libavfilter/af_afir.h | 3 ++-
2 files changed, 12 insertions(+), 9 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);
diff --git a/libavfilter/af_afir.h b/libavfilter/af_afir.h
index 4b35920fd8..f71ff34a0e 100644
--- a/libavfilter/af_afir.h
+++ b/libavfilter/af_afir.h
@@ -33,13 +33,14 @@
typedef struct AudioFIRSegment {
int nb_partitions;
- int part_index;
int part_size;
int block_size;
int fft_length;
int coeff_size;
int segment_size;
+ int *part_index;
+
AVFrame *sum;
AVFrame *block;
AVFrame *buffer;
More information about the ffmpeg-cvslog
mailing list