FFmpeg
Macros | Functions | Variables
af_volume.c File Reference
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/eval.h"
#include "libavutil/ffmath.h"
#include "libavutil/float_dsp.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "libavutil/replaygain.h"
#include "audio.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "af_volume.h"

Go to the source code of this file.

Macros

#define OFFSET(x)   offsetof(VolumeContext, x)
 
#define A   AV_OPT_FLAG_AUDIO_PARAM
 
#define F   AV_OPT_FLAG_FILTERING_PARAM
 
#define T   AV_OPT_FLAG_RUNTIME_PARAM
 

Functions

 AVFILTER_DEFINE_CLASS (volume)
 
static int set_expr (AVExpr **pexpr, const char *expr, void *log_ctx)
 
static av_cold int init (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 
static int query_formats (AVFilterContext *ctx)
 
static void scale_samples_u8 (uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
 
static void scale_samples_u8_small (uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
 
static void scale_samples_s16 (uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
 
static void scale_samples_s16_small (uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
 
static void scale_samples_s32 (uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
 
static av_cold void volume_init (VolumeContext *vol)
 
static int set_volume (AVFilterContext *ctx)
 
static int config_output (AVFilterLink *outlink)
 
static int process_command (AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *buf)
 

Variables

static const char *const precision_str []
 
static const char *const var_names []
 
static const AVOption volume_options []
 
static const AVFilterPad avfilter_af_volume_inputs []
 
static const AVFilterPad avfilter_af_volume_outputs []
 
const AVFilter ff_af_volume
 

Detailed Description

audio volume filter

Definition in file af_volume.c.

Macro Definition Documentation

◆ OFFSET

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

Definition at line 62 of file af_volume.c.

◆ A

#define A   AV_OPT_FLAG_AUDIO_PARAM

Definition at line 63 of file af_volume.c.

◆ F

Definition at line 64 of file af_volume.c.

◆ T

#define T   AV_OPT_FLAG_RUNTIME_PARAM

Definition at line 65 of file af_volume.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( volume  )

◆ set_expr()

static int set_expr ( AVExpr **  pexpr,
const char *  expr,
void *  log_ctx 
)
static

Definition at line 93 of file af_volume.c.

Referenced by init(), and process_command().

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 113 of file af_volume.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 124 of file af_volume.c.

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 132 of file af_volume.c.

◆ scale_samples_u8()

static void scale_samples_u8 ( uint8_t *  dst,
const uint8_t *  src,
int  nb_samples,
int  volume 
)
inlinestatic

Definition at line 167 of file af_volume.c.

Referenced by volume_init().

◆ scale_samples_u8_small()

static void scale_samples_u8_small ( uint8_t *  dst,
const uint8_t *  src,
int  nb_samples,
int  volume 
)
inlinestatic

Definition at line 175 of file af_volume.c.

Referenced by volume_init().

◆ scale_samples_s16()

static void scale_samples_s16 ( uint8_t *  dst,
const uint8_t *  src,
int  nb_samples,
int  volume 
)
inlinestatic

Definition at line 183 of file af_volume.c.

Referenced by volume_init().

◆ scale_samples_s16_small()

static void scale_samples_s16_small ( uint8_t *  dst,
const uint8_t *  src,
int  nb_samples,
int  volume 
)
inlinestatic

Definition at line 193 of file af_volume.c.

Referenced by volume_init().

◆ scale_samples_s32()

static void scale_samples_s32 ( uint8_t *  dst,
const uint8_t *  src,
int  nb_samples,
int  volume 
)
inlinestatic

Definition at line 203 of file af_volume.c.

Referenced by volume_init().

◆ volume_init()

static av_cold void volume_init ( VolumeContext vol)
static

Definition at line 213 of file af_volume.c.

Referenced by filter_frame(), and set_volume().

◆ set_volume()

static int set_volume ( AVFilterContext ctx)
static

Definition at line 245 of file af_volume.c.

Referenced by config_output(), filter_frame(), and process_command().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 277 of file af_volume.c.

◆ process_command()

static int process_command ( AVFilterContext ctx,
const char *  cmd,
const char *  args,
char *  res,
int  res_len,
int  flags 
)
static

Definition at line 309 of file af_volume.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame buf 
)
static

Definition at line 325 of file af_volume.c.

Variable Documentation

◆ precision_str

const char* const precision_str[]
static
Initial value:
= {
"fixed", "float", "double"
}

Definition at line 42 of file af_volume.c.

Referenced by set_volume().

◆ var_names

const char* const var_names[]
static
Initial value:
= {
"n",
"nb_channels",
"nb_consumed_samples",
"nb_samples",
"pos",
"pts",
"sample_rate",
"startpts",
"startt",
"t",
"tb",
"volume",
}

Definition at line 46 of file af_volume.c.

Referenced by set_expr().

◆ volume_options

const AVOption volume_options[]
static
Initial value:
= {
{ "volume", "set volume adjustment expression",
OFFSET(volume_expr), AV_OPT_TYPE_STRING, { .str = "1.0" }, .flags = A|F|T },
{ "precision", "select mathematical precision",
OFFSET(precision), AV_OPT_TYPE_INT, { .i64 = PRECISION_FLOAT }, PRECISION_FIXED, PRECISION_DOUBLE, A|F, "precision" },
{ "fixed", "select 8-bit fixed-point", 0, AV_OPT_TYPE_CONST, { .i64 = PRECISION_FIXED }, INT_MIN, INT_MAX, A|F, "precision" },
{ "float", "select 32-bit floating-point", 0, AV_OPT_TYPE_CONST, { .i64 = PRECISION_FLOAT }, INT_MIN, INT_MAX, A|F, "precision" },
{ "double", "select 64-bit floating-point", 0, AV_OPT_TYPE_CONST, { .i64 = PRECISION_DOUBLE }, INT_MIN, INT_MAX, A|F, "precision" },
{ "eval", "specify when to evaluate expressions", OFFSET(eval_mode), AV_OPT_TYPE_INT, {.i64 = EVAL_MODE_ONCE}, 0, EVAL_MODE_NB-1, .flags = A|F, "eval" },
{ "once", "eval volume expression once", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_ONCE}, .flags = A|F, .unit = "eval" },
{ "frame", "eval volume expression per-frame", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_FRAME}, .flags = A|F, .unit = "eval" },
{ "replaygain", "Apply replaygain side data when present",
OFFSET(replaygain), AV_OPT_TYPE_INT, { .i64 = REPLAYGAIN_DROP }, REPLAYGAIN_DROP, REPLAYGAIN_ALBUM, A|F, "replaygain" },
{ "drop", "replaygain side data is dropped", 0, AV_OPT_TYPE_CONST, { .i64 = REPLAYGAIN_DROP }, 0, 0, A|F, "replaygain" },
{ "ignore", "replaygain side data is ignored", 0, AV_OPT_TYPE_CONST, { .i64 = REPLAYGAIN_IGNORE }, 0, 0, A|F, "replaygain" },
{ "track", "track gain is preferred", 0, AV_OPT_TYPE_CONST, { .i64 = REPLAYGAIN_TRACK }, 0, 0, A|F, "replaygain" },
{ "album", "album gain is preferred", 0, AV_OPT_TYPE_CONST, { .i64 = REPLAYGAIN_ALBUM }, 0, 0, A|F, "replaygain" },
{ "replaygain_preamp", "Apply replaygain pre-amplification",
OFFSET(replaygain_preamp), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, -15.0, 15.0, A|F },
{ "replaygain_noclip", "Apply replaygain clipping prevention",
OFFSET(replaygain_noclip), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, A|F },
{ NULL }
}

Definition at line 67 of file af_volume.c.

◆ avfilter_af_volume_inputs

const AVFilterPad avfilter_af_volume_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
},
}

Definition at line 449 of file af_volume.c.

◆ avfilter_af_volume_outputs

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

Definition at line 457 of file af_volume.c.

◆ ff_af_volume

const AVFilter ff_af_volume
Initial value:
= {
.name = "volume",
.description = NULL_IF_CONFIG_SMALL("Change input volume."),
.priv_size = sizeof(VolumeContext),
.priv_class = &volume_class,
.init = init,
.process_command = process_command,
}

Definition at line 465 of file af_volume.c.

PRECISION_FIXED
@ PRECISION_FIXED
Definition: af_volume.h:34
OFFSET
#define OFFSET(x)
Definition: af_volume.c:62
REPLAYGAIN_ALBUM
@ REPLAYGAIN_ALBUM
Definition: af_volume.h:65
init
static av_cold int init(AVFilterContext *ctx)
Definition: af_volume.c:113
VolumeContext
Definition: af_volume.h:68
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
Definition: af_volume.c:325
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:168
REPLAYGAIN_DROP
@ REPLAYGAIN_DROP
Definition: af_volume.h:62
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_volume.c:124
config_output
static int config_output(AVFilterLink *outlink)
Definition: af_volume.c:277
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: af_volume.c:132
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:226
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
PRECISION_DOUBLE
@ PRECISION_DOUBLE
Definition: af_volume.h:36
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
NULL
#define NULL
Definition: coverity.c:32
process_command
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: af_volume.c:309
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:117
REPLAYGAIN_IGNORE
@ REPLAYGAIN_IGNORE
Definition: af_volume.h:63
F
#define F
Definition: af_volume.c:64
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition: avfilter.h:146
avfilter_af_volume_outputs
static const AVFilterPad avfilter_af_volume_outputs[]
Definition: af_volume.c:457
EVAL_MODE_ONCE
@ EVAL_MODE_ONCE
Definition: af_volume.h:40
EVAL_MODE_NB
@ EVAL_MODE_NB
Definition: af_volume.h:42
T
#define T
Definition: af_volume.c:65
EVAL_MODE_FRAME
@ EVAL_MODE_FRAME
Definition: af_volume.h:41
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
PRECISION_FLOAT
@ PRECISION_FLOAT
Definition: af_volume.h:35
A
#define A
Definition: af_volume.c:63
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Definition: opt.h:241
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
avfilter_af_volume_inputs
static const AVFilterPad avfilter_af_volume_inputs[]
Definition: af_volume.c:449
AV_OPT_TYPE_STRING
@ AV_OPT_TYPE_STRING
Definition: opt.h:228
REPLAYGAIN_TRACK
@ REPLAYGAIN_TRACK
Definition: af_volume.h:64
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233