FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
vaf_spectrumsynth.c File Reference
#include "libavcodec/avfft.h"
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/ffmath.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "avfilter.h"
#include "formats.h"
#include "audio.h"
#include "video.h"
#include "filters.h"
#include "internal.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, REPLACE,
  SCROLL, FULLFRAME, RSCROLL, NB_SLIDES,
  REPLACE, SCROLL, FULLFRAME, RSCROLL,
  NB_SLIDES
}
 
enum  Orientation {
  VERTICAL, HORIZONTAL, NB_ORIENTATIONS, VERTICAL,
  HORIZONTAL, NB_ORIENTATIONS
}
 

Functions

 AVFILTER_DEFINE_CLASS (spectrumsynth)
 
static int query_formats (AVFilterContext *ctx)
 
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 []
 
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 72 of file vaf_spectrumsynth.c.

◆ A

Definition at line 73 of file vaf_spectrumsynth.c.

◆ V

Definition at line 74 of file vaf_spectrumsynth.c.

Enumeration Type Documentation

◆ MagnitudeScale

Enumerator
LINEAR 
LOG 
NB_SCALES 

Definition at line 41 of file vaf_spectrumsynth.c.

◆ SlideMode

enum SlideMode
Enumerator
REPLACE 
SCROLL 
NB_SLIDES 
REPLACE 
SCROLL 
FULLFRAME 
RSCROLL 
NB_SLIDES 
REPLACE 
SCROLL 
FULLFRAME 
RSCROLL 
NB_SLIDES 

Definition at line 42 of file vaf_spectrumsynth.c.

◆ Orientation

Enumerator
VERTICAL 
HORIZONTAL 
NB_ORIENTATIONS 
VERTICAL 
HORIZONTAL 
NB_ORIENTATIONS 

Definition at line 43 of file vaf_spectrumsynth.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( spectrumsynth  )

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 103 of file vaf_spectrumsynth.c.

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 145 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 226 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 251 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 276 of file vaf_spectrumsynth.c.

Referenced by synth_window().

◆ synth_window()

static void synth_window ( AVFilterContext ctx,
int  x 
)
static

Definition at line 322 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 347 of file vaf_spectrumsynth.c.

Referenced by try_push_frames().

◆ try_push_frames()

static int try_push_frames ( AVFilterContext ctx)
static

Definition at line 416 of file vaf_spectrumsynth.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 455 of file vaf_spectrumsynth.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 494 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, "scale" },
{ "lin", "linear", 0, AV_OPT_TYPE_CONST, {.i64=LINEAR}, 0, 0, V, "scale" },
{ "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=LOG}, 0, 0, V, "scale" },
{ "slide", "set input sliding mode", OFFSET(sliding), AV_OPT_TYPE_INT, {.i64 = FULLFRAME}, 0, NB_SLIDES-1, V, "slide" },
{ "replace", "consume old columns with new", 0, AV_OPT_TYPE_CONST, {.i64=REPLACE}, 0, 0, V, "slide" },
{ "scroll", "consume only most right column", 0, AV_OPT_TYPE_CONST, {.i64=SCROLL}, 0, 0, V, "slide" },
{ "fullframe", "consume full frames", 0, AV_OPT_TYPE_CONST, {.i64=FULLFRAME}, 0, 0, V, "slide" },
{ "rscroll", "consume only most left column", 0, AV_OPT_TYPE_CONST, {.i64=RSCROLL}, 0, 0, V, "slide" },
{ "win_func", "set window function", OFFSET(win_func), AV_OPT_TYPE_INT, {.i64 = 0}, 0, NB_WFUNC-1, A, "win_func" },
{ "rect", "Rectangular", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_RECT}, 0, 0, A, "win_func" },
{ "bartlett", "Bartlett", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_BARTLETT}, 0, 0, A, "win_func" },
{ "hann", "Hann", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_HANNING}, 0, 0, A, "win_func" },
{ "hanning", "Hanning", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_HANNING}, 0, 0, A, "win_func" },
{ "hamming", "Hamming", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_HAMMING}, 0, 0, A, "win_func" },
{ "sine", "Sine", 0, AV_OPT_TYPE_CONST, {.i64=WFUNC_SINE}, 0, 0, A, "win_func" },
{ "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, "orientation" },
{ "vertical", NULL, 0, AV_OPT_TYPE_CONST, {.i64=VERTICAL}, 0, 0, V, "orientation" },
{ "horizontal", NULL, 0, AV_OPT_TYPE_CONST, {.i64=HORIZONTAL}, 0, 0, V, "orientation" },
{ NULL }
}

Definition at line 76 of file vaf_spectrumsynth.c.

◆ spectrumsynth_inputs

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

Definition at line 511 of file vaf_spectrumsynth.c.

◆ spectrumsynth_outputs

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

Definition at line 523 of file vaf_spectrumsynth.c.

◆ ff_vaf_spectrumsynth

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

Definition at line 532 of file vaf_spectrumsynth.c.

SCROLL
@ SCROLL
Definition: vaf_spectrumsynth.c:42
SpectrumSynthContext
Definition: vaf_spectrumsynth.c:45
sample_rate
sample_rate
Definition: ffmpeg_filter.c:170
config_output
static int config_output(AVFilterLink *outlink)
Definition: vaf_spectrumsynth.c:145
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
NB_SLIDES
@ NB_SLIDES
Definition: vaf_spectrumsynth.c:42
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
WFUNC_RECT
@ WFUNC_RECT
Definition: window_func.h:28
channels
channels
Definition: aptx.h:33
A
#define A
Definition: vaf_spectrumsynth.c:73
OFFSET
#define OFFSET(x)
Definition: vaf_spectrumsynth.c:72
NULL
#define NULL
Definition: coverity.c:32
WFUNC_HAMMING
@ WFUNC_HAMMING
Definition: af_firequalizer.c:35
WFUNC_HANNING
@ WFUNC_HANNING
Definition: window_func.h:28
WFUNC_BARTLETT
@ WFUNC_BARTLETT
Definition: window_func.h:29
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
spectrumsynth_outputs
static const AVFilterPad spectrumsynth_outputs[]
Definition: vaf_spectrumsynth.c:523
VERTICAL
@ VERTICAL
Definition: vaf_spectrumsynth.c:43
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:117
spectrumsynth_inputs
static const AVFilterPad spectrumsynth_inputs[]
Definition: vaf_spectrumsynth.c:511
NB_ORIENTATIONS
@ NB_ORIENTATIONS
Definition: vaf_spectrumsynth.c:43
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:228
HORIZONTAL
@ HORIZONTAL
Definition: vaf_spectrumsynth.c:43
FULLFRAME
@ FULLFRAME
Definition: vaf_spectrumsynth.c:42
NB_WFUNC
@ NB_WFUNC
Definition: af_firequalizer.c:43
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vaf_spectrumsynth.c:103
WFUNC_SINE
@ WFUNC_SINE
Definition: window_func.h:30
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
V
#define V
Definition: vaf_spectrumsynth.c:74
activate
static int activate(AVFilterContext *ctx)
Definition: vaf_spectrumsynth.c:455
LOG
@ LOG
Definition: vaf_spectrumsynth.c:41
LINEAR
@ LINEAR
Definition: vaf_spectrumsynth.c:41
REPLACE
@ REPLACE
Definition: vaf_spectrumsynth.c:42
RSCROLL
@ RSCROLL
Definition: vaf_spectrumsynth.c:42
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vaf_spectrumsynth.c:494
NB_SCALES
@ NB_SCALES
Definition: vaf_spectrumsynth.c:41