avfilter/af_aquant: add timeline support

This commit is contained in:
Paul B Mahol 2024-10-08 18:51:10 +02:00
parent 4466f67426
commit d47a05a263
2 changed files with 14 additions and 1 deletions

View File

@ -266,6 +266,7 @@ const AVFilter ff_af_aquant = {
FILTER_QUERY_FUNC2(query_formats),
.flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS |
AVFILTER_FLAG_DYNAMIC_INPUTS |
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL |
AVFILTER_FLAG_SLICE_THREADS,
.process_command = ff_filter_process_command,
};

View File

@ -37,6 +37,7 @@
static int fn(shaper_channels)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
{
const int is_disabled = ctx->is_disabled;
AudioQuantContext *s = ctx->priv;
AVFrame **frames = s->frame;
AVFrame **outs = arg;
@ -54,7 +55,10 @@ static int fn(shaper_channels)(AVFilterContext *ctx, void *arg, int jobnr, int n
ftype *output = (ftype *)out0->extended_data[c];
ftype *error = (ftype *)out1->extended_data[c];
if (filter) {
if (is_disabled) {
for (int n = 0; n < nb_samples; n++)
output[n] = input[n];
} else if (filter) {
for (int n = 0; n < nb_samples; n++) {
const ftype wanted = input[n] - filter[n];
@ -76,6 +80,7 @@ static int fn(shaper_channels)(AVFilterContext *ctx, void *arg, int jobnr, int n
static int fn(filter_channels)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
{
const int is_disabled = ctx->is_disabled;
AudioQuantContext *s = ctx->priv;
AVFrame **frames = s->frame;
AVFrame *out = arg;
@ -89,6 +94,13 @@ static int fn(filter_channels)(AVFilterContext *ctx, void *arg, int jobnr, int n
const ftype *input = (const ftype *)frames[0]->extended_data[c];
ftype *output = (ftype *)out->extended_data[c];
if (is_disabled) {
for (int n = 0; n < nb_samples; n++)
output[n] = input[n];
continue;
}
for (int n = 0; n < nb_samples; n++)
output[n] = ROUND(input[n] * factor) * scale;
}