FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
af_surround.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/opt.h"
#include "libavutil/tx.h"
#include "avfilter.h"
#include "audio.h"
#include "filters.h"
#include "internal.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 (AVFilterContext *ctx)
 
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 323 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 386 of file af_surround.c.

◆ OFFSET

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

Definition at line 1407 of file af_surround.c.

◆ FLAGS

Definition at line 1408 of file af_surround.c.

◆ TFLAGS

Definition at line 1409 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 ( AVFilterContext ctx)
static

Definition at line 149 of file af_surround.c.

◆ set_input_levels()

static void set_input_levels ( AVFilterContext ctx)
static

Definition at line 184 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 199 of file af_surround.c.

Referenced by config_output(), and process_command().

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 214 of file af_surround.c.

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 258 of file af_surround.c.

◆ sqrf()

static float sqrf ( float  x)
static

Definition at line 313 of file af_surround.c.

Referenced by r_distance().

◆ r_distance()

static float r_distance ( float  a)
static

Definition at line 318 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 325 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 349 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 373 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 390 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 444 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 473 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 527 of file af_surround.c.

Referenced by init().

◆ l2_1_upmix()

static void l2_1_upmix ( AVFilterContext ctx,
int  ch 
)
static

Definition at line 539 of file af_surround.c.

Referenced by init().

◆ surround_upmix()

static void surround_upmix ( AVFilterContext ctx,
int  ch 
)
static

Definition at line 608 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 627 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 687 of file af_surround.c.

Referenced by init().

◆ filter_stereo()

static void filter_stereo ( AVFilterContext ctx)
static

Definition at line 743 of file af_surround.c.

Referenced by init().

◆ filter_2_1()

static void filter_2_1 ( AVFilterContext ctx)
static

Definition at line 798 of file af_surround.c.

Referenced by init().

◆ filter_surround()

static void filter_surround ( AVFilterContext ctx)
static

Definition at line 855 of file af_surround.c.

Referenced by init().

◆ filter_5_0_side()

static void filter_5_0_side ( AVFilterContext ctx)
static

Definition at line 912 of file af_surround.c.

Referenced by init().

◆ filter_5_1_side()

static void filter_5_1_side ( AVFilterContext ctx)
static

Definition at line 970 of file af_surround.c.

Referenced by init().

◆ filter_5_1_back()

static void filter_5_1_back ( AVFilterContext ctx)
static

Definition at line 1030 of file af_surround.c.

Referenced by init().

◆ allchannels_spread()

static void allchannels_spread ( AVFilterContext ctx)
static

Definition at line 1090 of file af_surround.c.

Referenced by init(), and process_command().

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 1104 of file af_surround.c.

◆ fft_channel()

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

Definition at line 1211 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 1233 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 1245 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 1273 of file af_surround.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 1289 of file af_surround.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 1317 of file af_surround.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 1352 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 1388 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 1411 of file af_surround.c.

◆ inputs

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

Definition at line 1469 of file af_surround.c.

◆ outputs

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

Definition at line 1477 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 1485 of file af_surround.c.

AudioSurroundContext
Definition: af_surround.c:61
SC_BC
@ SC_BC
Definition: af_surround.c:33
ph
static int FUNC() ph(CodedBitstreamContext *ctx, RWContext *rw, H266RawPH *current)
Definition: cbs_h266_syntax_template.c:3002
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:1388
SC_FC
@ SC_FC
Definition: af_surround.c:33
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:159
SC_FL
@ SC_FL
Definition: af_surround.c:33
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_surround.c:1352
cosf
#define cosf(x)
Definition: libm.h:78
SC_BL
@ SC_BL
Definition: af_surround.c:33
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: af_surround.c:149
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:1477
AV_CHAN_SIDE_RIGHT
@ AV_CHAN_SIDE_RIGHT
Definition: channel_layout.h:60
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
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:106
AV_CHAN_LOW_FREQUENCY
@ AV_CHAN_LOW_FREQUENCY
Definition: channel_layout.h:53
activate
static int activate(AVFilterContext *ctx)
Definition: af_surround.c:1317
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:258
config_input
static int config_input(AVFilterLink *inlink)
Definition: af_surround.c:214
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:117
SC_SL
@ SC_SL
Definition: af_surround.c:33
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
SC_SR
@ SC_SR
Definition: af_surround.c:33
init
static av_cold int init(AVFilterContext *ctx)
Definition: af_surround.c:1104
AV_CHAN_FRONT_LEFT
@ AV_CHAN_FRONT_LEFT
Definition: channel_layout.h:50
inputs
static const AVFilterPad inputs[]
Definition: af_surround.c:1469