FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
af_surround.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/tx.h"
#include "avfilter.h"
#include "audio.h"
#include "filters.h"
#include "formats.h"
#include "window_func.h"

Go to the source code of this file.

Data Structures

struct  AudioSurroundContext
 

Macros

#define MIN_MAG_SUM   0.00000001f
 
#define TRANSFORM
 
#define OFFSET(x)   offsetof(AudioSurroundContext, x)
 
#define FLAGS   AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
 
#define TFLAGS   AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM
 

Enumerations

enum  SurroundChannel {
  SC_FL, SC_FR, SC_FC, SC_LF,
  SC_BL, SC_BR, SC_BC, SC_SL,
  SC_SR, SC_NB
}
 

Functions

static int query_formats (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
 
static void set_input_levels (AVFilterContext *ctx)
 
static void set_output_levels (AVFilterContext *ctx)
 
static int config_input (AVFilterLink *inlink)
 
static int config_output (AVFilterLink *outlink)
 
static float sqrf (float x)
 
static float r_distance (float a)
 
static void angle_transform (float *x, float *y, float angle)
 
static void focus_transform (float *x, float *y, float focus)
 
static void stereo_position (float a, float p, float *x, float *y)
 
static void get_lfe (int output_lfe, int n, float lowcut, float highcut, float *lfe_mag, float c_mag, float *mag_total, int lfe_mode)
 
static void calculate_factors (AVFilterContext *ctx, int ch, int chan)
 
static void do_transform (AVFilterContext *ctx, int ch)
 
static void stereo_copy (AVFilterContext *ctx, int ch, int chan)
 
static void stereo_upmix (AVFilterContext *ctx, int ch)
 
static void l2_1_upmix (AVFilterContext *ctx, int ch)
 
static void surround_upmix (AVFilterContext *ctx, int ch)
 
static void upmix_7_1_5_0_side (AVFilterContext *ctx, float c_re, float c_im, float mag_totall, float mag_totalr, float fl_phase, float fr_phase, float bl_phase, float br_phase, float sl_phase, float sr_phase, float xl, float yl, float xr, float yr, int n)
 
static void upmix_7_1_5_1 (AVFilterContext *ctx, float c_re, float c_im, float lfe_re, float lfe_im, float mag_totall, float mag_totalr, float fl_phase, float fr_phase, float bl_phase, float br_phase, float sl_phase, float sr_phase, float xl, float yl, float xr, float yr, int n)
 
static void filter_stereo (AVFilterContext *ctx)
 
static void filter_2_1 (AVFilterContext *ctx)
 
static void filter_surround (AVFilterContext *ctx)
 
static void filter_5_0_side (AVFilterContext *ctx)
 
static void filter_5_1_side (AVFilterContext *ctx)
 
static void filter_5_1_back (AVFilterContext *ctx)
 
static void allchannels_spread (AVFilterContext *ctx)
 
static av_cold int init (AVFilterContext *ctx)
 
static int fft_channel (AVFilterContext *ctx, AVFrame *in, int ch)
 
static int fft_channels (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int ifft_channel (AVFilterContext *ctx, AVFrame *out, int ch)
 
static int ifft_channels (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static int activate (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int process_command (AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
 
 AVFILTER_DEFINE_CLASS (surround)
 

Variables

static const int ch_map [SC_NB]
 
static const int sc_map [16]
 
static const AVOption surround_options []
 
static const AVFilterPad inputs []
 
static const AVFilterPad outputs []
 
const AVFilter ff_af_surround
 

Macro Definition Documentation

◆ MIN_MAG_SUM

#define MIN_MAG_SUM   0.00000001f

Definition at line 326 of file af_surround.c.

◆ TRANSFORM

#define TRANSFORM
Value:
dst[2 * n ] = mag * cosf(ph); \
dst[2 * n + 1] = mag * sinf(ph);

Definition at line 389 of file af_surround.c.

◆ OFFSET

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

Definition at line 1435 of file af_surround.c.

◆ FLAGS

Definition at line 1436 of file af_surround.c.

◆ TFLAGS

Definition at line 1437 of file af_surround.c.

Enumeration Type Documentation

◆ SurroundChannel

Enumerator
SC_FL 
SC_FR 
SC_FC 
SC_LF 
SC_BL 
SC_BR 
SC_BC 
SC_SL 
SC_SR 
SC_NB 

Definition at line 32 of file af_surround.c.

Function Documentation

◆ query_formats()

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

Definition at line 149 of file af_surround.c.

◆ set_input_levels()

static void set_input_levels ( AVFilterContext ctx)
static

Definition at line 187 of file af_surround.c.

Referenced by config_input(), and process_command().

◆ set_output_levels()

static void set_output_levels ( AVFilterContext ctx)
static

Definition at line 202 of file af_surround.c.

Referenced by config_output(), and process_command().

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 217 of file af_surround.c.

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 261 of file af_surround.c.

◆ sqrf()

static float sqrf ( float  x)
static

Definition at line 316 of file af_surround.c.

Referenced by r_distance().

◆ r_distance()

static float r_distance ( float  a)
static

Definition at line 321 of file af_surround.c.

Referenced by angle_transform(), and focus_transform().

◆ angle_transform()

static void angle_transform ( float x,
float y,
float  angle 
)
static

Definition at line 328 of file af_surround.c.

Referenced by filter_2_1(), filter_stereo(), and filter_surround().

◆ focus_transform()

static void focus_transform ( float x,
float y,
float  focus 
)
static

Definition at line 352 of file af_surround.c.

Referenced by filter_2_1(), filter_stereo(), and filter_surround().

◆ stereo_position()

static void stereo_position ( float  a,
float  p,
float x,
float y 
)
static

◆ get_lfe()

static void get_lfe ( int  output_lfe,
int  n,
float  lowcut,
float  highcut,
float lfe_mag,
float  c_mag,
float mag_total,
int  lfe_mode 
)
inlinestatic

Definition at line 376 of file af_surround.c.

Referenced by filter_stereo(), filter_surround(), and upmix_7_1_5_0_side().

◆ calculate_factors()

static void calculate_factors ( AVFilterContext ctx,
int  ch,
int  chan 
)
static

Definition at line 393 of file af_surround.c.

Referenced by l2_1_upmix(), stereo_upmix(), and surround_upmix().

◆ do_transform()

static void do_transform ( AVFilterContext ctx,
int  ch 
)
static

Definition at line 447 of file af_surround.c.

Referenced by l2_1_upmix(), stereo_upmix(), and surround_upmix().

◆ stereo_copy()

static void stereo_copy ( AVFilterContext ctx,
int  ch,
int  chan 
)
static

Definition at line 476 of file af_surround.c.

Referenced by stereo_upmix(), and surround_upmix().

◆ stereo_upmix()

static void stereo_upmix ( AVFilterContext ctx,
int  ch 
)
static

Definition at line 530 of file af_surround.c.

Referenced by init().

◆ l2_1_upmix()

static void l2_1_upmix ( AVFilterContext ctx,
int  ch 
)
static

Definition at line 542 of file af_surround.c.

Referenced by init().

◆ surround_upmix()

static void surround_upmix ( AVFilterContext ctx,
int  ch 
)
static

Definition at line 611 of file af_surround.c.

Referenced by init().

◆ upmix_7_1_5_0_side()

static void upmix_7_1_5_0_side ( AVFilterContext ctx,
float  c_re,
float  c_im,
float  mag_totall,
float  mag_totalr,
float  fl_phase,
float  fr_phase,
float  bl_phase,
float  br_phase,
float  sl_phase,
float  sr_phase,
float  xl,
float  yl,
float  xr,
float  yr,
int  n 
)
static

Definition at line 630 of file af_surround.c.

Referenced by init().

◆ upmix_7_1_5_1()

static void upmix_7_1_5_1 ( AVFilterContext ctx,
float  c_re,
float  c_im,
float  lfe_re,
float  lfe_im,
float  mag_totall,
float  mag_totalr,
float  fl_phase,
float  fr_phase,
float  bl_phase,
float  br_phase,
float  sl_phase,
float  sr_phase,
float  xl,
float  yl,
float  xr,
float  yr,
int  n 
)
static

Definition at line 690 of file af_surround.c.

Referenced by init().

◆ filter_stereo()

static void filter_stereo ( AVFilterContext ctx)
static

Definition at line 746 of file af_surround.c.

Referenced by init().

◆ filter_2_1()

static void filter_2_1 ( AVFilterContext ctx)
static

Definition at line 801 of file af_surround.c.

Referenced by init().

◆ filter_surround()

static void filter_surround ( AVFilterContext ctx)
static

Definition at line 858 of file af_surround.c.

Referenced by init().

◆ filter_5_0_side()

static void filter_5_0_side ( AVFilterContext ctx)
static

Definition at line 915 of file af_surround.c.

Referenced by init().

◆ filter_5_1_side()

static void filter_5_1_side ( AVFilterContext ctx)
static

Definition at line 973 of file af_surround.c.

Referenced by init().

◆ filter_5_1_back()

static void filter_5_1_back ( AVFilterContext ctx)
static

Definition at line 1033 of file af_surround.c.

Referenced by init().

◆ allchannels_spread()

static void allchannels_spread ( AVFilterContext ctx)
static

Definition at line 1093 of file af_surround.c.

Referenced by init(), and process_command().

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 1107 of file af_surround.c.

◆ fft_channel()

static int fft_channel ( AVFilterContext ctx,
AVFrame in,
int  ch 
)
static

Definition at line 1239 of file af_surround.c.

Referenced by fft_channels().

◆ fft_channels()

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

Definition at line 1261 of file af_surround.c.

Referenced by filter_frame().

◆ ifft_channel()

static int ifft_channel ( AVFilterContext ctx,
AVFrame out,
int  ch 
)
static

Definition at line 1273 of file af_surround.c.

Referenced by ifft_channels().

◆ ifft_channels()

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

Definition at line 1301 of file af_surround.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 1317 of file af_surround.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 1345 of file af_surround.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 1380 of file af_surround.c.

◆ process_command()

static int process_command ( AVFilterContext ctx,
const char *  cmd,
const char *  args,
char *  res,
int  res_len,
int  flags 
)
static

Definition at line 1416 of file af_surround.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( surround  )

Variable Documentation

◆ ch_map

const int ch_map[SC_NB]
static

◆ sc_map

const int sc_map[16]
static

◆ surround_options

const AVOption surround_options[]
static

Definition at line 1439 of file af_surround.c.

◆ inputs

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

Definition at line 1497 of file af_surround.c.

◆ outputs

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

Definition at line 1505 of file af_surround.c.

◆ ff_af_surround

const AVFilter ff_af_surround
Initial value:
= {
.name = "surround",
.description = NULL_IF_CONFIG_SMALL("Apply audio surround upmix filter."),
.priv_size = sizeof(AudioSurroundContext),
.priv_class = &surround_class,
.init = init,
.process_command = process_command,
}

Definition at line 1513 of file af_surround.c.

AudioSurroundContext
Definition: af_surround.c:61
SC_BC
@ SC_BC
Definition: af_surround.c:33
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
ph
static int FUNC() ph(CodedBitstreamContext *ctx, RWContext *rw, H266RawPH *current)
Definition: cbs_h266_syntax_template.c:3034
process_command
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: af_surround.c:1416
SC_FC
@ SC_FC
Definition: af_surround.c:33
SC_FL
@ SC_FL
Definition: af_surround.c:33
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_surround.c:1380
cosf
#define cosf(x)
Definition: libm.h:78
SC_BL
@ SC_BL
Definition: af_surround.c:33
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
SC_LF
@ SC_LF
Definition: af_surround.c:33
outputs
static const AVFilterPad outputs[]
Definition: af_surround.c:1505
AV_CHAN_SIDE_RIGHT
@ AV_CHAN_SIDE_RIGHT
Definition: channel_layout.h:60
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
SC_BR
@ SC_BR
Definition: af_surround.c:33
sinf
#define sinf(x)
Definition: libm.h:419
AV_CHAN_FRONT_RIGHT
@ AV_CHAN_FRONT_RIGHT
Definition: channel_layout.h:51
AV_CHAN_FRONT_CENTER
@ AV_CHAN_FRONT_CENTER
Definition: channel_layout.h:52
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
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
AV_CHAN_LOW_FREQUENCY
@ AV_CHAN_LOW_FREQUENCY
Definition: channel_layout.h:53
activate
static int activate(AVFilterContext *ctx)
Definition: af_surround.c:1345
AV_CHAN_BACK_RIGHT
@ AV_CHAN_BACK_RIGHT
Definition: channel_layout.h:55
AV_CHAN_SIDE_LEFT
@ AV_CHAN_SIDE_LEFT
Definition: channel_layout.h:59
SC_FR
@ SC_FR
Definition: af_surround.c:33
config_output
static int config_output(AVFilterLink *outlink)
Definition: af_surround.c:261
FILTER_QUERY_FUNC2
#define FILTER_QUERY_FUNC2(func)
Definition: filters.h:239
config_input
static int config_input(AVFilterLink *inlink)
Definition: af_surround.c:217
AV_CHAN_BACK_CENTER
@ AV_CHAN_BACK_CENTER
Definition: channel_layout.h:58
AV_CHAN_BACK_LEFT
@ AV_CHAN_BACK_LEFT
Definition: channel_layout.h:54
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
query_formats
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition: af_surround.c:149
SC_SL
@ SC_SL
Definition: af_surround.c:33
SC_SR
@ SC_SR
Definition: af_surround.c:33
init
static av_cold int init(AVFilterContext *ctx)
Definition: af_surround.c:1107
AV_CHAN_FRONT_LEFT
@ AV_CHAN_FRONT_LEFT
Definition: channel_layout.h:50
inputs
static const AVFilterPad inputs[]
Definition: af_surround.c:1497