42 "fixed",
"float",
"double"
48 "nb_consumed_samples",
61 #define OFFSET(x) offsetof(VolumeContext, x)
62 #define A AV_OPT_FLAG_AUDIO_PARAM
63 #define F AV_OPT_FLAG_FILTERING_PARAM
66 {
"volume",
"set volume adjustment expression",
68 {
"precision",
"select mathematical precision",
76 {
"replaygain",
"Apply replaygain side data when present",
82 {
"replaygain_preamp",
"Apply replaygain pre-amplification",
84 {
"replaygain_noclip",
"Apply replaygain clipping prevention",
99 NULL, NULL, NULL, NULL, 0, log_ctx);
102 "Error when evaluating the volume expression '%s'\n", expr);
170 int nb_samples,
int volume)
173 for (i = 0; i < nb_samples; i++)
174 dst[i] = av_clip_uint8(((((int64_t)src[i] - 128) * volume + 128) >> 8) + 128);
178 int nb_samples,
int volume)
181 for (i = 0; i < nb_samples; i++)
182 dst[i] = av_clip_uint8((((src[i] - 128) * volume + 128) >> 8) + 128);
186 int nb_samples,
int volume)
189 int16_t *smp_dst = (int16_t *)dst;
190 const int16_t *smp_src = (
const int16_t *)src;
191 for (i = 0; i < nb_samples; i++)
192 smp_dst[i] = av_clip_int16(((int64_t)smp_src[i] * volume + 128) >> 8);
196 int nb_samples,
int volume)
199 int16_t *smp_dst = (int16_t *)dst;
200 const int16_t *smp_src = (
const int16_t *)src;
201 for (i = 0; i < nb_samples; i++)
202 smp_dst[i] = av_clip_int16((smp_src[i] * volume + 128) >> 8);
206 int nb_samples,
int volume)
211 for (i = 0; i < nb_samples; i++)
212 smp_dst[i] = av_clipl_int32((((int64_t)smp_src[i] * volume + 128) >> 8));
314 char *res,
int res_len,
int flags)
319 if (!strcmp(cmd,
"volume")) {
329 #define D2TS(d) (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d))
330 #define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
331 #define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)*av_q2d(tb))
348 uint32_t peak = 100000;
357 }
else if (replaygain->
album_gain != INT32_MIN) {
364 "values are unknown.\n");
366 g = gain / 100000.0f;
367 p = peak / 100000.0f;
370 "Using gain %f dB from replaygain side data.\n", g);
416 int p, plane_samples;
424 for (p = 0; p < vol->
planes; p++) {
430 for (p = 0; p < vol->
planes; p++) {
433 vol->
volume, plane_samples);
436 for (p = 0; p < vol->
planes; p++) {
439 vol->
volume, plane_samples);
477 .priv_class = &volume_class,
480 .
inputs = avfilter_af_volume_inputs,
481 .
outputs = avfilter_af_volume_outputs,