FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
af_volume.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011 Stefano Sabatini
3  * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file
24  * audio volume filter
25  */
26 
28 #include "libavutil/common.h"
29 #include "libavutil/eval.h"
30 #include "libavutil/float_dsp.h"
31 #include "libavutil/intreadwrite.h"
32 #include "libavutil/opt.h"
33 #include "libavutil/replaygain.h"
34 
35 #include "audio.h"
36 #include "avfilter.h"
37 #include "formats.h"
38 #include "internal.h"
39 #include "af_volume.h"
40 
41 static const char * const precision_str[] = {
42  "fixed", "float", "double"
43 };
44 
45 static const char *const var_names[] = {
46  "n", ///< frame number (starting at zero)
47  "nb_channels", ///< number of channels
48  "nb_consumed_samples", ///< number of samples consumed by the filter
49  "nb_samples", ///< number of samples in the current frame
50  "pos", ///< position in the file of the frame
51  "pts", ///< frame presentation timestamp
52  "sample_rate", ///< sample rate
53  "startpts", ///< PTS at start of stream
54  "startt", ///< time at start of stream
55  "t", ///< time in the file of the frame
56  "tb", ///< timebase
57  "volume", ///< last set value
58  NULL
59 };
60 
61 #define OFFSET(x) offsetof(VolumeContext, x)
62 #define A AV_OPT_FLAG_AUDIO_PARAM
63 #define F AV_OPT_FLAG_FILTERING_PARAM
64 
65 static const AVOption volume_options[] = {
66  { "volume", "set volume adjustment expression",
67  OFFSET(volume_expr), AV_OPT_TYPE_STRING, { .str = "1.0" }, .flags = A|F },
68  { "precision", "select mathematical precision",
69  OFFSET(precision), AV_OPT_TYPE_INT, { .i64 = PRECISION_FLOAT }, PRECISION_FIXED, PRECISION_DOUBLE, A|F, "precision" },
70  { "fixed", "select 8-bit fixed-point", 0, AV_OPT_TYPE_CONST, { .i64 = PRECISION_FIXED }, INT_MIN, INT_MAX, A|F, "precision" },
71  { "float", "select 32-bit floating-point", 0, AV_OPT_TYPE_CONST, { .i64 = PRECISION_FLOAT }, INT_MIN, INT_MAX, A|F, "precision" },
72  { "double", "select 64-bit floating-point", 0, AV_OPT_TYPE_CONST, { .i64 = PRECISION_DOUBLE }, INT_MIN, INT_MAX, A|F, "precision" },
73  { "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" },
74  { "once", "eval volume expression once", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_ONCE}, .flags = A|F, .unit = "eval" },
75  { "frame", "eval volume expression per-frame", 0, AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_FRAME}, .flags = A|F, .unit = "eval" },
76  { "replaygain", "Apply replaygain side data when present",
77  OFFSET(replaygain), AV_OPT_TYPE_INT, { .i64 = REPLAYGAIN_DROP }, REPLAYGAIN_DROP, REPLAYGAIN_ALBUM, A, "replaygain" },
78  { "drop", "replaygain side data is dropped", 0, AV_OPT_TYPE_CONST, { .i64 = REPLAYGAIN_DROP }, 0, 0, A, "replaygain" },
79  { "ignore", "replaygain side data is ignored", 0, AV_OPT_TYPE_CONST, { .i64 = REPLAYGAIN_IGNORE }, 0, 0, A, "replaygain" },
80  { "track", "track gain is preferred", 0, AV_OPT_TYPE_CONST, { .i64 = REPLAYGAIN_TRACK }, 0, 0, A, "replaygain" },
81  { "album", "album gain is preferred", 0, AV_OPT_TYPE_CONST, { .i64 = REPLAYGAIN_ALBUM }, 0, 0, A, "replaygain" },
82  { "replaygain_preamp", "Apply replaygain pre-amplification",
83  OFFSET(replaygain_preamp), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, -15.0, 15.0, A },
84  { "replaygain_noclip", "Apply replaygain clipping prevention",
85  OFFSET(replaygain_noclip), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, A },
86  { NULL },
87 };
88 
89 AVFILTER_DEFINE_CLASS(volume);
90 
91 static int set_expr(AVExpr **pexpr, const char *expr, void *log_ctx)
92 {
93  int ret;
94  AVExpr *old = NULL;
95 
96  if (*pexpr)
97  old = *pexpr;
98  ret = av_expr_parse(pexpr, expr, var_names,
99  NULL, NULL, NULL, NULL, 0, log_ctx);
100  if (ret < 0) {
101  av_log(log_ctx, AV_LOG_ERROR,
102  "Error when evaluating the volume expression '%s'\n", expr);
103  *pexpr = old;
104  return ret;
105  }
106 
107  av_expr_free(old);
108  return 0;
109 }
110 
111 static av_cold int init(AVFilterContext *ctx)
112 {
113  VolumeContext *vol = ctx->priv;
114 
115  vol->fdsp = avpriv_float_dsp_alloc(0);
116  if (!vol->fdsp)
117  return AVERROR(ENOMEM);
118 
119  return set_expr(&vol->volume_pexpr, vol->volume_expr, ctx);
120 }
121 
122 static av_cold void uninit(AVFilterContext *ctx)
123 {
124  VolumeContext *vol = ctx->priv;
126  av_opt_free(vol);
127  av_freep(&vol->fdsp);
128 }
129 
131 {
132  VolumeContext *vol = ctx->priv;
135  static const enum AVSampleFormat sample_fmts[][7] = {
136  [PRECISION_FIXED] = {
144  },
145  [PRECISION_FLOAT] = {
149  },
150  [PRECISION_DOUBLE] = {
154  }
155  };
156  int ret;
157 
158  layouts = ff_all_channel_counts();
159  if (!layouts)
160  return AVERROR(ENOMEM);
161  ret = ff_set_common_channel_layouts(ctx, layouts);
162  if (ret < 0)
163  return ret;
164 
165  formats = ff_make_format_list(sample_fmts[vol->precision]);
166  if (!formats)
167  return AVERROR(ENOMEM);
168  ret = ff_set_common_formats(ctx, formats);
169  if (ret < 0)
170  return ret;
171 
172  formats = ff_all_samplerates();
173  if (!formats)
174  return AVERROR(ENOMEM);
175  return ff_set_common_samplerates(ctx, formats);
176 }
177 
178 static inline void scale_samples_u8(uint8_t *dst, const uint8_t *src,
179  int nb_samples, int volume)
180 {
181  int i;
182  for (i = 0; i < nb_samples; i++)
183  dst[i] = av_clip_uint8(((((int64_t)src[i] - 128) * volume + 128) >> 8) + 128);
184 }
185 
186 static inline void scale_samples_u8_small(uint8_t *dst, const uint8_t *src,
187  int nb_samples, int volume)
188 {
189  int i;
190  for (i = 0; i < nb_samples; i++)
191  dst[i] = av_clip_uint8((((src[i] - 128) * volume + 128) >> 8) + 128);
192 }
193 
194 static inline void scale_samples_s16(uint8_t *dst, const uint8_t *src,
195  int nb_samples, int volume)
196 {
197  int i;
198  int16_t *smp_dst = (int16_t *)dst;
199  const int16_t *smp_src = (const int16_t *)src;
200  for (i = 0; i < nb_samples; i++)
201  smp_dst[i] = av_clip_int16(((int64_t)smp_src[i] * volume + 128) >> 8);
202 }
203 
204 static inline void scale_samples_s16_small(uint8_t *dst, const uint8_t *src,
205  int nb_samples, int volume)
206 {
207  int i;
208  int16_t *smp_dst = (int16_t *)dst;
209  const int16_t *smp_src = (const int16_t *)src;
210  for (i = 0; i < nb_samples; i++)
211  smp_dst[i] = av_clip_int16((smp_src[i] * volume + 128) >> 8);
212 }
213 
214 static inline void scale_samples_s32(uint8_t *dst, const uint8_t *src,
215  int nb_samples, int volume)
216 {
217  int i;
218  int32_t *smp_dst = (int32_t *)dst;
219  const int32_t *smp_src = (const int32_t *)src;
220  for (i = 0; i < nb_samples; i++)
221  smp_dst[i] = av_clipl_int32((((int64_t)smp_src[i] * volume + 128) >> 8));
222 }
223 
225 {
226  vol->samples_align = 1;
227 
228  switch (av_get_packed_sample_fmt(vol->sample_fmt)) {
229  case AV_SAMPLE_FMT_U8:
230  if (vol->volume_i < 0x1000000)
232  else
234  break;
235  case AV_SAMPLE_FMT_S16:
236  if (vol->volume_i < 0x10000)
238  else
240  break;
241  case AV_SAMPLE_FMT_S32:
243  break;
244  case AV_SAMPLE_FMT_FLT:
245  vol->samples_align = 4;
246  break;
247  case AV_SAMPLE_FMT_DBL:
248  vol->samples_align = 8;
249  break;
250  }
251 
252  if (ARCH_X86)
253  ff_volume_init_x86(vol);
254 }
255 
256 static int set_volume(AVFilterContext *ctx)
257 {
258  VolumeContext *vol = ctx->priv;
259 
260  vol->volume = av_expr_eval(vol->volume_pexpr, vol->var_values, NULL);
261  if (isnan(vol->volume)) {
262  if (vol->eval_mode == EVAL_MODE_ONCE) {
263  av_log(ctx, AV_LOG_ERROR, "Invalid value NaN for volume\n");
264  return AVERROR(EINVAL);
265  } else {
266  av_log(ctx, AV_LOG_WARNING, "Invalid value NaN for volume, setting to 0\n");
267  vol->volume = 0;
268  }
269  }
270  vol->var_values[VAR_VOLUME] = vol->volume;
271 
272  av_log(ctx, AV_LOG_VERBOSE, "n:%f t:%f pts:%f precision:%s ",
273  vol->var_values[VAR_N], vol->var_values[VAR_T], vol->var_values[VAR_PTS],
274  precision_str[vol->precision]);
275 
276  if (vol->precision == PRECISION_FIXED) {
277  vol->volume_i = (int)(vol->volume * 256 + 0.5);
278  vol->volume = vol->volume_i / 256.0;
279  av_log(ctx, AV_LOG_VERBOSE, "volume_i:%d/255 ", vol->volume_i);
280  }
281  av_log(ctx, AV_LOG_VERBOSE, "volume:%f volume_dB:%f\n",
282  vol->volume, 20.0*log(vol->volume)/M_LN10);
283 
284  volume_init(vol);
285  return 0;
286 }
287 
288 static int config_output(AVFilterLink *outlink)
289 {
290  AVFilterContext *ctx = outlink->src;
291  VolumeContext *vol = ctx->priv;
292  AVFilterLink *inlink = ctx->inputs[0];
293 
294  vol->sample_fmt = inlink->format;
295  vol->channels = inlink->channels;
296  vol->planes = av_sample_fmt_is_planar(inlink->format) ? vol->channels : 1;
297 
298  vol->var_values[VAR_N] =
300  vol->var_values[VAR_NB_SAMPLES] =
301  vol->var_values[VAR_POS] =
302  vol->var_values[VAR_PTS] =
303  vol->var_values[VAR_STARTPTS] =
304  vol->var_values[VAR_STARTT] =
305  vol->var_values[VAR_T] =
306  vol->var_values[VAR_VOLUME] = NAN;
307 
308  vol->var_values[VAR_NB_CHANNELS] = inlink->channels;
309  vol->var_values[VAR_TB] = av_q2d(inlink->time_base);
310  vol->var_values[VAR_SAMPLE_RATE] = inlink->sample_rate;
311 
312  av_log(inlink->src, AV_LOG_VERBOSE, "tb:%f sample_rate:%f nb_channels:%f\n",
313  vol->var_values[VAR_TB],
316 
317  return set_volume(ctx);
318 }
319 
320 static int process_command(AVFilterContext *ctx, const char *cmd, const char *args,
321  char *res, int res_len, int flags)
322 {
323  VolumeContext *vol = ctx->priv;
324  int ret = AVERROR(ENOSYS);
325 
326  if (!strcmp(cmd, "volume")) {
327  if ((ret = set_expr(&vol->volume_pexpr, args, ctx)) < 0)
328  return ret;
329  if (vol->eval_mode == EVAL_MODE_ONCE)
330  set_volume(ctx);
331  }
332 
333  return ret;
334 }
335 
336 #define D2TS(d) (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d))
337 #define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
338 #define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)*av_q2d(tb))
339 
340 static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
341 {
342  AVFilterContext *ctx = inlink->dst;
343  VolumeContext *vol = inlink->dst->priv;
344  AVFilterLink *outlink = inlink->dst->outputs[0];
345  int nb_samples = buf->nb_samples;
346  AVFrame *out_buf;
347  int64_t pos;
349  int ret;
350 
351  if (sd && vol->replaygain != REPLAYGAIN_IGNORE) {
352  if (vol->replaygain != REPLAYGAIN_DROP) {
353  AVReplayGain *replaygain = (AVReplayGain*)sd->data;
354  int32_t gain = 100000;
355  uint32_t peak = 100000;
356  float g, p;
357 
358  if (vol->replaygain == REPLAYGAIN_TRACK &&
359  replaygain->track_gain != INT32_MIN) {
360  gain = replaygain->track_gain;
361 
362  if (replaygain->track_peak != 0)
363  peak = replaygain->track_peak;
364  } else if (replaygain->album_gain != INT32_MIN) {
365  gain = replaygain->album_gain;
366 
367  if (replaygain->album_peak != 0)
368  peak = replaygain->album_peak;
369  } else {
370  av_log(inlink->dst, AV_LOG_WARNING, "Both ReplayGain gain "
371  "values are unknown.\n");
372  }
373  g = gain / 100000.0f;
374  p = peak / 100000.0f;
375 
376  av_log(inlink->dst, AV_LOG_VERBOSE,
377  "Using gain %f dB from replaygain side data.\n", g);
378 
379  vol->volume = pow(10, (g + vol->replaygain_preamp) / 20);
380  if (vol->replaygain_noclip)
381  vol->volume = FFMIN(vol->volume, 1.0 / p);
382  vol->volume_i = (int)(vol->volume * 256 + 0.5);
383 
384  volume_init(vol);
385  }
387  }
388 
389  if (isnan(vol->var_values[VAR_STARTPTS])) {
390  vol->var_values[VAR_STARTPTS] = TS2D(buf->pts);
391  vol->var_values[VAR_STARTT ] = TS2T(buf->pts, inlink->time_base);
392  }
393  vol->var_values[VAR_PTS] = TS2D(buf->pts);
394  vol->var_values[VAR_T ] = TS2T(buf->pts, inlink->time_base);
395  vol->var_values[VAR_N ] = inlink->frame_count;
396 
397  pos = av_frame_get_pkt_pos(buf);
398  vol->var_values[VAR_POS] = pos == -1 ? NAN : pos;
399  if (vol->eval_mode == EVAL_MODE_FRAME)
400  set_volume(ctx);
401 
402  if (vol->volume == 1.0 || vol->volume_i == 256) {
403  out_buf = buf;
404  goto end;
405  }
406 
407  /* do volume scaling in-place if input buffer is writable */
408  if (av_frame_is_writable(buf)
409  && (vol->precision != PRECISION_FIXED || vol->volume_i > 0)) {
410  out_buf = buf;
411  } else {
412  out_buf = ff_get_audio_buffer(inlink, nb_samples);
413  if (!out_buf)
414  return AVERROR(ENOMEM);
415  ret = av_frame_copy_props(out_buf, buf);
416  if (ret < 0) {
417  av_frame_free(&out_buf);
418  av_frame_free(&buf);
419  return ret;
420  }
421  }
422 
423  if (vol->precision != PRECISION_FIXED || vol->volume_i > 0) {
424  int p, plane_samples;
425 
427  plane_samples = FFALIGN(nb_samples, vol->samples_align);
428  else
429  plane_samples = FFALIGN(nb_samples * vol->channels, vol->samples_align);
430 
431  if (vol->precision == PRECISION_FIXED) {
432  for (p = 0; p < vol->planes; p++) {
433  vol->scale_samples(out_buf->extended_data[p],
434  buf->extended_data[p], plane_samples,
435  vol->volume_i);
436  }
438  for (p = 0; p < vol->planes; p++) {
439  vol->fdsp->vector_fmul_scalar((float *)out_buf->extended_data[p],
440  (const float *)buf->extended_data[p],
441  vol->volume, plane_samples);
442  }
443  } else {
444  for (p = 0; p < vol->planes; p++) {
445  vol->fdsp->vector_dmul_scalar((double *)out_buf->extended_data[p],
446  (const double *)buf->extended_data[p],
447  vol->volume, plane_samples);
448  }
449  }
450  }
451 
452  emms_c();
453 
454  if (buf != out_buf)
455  av_frame_free(&buf);
456 
457 end:
459  return ff_filter_frame(outlink, out_buf);
460 }
461 
463  {
464  .name = "default",
465  .type = AVMEDIA_TYPE_AUDIO,
466  .filter_frame = filter_frame,
467  },
468  { NULL }
469 };
470 
472  {
473  .name = "default",
474  .type = AVMEDIA_TYPE_AUDIO,
475  .config_props = config_output,
476  },
477  { NULL }
478 };
479 
481  .name = "volume",
482  .description = NULL_IF_CONFIG_SMALL("Change input volume."),
483  .query_formats = query_formats,
484  .priv_size = sizeof(VolumeContext),
485  .priv_class = &volume_class,
486  .init = init,
487  .uninit = uninit,
488  .inputs = avfilter_af_volume_inputs,
489  .outputs = avfilter_af_volume_outputs,
492 };
int replaygain
Definition: af_volume.h:77
float, planar
Definition: samplefmt.h:70
#define NULL
Definition: coverity.c:32
int ff_set_common_channel_layouts(AVFilterContext *ctx, AVFilterChannelLayouts *layouts)
A helper for query_formats() which sets all links to the same list of channel layouts/sample rates...
Definition: formats.c:523
#define A
Definition: af_volume.c:62
This structure describes decoded (raw) audio or video data.
Definition: frame.h:171
AVOption.
Definition: opt.h:255
Definition: aeval.c:48
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:248
Main libavfilter public API header.
const char * g
Definition: vf_curves.c:108
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_volume.c:122
static const char *const var_names[]
Definition: af_volume.c:45
static av_cold void volume_init(VolumeContext *vol)
Definition: af_volume.c:224
double, planar
Definition: samplefmt.h:71
static av_cold int init(AVFilterContext *ctx)
Definition: af_volume.c:111
static int set_volume(AVFilterContext *ctx)
Definition: af_volume.c:256
static enum AVSampleFormat formats[]
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
Definition: eval.c:652
double var_values[VAR_VARS_NB]
Definition: af_volume.h:75
#define TS2T(ts, tb)
Definition: af_volume.c:338
uint32_t track_peak
Peak track amplitude, with 100000 representing full scale (but values may overflow).
Definition: replaygain.h:40
#define FFALIGN(x, a)
Definition: common.h:71
AVFilter ff_af_volume
Definition: af_volume.c:480
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
Definition: frame.c:620
const char * volume_expr
Definition: af_volume.h:73
#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:451
double replaygain_preamp
Definition: af_volume.h:78
const char * name
Pad name.
Definition: internal.h:67
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:641
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1145
if()
Definition: avfilter.c:975
uint8_t
#define av_cold
Definition: attributes.h:74
AV_SAMPLE_FMT_U8
AVOptions.
static av_always_inline av_const int isnan(float x)
Definition: libm.h:96
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:67
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:257
Definition: eval.c:143
Structure to hold side data for an AVFrame.
Definition: frame.h:134
static double av_q2d(AVRational a)
Convert rational to double.
Definition: rational.h:80
int samples_align
Definition: af_volume.h:88
void(* scale_samples)(uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
Definition: af_volume.h:86
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:192
signed 32 bits
Definition: samplefmt.h:63
int32_t album_gain
Same as track_gain, but for the whole album.
Definition: replaygain.h:44
#define av_log(a,...)
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
Definition: samplefmt.c:110
static void scale_samples_s32(uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
Definition: af_volume.c:214
A filter pad used for either input or output.
Definition: internal.h:61
audio volume filter
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:542
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
Definition: audio.c:70
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:148
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:175
void * priv
private data for use by the filter
Definition: avfilter.h:654
AVFILTER_DEFINE_CLASS(volume)
void(* vector_dmul_scalar)(double *dst, const double *src, double mul, int len)
Multiply a vector of double by a scalar double.
Definition: float_dsp.h:84
static int query_formats(AVFilterContext *ctx)
Definition: af_volume.c:130
#define F
Definition: af_volume.c:63
static void scale_samples_s16(uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
Definition: af_volume.c:194
audio channel layout utility functions
#define FFMIN(a, b)
Definition: common.h:66
signed 32 bits, planar
Definition: samplefmt.h:69
ret
Definition: avfilter.c:974
static void scale_samples_u8_small(uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
Definition: af_volume.c:186
int replaygain_noclip
Definition: af_volume.h:79
int32_t
Definition: aeval.c:51
void(* vector_fmul_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float.
Definition: float_dsp.h:69
unsigned 8 bits, planar
Definition: samplefmt.h:67
static const AVFilterPad avfilter_af_volume_outputs[]
Definition: af_volume.c:471
static void scale_samples_u8(uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
Definition: af_volume.c:178
#define TS2D(ts)
Definition: af_volume.c:337
static const char *const precision_str[]
Definition: af_volume.c:41
A list of supported channel layouts.
Definition: formats.h:85
double volume
Definition: af_volume.h:80
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
Definition: frame.h:232
enum AVSampleFormat sample_fmt
Definition: af_volume.h:84
AVFloatDSPContext * fdsp
Definition: af_volume.h:70
AVS_Value src
Definition: avisynth_c.h:482
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:59
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
Definition: eval.c:312
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:488
uint8_t * data
Definition: frame.h:136
void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type)
If side data of the supplied type exists in the frame, free it and remove it from the frame...
Definition: frame.c:691
void * buf
Definition: avisynth_c.h:553
Filter definition.
Definition: avfilter.h:470
static const AVFilterPad inputs[]
Definition: af_ashowinfo.c:239
AVExpr * volume_pexpr
Definition: af_volume.h:74
const char * name
Filter name.
Definition: avfilter.h:474
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
Definition: float_dsp.c:143
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
Definition: af_volume.c:320
static const AVOption volume_options[]
Definition: af_volume.c:65
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:648
enum MovChannelLayoutTag * layouts
Definition: mov_chan.c:434
AVFilterFormats * ff_all_samplerates(void)
Definition: formats.c:379
static void scale_samples_s16_small(uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
Definition: af_volume.c:204
static int flags
Definition: cpu.c:47
#define M_LN10
Definition: mathematics.h:37
void av_opt_free(void *obj)
Free all allocated objects in obj.
Definition: opt.c:1435
void ff_volume_init_x86(VolumeContext *vol)
static const AVFilterPad avfilter_af_volume_inputs[]
Definition: af_volume.c:462
common internal and external API header
enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt)
Get the packed alternative form of the given sample format.
Definition: samplefmt.c:73
signed 16 bits
Definition: samplefmt.h:62
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
Definition: af_volume.c:340
static int set_expr(AVExpr **pexpr, const char *expr, void *log_ctx)
Definition: af_volume.c:91
uint32_t album_peak
Same as track_peak, but for the whole album,.
Definition: replaygain.h:48
#define NAN
Definition: math.h:28
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
Definition: eval.c:707
int64_t av_frame_get_pkt_pos(const AVFrame *frame)
#define OFFSET(x)
Definition: af_volume.c:61
A list of supported formats for one end of a filter link.
Definition: formats.h:64
An instance of a filter.
Definition: avfilter.h:633
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:701
#define av_freep(p)
signed 16 bits, planar
Definition: samplefmt.h:68
int32_t track_gain
Track replay gain in microbels (divide by 100000 to get the value in dB).
Definition: replaygain.h:35
ReplayGain information in the form of the AVReplayGain struct.
Definition: frame.h:76
internal API functions
AVFilterChannelLayouts * ff_all_channel_counts(void)
Construct an AVFilterChannelLayouts coding for any channel layout, with known or unknown disposition...
Definition: formats.c:394
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:215
ReplayGain information (see http://wiki.hydrogenaudio.org/index.php?title=ReplayGain_1.0_specification).
Definition: replaygain.h:30
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:225
int ff_set_common_samplerates(AVFilterContext *ctx, AVFilterFormats *samplerates)
Definition: formats.c:530
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:548
simple arithmetic expression evaluator
static int config_output(AVFilterLink *outlink)
Definition: af_volume.c:288