FFmpeg
Data Structures | Macros | Functions | Variables
af_sofalizer.c File Reference
#include <math.h>
#include <mysofa.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 "internal.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 (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 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 []
 
static const AVFilterPad outputs []
 
const AVFilter ff_af_sofalizer
 

Macro Definition Documentation

◆ TIME_DOMAIN

#define TIME_DOMAIN   0

Definition at line 42 of file af_sofalizer.c.

◆ FREQUENCY_DOMAIN

#define FREQUENCY_DOMAIN   1

Definition at line 43 of file af_sofalizer.c.

◆ OFFSET

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

Definition at line 1056 of file af_sofalizer.c.

◆ FLAGS

Definition at line 1057 of file af_sofalizer.c.

Function Documentation

◆ close_sofa()

static int close_sofa ( struct MySofa sofa)
static

Definition at line 119 of file af_sofalizer.c.

Referenced by uninit().

◆ preload_sofa()

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

Definition at line 135 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 188 of file af_sofalizer.c.

Referenced by parse_speaker_pos().

◆ parse_speaker_pos()

static void parse_speaker_pos ( AVFilterContext ctx)
static

Definition at line 217 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 248 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 332 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 432 of file af_sofalizer.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 572 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 ( AVFilterContext ctx)
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 672 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 716 of file af_sofalizer.c.

Referenced by config_input().

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 967 of file af_sofalizer.c.

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 998 of file af_sofalizer.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 1022 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, "type" },
{ "time", "time domain", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, .flags = FLAGS, "type" },
{ "freq", "frequency domain", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, .flags = FLAGS, "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 1059 of file af_sofalizer.c.

◆ inputs

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

Definition at line 1081 of file af_sofalizer.c.

◆ outputs

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

Definition at line 1089 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 1096 of file af_sofalizer.c.

SOFAlizerContext
Definition: af_sofalizer.c:62
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:167
outputs
static const AVFilterPad outputs[]
Definition: af_sofalizer.c:1089
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:998
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
init
static av_cold int init(AVFilterContext *ctx)
Definition: af_sofalizer.c:967
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:190
activate
static int activate(AVFilterContext *ctx)
Definition: af_sofalizer.c:612
NULL
#define NULL
Definition: coverity.c:32
inputs
static const AVFilterPad inputs[]
Definition: af_sofalizer.c:1081
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:115
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: af_sofalizer.c:637
OFFSET
#define OFFSET(x)
Definition: af_sofalizer.c:1056
interpolate
static void interpolate(float *out, float v1, float v2, int size)
Definition: twinvq.c:84
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:228
normalize
Definition: normalize.py:1
FLAGS
#define FLAGS
Definition: af_sofalizer.c:1057
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_sofalizer.c:1022
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
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:127
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:244
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:191
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:229
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234