44#define FREQUENCY_DOMAIN 1
126 mysofa_lookup_free(sofa->
lookup);
129 mysofa_free(sofa->
hrtf);
139 struct MYSOFA_HRTF *mysofa;
143 mysofa = mysofa_load(filename, &ret);
144 s->sofa.hrtf = mysofa;
145 if (ret || !mysofa) {
150 ret = mysofa_check(mysofa);
151 if (ret != MYSOFA_OK) {
157 mysofa_loudness(
s->sofa.hrtf);
160 mysofa_minphase(
s->sofa.hrtf, 0.01f);
162 mysofa_tocartesian(
s->sofa.hrtf);
164 s->sofa.lookup = mysofa_lookup_init(
s->sofa.hrtf);
165 if (
s->sofa.lookup ==
NULL)
169 s->sofa.neighborhood = mysofa_neighborhood_init_withstepdefine(
s->sofa.hrtf,
174 s->sofa.fir =
av_calloc(
s->sofa.hrtf->N *
s->sofa.hrtf->R,
sizeof(*
s->sofa.fir));
178 if (mysofa->DataSamplingRate.elements != 1)
181 *samplingrate = mysofa->DataSamplingRate.values[0];
182 license = mysofa_getAttribute(mysofa->attributes, (
char *)
"License");
198 if (channel_id < 0 || channel_id >= 64) {
203 *rchannel = channel_id;
207 if (channel_id < 0 || channel_id >= 64) {
211 *rchannel = channel_id;
221 char *
arg, *tokenizer, *p, *args =
av_strdup(
s->speakers_pos);
236 s->vspkrpos[out_ch_id].set = 1;
237 s->vspkrpos[out_ch_id].azim = azim;
238 s->vspkrpos[out_ch_id].elev = elev;
240 s->vspkrpos[out_ch_id].set = 1;
241 s->vspkrpos[out_ch_id].azim = azim;
242 s->vspkrpos[out_ch_id].elev = 0;
250 float *speaker_azim,
float *speaker_elev)
254 float azim[64] = { 0 };
255 float elev[64] = { 0 };
256 int ch,
n_conv =
ctx->inputs[0]->ch_layout.nb_channels;
267 for (ch = 0; ch <
n_conv; ch++) {
284 elev[ch] = 90;
break;
286 elev[ch] = 45;
break;
288 elev[ch] = 45;
break;
290 elev[ch] = 45;
break;
292 elev[ch] = 45;
break;
294 elev[ch] = 45;
break;
296 elev[ch] = 45;
break;
307 if (
s->vspkrpos[ch].set) {
308 azim[ch] =
s->vspkrpos[ch].azim;
309 elev[ch] =
s->vspkrpos[ch].elev;
339 int *write = &td->
write[jobnr];
340 const int *
const delay = td->
delay[jobnr];
341 const float *
const ir = td->
ir[jobnr];
344 float *temp_src = td->
temp_src[jobnr];
345 const int ir_samples =
s->sofa.ir_samples;
346 const int n_samples =
s->sofa.n_samples;
350 float *
dst = (
float *)
out->extended_data[jobnr *
planar];
351 const int in_channels =
s->n_conv;
353 const int buffer_length =
s->buffer_length;
355 const uint32_t modulo = (uint32_t)buffer_length - 1;
364 for (l = 0; l < in_channels; l++) {
366 buffer[l] = ringbuffer + l * buffer_length;
370 const float *temp_ir = ir;
374 for (l = 0; l < in_channels; l++) {
381 for (l = 0; l < in_channels; l++) {
388 for (l = 0; l < in_channels; l++) {
389 const float *
const bptr =
buffer[l];
391 if (l ==
s->lfe_channel) {
394 dst[0] += *(
buffer[
s->lfe_channel] + wr) *
s->gain_lfe;
395 temp_ir += n_samples;
402 read = (wr - delay[l] - (ir_samples - 1) + buffer_length) & modulo;
404 if (
read + ir_samples < buffer_length) {
405 memmove(temp_src, bptr +
read, ir_samples *
sizeof(*temp_src));
409 memmove(temp_src, bptr +
read,
len *
sizeof(*temp_src));
410 memmove(temp_src +
len, bptr, (n_samples -
len) *
sizeof(*temp_src));
414 dst[0] +=
s->fdsp->scalarproduct_float(temp_ir, temp_src,
FFALIGN(ir_samples, 32));
415 temp_ir += n_samples;
425 wr = (wr + 1) & modulo;
439 int *write = &td->
write[jobnr];
443 const int ir_samples =
s->sofa.ir_samples;
446 float *
dst = (
float *)
out->extended_data[jobnr *
planar];
447 const int in_channels =
s->n_conv;
449 const int buffer_length =
s->buffer_length;
451 const uint32_t modulo = (uint32_t)buffer_length - 1;
459 const int n_conv =
s->n_conv;
460 const int n_fft =
s->n_fft;
461 const float fft_scale = 1.0f /
s->n_fft;
473 for (j = 0; j < n_read; j++) {
475 dst[
mult * j] = ringbuffer[wr];
476 ringbuffer[wr] = 0.0f;
478 wr = (wr + 1) & modulo;
489 for (
i = 0;
i < n_conv;
i++) {
492 if (
i ==
s->lfe_channel) {
496 dst[2 * j] +=
src[
i + j * in_channels] *
s->gain_lfe;
501 dst[j] +=
src[j] *
s->gain_lfe;
509 hrtf_offset = hrtf +
offset;
518 fft_in[j].
re =
src[j * in_channels +
i];
524 fft_in[j].
re =
src[j];
529 tx_fn(fft, fft_out, fft_in,
sizeof(*fft_in));
531 for (j = 0; j < n_fft; j++) {
533 const float re = fft_out[j].
re;
534 const float im = fft_out[j].
im;
538 fft_acc[j].
re += re * hcomplex->
re - im * hcomplex->
im;
540 fft_acc[j].
im += re * hcomplex->
im + im * hcomplex->
re;
545 itx_fn(ifft, fft_out, fft_acc,
sizeof(*fft_acc));
549 dst[
mult * j] += fft_out[j].
re * fft_scale;
552 for (j = 0; j < ir_samples - 1; j++) {
554 int write_pos = (wr + j) & modulo;
556 *(ringbuffer + write_pos) += fft_out[in->
nb_samples + j].
re * fft_scale;
560 for (
i = 0;
i <
out->nb_samples;
i++) {
578 int n_clippings[2] = { 0 };
603 if (n_clippings[0] + n_clippings[1] > 0) {
605 n_clippings[0] + n_clippings[1],
out->nb_samples * 2);
675 float *
left,
float *right,
676 float *delay_left,
float *delay_right)
679 float c[3], delays[2];
685 c[0] = x,
c[1] = y,
c[2] = z;
686 nearest = mysofa_lookup(
s->sofa.lookup,
c);
690 if (
s->interpolate) {
691 neighbors = mysofa_neighborhood(
s->sofa.neighborhood, nearest);
692 res = mysofa_interpolate(
s->sofa.hrtf,
c,
694 s->sofa.fir, delays);
696 if (
s->sofa.hrtf->DataDelay.elements >
s->sofa.hrtf->R) {
697 delays[0] =
s->sofa.hrtf->DataDelay.values[nearest *
s->sofa.hrtf->R];
698 delays[1] =
s->sofa.hrtf->DataDelay.values[nearest *
s->sofa.hrtf->R + 1];
700 delays[0] =
s->sofa.hrtf->DataDelay.values[0];
701 delays[1] =
s->sofa.hrtf->DataDelay.values[1];
703 res =
s->sofa.hrtf->DataIR.values + nearest *
s->sofa.hrtf->N *
s->sofa.hrtf->R;
706 *delay_left = delays[0];
707 *delay_right = delays[1];
710 fr = res +
s->sofa.hrtf->N;
712 memcpy(
left, fl,
sizeof(
float) *
s->sofa.hrtf->N);
713 memcpy(right, fr,
sizeof(
float) *
s->sofa.hrtf->N);
727 int nb_input_channels =
ctx->inputs[0]->ch_layout.nb_channels;
728 float gain_lin =
expf((
s->gain - 3 * nb_input_channels) / 20 *
M_LN10);
735 float *data_ir_l =
NULL;
736 float *data_ir_r =
NULL;
738 int i, j, azim_orig = azim, elev_orig = elev;
744 s->sofa.ir_samples =
s->sofa.hrtf->N;
745 s->sofa.n_samples = 1 << (32 -
ff_clz(
s->sofa.ir_samples));
747 n_samples =
s->sofa.n_samples;
748 ir_samples =
s->sofa.ir_samples;
751 s->data_ir[0] =
av_calloc(n_samples,
sizeof(
float) *
s->n_conv);
752 s->data_ir[1] =
av_calloc(n_samples,
sizeof(
float) *
s->n_conv);
754 if (!
s->data_ir[0] || !
s->data_ir[1]) {
763 if (!
s->delay[0] || !
s->delay[1]) {
771 if (!data_ir_r || !data_ir_l) {
777 s->temp_src[0] =
av_calloc(n_samples,
sizeof(
float));
778 s->temp_src[1] =
av_calloc(n_samples,
sizeof(
float));
779 if (!
s->temp_src[0] || !
s->temp_src[1]) {
785 s->speaker_azim =
av_calloc(
s->n_conv,
sizeof(*
s->speaker_azim));
786 s->speaker_elev =
av_calloc(
s->n_conv,
sizeof(*
s->speaker_elev));
787 if (!
s->speaker_azim || !
s->speaker_elev) {
794 av_log(
ctx,
AV_LOG_ERROR,
"Couldn't get speaker positions. Input channel configuration not supported.\n");
798 for (
i = 0;
i <
s->n_conv;
i++) {
799 float coordinates[3];
802 azim = (int)(
s->speaker_azim[
i] + azim_orig) % 360;
803 elev = (int)(
s->speaker_elev[
i] + elev_orig) % 90;
805 coordinates[0] = azim;
806 coordinates[1] = elev;
809 mysofa_s2c(coordinates);
813 data_ir_l + n_samples *
i,
814 data_ir_r + n_samples *
i,
822 s->sofa.max_delay =
FFMAX3(
s->sofa.max_delay,
s->delay[0][
i],
s->delay[1][
i]);
827 n_current = n_samples +
s->sofa.max_delay;
829 n_max =
FFMAX(n_max, n_current);
833 s->buffer_length = 1 << (32 -
ff_clz(n_max));
858 s->ringbuffer[0] =
av_calloc(
s->buffer_length,
sizeof(
float) * nb_input_channels);
859 s->ringbuffer[1] =
av_calloc(
s->buffer_length,
sizeof(
float) * nb_input_channels);
864 if (!data_hrtf_r || !data_hrtf_l) {
869 s->ringbuffer[0] =
av_calloc(
s->buffer_length,
sizeof(
float));
870 s->ringbuffer[1] =
av_calloc(
s->buffer_length,
sizeof(
float));
877 if (!
s->in_fft[0] || !
s->in_fft[1] ||
878 !
s->out_fft[0] || !
s->out_fft[1] ||
879 !
s->temp_afft[0] || !
s->temp_afft[1]) {
885 if (!
s->ringbuffer[0] || !
s->ringbuffer[1]) {
895 if (!fft_in_l || !fft_in_r ||
896 !fft_out_l || !fft_out_r) {
902 for (
i = 0;
i <
s->n_conv;
i++) {
911 for (j = 0; j < ir_samples; j++) {
914 s->data_ir[0][
offset + j] = lir[ir_samples - 1 - j] * gain_lin;
915 s->data_ir[1][
offset + j] = rir[ir_samples - 1 - j] * gain_lin;
918 memset(fft_in_l, 0,
n_fft *
sizeof(*fft_in_l));
919 memset(fft_in_r, 0,
n_fft *
sizeof(*fft_in_r));
922 for (j = 0; j < ir_samples; j++) {
927 fft_in_l[
s->delay[0][
i] + j].
re = lir[j] * gain_lin;
928 fft_in_r[
s->delay[1][
i] + j].
re = rir[j] * gain_lin;
932 s->tx_fn[0](
s->fft[0], fft_out_l, fft_in_l,
sizeof(*fft_in_l));
933 memcpy(data_hrtf_l +
offset, fft_out_l,
n_fft *
sizeof(*fft_out_l));
934 s->tx_fn[1](
s->fft[1], fft_out_r, fft_in_r,
sizeof(*fft_in_r));
935 memcpy(data_hrtf_r +
offset, fft_out_r,
n_fft *
sizeof(*fft_out_r));
942 if (!
s->data_hrtf[0] || !
s->data_hrtf[1]) {
947 memcpy(
s->data_hrtf[0], data_hrtf_l,
949 memcpy(
s->data_hrtf[1], data_hrtf_r,
1007 s->nb_samples =
s->framesize;
1018 av_log(
ctx,
AV_LOG_DEBUG,
"Samplerate: %d Channels to convolute: %d, Length of ringbuffer: %d x %d\n",
1058#define OFFSET(x) offsetof(SOFAlizerContext, x)
1059#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
1092 .p.name =
"sofalizer",
1094 .p.priv_class = &sofalizer_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static enum AVSampleFormat sample_fmts[]
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static const AVFilterPad inputs[]
static int config_input(AVFilterLink *inlink)
static int preload_sofa(AVFilterContext *ctx, char *filename, int *samplingrate)
const FFFilter ff_af_sofalizer
static int close_sofa(struct MySofa *sofa)
static int load_data(AVFilterContext *ctx, int azim, int elev, float radius, int sample_rate)
static int config_input(AVFilterLink *inlink)
static int sofalizer_convolute(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static const AVOption sofalizer_options[]
static int get_speaker_pos(AVFilterContext *ctx, float *speaker_azim, float *speaker_elev)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int activate(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx)
static int getfilter_float(AVFilterContext *ctx, float x, float y, float z, float *left, float *right, float *delay_left, float *delay_right)
static int sofalizer_fast_convolute(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
static void parse_speaker_pos(AVFilterContext *ctx)
static int parse_channel_name(AVFilterContext *ctx, char **arg, int *rchannel)
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi > >8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1<< 16)) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi > >24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi > >56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(UINT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(UINT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out->ch+ch,(const uint8_t **) in->ch+ch, off *(out-> planar
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs)
int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max, AVFrame **rframe)
Take samples from the link's FIFO and update the link's stats.
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Main libavfilter public API header.
int av_sscanf(const char *string, const char *format,...)
static uint32_t BS_FUNC read(BSCTX *bc, unsigned int n)
Return n bits from the buffer, n has to be in the 0-32 range.
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
static __device__ float fabsf(float a)
static const uint16_t channel_layouts[7]
static const int sample_rates[]
int(* init)(AVBSFContext *ctx)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
#define AV_CHANNEL_LAYOUT_STEREO
enum AVChannel av_channel_layout_channel_from_index(const AVChannelLayout *channel_layout, unsigned int idx)
Get the channel with the given index in a channel layout.
enum AVChannel av_channel_from_string(const char *str)
This is the inverse function of av_channel_name().
@ AV_CHAN_FRONT_RIGHT_OF_CENTER
@ AV_CHAN_TOP_FRONT_RIGHT
@ AV_CHAN_FRONT_LEFT_OF_CENTER
@ AV_CHAN_LOW_FREQUENCY_2
@ AV_CHAN_TOP_BACK_CENTER
@ AV_CHAN_SURROUND_DIRECT_RIGHT
@ AV_CHAN_STEREO_RIGHT
See above.
@ AV_CHAN_SURROUND_DIRECT_LEFT
@ AV_CHAN_STEREO_LEFT
Stereo downmix.
@ AV_CHAN_TOP_FRONT_CENTER
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_FLTP
float, planar
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
static void scale(int *out, const int *in, const int w, const int h, const int shift)
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
static int16_t mult(Float11 *f1, Float11 *f2)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FF_FILTER_FORWARD_WANTED(outlink, inlink)
Forward the frame_wanted_out flag from an output link to an input link.
#define FF_FILTER_FORWARD_STATUS(inlink, outlink)
Acknowledge the status on an input link and forward it to an output link.
#define FFERROR_NOT_READY
Filters implementation helper functions and internal structures.
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
#define AVFILTER_DEFINE_CLASS(fname)
#define FILTER_QUERY_FUNC2(func)
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
enum MovChannelLayoutTag * layouts
An AVChannelLayout holds information about the channel layout of audio data.
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
A list of supported channel layouts.
A link between two filters.
int sample_rate
samples per second
AVChannelLayout ch_layout
channel layout of current buffer (see libavutil/channel_layout.h)
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
uint8_t ** extended_data
pointers to the data planes/channels.
struct MYSOFA_NEIGHBORHOOD * neighborhood
struct MYSOFA_HRTF * hrtf
struct MYSOFA_LOOKUP * lookup
AVComplexFloat * in_fft[2]
AVComplexFloat * temp_afft[2]
AVComplexFloat * out_fft[2]
VirtualSpeaker vspkrpos[64]
AVComplexFloat * data_hrtf[2]
Used for passing data between threads.
AVComplexFloat ** out_fft
AVComplexFloat ** temp_afft
#define av_malloc_array(a, b)
static AVFormatContext * ctx
static void interpolate(float *out, float v1, float v2, int size)
av_cold void av_tx_uninit(AVTXContext **ctx)
Frees a context and sets *ctx to NULL, does nothing when *ctx == NULL.
av_cold int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type, int inv, int len, const void *scale, uint64_t flags)
Initialize a transform context with the given configuration (i)MDCTs with an odd length are currently...
@ AV_TX_FLOAT_FFT
Standard complex to complex FFT with sample data type of AVComplexFloat, AVComplexDouble or AVComplex...
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.