FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
avf_showvolume.c File Reference
#include "libavutil/avstring.h"
#include "libavutil/channel_layout.h"
#include "libavutil/eval.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "libavutil/xga_font_data.h"
#include "avfilter.h"
#include "filters.h"
#include "formats.h"
#include "audio.h"
#include "video.h"
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  ShowVolumeContext
 

Macros

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

Enumerations

enum  { VAR_VOLUME, VAR_CHANNEL, VAR_PEAK, VAR_VARS_NB }
 
enum  DisplayScale {
  LINEAR, SQRT, CBRT, LOG,
  RLOG, NB_SCALES, LINEAR, SQRT,
  CBRT, LOG, FOURTHRT, FIFTHRT,
  NB_SCALES, LINEAR, LOG, NB_DISPLAY_SCALE
}
 

Functions

 AVFILTER_DEFINE_CLASS (showvolume)
 
static av_cold int init (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
static void find_peak (float *src, int nb_samples, float *peak)
 
static void find_rms (float *src, int nb_samples, float *rms)
 
static int config_input (AVFilterLink *inlink)
 
static int config_output (AVFilterLink *outlink)
 
static void drawtext (AVFrame *pic, int x, int y, const char *txt, int o)
 
static void clear_picture (ShowVolumeContext *s, AVFilterLink *outlink)
 
static int calc_max_draw (ShowVolumeContext *s, AVFilterLink *outlink, float max)
 
static void calc_persistent_max (ShowVolumeContext *s, float max, int channel)
 
static void draw_max_line (ShowVolumeContext *s, int max_draw, int channel)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *insamples)
 
static int activate (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const char *const var_names [] = { "VOLUME", "CHANNEL", "PEAK", NULL }
 
static const AVOption showvolume_options []
 
static const AVFilterPad showvolume_inputs []
 
static const AVFilterPad showvolume_outputs []
 
const AVFilter ff_avf_showvolume
 

Macro Definition Documentation

◆ OFFSET

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

Definition at line 70 of file avf_showvolume.c.

◆ FLAGS

Definition at line 71 of file avf_showvolume.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
VAR_VOLUME 
VAR_CHANNEL 
VAR_PEAK 
VAR_VARS_NB 

Definition at line 36 of file avf_showvolume.c.

◆ DisplayScale

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

Definition at line 37 of file avf_showvolume.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( showvolume  )

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 101 of file avf_showvolume.c.

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 116 of file avf_showvolume.c.

◆ find_peak()

static void find_peak ( float src,
int  nb_samples,
float peak 
)
static

Definition at line 145 of file avf_showvolume.c.

Referenced by config_input().

◆ find_rms()

static void find_rms ( float src,
int  nb_samples,
float rms 
)
static

Definition at line 155 of file avf_showvolume.c.

Referenced by config_input().

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 164 of file avf_showvolume.c.

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 199 of file avf_showvolume.c.

◆ drawtext()

static void drawtext ( AVFrame pic,
int  x,
int  y,
const char *  txt,
int  o 
)
static

Definition at line 233 of file avf_showvolume.c.

Referenced by filter_frame().

◆ clear_picture()

static void clear_picture ( ShowVolumeContext s,
AVFilterLink outlink 
)
static

Definition at line 267 of file avf_showvolume.c.

Referenced by filter_frame().

◆ calc_max_draw()

static int calc_max_draw ( ShowVolumeContext s,
AVFilterLink outlink,
float  max 
)
inlinestatic

Definition at line 279 of file avf_showvolume.c.

Referenced by filter_frame().

◆ calc_persistent_max()

static void calc_persistent_max ( ShowVolumeContext s,
float  max,
int  channel 
)
inlinestatic

Definition at line 294 of file avf_showvolume.c.

Referenced by filter_frame().

◆ draw_max_line()

static void draw_max_line ( ShowVolumeContext s,
int  max_draw,
int  channel 
)
inlinestatic

Definition at line 305 of file avf_showvolume.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame insamples 
)
static

Definition at line 321 of file avf_showvolume.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 460 of file avf_showvolume.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 487 of file avf_showvolume.c.

Variable Documentation

◆ var_names

const char* const var_names[] = { "VOLUME", "CHANNEL", "PEAK", NULL }
static

Definition at line 35 of file avf_showvolume.c.

Referenced by init().

◆ showvolume_options

