avfilter/af_adenorm: simplify handling of commands

This commit is contained in:
Paul B Mahol 2022-04-13 21:55:22 +02:00
parent 24144af2dd
commit bf6735e945
1 changed files with 17 additions and 42 deletions

View File

@ -39,8 +39,8 @@ typedef struct ADenormContext {
int type; int type;
int64_t in_samples; int64_t in_samples;
void (*filter)(AVFilterContext *ctx, void *dst, void (*filter[NB_TYPES])(AVFilterContext *ctx, void *dst,
const void *src, int nb_samples); const void *src, int nb_samples);
} ADenormContext; } ADenormContext;
static void dc_denorm_fltp(AVFilterContext *ctx, void *dstp, static void dc_denorm_fltp(AVFilterContext *ctx, void *dstp,
@ -158,30 +158,18 @@ static int config_output(AVFilterLink *outlink)
AVFilterContext *ctx = outlink->src; AVFilterContext *ctx = outlink->src;
ADenormContext *s = ctx->priv; ADenormContext *s = ctx->priv;
switch (s->type) { switch (outlink->format) {
case DC_TYPE: case AV_SAMPLE_FMT_FLTP:
switch (outlink->format) { s->filter[DC_TYPE] = dc_denorm_fltp;
case AV_SAMPLE_FMT_FLTP: s->filter = dc_denorm_fltp; break; s->filter[AC_TYPE] = ac_denorm_fltp;
case AV_SAMPLE_FMT_DBLP: s->filter = dc_denorm_dblp; break; s->filter[SQ_TYPE] = sq_denorm_fltp;
} s->filter[PS_TYPE] = ps_denorm_fltp;
break; break;
case AC_TYPE: case AV_SAMPLE_FMT_DBLP:
switch (outlink->format) { s->filter[DC_TYPE] = dc_denorm_dblp;
case AV_SAMPLE_FMT_FLTP: s->filter = ac_denorm_fltp; break; s->filter[AC_TYPE] = ac_denorm_dblp;
case AV_SAMPLE_FMT_DBLP: s->filter = ac_denorm_dblp; break; s->filter[SQ_TYPE] = sq_denorm_dblp;
} s->filter[PS_TYPE] = ps_denorm_dblp;
break;
case SQ_TYPE:
switch (outlink->format) {
case AV_SAMPLE_FMT_FLTP: s->filter = sq_denorm_fltp; break;
case AV_SAMPLE_FMT_DBLP: s->filter = sq_denorm_dblp; break;
}
break;
case PS_TYPE:
switch (outlink->format) {
case AV_SAMPLE_FMT_FLTP: s->filter = ps_denorm_fltp; break;
case AV_SAMPLE_FMT_DBLP: s->filter = ps_denorm_dblp; break;
}
break; break;
default: default:
av_assert0(0); av_assert0(0);
@ -204,9 +192,9 @@ static int filter_channels(AVFilterContext *ctx, void *arg, int jobnr, int nb_jo
const int end = (in->ch_layout.nb_channels * (jobnr+1)) / nb_jobs; const int end = (in->ch_layout.nb_channels * (jobnr+1)) / nb_jobs;
for (int ch = start; ch < end; ch++) { for (int ch = start; ch < end; ch++) {
s->filter(ctx, out->extended_data[ch], s->filter[s->type](ctx, out->extended_data[ch],
in->extended_data[ch], in->extended_data[ch],
in->nb_samples); in->nb_samples);
} }
return 0; return 0;
@ -243,19 +231,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
return ff_filter_frame(outlink, out); return ff_filter_frame(outlink, out);
} }
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
char *res, int res_len, int flags)
{
AVFilterLink *outlink = ctx->outputs[0];
int ret;
ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags);
if (ret < 0)
return ret;
return config_output(outlink);
}
static const AVFilterPad adenorm_inputs[] = { static const AVFilterPad adenorm_inputs[] = {
{ {
.name = "default", .name = "default",
@ -295,7 +270,7 @@ const AVFilter ff_af_adenorm = {
FILTER_OUTPUTS(adenorm_outputs), FILTER_OUTPUTS(adenorm_outputs),
FILTER_SAMPLEFMTS(AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_DBLP), FILTER_SAMPLEFMTS(AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_DBLP),
.priv_class = &adenorm_class, .priv_class = &adenorm_class,
.process_command = process_command, .process_command = ff_filter_process_command,
.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC |
AVFILTER_FLAG_SLICE_THREADS, AVFILTER_FLAG_SLICE_THREADS,
}; };