Commit 21d1bb00 authored by Paul B Mahol's avatar Paul B Mahol

avfilter/af_sofalizer: switch to activate

parent 21b1f08e
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "libavutil/intmath.h" #include "libavutil/intmath.h"
#include "libavutil/opt.h" #include "libavutil/opt.h"
#include "avfilter.h" #include "avfilter.h"
#include "filters.h"
#include "internal.h" #include "internal.h"
#include "audio.h" #include "audio.h"
...@@ -81,6 +82,7 @@ typedef struct SOFAlizerContext { ...@@ -81,6 +82,7 @@ typedef struct SOFAlizerContext {
int buffer_length; /* is: longest IR plus max. delay in all SOFA files */ int buffer_length; /* is: longest IR plus max. delay in all SOFA files */
/* then choose next power of 2 */ /* then choose next power of 2 */
int n_fft; /* number of samples in one FFT block */ int n_fft; /* number of samples in one FFT block */
int nb_samples;
/* netCDF variables */ /* netCDF variables */
int *delay[2]; /* broadband delay for each channel/IR to be convolved */ int *delay[2]; /* broadband delay for each channel/IR to be convolved */
...@@ -603,6 +605,31 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) ...@@ -603,6 +605,31 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
return ff_filter_frame(outlink, out); return ff_filter_frame(outlink, out);
} }
static int activate(AVFilterContext *ctx)
{
AVFilterLink *inlink = ctx->inputs[0];
AVFilterLink *outlink = ctx->outputs[0];
SOFAlizerContext *s = ctx->priv;
AVFrame *in;
int ret;
FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
if (s->nb_samples)
ret = ff_inlink_consume_samples(inlink, s->nb_samples, s->nb_samples, &in);
else
ret = ff_inlink_consume_frame(inlink, &in);
if (ret < 0)
return ret;
if (ret > 0)
return filter_frame(inlink, in);
FF_FILTER_FORWARD_STATUS(inlink, outlink);
FF_FILTER_FORWARD_WANTED(outlink, inlink);
return FFERROR_NOT_READY;
}
static int query_formats(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx)
{ {
struct SOFAlizerContext *s = ctx->priv; struct SOFAlizerContext *s = ctx->priv;
...@@ -964,11 +991,8 @@ static int config_input(AVFilterLink *inlink) ...@@ -964,11 +991,8 @@ static int config_input(AVFilterLink *inlink)
SOFAlizerContext *s = ctx->priv; SOFAlizerContext *s = ctx->priv;
int ret; int ret;
if (s->type == FREQUENCY_DOMAIN) { if (s->type == FREQUENCY_DOMAIN)
inlink->partial_buf_size = s->nb_samples = s->framesize;
inlink->min_samples =
inlink->max_samples = s->framesize;
}
/* gain -3 dB per channel */ /* gain -3 dB per channel */
s->gain_lfe = expf((s->gain - 3 * inlink->channels + s->lfe_gain) / 20 * M_LN10); s->gain_lfe = expf((s->gain - 3 * inlink->channels + s->lfe_gain) / 20 * M_LN10);
...@@ -1047,7 +1071,6 @@ static const AVFilterPad inputs[] = { ...@@ -1047,7 +1071,6 @@ static const AVFilterPad inputs[] = {
.name = "default", .name = "default",
.type = AVMEDIA_TYPE_AUDIO, .type = AVMEDIA_TYPE_AUDIO,
.config_props = config_input, .config_props = config_input,
.filter_frame = filter_frame,
}, },
{ NULL } { NULL }
}; };
...@@ -1066,6 +1089,7 @@ AVFilter ff_af_sofalizer = { ...@@ -1066,6 +1089,7 @@ AVFilter ff_af_sofalizer = {
.priv_size = sizeof(SOFAlizerContext), .priv_size = sizeof(SOFAlizerContext),
.priv_class = &sofalizer_class, .priv_class = &sofalizer_class,
.init = init, .init = init,
.activate = activate,
.uninit = uninit, .uninit = uninit,
.query_formats = query_formats, .query_formats = query_formats,
.inputs = inputs, .inputs = inputs,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment