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 "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 int request_frame (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 filter_frame_magnitude (AVFilterLink *inlink, AVFrame *magnitude)
 
static int filter_frame_phase (AVFilterLink *inlink, AVFrame *phase)
 
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 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 40 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 41 of file vaf_spectrumsynth.c.

◆ Orientation

Enumerator
VERTICAL 
HORIZONTAL 
NB_ORIENTATIONS 
VERTICAL 
HORIZONTAL 
NB_ORIENTATIONS 

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

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 144 of file vaf_spectrumsynth.c.

◆ request_frame()

static int request_frame ( AVFilterLink outlink)
static

Definition at line 225 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 244 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 269 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 294 of file vaf_spectrumsynth.c.

Referenced by synth_window().

◆ synth_window()

static void synth_window ( AVFilterContext ctx,
int  x 
)
static

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

Referenced by try_push_frames().

◆ try_push_frames()

static int try_push_frames ( AVFilterContext ctx)
static

Definition at line 434 of file vaf_spectrumsynth.c.

Referenced by filter_frame_magnitude(), and filter_frame_phase().

◆ filter_frame_magnitude()

static int filter_frame_magnitude ( AVFilterLink inlink,
AVFrame magnitude 
)
static

Definition at line 473 of file vaf_spectrumsynth.c.

◆ filter_frame_phase()

static int filter_frame_phase ( AVFilterLink inlink,
AVFrame phase 
)
static

Definition at line 482 of file vaf_spectrumsynth.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

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

◆ spectrumsynth_inputs

const AVFilterPad spectrumsynth_inputs[]
static
Initial value:
= {
{
.name = "magnitude",
.filter_frame = filter_frame_magnitude,
.needs_fifo = 1,
},
{
.name = "phase",
.filter_frame = filter_frame_phase,
.needs_fifo = 1,
},
{ NULL }
}

Definition at line 508 of file vaf_spectrumsynth.c.

◆ spectrumsynth_outputs

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

Definition at line 524 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,
.priv_size = sizeof(SpectrumSynthContext),
.priv_class = &spectrumsynth_class,
}

Definition at line 534 of file vaf_spectrumsynth.c.

SCROLL
@ SCROLL
Definition: vaf_spectrumsynth.c:41
request_frame
static int request_frame(AVFilterLink *outlink)
Definition: vaf_spectrumsynth.c:225
channels
channels
Definition: aptx.c:30
SpectrumSynthContext
Definition: vaf_spectrumsynth.c:44
sample_rate
sample_rate
Definition: ffmpeg_filter.c:191
filter_frame_phase
static int filter_frame_phase(AVFilterLink *inlink, AVFrame *phase)
Definition: vaf_spectrumsynth.c:482
config_output
static int config_output(AVFilterLink *outlink)
Definition: vaf_spectrumsynth.c:144
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
NB_SLIDES
@ NB_SLIDES
Definition: vaf_spectrumsynth.c:41
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
WFUNC_RECT
@ WFUNC_RECT
Definition: window_func.h:28
A
#define A
Definition: vaf_spectrumsynth.c:72
OFFSET
#define OFFSET(x)
Definition: vaf_spectrumsynth.c:71
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:524
VERTICAL
@ VERTICAL
Definition: vaf_spectrumsynth.c:42
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:188
spectrumsynth_inputs
static const AVFilterPad spectrumsynth_inputs[]
Definition: vaf_spectrumsynth.c:508
NB_ORIENTATIONS
@ NB_ORIENTATIONS
Definition: vaf_spectrumsynth.c:42
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:226
HORIZONTAL
@ HORIZONTAL
Definition: vaf_spectrumsynth.c:42
filter_frame_magnitude
static int filter_frame_magnitude(AVFilterLink *inlink, AVFrame *magnitude)
Definition: vaf_spectrumsynth.c:473
FULLFRAME
@ FULLFRAME
Definition: vaf_spectrumsynth.c:41
NB_WFUNC
@ NB_WFUNC
Definition: af_firequalizer.c:43
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vaf_spectrumsynth.c:102
WFUNC_SINE
@ WFUNC_SINE
Definition: window_func.h:30
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:223
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
V
#define V
Definition: vaf_spectrumsynth.c:73
LOG
@ LOG
Definition: vaf_spectrumsynth.c:40
LINEAR
@ LINEAR
Definition: vaf_spectrumsynth.c:40
REPLACE
@ REPLACE
Definition: vaf_spectrumsynth.c:41
RSCROLL
@ RSCROLL
Definition: vaf_spectrumsynth.c:41
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:232
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vaf_spectrumsynth.c:491
NB_SCALES
@ NB_SCALES
Definition: vaf_spectrumsynth.c:40