FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
avf_showwaves.c File Reference
#include "config_components.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/channel_layout.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "avfilter.h"
#include "filters.h"
#include "formats.h"
#include "audio.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  frame_node
 
struct  ShowWavesContext
 

Macros

#define OFFSET(x)   offsetof(ShowWavesContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 

Enumerations

enum  ShowWavesMode {
  MODE_POINT, MODE_LINE, MODE_P2P, MODE_CENTERED_LINE,
  MODE_NB
}
 
enum  ShowWavesScale {
  SCALE_LIN, SCALE_LOG, SCALE_SQRT, SCALE_CBRT,
  SCALE_NB
}
 
enum  ShowWavesDrawMode { DRAW_SCALE, DRAW_FULL, DRAW_NB }
 
enum  ShowWavesFilterMode { FILTER_AVERAGE, FILTER_PEAK, FILTER_NB }
 

Functions

 AVFILTER_DEFINE_CLASS (showwaves)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int query_formats (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
 
static int get_lin_h (int16_t sample, int height)
 
static int get_lin_h2 (int16_t sample, int height)
 
static int get_log_h (int16_t sample, int height)
 
static int get_log_h2 (int16_t sample, int height)
 
static int get_sqrt_h (int16_t sample, int height)
 
static int get_sqrt_h2 (int16_t sample, int height)
 
static int get_cbrt_h (int16_t sample, int height)
 
static int get_cbrt_h2 (int16_t sample, int height)
 
static void draw_sample_point_rgba_scale (uint8_t *buf, int height, int linesize, int16_t *prev_y, const uint8_t color[4], int h)
 
static void draw_sample_point_rgba_full (uint8_t *buf, int height, int linesize, int16_t *prev_y, const uint8_t color[4], int h)
 
static void draw_sample_line_rgba_scale (uint8_t *buf, int height, int linesize, int16_t *prev_y, const uint8_t color[4], int h)
 
static void draw_sample_line_rgba_full (uint8_t *buf, int height, int linesize, int16_t *prev_y, const uint8_t color[4], int h)
 
static void draw_sample_p2p_rgba_scale (uint8_t *buf, int height, int linesize, int16_t *prev_y, const uint8_t color[4], int h)
 
static void draw_sample_p2p_rgba_full (uint8_t *buf, int height, int linesize, int16_t *prev_y, const uint8_t color[4], int h)
 
static void draw_sample_cline_rgba_scale (uint8_t *buf, int height, int linesize, int16_t *prev_y, const uint8_t color[4], int h)
 
static void draw_sample_cline_rgba_full (uint8_t *buf, int height, int linesize, int16_t *prev_y, const uint8_t color[4], int h)
 
static void draw_sample_point_gray (uint8_t *buf, int height, int linesize, int16_t *prev_y, const uint8_t color[4], int h)
 
static void draw_sample_line_gray (uint8_t *buf, int height, int linesize, int16_t *prev_y, const uint8_t color[4], int h)
 
static void draw_sample_p2p_gray (uint8_t *buf, int height, int linesize, int16_t *prev_y, const uint8_t color[4], int h)
 
static void draw_sample_cline_gray (uint8_t *buf, int height, int linesize, int16_t *prev_y, const uint8_t color[4], int h)
 
static int config_output (AVFilterLink *outlink)
 
static int push_frame (AVFilterLink *outlink, int i, int64_t pts)
 
static int push_single_pic (AVFilterLink *outlink)
 
static int request_frame (AVFilterLink *outlink)
 
static int alloc_out_frame (ShowWavesContext *showwaves, AVFilterLink *outlink)
 
static av_cold int init (AVFilterContext *ctx)
 

Variables

static const AVOption showwaves_options []
 

Detailed Description

audio to video multimedia filter

Definition in file avf_showwaves.c.

Macro Definition Documentation

◆ OFFSET

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

Definition at line 106 of file avf_showwaves.c.

◆ FLAGS

Definition at line 107 of file avf_showwaves.c.

Enumeration Type Documentation

◆ ShowWavesMode

Enumerator
MODE_POINT 
MODE_LINE 
MODE_P2P 
MODE_CENTERED_LINE 
MODE_NB 

Definition at line 41 of file avf_showwaves.c.

◆ ShowWavesScale

Enumerator
SCALE_LIN 
SCALE_LOG 
SCALE_SQRT 
SCALE_CBRT 
SCALE_NB 

Definition at line 49 of file avf_showwaves.c.

◆ ShowWavesDrawMode

Enumerator
DRAW_SCALE 
DRAW_FULL 
DRAW_NB 

Definition at line 57 of file avf_showwaves.c.

◆ ShowWavesFilterMode

Enumerator
FILTER_AVERAGE 
FILTER_PEAK 
FILTER_NB 

Definition at line 63 of file avf_showwaves.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( showwaves  )

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 135 of file avf_showwaves.c.

◆ query_formats()

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

Definition at line 158 of file avf_showwaves.c.

◆ get_lin_h()

static int get_lin_h ( int16_t  sample,
int  height 
)
static

Definition at line 180 of file avf_showwaves.c.

Referenced by config_output().

◆ get_lin_h2()

static int get_lin_h2 ( int16_t  sample,
int  height 
)
static

Definition at line 185 of file avf_showwaves.c.

Referenced by config_output().

◆ get_log_h()

static int get_log_h ( int16_t  sample,
int  height 
)
static

Definition at line 190 of file avf_showwaves.c.

Referenced by config_output().

◆ get_log_h2()

static int get_log_h2 ( int16_t  sample,
int  height 
)
static

Definition at line 195 of file avf_showwaves.c.

Referenced by config_output().

◆ get_sqrt_h()

static int get_sqrt_h ( int16_t  sample,
int  height 
)
static

Definition at line 200 of file avf_showwaves.c.

Referenced by config_output().

◆ get_sqrt_h2()

static int get_sqrt_h2 ( int16_t  sample,
int  height 
)
static

Definition at line 205 of file avf_showwaves.c.

Referenced by config_output().

◆ get_cbrt_h()

static int get_cbrt_h ( int16_t  sample,
int  height 
)
static

Definition at line 210 of file avf_showwaves.c.

Referenced by config_output().

◆ get_cbrt_h2()

static int get_cbrt_h2 ( int16_t  sample,
int  height 
)
static

Definition at line 215 of file avf_showwaves.c.

Referenced by config_output().

◆ draw_sample_point_rgba_scale()

static void draw_sample_point_rgba_scale ( uint8_t *  buf,
int  height,
int  linesize,
int16_t *  prev_y,
const uint8_t  color[4],
int  h 
)
static

Definition at line 220 of file avf_showwaves.c.

Referenced by config_output().

◆ draw_sample_point_rgba_full()

static void draw_sample_point_rgba_full ( uint8_t *  buf,
int  height,
int  linesize,
int16_t *  prev_y,
const uint8_t  color[4],
int  h 
)
static

Definition at line 232 of file avf_showwaves.c.

Referenced by config_output().

◆ draw_sample_line_rgba_scale()

static void draw_sample_line_rgba_scale ( uint8_t *  buf,
int  height,
int  linesize,
int16_t *  prev_y,
const uint8_t  color[4],
int  h 
)
static

Definition at line 241 of file avf_showwaves.c.

Referenced by config_output().

◆ draw_sample_line_rgba_full()

static void draw_sample_line_rgba_full ( uint8_t *  buf,
int  height,
int  linesize,
int16_t *  prev_y,
const uint8_t  color[4],
int  h 
)
static

Definition at line 259 of file avf_showwaves.c.

Referenced by config_output().

◆ draw_sample_p2p_rgba_scale()

static void draw_sample_p2p_rgba_scale ( uint8_t *  buf,
int  height,
int  linesize,
int16_t *  prev_y,
const uint8_t  color[4],
int  h 
)
static

Definition at line 274 of file avf_showwaves.c.

Referenced by config_output().

◆ draw_sample_p2p_rgba_full()

static void draw_sample_p2p_rgba_full ( uint8_t *  buf,
int  height,
int  linesize,
int16_t *  prev_y,
const uint8_t  color[4],
int  h 
)
static

Definition at line 301 of file avf_showwaves.c.

Referenced by config_output().

◆ draw_sample_cline_rgba_scale()

static void draw_sample_cline_rgba_scale ( uint8_t *  buf,
int  height,
int  linesize,
int16_t *  prev_y,
const uint8_t  color[4],
int  h 
)
static

Definition at line 322 of file avf_showwaves.c.

Referenced by config_output().

◆ draw_sample_cline_rgba_full()

static void draw_sample_cline_rgba_full ( uint8_t *  buf,
int  height,
int  linesize,
int16_t *  prev_y,
const uint8_t  color[4],
int  h 
)
static

Definition at line 337 of file avf_showwaves.c.

Referenced by config_output().

◆ draw_sample_point_gray()

static void draw_sample_point_gray ( uint8_t *  buf,
int  height,
int  linesize,
int16_t *  prev_y,
const uint8_t  color[4],
int  h 
)
static

Definition at line 349 of file avf_showwaves.c.

Referenced by config_output().

◆ draw_sample_line_gray()

static void draw_sample_line_gray ( uint8_t *  buf,
int  height,
int  linesize,
int16_t *  prev_y,
const uint8_t  color[4],
int  h 
)
static

Definition at line 357 of file avf_showwaves.c.

Referenced by config_output().

◆ draw_sample_p2p_gray()

static void draw_sample_p2p_gray ( uint8_t *  buf,
int  height,
int  linesize,
int16_t *  prev_y,
const uint8_t  color[4],
int  h 
)
static

Definition at line 370 of file avf_showwaves.c.

Referenced by config_output().

◆ draw_sample_cline_gray()

static void draw_sample_cline_gray ( uint8_t *  buf,
int  height,
int  linesize,
int16_t *  prev_y,
const uint8_t  color[4],
int  h 
)
static

Definition at line 389 of file avf_showwaves.c.

Referenced by config_output().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 400 of file avf_showwaves.c.

◆ push_frame()

static int push_frame ( AVFilterLink outlink,
int  i,
int64_t  pts 
)
inlinestatic

Definition at line 555 of file avf_showwaves.c.

Referenced by push_single_pic().

◆ push_single_pic()

static int push_single_pic ( AVFilterLink outlink)
static

Definition at line 576 of file avf_showwaves.c.

Referenced by request_frame().

◆ request_frame()

static int request_frame ( AVFilterLink outlink)
static

Definition at line 646 of file avf_showwaves.c.

◆ alloc_out_frame()

static int alloc_out_frame ( ShowWavesContext showwaves,
AVFilterLink outlink 
)
static

Definition at line 660 of file avf_showwaves.c.

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 676 of file avf_showwaves.c.

Variable Documentation

◆ showwaves_options

const AVOption showwaves_options[]
static
Initial value:
= {
{ "size", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "600x240"}, 0, 0, FLAGS },
{ "s", "set video size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE, {.str = "600x240"}, 0, 0, FLAGS },
{ "mode", "select display mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=MODE_POINT}, 0, MODE_NB-1, .flags=FLAGS, .unit="mode"},
{ "point", "draw a point for each sample", 0, AV_OPT_TYPE_CONST, {.i64=MODE_POINT}, .flags=FLAGS, .unit="mode"},
{ "line", "draw a line for each sample", 0, AV_OPT_TYPE_CONST, {.i64=MODE_LINE}, .flags=FLAGS, .unit="mode"},
{ "p2p", "draw a line between samples", 0, AV_OPT_TYPE_CONST, {.i64=MODE_P2P}, .flags=FLAGS, .unit="mode"},
{ "cline", "draw a centered line for each sample", 0, AV_OPT_TYPE_CONST, {.i64=MODE_CENTERED_LINE}, .flags=FLAGS, .unit="mode"},
{ "n", "set how many samples to show in the same point", OFFSET(n), AV_OPT_TYPE_RATIONAL, {.i64 = 0}, 0, INT_MAX, FLAGS },
{ "rate", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, FLAGS },
{ "r", "set video rate", OFFSET(rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, INT_MAX, FLAGS },
{ "split_channels", "draw channels separately", OFFSET(split_channels), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS },
{ "colors", "set channels colors", OFFSET(colors), AV_OPT_TYPE_STRING, {.str = "red|green|blue|yellow|orange|lime|pink|magenta|brown" }, 0, 0, FLAGS },
{ "scale", "set amplitude scale", OFFSET(scale), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, SCALE_NB-1, FLAGS, .unit="scale" },
{ "lin", "linear", 0, AV_OPT_TYPE_CONST, {.i64=SCALE_LIN}, .flags=FLAGS, .unit="scale"},
{ "log", "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=SCALE_LOG}, .flags=FLAGS, .unit="scale"},
{ "sqrt", "square root", 0, AV_OPT_TYPE_CONST, {.i64=SCALE_SQRT}, .flags=FLAGS, .unit="scale"},
{ "cbrt", "cubic root", 0, AV_OPT_TYPE_CONST, {.i64=SCALE_CBRT}, .flags=FLAGS, .unit="scale"},
{ "draw", "set draw mode", OFFSET(draw_mode), AV_OPT_TYPE_INT, {.i64 = DRAW_SCALE}, 0, DRAW_NB-1, FLAGS, .unit="draw" },
{ "scale", "scale pixel values for each drawn sample", 0, AV_OPT_TYPE_CONST, {.i64=DRAW_SCALE}, .flags=FLAGS, .unit="draw"},
{ "full", "draw every pixel for sample directly", 0, AV_OPT_TYPE_CONST, {.i64=DRAW_FULL}, .flags=FLAGS, .unit="draw"},
{ NULL }
}

Definition at line 109 of file avf_showwaves.c.

SCALE_SQRT
@ SCALE_SQRT
Definition: avf_showwaves.c:52
DRAW_SCALE
@ DRAW_SCALE
Definition: avf_showwaves.c:58
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
Definition: opt.h:315
w
uint8_t w
Definition: llviddspenc.c:38
AV_OPT_TYPE_RATIONAL
@ AV_OPT_TYPE_RATIONAL
Underlying C type is AVRational.
Definition: opt.h:280
DRAW_FULL
@ DRAW_FULL
Definition: avf_showwaves.c:59
MODE_NB
@ MODE_NB
Definition: avf_showwaves.c:46
SCALE_CBRT
@ SCALE_CBRT
Definition: avf_showwaves.c:53
DRAW_NB
@ DRAW_NB
Definition: avf_showwaves.c:60
FLAGS
#define FLAGS
Definition: avf_showwaves.c:107
NULL
#define NULL
Definition: coverity.c:32
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
Definition: opt.h:303
MODE_POINT
@ MODE_POINT
Definition: avf_showwaves.c:42
MODE_CENTERED_LINE
@ MODE_CENTERED_LINE
Definition: avf_showwaves.c:45
SCALE_LIN
@ SCALE_LIN
Definition: avf_showwaves.c:50
MODE_P2P
@ MODE_P2P
Definition: avf_showwaves.c:44
SCALE_LOG
@ SCALE_LOG
Definition: avf_showwaves.c:51
mode
mode
Definition: ebur128.h:83
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
MODE_LINE
@ MODE_LINE
Definition: avf_showwaves.c:43
OFFSET
#define OFFSET(x)
Definition: avf_showwaves.c:106
scale
static void scale(int *out, const int *in, const int w, const int h, const int shift)
Definition: intra.c:291
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
Definition: opt.h:276
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
SCALE_NB
@ SCALE_NB
Definition: avf_showwaves.c:54