FFmpeg
Data Structures | Macros | Functions | Variables
af_sofalizer.c File Reference
#include <math.h>
#include <mysofa.h>
#include "libavcodec/avfft.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 (char **arg, int *rchannel, char *buf)
 
static void parse_speaker_pos (AVFilterContext *ctx, int64_t in_channel_layout)
 
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 []
 
AVFilter ff_af_sofalizer
 

Macro Definition Documentation

#define TIME_DOMAIN   0

Definition at line 42 of file af_sofalizer.c.

Referenced by filter_frame(), and load_data().

#define FREQUENCY_DOMAIN   1

Definition at line 43 of file af_sofalizer.c.

Referenced by config_input(), filter_frame(), and load_data().

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

Definition at line 1044 of file af_sofalizer.c.

Definition at line 1045 of file af_sofalizer.c.

Function Documentation

static int close_sofa ( struct MySofa sofa)
static

Definition at line 117 of file af_sofalizer.c.

Referenced by uninit().

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

Definition at line 133 of file af_sofalizer.c.

Referenced by init().

static int parse_channel_name ( char **  arg,
int rchannel,
char *  buf 
)
static

Definition at line 186 of file af_sofalizer.c.

Referenced by parse_speaker_pos().

static void parse_speaker_pos ( AVFilterContext ctx,
int64_t  in_channel_layout 
)
static

Definition at line 211 of file af_sofalizer.c.

Referenced by get_speaker_pos().

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

Definition at line 244 of file af_sofalizer.c.

Referenced by load_data().

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

Definition at line 331 of file af_sofalizer.c.

Referenced by filter_frame().

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

Definition at line 431 of file af_sofalizer.c.

Referenced by filter_frame().

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 569 of file af_sofalizer.c.

Referenced by activate().

static int activate ( AVFilterContext ctx)
static

Definition at line 608 of file af_sofalizer.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 633 of file af_sofalizer.c.

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 675 of file af_sofalizer.c.

Referenced by load_data().

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

Definition at line 719 of file af_sofalizer.c.

Referenced by config_input().

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 957 of file af_sofalizer.c.

static int config_input ( AVFilterLink inlink)
static

Definition at line 988 of file af_sofalizer.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 1012 of file af_sofalizer.c.

AVFILTER_DEFINE_CLASS ( sofalizer  )

Variable Documentation

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 }
}
#define NULL
Definition: coverity.c:32
GLint GLenum type
Definition: opengl_enc.c:104
#define FLAGS
static void interpolate(float *out, float v1, float v2, int size)
Definition: twinvq.c:84
#define OFFSET(x)

Definition at line 1047 of file af_sofalizer.c.

const AVFilterPad inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int config_input(AVFilterLink *inlink)
Definition: af_sofalizer.c:988

Definition at line 1069 of file af_sofalizer.c.

const AVFilterPad outputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}
#define NULL
Definition: coverity.c:32

Definition at line 1078 of file af_sofalizer.c.

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,
}
static int query_formats(AVFilterContext *ctx)
Definition: af_sofalizer.c:633
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:116
static const AVFilterPad outputs[]
static int activate(AVFilterContext *ctx)
Definition: af_sofalizer.c:608
static const AVFilterPad inputs[]
#define flags(name, subs,...)
Definition: cbs_av1.c:561
static av_cold int init(AVFilterContext *ctx)
Definition: af_sofalizer.c:957
static av_cold void uninit(AVFilterContext *ctx)

Definition at line 1086 of file af_sofalizer.c.