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);
176 int nb_samples,
int volume)
179 for (i = 0; i < nb_samples; i++)
180 dst[i] = av_clip_uint8(((((int64_t)src[i] - 128) * volume + 128) >> 8) + 128);
184 int nb_samples,
int volume)
187 for (i = 0; i < nb_samples; i++)
188 dst[i] = av_clip_uint8((((src[i] - 128) * volume + 128) >> 8) + 128);
192 int nb_samples,
int volume)
195 int16_t *smp_dst = (int16_t *)dst;
196 const int16_t *smp_src = (
const int16_t *)src;
197 for (i = 0; i < nb_samples; i++)
198 smp_dst[i] = av_clip_int16(((int64_t)smp_src[i] * volume + 128) >> 8);
202 int nb_samples,
int volume)
205 int16_t *smp_dst = (int16_t *)dst;
206 const int16_t *smp_src = (
const int16_t *)src;
207 for (i = 0; i < nb_samples; i++)
208 smp_dst[i] = av_clip_int16((smp_src[i] * volume + 128) >> 8);
212 int nb_samples,
int volume)
217 for (i = 0; i < nb_samples; i++)
218 smp_dst[i] = av_clipl_int32((((int64_t)smp_src[i] * volume + 128) >> 8));
318 char *res,
int res_len,
int flags)
323 if (!strcmp(cmd,
"volume")) {
333 #define D2TS(d) (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d))
334 #define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
335 #define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)*av_q2d(tb))
352 uint32_t peak = 100000;
361 }
else if (replaygain->
album_gain != INT32_MIN) {
368 "values are unknown.\n");
370 g = gain / 100000.0f;
371 p = peak / 100000.0f;
374 "Using gain %f dB from replaygain side data.\n", g);
420 int p, plane_samples;
428 for (p = 0; p < vol->
planes; p++) {
434 for (p = 0; p < vol->
planes; p++) {
437 vol->
volume, plane_samples);
440 for (p = 0; p < vol->
planes; p++) {
443 vol->
volume, plane_samples);
481 .priv_class = &volume_class,
484 .
inputs = avfilter_af_volume_inputs,
485 .
outputs = avfilter_af_volume_outputs,