2 * Copyright (C) 2017 Paul B Mahol
3 * Copyright (C) 2013-2015 Andreas Fuchs, Wolfgang Hrauda
4 * This file is part of FFmpeg.
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "libavutil/audio_fifo.h"
24 #include "libavutil/avstring.h"
25 #include "libavutil/channel_layout.h"
26 #include "libavutil/float_dsp.h"
27 #include "libavutil/intmath.h"
28 #include "libavutil/opt.h"
29 #include "libavcodec/avfft.h"
36 #define FREQUENCY_DOMAIN 1
38 typedef struct HeadphoneContext {
59 float lfe_gain, gain_lfe;
71 FFTComplex *temp_fft[2];
73 FFTContext *fft[2], *ifft[2];
74 FFTComplex *data_hrtf[2];
76 AVFloatDSPContext *fdsp;
77 struct headphone_inputs {
87 static int parse_channel_name(HeadphoneContext *s, int x, char **arg, int *rchannel, char *buf)
89 int len, i, channel_id = 0;
90 int64_t layout, layout0;
92 if (sscanf(*arg, "%7[A-Z]%n", buf, &len)) {
93 layout0 = layout = av_get_channel_layout(buf);
94 if (layout == AV_CH_LOW_FREQUENCY)
96 for (i = 32; i > 0; i >>= 1) {
97 if (layout >= 1LL << i) {
102 if (channel_id >= 64 || layout0 != 1LL << channel_id)
103 return AVERROR(EINVAL);
104 *rchannel = channel_id;
108 return AVERROR(EINVAL);
111 static void parse_map(AVFilterContext *ctx)
113 HeadphoneContext *s = ctx->priv;
114 char *arg, *tokenizer, *p, *args = av_strdup(s->map);
124 for (i = 0; i < 64; i++) {
128 while ((arg = av_strtok(p, "|", &tokenizer))) {
133 if (parse_channel_name(s, s->nb_inputs - 1, &arg, &out_ch_id, buf)) {
134 av_log(ctx, AV_LOG_WARNING, "Failed to parse \'%s\' as channel name.\n", buf);
137 s->mapping[s->nb_inputs - 1] = out_ch_id;
140 s->nb_irs = s->nb_inputs - 1;
145 typedef struct ThreadData {
153 FFTComplex **temp_fft;
156 static int headphone_convolute(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
158 HeadphoneContext *s = ctx->priv;
159 ThreadData *td = arg;
160 AVFrame *in = td->in, *out = td->out;
162 int *write = &td->write[jobnr];
163 const int *const delay = td->delay[jobnr];
164 const float *const ir = td->ir[jobnr];
165 int *n_clippings = &td->n_clippings[jobnr];
166 float *ringbuffer = td->ringbuffer[jobnr];
167 float *temp_src = td->temp_src[jobnr];
168 const int ir_len = s->ir_len;
169 const float *src = (const float *)in->data[0];
170 float *dst = (float *)out->data[0];
171 const int in_channels = in->channels;
172 const int buffer_length = s->buffer_length;
173 const uint32_t modulo = (uint32_t)buffer_length - 1;
180 for (l = 0; l < in_channels; l++) {
181 buffer[l] = ringbuffer + l * buffer_length;
184 for (i = 0; i < in->nb_samples; i++) {
185 const float *temp_ir = ir;
188 for (l = 0; l < in_channels; l++) {
189 *(buffer[l] + wr) = src[l];
192 for (l = 0; l < in_channels; l++) {
193 const float *const bptr = buffer[l];
195 if (l == s->lfe_channel) {
196 *dst += *(buffer[s->lfe_channel] + wr) * s->gain_lfe;
197 temp_ir += FFALIGN(ir_len, 16);
201 read = (wr - *(delay + l) - (ir_len - 1) + buffer_length) & modulo;
203 if (read + ir_len < buffer_length) {
204 memcpy(temp_src, bptr + read, ir_len * sizeof(*temp_src));
206 int len = FFMIN(ir_len - (read % ir_len), buffer_length - read);
208 memcpy(temp_src, bptr + read, len * sizeof(*temp_src));
209 memcpy(temp_src + len, bptr, (ir_len - len) * sizeof(*temp_src));
212 dst[0] += s->fdsp->scalarproduct_float(temp_ir, temp_src, ir_len);
213 temp_ir += FFALIGN(ir_len, 16);
221 wr = (wr + 1) & modulo;
229 static int headphone_fast_convolute(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
231 HeadphoneContext *s = ctx->priv;
232 ThreadData *td = arg;
233 AVFrame *in = td->in, *out = td->out;
235 int *write = &td->write[jobnr];
236 FFTComplex *hrtf = s->data_hrtf[jobnr];
237 int *n_clippings = &td->n_clippings[jobnr];
238 float *ringbuffer = td->ringbuffer[jobnr];
239 const int ir_len = s->ir_len;
240 const float *src = (const float *)in->data[0];
241 float *dst = (float *)out->data[0];
242 const int in_channels = in->channels;
243 const int buffer_length = s->buffer_length;
244 const uint32_t modulo = (uint32_t)buffer_length - 1;
245 FFTComplex *fft_in = s->temp_fft[jobnr];
246 FFTContext *ifft = s->ifft[jobnr];
247 FFTContext *fft = s->fft[jobnr];
248 const int n_fft = s->n_fft;
249 const float fft_scale = 1.0f / s->n_fft;
250 FFTComplex *hrtf_offset;
257 n_read = FFMIN(s->ir_len, in->nb_samples);
258 for (j = 0; j < n_read; j++) {
259 dst[2 * j] = ringbuffer[wr];
260 ringbuffer[wr] = 0.0;
261 wr = (wr + 1) & modulo;
264 for (j = n_read; j < in->nb_samples; j++) {
268 for (i = 0; i < in_channels; i++) {
269 if (i == s->lfe_channel) {
270 for (j = 0; j < in->nb_samples; j++) {
271 dst[2 * j] += src[i + j * in_channels] * s->gain_lfe;
277 hrtf_offset = hrtf + offset;
279 memset(fft_in, 0, sizeof(FFTComplex) * n_fft);
281 for (j = 0; j < in->nb_samples; j++) {
282 fft_in[j].re = src[j * in_channels + i];
285 av_fft_permute(fft, fft_in);
286 av_fft_calc(fft, fft_in);
287 for (j = 0; j < n_fft; j++) {
288 const FFTComplex *hcomplex = hrtf_offset + j;
289 const float re = fft_in[j].re;
290 const float im = fft_in[j].im;
292 fft_in[j].re = re * hcomplex->re - im * hcomplex->im;
293 fft_in[j].im = re * hcomplex->im + im * hcomplex->re;
296 av_fft_permute(ifft, fft_in);
297 av_fft_calc(ifft, fft_in);
299 for (j = 0; j < in->nb_samples; j++) {
300 dst[2 * j] += fft_in[j].re * fft_scale;
303 for (j = 0; j < ir_len - 1; j++) {
304 int write_pos = (wr + j) & modulo;
306 *(ringbuffer + write_pos) += fft_in[in->nb_samples + j].re * fft_scale;
310 for (i = 0; i < out->nb_samples; i++) {
311 if (fabs(*dst) > 1) {
323 static int read_ir(AVFilterLink *inlink, AVFrame *frame)
325 AVFilterContext *ctx = inlink->dst;
326 HeadphoneContext *s = ctx->priv;
327 int ir_len, max_ir_len, input_number;
329 for (input_number = 0; input_number < s->nb_inputs; input_number++)
330 if (inlink == ctx->inputs[input_number])
333 av_audio_fifo_write(s->in[input_number].fifo, (void **)frame->extended_data,
335 av_frame_free(&frame);
337 ir_len = av_audio_fifo_size(s->in[input_number].fifo);
339 if (ir_len > max_ir_len) {
340 av_log(ctx, AV_LOG_ERROR, "Too big length of IRs: %d > %d.\n", ir_len, max_ir_len);
341 return AVERROR(EINVAL);
343 s->in[input_number].ir_len = ir_len;
344 s->ir_len = FFMAX(ir_len, s->ir_len);
349 static int headphone_frame(HeadphoneContext *s, AVFilterLink *outlink)
351 AVFilterContext *ctx = outlink->src;
352 AVFrame *in = s->in[0].frame;
353 int n_clippings[2] = { 0 };
357 av_audio_fifo_read(s->in[0].fifo, (void **)in->extended_data, s->size);
359 out = ff_get_audio_buffer(outlink, in->nb_samples);
361 return AVERROR(ENOMEM);
363 if (s->pts != AV_NOPTS_VALUE)
364 s->pts += av_rescale_q(out->nb_samples, (AVRational){1, outlink->sample_rate}, outlink->time_base);
366 td.in = in; td.out = out; td.write = s->write;
367 td.delay = s->delay; td.ir = s->data_ir; td.n_clippings = n_clippings;
368 td.ringbuffer = s->ringbuffer; td.temp_src = s->temp_src;
369 td.temp_fft = s->temp_fft;
371 if (s->type == TIME_DOMAIN) {
372 ctx->internal->execute(ctx, headphone_convolute, &td, NULL, 2);
374 ctx->internal->execute(ctx, headphone_fast_convolute, &td, NULL, 2);
378 if (n_clippings[0] + n_clippings[1] > 0) {
379 av_log(ctx, AV_LOG_WARNING, "%d of %d samples clipped. Please reduce gain.\n",
380 n_clippings[0] + n_clippings[1], out->nb_samples * 2);
383 return ff_filter_frame(outlink, out);
386 static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink)
388 struct HeadphoneContext *s = ctx->priv;
389 const int ir_len = s->ir_len;
390 int nb_irs = s->nb_irs;
391 int nb_input_channels = ctx->inputs[0]->channels;
392 float gain_lin = expf((s->gain - 3 * nb_input_channels) / 20 * M_LN10);
393 FFTComplex *data_hrtf_l = NULL;
394 FFTComplex *data_hrtf_r = NULL;
395 FFTComplex *fft_in_l = NULL;
396 FFTComplex *fft_in_r = NULL;
397 float *data_ir_l = NULL;
398 float *data_ir_r = NULL;
399 int offset = 0, ret = 0;
403 s->buffer_length = 1 << (32 - ff_clz(s->ir_len));
404 s->n_fft = n_fft = 1 << (32 - ff_clz(s->ir_len + inlink->sample_rate));
406 if (s->type == FREQUENCY_DOMAIN) {
407 fft_in_l = av_calloc(n_fft, sizeof(*fft_in_l));
408 fft_in_r = av_calloc(n_fft, sizeof(*fft_in_r));
409 if (!fft_in_l || !fft_in_r) {
410 ret = AVERROR(ENOMEM);
414 av_fft_end(s->fft[0]);
415 av_fft_end(s->fft[1]);
416 s->fft[0] = av_fft_init(log2(s->n_fft), 0);
417 s->fft[1] = av_fft_init(log2(s->n_fft), 0);
418 av_fft_end(s->ifft[0]);
419 av_fft_end(s->ifft[1]);
420 s->ifft[0] = av_fft_init(log2(s->n_fft), 1);
421 s->ifft[1] = av_fft_init(log2(s->n_fft), 1);
423 if (!s->fft[0] || !s->fft[1] || !s->ifft[0] || !s->ifft[1]) {
424 av_log(ctx, AV_LOG_ERROR, "Unable to create FFT contexts of size %d.\n", s->n_fft);
425 ret = AVERROR(ENOMEM);
430 s->data_ir[0] = av_calloc(FFALIGN(s->ir_len, 16), sizeof(float) * s->nb_irs);
431 s->data_ir[1] = av_calloc(FFALIGN(s->ir_len, 16), sizeof(float) * s->nb_irs);
432 s->delay[0] = av_malloc_array(s->nb_irs, sizeof(float));
433 s->delay[1] = av_malloc_array(s->nb_irs, sizeof(float));
435 if (s->type == TIME_DOMAIN) {
436 s->ringbuffer[0] = av_calloc(s->buffer_length, sizeof(float) * nb_input_channels);
437 s->ringbuffer[1] = av_calloc(s->buffer_length, sizeof(float) * nb_input_channels);
439 s->ringbuffer[0] = av_calloc(s->buffer_length, sizeof(float));
440 s->ringbuffer[1] = av_calloc(s->buffer_length, sizeof(float));
441 s->temp_fft[0] = av_malloc_array(s->n_fft, sizeof(FFTComplex));
442 s->temp_fft[1] = av_malloc_array(s->n_fft, sizeof(FFTComplex));
443 if (!s->temp_fft[0] || !s->temp_fft[1]) {
444 ret = AVERROR(ENOMEM);
449 if (!s->data_ir[0] || !s->data_ir[1] ||
450 !s->ringbuffer[0] || !s->ringbuffer[1]) {
451 ret = AVERROR(ENOMEM);
455 s->in[0].frame = ff_get_audio_buffer(ctx->inputs[0], s->size);
456 if (!s->in[0].frame) {
457 ret = AVERROR(ENOMEM);
460 for (i = 0; i < s->nb_irs; i++) {
461 s->in[i + 1].frame = ff_get_audio_buffer(ctx->inputs[i + 1], s->ir_len);
462 if (!s->in[i + 1].frame) {
463 ret = AVERROR(ENOMEM);
468 if (s->type == TIME_DOMAIN) {
469 s->temp_src[0] = av_calloc(FFALIGN(ir_len, 16), sizeof(float));
470 s->temp_src[1] = av_calloc(FFALIGN(ir_len, 16), sizeof(float));
472 data_ir_l = av_calloc(nb_irs * FFALIGN(ir_len, 16), sizeof(*data_ir_l));
473 data_ir_r = av_calloc(nb_irs * FFALIGN(ir_len, 16), sizeof(*data_ir_r));
474 if (!data_ir_r || !data_ir_l || !s->temp_src[0] || !s->temp_src[1]) {
475 ret = AVERROR(ENOMEM);
479 data_hrtf_l = av_malloc_array(n_fft, sizeof(*data_hrtf_l) * nb_irs);
480 data_hrtf_r = av_malloc_array(n_fft, sizeof(*data_hrtf_r) * nb_irs);
481 if (!data_hrtf_r || !data_hrtf_l) {
482 ret = AVERROR(ENOMEM);
487 for (i = 0; i < s->nb_irs; i++) {
488 int len = s->in[i + 1].ir_len;
489 int delay_l = s->in[i + 1].delay_l;
490 int delay_r = s->in[i + 1].delay_r;
494 for (j = 0; j < inlink->channels; j++) {
495 if (s->mapping[i] < 0) {
499 if ((av_channel_layout_extract_channel(inlink->channel_layout, j)) == (1LL << s->mapping[i])) {
507 av_audio_fifo_read(s->in[i + 1].fifo, (void **)s->in[i + 1].frame->extended_data, len);
508 ptr = (float *)s->in[i + 1].frame->extended_data[0];
510 if (s->type == TIME_DOMAIN) {
511 offset = idx * FFALIGN(len, 16);
512 for (j = 0; j < len; j++) {
513 data_ir_l[offset + j] = ptr[len * 2 - j * 2 - 2] * gain_lin;
514 data_ir_r[offset + j] = ptr[len * 2 - j * 2 - 1] * gain_lin;
517 memset(fft_in_l, 0, n_fft * sizeof(*fft_in_l));
518 memset(fft_in_r, 0, n_fft * sizeof(*fft_in_r));
520 offset = idx * n_fft;
521 for (j = 0; j < len; j++) {
522 fft_in_l[delay_l + j].re = ptr[j * 2 ] * gain_lin;
523 fft_in_r[delay_r + j].re = ptr[j * 2 + 1] * gain_lin;
526 av_fft_permute(s->fft[0], fft_in_l);
527 av_fft_calc(s->fft[0], fft_in_l);
528 memcpy(data_hrtf_l + offset, fft_in_l, n_fft * sizeof(*fft_in_l));
529 av_fft_permute(s->fft[0], fft_in_r);
530 av_fft_calc(s->fft[0], fft_in_r);
531 memcpy(data_hrtf_r + offset, fft_in_r, n_fft * sizeof(*fft_in_r));
535 if (s->type == TIME_DOMAIN) {
536 memcpy(s->data_ir[0], data_ir_l, sizeof(float) * nb_irs * FFALIGN(ir_len, 16));
537 memcpy(s->data_ir[1], data_ir_r, sizeof(float) * nb_irs * FFALIGN(ir_len, 16));
539 s->data_hrtf[0] = av_malloc_array(n_fft * s->nb_irs, sizeof(FFTComplex));
540 s->data_hrtf[1] = av_malloc_array(n_fft * s->nb_irs, sizeof(FFTComplex));
541 if (!s->data_hrtf[0] || !s->data_hrtf[1]) {
542 ret = AVERROR(ENOMEM);
546 memcpy(s->data_hrtf[0], data_hrtf_l,
547 sizeof(FFTComplex) * nb_irs * n_fft);
548 memcpy(s->data_hrtf[1], data_hrtf_r,
549 sizeof(FFTComplex) * nb_irs * n_fft);
556 av_freep(&data_ir_l);
557 av_freep(&data_ir_r);
559 av_freep(&data_hrtf_l);
560 av_freep(&data_hrtf_r);
568 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
570 AVFilterContext *ctx = inlink->dst;
571 HeadphoneContext *s = ctx->priv;
572 AVFilterLink *outlink = ctx->outputs[0];
575 av_audio_fifo_write(s->in[0].fifo, (void **)in->extended_data,
577 if (s->pts == AV_NOPTS_VALUE)
582 if (!s->have_hrirs && s->eof_hrirs) {
583 ret = convert_coeffs(ctx, inlink);
589 while (av_audio_fifo_size(s->in[0].fifo) >= s->size) {
590 ret = headphone_frame(s, outlink);
598 static int query_formats(AVFilterContext *ctx)
600 struct HeadphoneContext *s = ctx->priv;
601 AVFilterFormats *formats = NULL;
602 AVFilterChannelLayouts *layouts = NULL;
605 ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLT);
608 ret = ff_set_common_formats(ctx, formats);
612 layouts = ff_all_channel_layouts();
614 return AVERROR(ENOMEM);
616 ret = ff_channel_layouts_ref(layouts, &ctx->inputs[0]->out_channel_layouts);
621 ret = ff_add_channel_layout(&layouts, AV_CH_LAYOUT_STEREO);
625 for (i = 1; i < s->nb_inputs; i++) {
626 ret = ff_channel_layouts_ref(layouts, &ctx->inputs[i]->out_channel_layouts);
631 ret = ff_channel_layouts_ref(layouts, &ctx->outputs[0]->in_channel_layouts);
635 formats = ff_all_samplerates();
637 return AVERROR(ENOMEM);
638 return ff_set_common_samplerates(ctx, formats);
641 static int config_input(AVFilterLink *inlink)
643 AVFilterContext *ctx = inlink->dst;
644 HeadphoneContext *s = ctx->priv;
646 if (s->type == FREQUENCY_DOMAIN) {
647 inlink->partial_buf_size =
648 inlink->min_samples =
649 inlink->max_samples = inlink->sample_rate;
652 if (s->nb_irs < inlink->channels) {
653 av_log(ctx, AV_LOG_ERROR, "Number of inputs must be >= %d.\n", inlink->channels + 1);
654 return AVERROR(EINVAL);
660 static av_cold int init(AVFilterContext *ctx)
662 HeadphoneContext *s = ctx->priv;
667 .type = AVMEDIA_TYPE_AUDIO,
668 .config_props = config_input,
669 .filter_frame = filter_frame,
671 if ((ret = ff_insert_inpad(ctx, 0, &pad)) < 0)
675 av_log(ctx, AV_LOG_ERROR, "Valid mapping must be set.\n");
676 return AVERROR(EINVAL);
681 s->in = av_calloc(s->nb_inputs, sizeof(*s->in));
683 return AVERROR(ENOMEM);
685 for (i = 1; i < s->nb_inputs; i++) {
686 char *name = av_asprintf("hrir%d", i - 1);
689 .type = AVMEDIA_TYPE_AUDIO,
690 .filter_frame = read_ir,
693 return AVERROR(ENOMEM);
694 if ((ret = ff_insert_inpad(ctx, i, &pad)) < 0) {
700 s->fdsp = avpriv_float_dsp_alloc(0);
702 return AVERROR(ENOMEM);
703 s->pts = AV_NOPTS_VALUE;
708 static int config_output(AVFilterLink *outlink)
710 AVFilterContext *ctx = outlink->src;
711 HeadphoneContext *s = ctx->priv;
712 AVFilterLink *inlink = ctx->inputs[0];
715 if (s->type == TIME_DOMAIN)
718 s->size = inlink->sample_rate;
720 for (i = 0; i < s->nb_inputs; i++) {
721 s->in[i].fifo = av_audio_fifo_alloc(ctx->inputs[i]->format, ctx->inputs[i]->channels, 1024);
723 return AVERROR(ENOMEM);
725 s->gain_lfe = expf((s->gain - 3 * inlink->channels - 6 + s->lfe_gain) / 20 * M_LN10);
730 static int request_frame(AVFilterLink *outlink)
732 AVFilterContext *ctx = outlink->src;
733 HeadphoneContext *s = ctx->priv;
736 for (i = 1; !s->eof_hrirs && i < s->nb_inputs; i++) {
738 ret = ff_request_frame(ctx->inputs[i]);
739 if (ret == AVERROR_EOF) {
745 if (i == s->nb_inputs - 1)
749 return ff_request_frame(ctx->inputs[0]);
752 static av_cold void uninit(AVFilterContext *ctx)
754 HeadphoneContext *s = ctx->priv;
757 av_fft_end(s->ifft[0]);
758 av_fft_end(s->ifft[1]);
759 av_fft_end(s->fft[0]);
760 av_fft_end(s->fft[1]);
761 av_freep(&s->delay[0]);
762 av_freep(&s->delay[1]);
763 av_freep(&s->data_ir[0]);
764 av_freep(&s->data_ir[1]);
765 av_freep(&s->ringbuffer[0]);
766 av_freep(&s->ringbuffer[1]);
767 av_freep(&s->temp_src[0]);
768 av_freep(&s->temp_src[1]);
769 av_freep(&s->temp_fft[0]);
770 av_freep(&s->temp_fft[1]);
771 av_freep(&s->data_hrtf[0]);
772 av_freep(&s->data_hrtf[1]);
775 for (i = 0; i < s->nb_inputs; i++) {
776 av_frame_free(&s->in[i].frame);
777 av_audio_fifo_free(s->in[i].fifo);
778 if (ctx->input_pads && i)
779 av_freep(&ctx->input_pads[i].name);
784 #define OFFSET(x) offsetof(HeadphoneContext, x)
785 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
787 static const AVOption headphone_options[] = {
788 { "map", "set channels convolution mappings", OFFSET(map), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
789 { "gain", "set gain in dB", OFFSET(gain), AV_OPT_TYPE_FLOAT, {.dbl=0}, -20, 40, .flags = FLAGS },
790 { "lfe", "set lfe gain in dB", OFFSET(lfe_gain), AV_OPT_TYPE_FLOAT, {.dbl=0}, -20, 40, .flags = FLAGS },
791 { "type", "set processing", OFFSET(type), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, .flags = FLAGS, "type" },
792 { "time", "time domain", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, .flags = FLAGS, "type" },
793 { "freq", "frequency domain", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, .flags = FLAGS, "type" },
797 AVFILTER_DEFINE_CLASS(headphone);
799 static const AVFilterPad outputs[] = {
802 .type = AVMEDIA_TYPE_AUDIO,
803 .config_props = config_output,
804 .request_frame = request_frame,
809 AVFilter ff_af_headphone = {
811 .description = NULL_IF_CONFIG_SMALL("Apply headphone binaural spatialization with HRTFs in additional streams."),
812 .priv_size = sizeof(HeadphoneContext),
813 .priv_class = &headphone_class,
816 .query_formats = query_formats,
819 .flags = AVFILTER_FLAG_SLICE_THREADS | AVFILTER_FLAG_DYNAMIC_INPUTS,