FFmpeg
Data Structures | Macros | Functions | Variables
af_sofalizer.c File Reference
#include <math.h>
#include <mysofa.h>
#include "libavutil/mem.h"
#include "libavutil/tx.h"
#include "libavutil/avstring.h"
#include "libavutil/channel_layout.h"
#include "libavutil/float_dsp.h"
#include "libavutil/intmath.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "filters.h"
#include "formats.h"
#include "audio.h"

Go to the source code of this file.

Data Structures

struct  MySofa
 
struct  VirtualSpeaker
 
struct  SOFAlizerContext
 
struct  ThreadData
 Used for passing data between threads. More...
 

Macros

#define TIME_DOMAIN   0
 
#define FREQUENCY_DOMAIN   1
 
#define OFFSET(x)   offsetof(SOFAlizerContext, x)
 
#define FLAGS   AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 

Functions

static int close_sofa (struct MySofa *sofa)
 
static int preload_sofa (AVFilterContext *ctx, char *filename, int *samplingrate)
 
static int parse_channel_name (AVFilterContext *ctx, char **arg, int *rchannel)
 
static void parse_speaker_pos (AVFilterContext *ctx)
 
static int get_speaker_pos (AVFilterContext *ctx, float *speaker_azim, float *speaker_elev)
 
static int sofalizer_convolute (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int sofalizer_fast_convolute (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static int activate (AVFilterContext *ctx)
 
static int query_formats (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
 
static int getfilter_float (AVFilterContext *ctx, float x, float y, float z, float *left, float *right, float *delay_left, float *delay_right)
 
static int load_data (AVFilterContext *ctx, int azim, int elev, float radius, int sample_rate)
 
static av_cold int init (AVFilterContext *ctx)
 
static int config_input (AVFilterLink *inlink)
 
static av_cold void uninit (AVFilterContext *ctx)
 
 AVFILTER_DEFINE_CLASS (sofalizer)
 

Variables

static const AVOption sofalizer_options []
 
static const AVFilterPad inputs []
 
const AVFilter ff_af_sofalizer
 

Macro Definition Documentation

◆ TIME_DOMAIN

#define TIME_DOMAIN   0

Definition at line 43 of file af_sofalizer.c.

◆ FREQUENCY_DOMAIN

#define FREQUENCY_DOMAIN   1

Definition at line 44 of file af_sofalizer.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(SOFAlizerContext, x)

Definition at line 1058 of file af_sofalizer.c.

◆ FLAGS

Definition at line 1059 of file af_sofalizer.c.

Function Documentation

◆ close_sofa()

static int close_sofa ( struct MySofa sofa)
static

Definition at line 120 of file af_sofalizer.c.

Referenced by uninit().

◆ preload_sofa()

static int preload_sofa ( AVFilterContext ctx,
char *  filename,
int *  samplingrate 
)
static

Definition at line 136 of file af_sofalizer.c.

Referenced by init().

◆ parse_channel_name()

static int parse_channel_name ( AVFilterContext ctx,
char **  arg,
int *  rchannel 
)
static

Definition at line 189 of file af_sofalizer.c.

Referenced by parse_speaker_pos().

◆ parse_speaker_pos()

static void parse_speaker_pos ( AVFilterContext ctx)
static

Definition at line 218 of file af_sofalizer.c.

Referenced by get_speaker_pos().

◆ get_speaker_pos()

static int get_speaker_pos ( AVFilterContext ctx,
float speaker_azim,
float speaker_elev 
)
static

Definition at line 249 of file af_sofalizer.c.

Referenced by load_data().

◆ sofalizer_convolute()

static int sofalizer_convolute ( AVFilterContext ctx,
void *  arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 333 of file af_sofalizer.c.

Referenced by filter_frame().

◆ sofalizer_fast_convolute()

static int sofalizer_fast_convolute ( AVFilterContext ctx,
void *  arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 433 of file af_sofalizer.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 573 of file af_sofalizer.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 612 of file af_sofalizer.c.

◆ query_formats()

static int query_formats ( const AVFilterContext ctx,
AVFilterFormatsConfig **  cfg_in,
AVFilterFormatsConfig **  cfg_out 
)
static

Definition at line 637 of file af_sofalizer.c.

◆ getfilter_float()

static int getfilter_float ( AVFilterContext ctx,
float  x,
float  y,
float  z,
float left,
float right,
float delay_left,
float delay_right 
)
static

Definition at line 674 of file af_sofalizer.c.

Referenced by load_data().

◆ load_data()

static int load_data ( AVFilterContext ctx,
int  azim,
int  elev,
float  radius,
int  sample_rate 
)
static

Definition at line 718 of file af_sofalizer.c.

Referenced by config_input().

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 969 of file af_sofalizer.c.

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 1000 of file af_sofalizer.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 1024 of file af_sofalizer.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( sofalizer  )

Variable Documentation

◆ sofalizer_options

const AVOption sofalizer_options[]
static
Initial value:
= {
{ "sofa", "sofa filename", OFFSET(filename), AV_OPT_TYPE_STRING, {.str=NULL}, .flags = FLAGS },
{ "gain", "set gain in dB", OFFSET(gain), AV_OPT_TYPE_FLOAT, {.dbl=0}, -20, 40, .flags = FLAGS },
{ "rotation", "set rotation" , OFFSET(rotation), AV_OPT_TYPE_FLOAT, {.dbl=0}, -360, 360, .flags = FLAGS },
{ "elevation", "set elevation", OFFSET(elevation), AV_OPT_TYPE_FLOAT, {.dbl=0}, -90, 90, .flags = FLAGS },
{ "radius", "set radius", OFFSET(radius), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 5, .flags = FLAGS },
{ "type", "set processing", OFFSET(type), AV_OPT_TYPE_INT, {.i64=1}, 0, 1, .flags = FLAGS, .unit = "type" },
{ "time", "time domain", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, .flags = FLAGS, .unit = "type" },
{ "freq", "frequency domain", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, .flags = FLAGS, .unit = "type" },
{ "speakers", "set speaker custom positions", OFFSET(speakers_pos), AV_OPT_TYPE_STRING, {.str=0}, 0, 0, .flags = FLAGS },
{ "lfegain", "set lfe gain", OFFSET(lfe_gain), AV_OPT_TYPE_FLOAT, {.dbl=0}, -20,40, .flags = FLAGS },
{ "framesize", "set frame size", OFFSET(framesize), AV_OPT_TYPE_INT, {.i64=1024},1024,96000, .flags = FLAGS },
{ "normalize", "normalize IRs", OFFSET(normalize), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, .flags = FLAGS },
{ "interpolate","interpolate IRs from neighbors", OFFSET(interpolate),AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, .flags = FLAGS },
{ "minphase", "minphase IRs", OFFSET(minphase), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, .flags = FLAGS },
{ "anglestep", "set neighbor search angle step", OFFSET(anglestep), AV_OPT_TYPE_FLOAT, {.dbl=.5}, 0.01, 10, .flags = FLAGS },
{ "radstep", "set neighbor search radius step", OFFSET(radstep), AV_OPT_TYPE_FLOAT, {.dbl=.01}, 0.01, 1, .flags = FLAGS },
{ NULL }
}

Definition at line 1061 of file af_sofalizer.c.

◆ inputs

const AVFilterPad inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
},
}

Definition at line 1083 of file af_sofalizer.c.

◆ ff_af_sofalizer

const AVFilter ff_af_sofalizer
Initial value:
= {
.name = "sofalizer",
.description = NULL_IF_CONFIG_SMALL("SOFAlizer (Spatially Oriented Format for Acoustics)."),
.priv_size = sizeof(SOFAlizerContext),
.priv_class = &sofalizer_class,
.init = init,
}

Definition at line 1091 of file af_sofalizer.c.

SOFAlizerContext
Definition: af_sofalizer.c:63
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
config_input
static int config_input(AVFilterLink *inlink)
Definition: af_sofalizer.c:1000
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
init
static av_cold int init(AVFilterContext *ctx)
Definition: af_sofalizer.c:969
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
activate
static int activate(AVFilterContext *ctx)
Definition: af_sofalizer.c:612
NULL
#define NULL
Definition: coverity.c:32
ff_audio_default_filterpad
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
Definition: audio.c:34
query_formats
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition: af_sofalizer.c:637
inputs
static const AVFilterPad inputs[]
Definition: af_sofalizer.c:1083
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
OFFSET
#define OFFSET(x)
Definition: af_sofalizer.c:1058
interpolate
static void interpolate(float *out, float v1, float v2, int size)
Definition: twinvq.c:85
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition: opt.h:271
normalize
Definition: normalize.py:1
FLAGS
#define FLAGS
Definition: af_sofalizer.c:1059
FILTER_QUERY_FUNC2
#define FILTER_QUERY_FUNC2(func)
Definition: filters.h:239
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_sofalizer.c:1024
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:152
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
AV_OPT_TYPE_STRING
@ 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...
Definition: opt.h:276
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299