[FFmpeg-cvslog] avfilter/af_headphone: Only keep one AVFrame at a time
Andreas Rheinhardt
git at videolan.org
Wed Sep 9 16:00:14 EEST 2020
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Wed Aug 26 06:10:47 2020 +0200| [990d9dd80000468ea4088cf318370b5045ea69d1] | committer: Andreas Rheinhardt
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 at gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=990d9dd80000468ea4088cf318370b5045ea69d1
---
libavfilter/af_headphone.c | 14 ++++----------
1 file 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;
}
More information about the ffmpeg-cvslog
mailing list