const AVOption showvolume_options[]
static
Initial value:
= {
{ "rate", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
{ "r", "set video rate", OFFSET(frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="25"}, 0, INT_MAX, FLAGS },
{ "b", "set border width", OFFSET(b), AV_OPT_TYPE_INT, {.i64=1}, 0, 5, FLAGS },
{ "w", "set channel width", OFFSET(w), AV_OPT_TYPE_INT, {.i64=400}, 80, 8192, FLAGS },
{ "h", "set channel height", OFFSET(h), AV_OPT_TYPE_INT, {.i64=20}, 1, 900, FLAGS },
{ "f", "set fade", OFFSET(f), AV_OPT_TYPE_DOUBLE, {.dbl=0.95}, 0, 1, FLAGS },
{ "c", "set volume color expression", OFFSET(color), AV_OPT_TYPE_STRING, {.str="PEAK*255+floor((1-PEAK)*255)*256+0xff000000"}, 0, 0, FLAGS },
{ "t", "display channel names", OFFSET(draw_text), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGS },
{ "v", "display volume value", OFFSET(draw_volume), AV_OPT_TYPE_BOOL, {.i64=1}, 0, 1, FLAGS },
{ "dm", "duration for max value display", OFFSET(draw_persistent_duration), AV_OPT_TYPE_DOUBLE, {.dbl=0.}, 0, 9000, FLAGS},
{ "dmc","set color of the max value line", OFFSET(persistant_max_rgba), AV_OPT_TYPE_COLOR, {.str = "orange"}, 0, 0, FLAGS },
{ "o", "set orientation", OFFSET(orientation), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, .unit = "orientation" },
{ "h", "horizontal", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, .unit = "orientation" },
{ "v", "vertical", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, .unit = "orientation" },
{ "s", "set step size", OFFSET(step), AV_OPT_TYPE_INT, {.i64=0}, 0, 5, FLAGS },
{ "p", "set background opacity", OFFSET(bgopacity), AV_OPT_TYPE_FLOAT, {.dbl=0}, 0, 1, FLAGS },
{ "m", "set mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, .unit = "mode" },
{ "p", "peak", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, .unit = "mode" },
{ "r", "rms", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, .unit = "mode" },
{ "ds", "set display scale", OFFSET(display_scale), AV_OPT_TYPE_INT, {.i64=LINEAR}, LINEAR, NB_DISPLAY_SCALE - 1, FLAGS, .unit = "display_scale" },
{ "lin", "linear", 0, AV_OPT_TYPE_CONST, {.i64=LINEAR}, 0, 0, FLAGS, .unit = "display_scale" },
{ "log", "log", 0, AV_OPT_TYPE_CONST, {.i64=LOG}, 0, 0, FLAGS, .unit = "display_scale" },
{ NULL }
}

Definition at line 73 of file avf_showvolume.c.

◆ showvolume_inputs

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

Definition at line 500 of file avf_showvolume.c.

◆ showvolume_outputs

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

Definition at line 508 of file avf_showvolume.c.

◆ ff_avf_showvolume

const AVFilter ff_avf_showvolume
Initial value:
= {
.name = "showvolume",
.description = NULL_IF_CONFIG_SMALL("Convert input audio volume to video output."),
.init = init,
.activate = activate,
.uninit = uninit,
.priv_size = sizeof(ShowVolumeContext),
.priv_class = &showvolume_class,
}

Definition at line 516 of file avf_showvolume.c.

ShowVolumeContext
Definition: avf_showvolume.c:39
color
Definition: vf_paletteuse.c:511
showvolume_inputs
static const AVFilterPad showvolume_inputs[]
Definition: avf_showvolume.c:500
AV_OPT_TYPE_VIDEO_RATE
@ AV_OPT_TYPE_VIDEO_RATE
offset must point to AVRational
Definition: opt.h:248
step
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about which is also called distortion Distortion can be quantified by almost any quality measurement one chooses the sum of squared differences is used but more complex methods that consider psychovisual effects can be used as well It makes no difference in this discussion First step
Definition: rate_distortion.txt:58
w
uint8_t w
Definition: llviddspenc.c:38
b
#define b
Definition: input.c:41
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:159
LOG
@ LOG
Definition: avf_showvolume.c:37
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:237
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
activate
static int activate(AVFilterContext *ctx)
Definition: avf_showvolume.c:460
init
static av_cold int init(AVFilterContext *ctx)
Definition: avf_showvolume.c:101
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
NULL
#define NULL
Definition: coverity.c:32
AV_OPT_TYPE_COLOR
@ AV_OPT_TYPE_COLOR
Definition: opt.h:250
config_output
static int config_output(AVFilterLink *outlink)
Definition: avf_showvolume.c:199
f
f
Definition: af_crystalizer.c:121
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:106
OFFSET
#define OFFSET(x)
Definition: avf_showvolume.c:70
AV_OPT_TYPE_FLOAT
@ AV_OPT_TYPE_FLOAT
Definition: opt.h:238
showvolume_outputs
static const AVFilterPad showvolume_outputs[]
Definition: avf_showvolume.c:508
LINEAR
@ LINEAR
Definition: avf_showvolume.c:37
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: avf_showvolume.c:116
draw_text
static void draw_text(FFDrawContext *draw, AVFrame *out, FFDrawColor *color, int x0, int y0, const uint8_t *text)
Definition: src_avsynctest.c:247
mode
mode
Definition: ebur128.h:83
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:235
FLAGS
#define FLAGS
Definition: avf_showvolume.c:71
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:251
NB_DISPLAY_SCALE
@ NB_DISPLAY_SCALE
Definition: avf_showvolume.c:37
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
config_input
static int config_input(AVFilterLink *inlink)
Definition: avf_showvolume.c:164
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: avf_showvolume.c:487
h
h
Definition: vp9dsp_template.c:2038
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:239
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:244