FFmpeg
Loading...
Searching...
No Matches
avf_showvolume.c File Reference
#include "libavutil/channel_layout.h"
#include "libavutil/eval.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/xga_font_data.h"
#include "avfilter.h"
#include "filters.h"
#include "formats.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  ShowVolumeContext
 

Macros

#define OFFSET(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 , LOG , NB_DISPLAY_SCALE }
 

Functions

 AVFILTER_DEFINE_CLASS (showvolume)
 
static av_cold int init (AVFilterContext *ctx)
 
static int query_formats (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
 
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 FFFilter ff_avf_showvolume
 

Macro Definition Documentation

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 67 of file avf_showvolume.c.

◆ FLAGS

Definition at line 68 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 33 of file avf_showvolume.c.

◆ DisplayScale

Enumerator
LINEAR 
LOG 
NB_DISPLAY_SCALE 

Definition at line 34 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 98 of file avf_showvolume.c.

◆ query_formats()

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

Definition at line 113 of file avf_showvolume.c.

◆ find_peak()

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

Definition at line 133 of file avf_showvolume.c.

◆ find_rms()

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

Definition at line 143 of file avf_showvolume.c.

Referenced by config_input().

◆ config_input()

static int config_input ( AVFilterLink * inlink)
static

Definition at line 152 of file avf_showvolume.c.

◆ config_output()

static int config_output ( AVFilterLink * outlink)
static

Definition at line 187 of file avf_showvolume.c.

◆ drawtext()

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

Definition at line 222 of file avf_showvolume.c.

Referenced by filter_frame().

◆ clear_picture()

static void clear_picture ( ShowVolumeContext * s,
AVFilterLink * outlink )
static

Definition at line 256 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 268 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 283 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 294 of file avf_showvolume.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink * inlink,
AVFrame * insamples )
static

Definition at line 310 of file avf_showvolume.c.

Referenced by activate().

◆ activate()

static int activate ( AVFilterContext * ctx)
static

Definition at line 449 of file avf_showvolume.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext * ctx)
static

Definition at line 476 of file avf_showvolume.c.

Variable Documentation

◆ var_names

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

Definition at line 32 of file avf_showvolume.c.

◆ 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 }
}
@ NB_DISPLAY_SCALE
#define f(width, name)
Definition cbs_vp8.c:236
#define FLAGS
Definition cmdutils.c:598
#define NULL
Definition coverity.c:32
mode
Use these values in ebur128_init (or'ed).
Definition ebur128.h:83
#define OFFSET(x)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_VIDEO_RATE
Underlying C type is AVRational.
Definition opt.h:314
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
Definition opt.h:266
@ AV_OPT_TYPE_FLOAT
Underlying C type is float.
Definition opt.h:270
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition opt.h:326
@ 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:275
@ AV_OPT_TYPE_COLOR
Underlying C type is uint8_t[4].
Definition opt.h:322
#define b
Definition input.c:43
uint8_t w
Definition llvidencdsp.c:39
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
Definition log.c:98
static void draw_text(FFDrawContext *draw, AVFrame *out, FFDrawColor *color, int x0, int y0, const uint8_t *text)
#define LOG(...)
Definition internal.h:126
#define LINEAR

Definition at line 70 of file avf_showvolume.c.

◆ showvolume_inputs

const AVFilterPad showvolume_inputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_input,
},
}
static int config_input(AVFilterLink *inlink)
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201

Definition at line 489 of file avf_showvolume.c.

◆ showvolume_outputs

const AVFilterPad showvolume_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
}
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
static int config_output(AVBitStreamFilterLink *outlink)

Definition at line 497 of file avf_showvolume.c.

◆ ff_avf_showvolume

const FFFilter ff_avf_showvolume
Initial value:
= {
.p.name = "showvolume",
.p.description = NULL_IF_CONFIG_SMALL("Convert input audio volume to video output."),
.p.priv_class = &showvolume_class,
.init = init,
.activate = activate,
.uninit = uninit,
.priv_size = sizeof(ShowVolumeContext),
}
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition aeval.c:246
static const AVFilterPad showvolume_outputs[]
static const AVFilterPad showvolume_inputs[]
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_QUERY_FUNC2(func)
Definition filters.h:241
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88

Definition at line 505 of file avf_showvolume.c.