42 #define FREQUENCY_DOMAIN 1
106 mysofa_close(sofa->
easy);
115 struct MYSOFA_HRTF *mysofa;
118 mysofa = mysofa_load(filename, &ret);
119 if (ret || !mysofa) {
124 if (mysofa->DataSamplingRate.elements != 1)
126 *samplingrate = mysofa->DataSamplingRate.values[0];
135 int len, i, channel_id = 0;
139 if (sscanf(*arg,
"%7[A-Z]%n", buf, &len)) {
142 for (i = 32; i > 0; i >>= 1) {
143 if (layout >= 1LL << i) {
149 if (channel_id >= 64 || layout0 != 1LL << channel_id)
151 *rchannel = channel_id;
167 while ((arg =
av_strtok(p,
"|", &tokenizer))) {
177 if (sscanf(arg,
"%f %f", &azim, &elev) == 2) {
181 }
else if (sscanf(arg,
"%f", &azim) == 1) {
192 float *speaker_azim,
float *speaker_elev)
196 float azim[16] = { 0 };
197 float elev[16] = { 0 };
209 for (m = 0, ch = 0; ch < n_conv && m < 64; m++) {
210 uint64_t
mask = channels_layout & (1ULL << m);
226 elev[
ch] = 90;
break;
228 elev[
ch] = 45;
break;
230 elev[
ch] = 45;
break;
232 elev[
ch] = 45;
break;
234 elev[
ch] = 45;
break;
236 elev[
ch] = 45;
break;
238 elev[
ch] = 45;
break;
259 memcpy(speaker_azim, azim, n_conv *
sizeof(
float));
260 memcpy(speaker_elev, elev, n_conv *
sizeof(
float));
283 int *write = &td->
write[jobnr];
284 const int *
const delay = td->
delay[jobnr];
285 const float *
const ir = td->
ir[jobnr];
288 float *temp_src = td->
temp_src[jobnr];
290 const float *
src = (
const float *)in->
data[0];
291 float *dst = (
float *)
out->data[0];
292 const int in_channels = s->
n_conv;
296 const uint32_t modulo = (uint32_t)buffer_length - 1;
303 for (l = 0; l < in_channels; l++) {
305 buffer[l] = ringbuffer + l * buffer_length;
309 const float *temp_ir = ir;
312 for (l = 0; l < in_channels; l++) {
314 buffer[l][wr] = src[l];
318 for (l = 0; l < in_channels; l++) {
319 const float *
const bptr = buffer[l];
325 temp_ir +=
FFALIGN(n_samples, 32);
332 read = (wr - delay[l] - (n_samples - 1) + buffer_length) & modulo;
334 if (read + n_samples < buffer_length) {
335 memmove(temp_src, bptr + read, n_samples *
sizeof(*temp_src));
337 int len =
FFMIN(n_samples - (read % n_samples), buffer_length - read);
339 memmove(temp_src, bptr + read, len *
sizeof(*temp_src));
340 memmove(temp_src + len, bptr, (n_samples - len) *
sizeof(*temp_src));
345 temp_ir +=
FFALIGN(n_samples, 32);
349 if (fabs(dst[0]) > 1)
355 wr = (wr + 1) & modulo;
369 int *write = &td->
write[jobnr];
374 const float *
src = (
const float *)in->
data[0];
375 float *dst = (
float *)
out->data[0];
376 const int in_channels = s->
n_conv;
380 const uint32_t modulo = (uint32_t)buffer_length - 1;
384 const int n_conv = s->
n_conv;
385 const int n_fft = s->
n_fft;
386 const float fft_scale = 1.0f / s->
n_fft;
397 for (j = 0; j < n_read; j++) {
399 dst[2 * j] = ringbuffer[wr];
400 ringbuffer[wr] = 0.0;
402 wr = (wr + 1) & modulo;
410 for (i = 0; i < n_conv; i++) {
414 dst[2 * j] += src[i + j * in_channels] * s->
gain_lfe;
421 hrtf_offset = hrtf +
offset;
424 memset(fft_in, 0,
sizeof(
FFTComplex) * n_fft);
429 fft_in[j].
re = src[j * in_channels + i];
435 for (j = 0; j < n_fft; j++) {
437 const float re = fft_in[j].
re;
438 const float im = fft_in[j].
im;
442 fft_in[j].
re = re * hcomplex->
re - im * hcomplex->
im;
444 fft_in[j].
im = re * hcomplex->
im + im * hcomplex->
re;
453 dst[2 * j] += fft_in[j].
re * fft_scale;
456 for (j = 0; j < n_samples - 1; j++) {
458 int write_pos = (wr + j) & modulo;
460 *(ringbuffer + write_pos) += fft_in[in->
nb_samples + j].
re * fft_scale;
465 for (i = 0; i <
out->nb_samples; i++) {
467 if (fabs(*dst) > 1) {
486 int n_clippings[2] = { 0 };
510 if (n_clippings[0] + n_clippings[1] > 0) {
512 n_clippings[0] + n_clippings[1], out->
nb_samples * 2);
566 float gain_lin =
expf((s->
gain - 3 * nb_input_channels) / 20 *
M_LN10);
571 float *data_ir_l =
NULL;
572 float *data_ir_r =
NULL;
574 int i, j, azim_orig = azim, elev_orig = elev;
575 int filter_length, ret = 0;
581 av_log(ctx,
AV_LOG_ERROR,
"Selected SOFA file is invalid. Please select valid SOFA file.\n");
600 if (!data_ir_r || !data_ir_l) {
623 av_log(ctx,
AV_LOG_ERROR,
"Couldn't get speaker positions. Input channel configuration not supported.\n");
627 for (i = 0; i < s->
n_conv; i++) {
628 float coordinates[3];
634 coordinates[0] = azim;
635 coordinates[1] = elev;
638 mysofa_s2c(coordinates);
641 mysofa_getfilter_float(s->
sofa.
easy, coordinates[0], coordinates[1], coordinates[2],
642 data_ir_l +
FFALIGN(n_samples, 32) * i,
643 data_ir_r +
FFALIGN(n_samples, 32) * i,
656 n_max =
FFMAX(n_max, n_current);
661 s->
n_fft = n_fft = 1 << (32 -
ff_clz(n_max + sample_rate));
687 if (!data_hrtf_r || !data_hrtf_l) {
708 fft_in_l =
av_calloc(n_fft,
sizeof(*fft_in_l));
709 fft_in_r =
av_calloc(n_fft,
sizeof(*fft_in_r));
710 if (!fft_in_l || !fft_in_r) {
716 for (i = 0; i < s->
n_conv; i++) {
719 offset = i *
FFALIGN(n_samples, 32);
725 for (j = 0; j < n_samples; j++) {
728 s->
data_ir[0][offset + j] = lir[n_samples - 1 - j] * gain_lin;
729 s->
data_ir[1][offset + j] = rir[n_samples - 1 - j] * gain_lin;
732 memset(fft_in_l, 0, n_fft *
sizeof(*fft_in_l));
733 memset(fft_in_r, 0, n_fft *
sizeof(*fft_in_r));
736 for (j = 0; j < n_samples; j++) {
741 fft_in_l[s->
delay[0][i] + j].
re = lir[j] * gain_lin;
742 fft_in_r[s->
delay[1][i] + j].
re = rir[j] * gain_lin;
748 memcpy(data_hrtf_l + offset, fft_in_l, n_fft *
sizeof(*fft_in_l));
751 memcpy(data_hrtf_r + offset, fft_in_r, n_fft *
sizeof(*fft_in_r));
802 av_log(ctx,
AV_LOG_ERROR,
"No valid SOFA file could be loaded. Please specify valid SOFA file.\n");
834 av_log(ctx,
AV_LOG_DEBUG,
"Samplerate: %d Channels to convolute: %d, Length of ringbuffer: %d x %d\n",
866 #define OFFSET(x) offsetof(SOFAlizerContext, x)
867 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
907 .priv_class = &sofalizer_class,
static int sofalizer_fast_convolute(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
FFTComplex * data_hrtf[2]
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
#define AV_CH_TOP_FRONT_RIGHT
av_cold void av_fft_end(FFTContext *s)
#define AV_LOG_WARNING
Something somehow does not look correct.
Main libavfilter public API header.
AVFILTER_DEFINE_CLASS(sofalizer)
int max_samples
Maximum number of samples to filter at once.
#define AV_CH_TOP_FRONT_LEFT
#define AV_CH_TOP_FRONT_CENTER
#define AV_CH_LOW_FREQUENCY_2
float(* scalarproduct_float)(const float *v1, const float *v2, int len)
Calculate the scalar product of two vectors of floats.
void av_fft_permute(FFTContext *s, FFTComplex *z)
Do the permutation needed BEFORE calling ff_fft_calc().
#define AV_CH_SURROUND_DIRECT_RIGHT
#define AV_CH_LAYOUT_STEREO
struct AVFilterChannelLayouts * in_channel_layouts
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
static int close_sofa(struct MySofa *sofa)
const char * name
Pad name.
uint64_t av_get_channel_layout(const char *name)
Return a channel layout id that matches name, or 0 if no match is found.
AVFilterLink ** inputs
array of pointers to input links
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
#define AV_CH_TOP_BACK_LEFT
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(constuint8_t *) pi-0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(constint16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(constint32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(constint64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(constfloat *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(constdouble *) pi *(INT64_C(1)<< 63)))#defineFMT_PAIR_FUNC(out, in) staticconv_func_type *constfmt_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),};staticvoidcpy1(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, len);}staticvoidcpy2(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 2 *len);}staticvoidcpy4(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 4 *len);}staticvoidcpy8(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 8 *len);}AudioConvert *swri_audio_convert_alloc(enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, constint *ch_map, intflags){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) returnNULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) returnNULL;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)){case1:ctx->simd_f=cpy1;break;case2:ctx->simd_f=cpy2;break;case4:ctx->simd_f=cpy4;break;case8:ctx->simd_f=cpy8;break;}}if(HAVE_X86ASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);returnctx;}voidswri_audio_convert_free(AudioConvert **ctx){av_freep(ctx);}intswri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, intlen){intch;intoff=0;constintos=(out->planar?1:out->ch_count)*out->bps;unsignedmisaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){intplanes=in->planar?in->ch_count:1;unsignedm=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){intplanes=out->planar?out->ch_count:1;unsignedm=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){intplanes=out->planar?out->ch_count:1;for(ch=0;ch< planes;ch++){ctx->simd_f(out-> ch ch
#define AV_CH_TOP_BACK_CENTER
#define AV_CH_LOW_FREQUENCY
A filter pad used for either input or output.
A link between two filters.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
int min_samples
Minimum number of samples to filter at once.
int sample_rate
samples per second
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
static const uint16_t mask[17]
static int get_speaker_pos(AVFilterContext *ctx, float *speaker_azim, float *speaker_elev)
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static int query_formats(AVFilterContext *ctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
struct AVFilterChannelLayouts * out_channel_layouts
FFTContext * av_fft_init(int nbits, int inverse)
Set up a complex FFT.
static const uint8_t offset[127][2]
#define AV_CH_STEREO_RIGHT
See AV_CH_STEREO_LEFT.
static int load_data(AVFilterContext *ctx, int azim, int elev, float radius, int sample_rate)
audio channel layout utility functions
#define AV_CH_FRONT_LEFT_OF_CENTER
int partial_buf_size
Size of the partial buffer to allocate.
#define AV_CH_FRONT_CENTER
static const AVFilterPad outputs[]
#define AV_CH_FRONT_RIGHT_OF_CENTER
A list of supported channel layouts.
static const AVOption sofalizer_options[]
static int preload_sofa(AVFilterContext *ctx, char *filename, int *samplingrate)
char * av_strdup(const char *s)
Duplicate a string.
static int config_input(AVFilterLink *inlink)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
#define AV_CH_TOP_BACK_RIGHT
Describe the class of an AVClass context structure.
struct MYSOFA_EASY * easy
const char * name
Filter name.
static const AVFilterPad inputs[]
AVFilterLink ** outputs
array of pointers to output links
enum MovChannelLayoutTag * layouts
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
#define AV_CH_BACK_CENTER
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static int sofalizer_convolute(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
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 int parse_channel_name(char **arg, int *rchannel, char *buf)
static void fft(const int32_t in[2 *256], cplx32 out[256])
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
int channels
Number of channels.
avfilter_execute_func * execute
static av_cold int init(AVFilterContext *ctx)
static void parse_speaker_pos(AVFilterContext *ctx, int64_t in_channel_layout)
AVFilterContext * dst
dest filter
#define AV_CH_SURROUND_DIRECT_LEFT
#define AV_CH_FRONT_RIGHT
VirtualSpeaker vspkrpos[64]
#define av_malloc_array(a, b)
static av_cold void uninit(AVFilterContext *ctx)
void av_fft_calc(FFTContext *s, FFTComplex *z)
Do a complex FFT with the parameters defined in av_fft_init().
int nb_samples
number of audio samples (per channel) described by this frame
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
#define AV_CH_STEREO_LEFT
Stereo downmix.