1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-15 14:13:16 +02:00

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>
This commit is contained in:
Andreas Rheinhardt
2020-08-26 06:10:47 +02:00
parent abe0a5dd0a
commit 990d9dd800

View File

@@ -77,7 +77,6 @@ typedef struct HeadphoneContext {
AVFloatDSPContext *fdsp; AVFloatDSPContext *fdsp;
struct headphone_inputs { struct headphone_inputs {
AVFrame *frame;
int ir_len; int ir_len;
int eof; int eof;
} *in; } *in;
@@ -367,6 +366,7 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink)
const int ir_len = s->ir_len; const int ir_len = s->ir_len;
int nb_input_channels = ctx->inputs[0]->channels; int nb_input_channels = ctx->inputs[0]->channels;
float gain_lin = expf((s->gain - 3 * nb_input_channels) / 20 * M_LN10); float gain_lin = expf((s->gain - 3 * nb_input_channels) / 20 * M_LN10);
AVFrame *frame;
int ret = 0; int ret = 0;
int n_fft; int n_fft;
int i, j, k; 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; int len = s->in[i + 1].ir_len;
float *ptr; 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) if (ret < 0)
goto fail; goto fail;
ptr = (float *)s->in[i + 1].frame->extended_data[0]; ptr = (float *)frame->extended_data[0];
if (s->hrir_fmt == HRIR_STEREO) { if (s->hrir_fmt == HRIR_STEREO) {
int idx = av_get_channel_layout_channel_index(inlink->channel_layout, 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; s->have_hrirs = 1;
fail: fail:
for (i = 0; i < s->nb_inputs - 1; i++)
av_frame_free(&s->in[i + 1].frame);
return ret; return ret;
} }