FFmpeg
Loading...
Searching...
No Matches
af_headphone.c File Reference
#include <math.h>
#include "libavutil/avstring.h"
#include "libavutil/channel_layout.h"
#include "libavutil/float_dsp.h"
#include "libavutil/intmath.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/tx.h"
#include "avfilter.h"
#include "filters.h"
#include "formats.h"
#include "audio.h"

Go to the source code of this file.

Data Structures

struct  HeadphoneContext
 
struct  HeadphoneContext::hrir_inputs
 
struct  ThreadData
 Used for passing data between threads. More...
 

Macros

#define TIME_DOMAIN   0
 
#define FREQUENCY_DOMAIN   1
 
#define HRIR_STEREO   0
 
#define HRIR_MULTI   1
 
#define OFFSET(x)
 
#define FLAGS   AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 

Functions

static int parse_channel_name (const char *arg, enum AVChannel *rchannel)
 
static void parse_map (AVFilterContext *ctx)
 
static int headphone_convolute (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int headphone_fast_convolute (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int check_ir (AVFilterLink *inlink, int input_number)
 
static int headphone_frame (HeadphoneContext *s, AVFrame *in, AVFilterLink *outlink)
 
static int convert_coeffs (AVFilterContext *ctx, AVFilterLink *inlink)
 
static int activate (AVFilterContext *ctx)
 
static int query_formats (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
 
static int config_input (AVFilterLink *inlink)
 
static av_cold int init (AVFilterContext *ctx)
 
static int config_output (AVFilterLink *outlink)
 
static av_cold void uninit (AVFilterContext *ctx)
 
 AVFILTER_DEFINE_CLASS (headphone)
 

Variables

static const AVOption headphone_options []
 
static const AVFilterPad outputs []
 
const FFFilter ff_af_headphone
 

Macro Definition Documentation

◆ TIME_DOMAIN

#define TIME_DOMAIN   0

Definition at line 36 of file af_headphone.c.

Referenced by convert_coeffs(), filter_frame(), headphone_frame(), init(), and load_data().

◆ FREQUENCY_DOMAIN

#define FREQUENCY_DOMAIN   1

Definition at line 37 of file af_headphone.c.

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

◆ HRIR_STEREO

#define HRIR_STEREO   0

Definition at line 39 of file af_headphone.c.

Referenced by convert_coeffs().

◆ HRIR_MULTI

#define HRIR_MULTI   1

Definition at line 40 of file af_headphone.c.

Referenced by config_output(), parse_map(), and query_formats().

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 752 of file af_headphone.c.

◆ FLAGS

Definition at line 753 of file af_headphone.c.

Function Documentation

◆ parse_channel_name()

static int parse_channel_name ( const char * arg,
enum AVChannel * rchannel )
static

Definition at line 91 of file af_headphone.c.

Referenced by parse_map().

◆ parse_map()

static void parse_map ( AVFilterContext * ctx)
static

Definition at line 101 of file af_headphone.c.

Referenced by init().

◆ headphone_convolute()

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

Definition at line 144 of file af_headphone.c.

Referenced by headphone_frame().

◆ headphone_fast_convolute()

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

Definition at line 215 of file af_headphone.c.

Referenced by headphone_frame().

◆ check_ir()

static int check_ir ( AVFilterLink * inlink,
int input_number )
static

Definition at line 308 of file af_headphone.c.

Referenced by activate().

◆ headphone_frame()

static int headphone_frame ( HeadphoneContext * s,
AVFrame * in,
AVFilterLink * outlink )
static

Definition at line 336 of file af_headphone.c.

Referenced by activate().

◆ convert_coeffs()

static int convert_coeffs ( AVFilterContext * ctx,
AVFilterLink * inlink )
static

Definition at line 372 of file af_headphone.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext * ctx)
static

Definition at line 539 of file af_headphone.c.

◆ query_formats()

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

Definition at line 597 of file af_headphone.c.

◆ config_input()

static int config_input ( AVFilterLink * inlink)
static

Definition at line 650 of file af_headphone.c.

◆ init()

static av_cold int init ( AVFilterContext * ctx)
static

Definition at line 665 of file af_headphone.c.

◆ config_output()

static int config_output ( AVFilterLink * outlink)
static

Definition at line 708 of file af_headphone.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext * ctx)
static

Definition at line 728 of file af_headphone.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( headphone )

Variable Documentation

◆ headphone_options

const AVOption headphone_options[]
static
Initial value:
= {
{ "map", "set channels convolution mappings", OFFSET(map), 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 },
{ "lfe", "set lfe gain in dB", OFFSET(lfe_gain), AV_OPT_TYPE_FLOAT, {.dbl=0}, -20, 40, .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" },
{ "size", "set frame size", OFFSET(size), AV_OPT_TYPE_INT, {.i64=1024},1024,96000, .flags = FLAGS },
{ "hrir", "set hrir format", OFFSET(hrir_fmt), AV_OPT_TYPE_INT, {.i64=HRIR_STEREO}, 0, 1, .flags = FLAGS, .unit = "hrir" },
{ "stereo", "hrir files have exactly 2 channels", 0, AV_OPT_TYPE_CONST, {.i64=HRIR_STEREO}, 0, 0, .flags = FLAGS, .unit = "hrir" },
{ "multich", "single multichannel hrir file", 0, AV_OPT_TYPE_CONST, {.i64=HRIR_MULTI}, 0, 0, .flags = FLAGS, .unit = "hrir" },
{ NULL }
}
#define HRIR_MULTI
#define HRIR_STEREO
#define FLAGS
Definition cmdutils.c:598
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition opt.h:270
@ 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:275
cl_device_type type
const VDPAUPixFmtMap * map
int size

Definition at line 755 of file af_headphone.c.

◆ outputs

const AVFilterPad outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
}
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
static int config_output(AVBitStreamFilterLink *outlink)

Definition at line 771 of file af_headphone.c.

◆ ff_af_headphone

const FFFilter ff_af_headphone
Initial value:
= {
.p.name = "headphone",
.p.description = NULL_IF_CONFIG_SMALL("Apply headphone binaural spatialization with HRTFs in additional streams."),
.p.priv_class = &headphone_class,
.priv_size = sizeof(HeadphoneContext),
.init = init,
}
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition aeval.c:246
static const AVFilterPad outputs[]
Definition af_aap.c:310
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition avfilter.h:166
#define AVFILTER_FLAG_DYNAMIC_INPUTS
The number of the filter inputs is not determined just by AVFilter.inputs.
Definition avfilter.h:155
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_QUERY_FUNC2(func)
Definition filters.h:241
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88

Definition at line 779 of file af_headphone.c.