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

audio volume filter More...

#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/eval.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 D2TS(d)   (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d))
 
#define TS2D(ts)   ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
 
#define TS2T(ts, tb)   ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)*av_q2d(tb))
 

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 []
 
AVFilter ff_af_volume
 

Detailed Description

audio volume filter

Definition in file af_volume.c.

Macro Definition Documentation

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

Definition at line 61 of file af_volume.c.

#define A   AV_OPT_FLAG_AUDIO_PARAM

Definition at line 62 of file af_volume.c.

Definition at line 63 of file af_volume.c.

#define D2TS (   d)    (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d))

Definition at line 329 of file af_volume.c.

#define TS2D (   ts)    ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))

Definition at line 330 of file af_volume.c.

Referenced by filter_frame().

#define TS2T (   ts,
  tb 
)    ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)*av_q2d(tb))

Definition at line 331 of file af_volume.c.

Referenced by filter_frame().

Function Documentation

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

Definition at line 91 of file af_volume.c.

Referenced by init(), and process_command().

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 111 of file af_volume.c.

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 117 of file af_volume.c.

static int query_formats ( AVFilterContext ctx)
static

Definition at line 124 of file af_volume.c.

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

Definition at line 169 of file af_volume.c.

Referenced by volume_init().

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

Definition at line 177 of file af_volume.c.

Referenced by volume_init().

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

Definition at line 185 of file af_volume.c.

Referenced by volume_init().

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

Definition at line 195 of file af_volume.c.

Referenced by volume_init().

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

Definition at line 205 of file af_volume.c.

Referenced by volume_init().

static av_cold void volume_init ( VolumeContext vol)
static

Definition at line 215 of file af_volume.c.

Referenced by filter_frame(), and set_volume().

static int set_volume ( AVFilterContext ctx)
static

Definition at line 249 of file af_volume.c.

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

static int config_output ( AVFilterLink outlink)
static

Definition at line 281 of file af_volume.c.

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

Definition at line 313 of file af_volume.c.

static int filter_frame ( AVFilterLink inlink,
AVFrame buf 
)
static

Definition at line 333 of file af_volume.c.

Variable Documentation

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

Definition at line 41 of file af_volume.c.

Referenced by set_volume().

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",
NULL
}

Definition at line 45 of file af_volume.c.

Referenced by set_expr().

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 },
{ "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, "replaygain" },
{ "drop", "replaygain side data is dropped", 0, AV_OPT_TYPE_CONST, { .i64 = REPLAYGAIN_DROP }, 0, 0, A, "replaygain" },
{ "ignore", "replaygain side data is ignored", 0, AV_OPT_TYPE_CONST, { .i64 = REPLAYGAIN_IGNORE }, 0, 0, A, "replaygain" },
{ "track", "track gain is preferred", 0, AV_OPT_TYPE_CONST, { .i64 = REPLAYGAIN_TRACK }, 0, 0, A, "replaygain" },
{ "album", "album gain is preferred", 0, AV_OPT_TYPE_CONST, { .i64 = REPLAYGAIN_ALBUM }, 0, 0, A, "replaygain" },
{ "replaygain_preamp", "Apply replaygain pre-amplification",
OFFSET(replaygain_preamp), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, -15.0, 15.0, A },
{ "replaygain_noclip", "Apply replaygain clipping prevention",
OFFSET(replaygain_noclip), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, A },
{ NULL },
}

Definition at line 65 of file af_volume.c.

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

Definition at line 454 of file af_volume.c.

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

Definition at line 463 of file af_volume.c.

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

Definition at line 472 of file af_volume.c.