FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
avf_showspectrum.c File Reference

audio to spectrum (video) transmedia filter, based on ffplay rdft showmode (by Michael Niedermayer) and lavfi/avf_showwaves (by Stefano Sabatini). More...

#include <math.h>
#include "libavcodec/avfft.h"
#include "libavutil/audio_fifo.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/channel_layout.h"
#include "libavutil/opt.h"
#include "libavutil/xga_font_data.h"
#include "audio.h"
#include "video.h"
#include "avfilter.h"
#include "internal.h"
#include "window_func.h"

Go to the source code of this file.

Data Structures

struct  ShowSpectrumContext
 
struct  ColorTable
 

Macros

#define OFFSET(x)   offsetof(ShowSpectrumContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define RE(y, ch)   s->fft_data[ch][y].re
 
#define IM(y, ch)   s->fft_data[ch][y].im
 
#define MAGNITUDE(y, ch)   hypot(RE(y, ch), IM(y, ch))
 
#define PHASE(y, ch)   atan2(IM(y, ch), RE(y, ch))
 

Enumerations

enum  DisplayMode {
  SINGLE, SEPARATE, NB_DMODES, LINE,
  BAR, DOT, NB_MODES, COMBINED,
  SEPARATE, NB_MODES
}
 
enum  DataMode { D_MAGNITUDE, D_PHASE, NB_DMODES }
 
enum  DisplayScale {
  LINEAR, SQRT, CBRT, LOG,
  RLOG, NB_SCALES, LINEAR, SQRT,
  CBRT, LOG, FOURTHRT, FIFTHRT,
  NB_SCALES
}
 
enum  ColorMode {
  CHANNEL, INTENSITY, RAINBOW, MORELAND,
  NEBULAE, FIRE, FIERY, FRUIT,
  COOL, NB_CLMODES, COLOR_MODE_NONE = -1, COLOR_MODE_BT709,
  COLOR_MODE_FCC, COLOR_MODE_BT601, COLOR_MODE_SMPTE240M, COLOR_MODE_BT2020,
  COLOR_MODE_COUNT
}
 
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 (showspectrum)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
static int config_output (AVFilterLink *outlink)
 
static void run_fft (ShowSpectrumContext *s, AVFrame *fin)
 
static void calc_magnitudes (ShowSpectrumContext *s)
 
static void calc_phases (ShowSpectrumContext *s)
 
static void acalc_magnitudes (ShowSpectrumContext *s)
 
static void scale_magnitudes (ShowSpectrumContext *s, float scale)
 
static void color_range (ShowSpectrumContext *s, int ch, float *yf, float *uf, float *vf)
 
static void pick_color (ShowSpectrumContext *s, float yf, float uf, float vf, float a, float *out)
 
static void clear_combine_buffer (ShowSpectrumContext *s, int size)
 
static int plot_spectrum_column (AVFilterLink *inlink, AVFrame *insamples)
 

Variables

static const AVOption showspectrum_options []
 
static const struct ColorTable color_table [][8]
 

Detailed Description

audio to spectrum (video) transmedia filter, based on ffplay rdft showmode (by Michael Niedermayer) and lavfi/avf_showwaves (by Stefano Sabatini).

Definition in file avf_showspectrum.c.

Macro Definition Documentation

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

Definition at line 86 of file avf_showspectrum.c.

Definition at line 87 of file avf_showspectrum.c.

#define RE (   y,
  ch 
)    s->fft_data[ch][y].re

Definition at line 447 of file avf_showspectrum.c.

#define IM (   y,
  ch 
)    s->fft_data[ch][y].im

Definition at line 448 of file avf_showspectrum.c.

#define MAGNITUDE (   y,
  ch 
)    hypot(RE(y, ch), IM(y, ch))

Definition at line 449 of file avf_showspectrum.c.

Referenced by acalc_magnitudes(), and calc_magnitudes().

#define PHASE (   y,
  ch 
)    atan2(IM(y, ch), RE(y, ch))

Definition at line 450 of file avf_showspectrum.c.

Referenced by avfilter_register_all(), and calc_phases().

Enumeration Type Documentation

Enumerator
SINGLE 
SEPARATE 
NB_DMODES 
LINE 
BAR 
DOT 
NB_MODES 
COMBINED 
SEPARATE 
NB_MODES 

Definition at line 44 of file avf_showspectrum.c.

enum DataMode
Enumerator
D_MAGNITUDE 
D_PHASE 
NB_DMODES 

Definition at line 45 of file avf_showspectrum.c.

Enumerator
LINEAR 
SQRT 
CBRT 
LOG 
RLOG 
NB_SCALES 
LINEAR 
SQRT 
CBRT 
LOG 
FOURTHRT 
FIFTHRT 
NB_SCALES 

Definition at line 46 of file avf_showspectrum.c.

enum ColorMode
Enumerator
CHANNEL 
INTENSITY 
RAINBOW 
MORELAND 
NEBULAE 
FIRE 
FIERY 
FRUIT 
COOL 
NB_CLMODES 
COLOR_MODE_NONE 
COLOR_MODE_BT709 
COLOR_MODE_FCC 
COLOR_MODE_BT601 
COLOR_MODE_SMPTE240M 
COLOR_MODE_BT2020 
COLOR_MODE_COUNT 

Definition at line 47 of file avf_showspectrum.c.

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

Definition at line 48 of file avf_showspectrum.c.

Enumerator
VERTICAL 
HORIZONTAL 
NB_ORIENTATIONS 
VERTICAL 
HORIZONTAL 
NB_ORIENTATIONS 

Definition at line 49 of file avf_showspectrum.c.

Function Documentation

AVFILTER_DEFINE_CLASS ( showspectrum  )
static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 220 of file avf_showspectrum.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 247 of file avf_showspectrum.c.

static int config_output ( AVFilterLink outlink)
static

Definition at line 278 of file avf_showspectrum.c.

static void run_fft ( ShowSpectrumContext s,
AVFrame fin 
)
static

Definition at line 426 of file avf_showspectrum.c.

static void calc_magnitudes ( ShowSpectrumContext s)
static

Definition at line 452 of file avf_showspectrum.c.

static void calc_phases ( ShowSpectrumContext s)
static

Definition at line 466 of file avf_showspectrum.c.

static void acalc_magnitudes ( ShowSpectrumContext s)
static

Definition at line 478 of file avf_showspectrum.c.

static void scale_magnitudes ( ShowSpectrumContext s,
float  scale 
)
static

Definition at line 492 of file avf_showspectrum.c.

static void color_range ( ShowSpectrumContext s,
int  ch,
float *  yf,
float *  uf,
float *  vf 
)
static

Definition at line 504 of file avf_showspectrum.c.

Referenced by plot_spectrum_column().

static void pick_color ( ShowSpectrumContext s,
float  yf,
float  uf,
float  vf,
float  a,
float *  out 
)
static

Definition at line 556 of file avf_showspectrum.c.

Referenced by plot_spectrum_column().

static void clear_combine_buffer ( ShowSpectrumContext s,
int  size 
)
static

Definition at line 600 of file avf_showspectrum.c.

Referenced by plot_spectrum_column().

static int plot_spectrum_column ( AVFilterLink inlink,
AVFrame insamples 
)
static

Definition at line 611 of file avf_showspectrum.c.

Variable Documentation

const AVOption showspectrum_options[]
static

Definition at line 89 of file avf_showspectrum.c.

const struct ColorTable color_table[][8]
static