summaryrefslogtreecommitdiff
path: root/libavfilter
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-08-26 06:10:47 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-09-09 13:47:40 +0200
commit990d9dd80000468ea4088cf318370b5045ea69d1 (patch)
treec0be537b546d51cda32bece58a65c4a8c42f616a /libavfilter
parentabe0a5dd0a87aa8f509a366910ed6e3ccc2bd281 (diff)
avfilter/af_headphone: Only keep one AVFrame at a time
Despite the headphone filter only using one AVFrame at a time, it kept an array each of whose entries contained a pointer to an AVFrame at all times; the pointers were mostly NULL. This commit instead replaces them by using a single pointer to an AVFrame on the stack of the only function that actually uses them. Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/af_headphone.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/libavfilter/af_headphone.c b/libavfilter/af_headphone.c
index d57ecb1f50..c84142e1ce 100644
--- a/libavfilter/af_headphone.c
+++ b/libavfilter/af_headphone.c
@@ -77,7 +77,6 @@ typedef struct HeadphoneContext {
AVFloatDSPContext *fdsp;
struct headphone_inputs {
- AVFrame *frame;
int ir_len;
int eof;
} *in;
@@ -367,6 +366,7 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink)
const int ir_len = s->ir_len;
int nb_input_channels = ctx->inputs[0]->channels;
float gain_lin = expf((s->gain - 3 * nb_input_channels) / 20 * M_LN10);
+ AVFrame *frame;
int ret = 0;
int n_fft;
int i, j, k;
@@ -432,14 +432,14 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink)
}
}
- for (i = 0; i < s->nb_inputs - 1; i++) {
+ for (i = 0; i < s->nb_inputs - 1; av_frame_free(&frame), i++) {
int len = s->in[i + 1].ir_len;
float *ptr;
- ret = ff_inlink_consume_samples(ctx->inputs[i + 1], len, len, &s->in[i + 1].frame);
+ ret = ff_inlink_consume_samples(ctx->inputs[i + 1], len, len, &frame);
if (ret < 0)
goto fail;
- ptr = (float *)s->in[i + 1].frame->extended_data[0];
+ ptr = (float *)frame->extended_data[0];
if (s->hrir_fmt == HRIR_STEREO) {
int idx = av_get_channel_layout_channel_index(inlink->channel_layout,
@@ -502,17 +502,11 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink)
}
}
}
-
- av_frame_free(&s->in[i + 1].frame);
}
s->have_hrirs = 1;
fail:
-
- for (i = 0; i < s->nb_inputs - 1; i++)
- av_frame_free(&s->in[i + 1].frame);
-
return ret;
}