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

Go to the source code of this file.

Data Structures

struct  SpectrumSynthContext
 

Macros

#define OFFSET(x)   offsetof(SpectrumSynthContext, x)
 
#define A   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_AUDIO_PARAM
 
#define V   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 

Enumerations

enum  MagnitudeScale { LINEAR, LOG, NB_SCALES }
 
enum  SlideMode {
  REPLACE, SCROLL, NB_SLIDES, SLIDE_REPLACE,
  SLIDE_SCROLL, SLIDE_FRAME, NB_SLIDE, REPLACE,
  SCROLL, FULLFRAME, RSCROLL, LREPLACE,
  NB_SLIDES, REPLACE, SCROLL, FULLFRAME,
  RSCROLL, NB_SLIDES
}
 
enum  Orientation {
  VERTICAL, HORIZONTAL, NB_ORIENTATIONS, VERTICAL,
  HORIZONTAL, NB_ORIENTATIONS
}
 
enum  { MAGNITUDE = 0, PHASE = 1 }
 

Functions

 AVFILTER_DEFINE_CLASS (spectrumsynth)
 
static int query_formats (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
 
static int config_output (AVFilterLink *outlink)
 
static void read16_fft_bin (SpectrumSynthContext *s, int x, int y, int f, int ch)
 
static void read8_fft_bin (SpectrumSynthContext *s, int x, int y, int f, int ch)
 
static void read_fft_data (AVFilterContext *ctx, int x, int h, int ch)
 
static void synth_window (AVFilterContext *ctx, int x)
 
static int try_push_frame (AVFilterContext *ctx, int x)
 
static int try_push_frames (AVFilterContext *ctx)
 
static int activate (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption spectrumsynth_options []
 
static const AVFilterPad spectrumsynth_inputs []
 
static const AVFilterPad spectrumsynth_outputs []
 
const AVFilter ff_vaf_spectrumsynth
 

Detailed Description

SpectrumSynth filter

Todo:
support float pixel format

Definition in file vaf_spectrumsynth.c.

Macro Definition Documentation

◆ OFFSET

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

Definition at line 71 of file vaf_spectrumsynth.c.

◆ A

Definition at line 72 of file vaf_spectrumsynth.c.

◆ V

Definition at line 73 of file vaf_spectrumsynth.c.

Enumeration Type Documentation

◆ MagnitudeScale

Enumerator
LINEAR 
LOG 
NB_SCALES 

Definition at line 39 of file vaf_spectrumsynth.c.

◆ SlideMode

enum SlideMode
Enumerator
REPLACE 
SCROLL 
NB_SLIDES 
SLIDE_REPLACE 
SLIDE_SCROLL 
SLIDE_FRAME 
NB_SLIDE 
REPLACE 
SCROLL 
FULLFRAME 
RSCROLL 
LREPLACE 
NB_SLIDES 
REPLACE 
SCROLL 
FULLFRAME 
RSCROLL 
NB_SLIDES 

Definition at line 40 of file vaf_spectrumsynth.c.

◆ Orientation

Enumerator
VERTICAL 
HORIZONTAL 
NB_ORIENTATIONS 
VERTICAL 
HORIZONTAL 
NB_ORIENTATIONS 

Definition at line 41 of file vaf_spectrumsynth.c.

◆ anonymous enum

anonymous enum
Enumerator
MAGNITUDE 
PHASE 

Definition at line 96 of file vaf_spectrumsynth.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( spectrumsynth  )

◆ query_formats()

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

Definition at line 101 of file vaf_spectrumsynth.c.

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 142 of file vaf_spectrumsynth.c.

◆ read16_fft_bin()

static void read16_fft_bin ( SpectrumSynthContext s,
int  x,
int  y,
int  f,
int  ch 
)
static

Definition at line 232 of file vaf_spectrumsynth.c.

Referenced by read_fft_data().

◆ read8_fft_bin()

static void read8_fft_bin ( SpectrumSynthContext s,
int  x,
int  y,
int  f,
int  ch 
)
static

Definition at line 257 of file vaf_spectrumsynth.c.

Referenced by read_fft_data().

◆ read_fft_data()

static void read_fft_data ( AVFilterContext ctx,
int  x,
int  h,
int  ch 
)
static

Definition at line 282 of file vaf_spectrumsynth.c.

Referenced by synth_window().

◆ synth_window()

static void synth_window ( AVFilterContext ctx,
int  x 
)
static

Definition at line 328 of file vaf_spectrumsynth.c.

Referenced by try_push_frame().

◆ try_push_frame()

static int try_push_frame ( AVFilterContext ctx,
int  x 
)
static

Definition at line 352 of file vaf_spectrumsynth.c.

Referenced by try_push_frames().

◆ try_push_frames()

static int try_push_frames ( AVFilterContext ctx)
static

Definition at line 421 of file vaf_spectrumsynth.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 460 of file vaf_spectrumsynth.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 499 of file vaf_spectrumsynth.c.

Variable Documentation

◆ spectrumsynth_options

const AVOption spectrumsynth_options[]
static
Initial value:
= {
{ "sample_rate", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64 = 44100}, 15, INT_MAX, A },
{ "channels", "set channels", OFFSET(channels), AV_OPT_TYPE_INT, {.i64 = 1}, 1, 8, A },
{ "scale", "set input amplitude scale", OFFSET(scale), AV_OPT_TYPE_INT, {.i64 = LOG}, 0, NB_SCALES-1, V, .unit = "scale" },
{ "lin", "linear", 0, AV_OPT_TYPE_CONST, {.i64=LINEAR}, 0, 0, V, .unit = "scale" },
{ "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=LOG}, 0, 0, V, .unit = "scale" },
{ "slide", "set input sliding mode", OFFSET(sliding), AV_OPT_TYPE_INT, {.i64 = FULLFRAME}, 0, NB_SLIDES-1, V, .unit = "slide" },
{ "replace", "consume old columns with new", 0, AV_OPT_TYPE_CONST, {.i64=REPLACE}, 0, 0, V, .unit = "slide" },
{ "scroll", "consume only most right column", 0, AV_OPT_TYPE_CONST, {.i64=SCROLL}, 0, 0, V, .unit = "slide" },
{ "fullframe", "consume full frames", 0, AV_OPT_TYPE_CONST, {.i64=FULLFRAME}, 0, 0, V, .unit = "slide" },
{ "rscroll", "consume only most left column", 0, AV_OPT_TYPE_CONST, {.i64=RSCROLL}, 0, 0, V, .unit = "slide" },
WIN_FUNC_OPTION("win_func", OFFSET(win_func), A, 0),
{ "overlap", "set window overlap", OFFSET(overlap), AV_OPT_TYPE_FLOAT, {.dbl=1}, 0, 1, A },
{ "orientation", "set orientation", OFFSET(orientation), AV_OPT_TYPE_INT, {.i64=VERTICAL}, 0, NB_ORIENTATIONS-1, V, .unit = "orientation" },
{ "vertical", NULL, 0, AV_OPT_TYPE_CONST, {.i64=VERTICAL}, 0, 0, V, .unit = "orientation" },
{ "horizontal", NULL, 0, AV_OPT_TYPE_CONST, {.i64=HORIZONTAL}, 0, 0, V, .unit = "orientation" },
{ NULL }
}

Definition at line 75 of file vaf_spectrumsynth.c.

◆ spectrumsynth_inputs

const AVFilterPad spectrumsynth_inputs[]
static
Initial value:
= {
{
.name = "magnitude",
},
{
.name = "phase",
},
}

Definition at line 523 of file vaf_spectrumsynth.c.

◆ spectrumsynth_outputs

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

Definition at line 534 of file vaf_spectrumsynth.c.

◆ ff_vaf_spectrumsynth

const AVFilter ff_vaf_spectrumsynth
Initial value:
= {
.name = "spectrumsynth",
.description = NULL_IF_CONFIG_SMALL("Convert input spectrum videos to audio output."),
.uninit = uninit,
.activate = activate,
.priv_size = sizeof(SpectrumSynthContext),
.priv_class = &spectrumsynth_class,
}

Definition at line 542 of file vaf_spectrumsynth.c.

SCROLL
@ SCROLL
Definition: vaf_spectrumsynth.c:40
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
WIN_FUNC_OPTION
#define WIN_FUNC_OPTION(win_func_opt_name, win_func_offset, flag, default_window_func)
Definition: window_func.h:37
SpectrumSynthContext
Definition: vaf_spectrumsynth.c:43
config_output
static int config_output(AVFilterLink *outlink)
Definition: vaf_spectrumsynth.c:142
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
NB_SLIDES
@ NB_SLIDES
Definition: vaf_spectrumsynth.c:40
channels
channels
Definition: aptx.h:31
A
#define A
Definition: vaf_spectrumsynth.c:72
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
query_formats
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition: vaf_spectrumsynth.c:101
OFFSET
#define OFFSET(x)
Definition: vaf_spectrumsynth.c:71
NULL
#define NULL
Definition: coverity.c:32
spectrumsynth_outputs
static const AVFilterPad spectrumsynth_outputs[]
Definition: vaf_spectrumsynth.c:534
VERTICAL
@ VERTICAL
Definition: vaf_spectrumsynth.c:41
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
spectrumsynth_inputs
static const AVFilterPad spectrumsynth_inputs[]
Definition: vaf_spectrumsynth.c:523
NB_ORIENTATIONS
@ NB_ORIENTATIONS
Definition: vaf_spectrumsynth.c:41
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition: opt.h:271
HORIZONTAL
@ HORIZONTAL
Definition: vaf_spectrumsynth.c:41
FILTER_QUERY_FUNC2
#define FILTER_QUERY_FUNC2(func)
Definition: filters.h:239
FULLFRAME
@ FULLFRAME
Definition: vaf_spectrumsynth.c:40
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
V
#define V
Definition: vaf_spectrumsynth.c:73
scale
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition: intra.c:291
activate
static int activate(AVFilterContext *ctx)
Definition: vaf_spectrumsynth.c:460
LOG
@ LOG
Definition: vaf_spectrumsynth.c:39
LINEAR
@ LINEAR
Definition: vaf_spectrumsynth.c:39
REPLACE
@ REPLACE
Definition: vaf_spectrumsynth.c:40
RSCROLL
@ RSCROLL
Definition: vaf_spectrumsynth.c:40
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vaf_spectrumsynth.c:499
NB_SCALES
@ NB_SCALES
Definition: vaf_spectrumsynth.c:39