Go to the documentation of this file.
43 "fixed",
"float",
"double"
49 "nb_consumed_samples",
62 #define OFFSET(x) offsetof(VolumeContext, x)
63 #define A AV_OPT_FLAG_AUDIO_PARAM
64 #define F AV_OPT_FLAG_FILTERING_PARAM
67 {
"volume",
"set volume adjustment expression",
69 {
"precision",
"select mathematical precision",
77 {
"replaygain",
"Apply replaygain side data when present",
83 {
"replaygain_preamp",
"Apply replaygain pre-amplification",
85 {
"replaygain_noclip",
"Apply replaygain clipping prevention",
103 "Error when evaluating the volume expression '%s'\n", expr);
180 int nb_samples,
int volume)
183 for (
i = 0;
i < nb_samples;
i++)
184 dst[
i] = av_clip_uint8(((((int64_t)
src[
i] - 128) * volume + 128) >> 8) + 128);
188 int nb_samples,
int volume)
191 for (
i = 0;
i < nb_samples;
i++)
192 dst[
i] = av_clip_uint8((((
src[
i] - 128) * volume + 128) >> 8) + 128);
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(((int64_t)smp_src[
i] * volume + 128) >> 8);
206 int nb_samples,
int volume)
209 int16_t *smp_dst = (int16_t *)dst;
210 const int16_t *smp_src = (
const int16_t *)
src;
211 for (
i = 0;
i < nb_samples;
i++)
212 smp_dst[
i] = av_clip_int16((smp_src[
i] * volume + 128) >> 8);
216 int nb_samples,
int volume)
221 for (
i = 0;
i < nb_samples;
i++)
222 smp_dst[
i] = av_clipl_int32((((int64_t)smp_src[
i] * volume + 128) >> 8));
322 char *res,
int res_len,
int flags)
327 if (!strcmp(cmd,
"volume")) {
337 #define D2TS(d) (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d))
338 #define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts))
339 #define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)*av_q2d(tb))
346 int nb_samples =
buf->nb_samples;
356 uint32_t peak = 100000;
365 }
else if (replaygain->
album_gain != INT32_MIN) {
372 "values are unknown.\n");
374 g = gain / 100000.0f;
375 p = peak / 100000.0f;
378 "Using gain %f dB from replaygain side data.\n",
g);
427 int p, plane_samples;
435 for (p = 0; p < vol->
planes; p++) {
437 buf->extended_data[p], plane_samples,
441 for (p = 0; p < vol->
planes; p++) {
443 (
const float *)
buf->extended_data[p],
444 vol->
volume, plane_samples);
447 for (p = 0; p < vol->
planes; p++) {
449 (
const double *)
buf->extended_data[p],
450 vol->
volume, plane_samples);
488 .priv_class = &volume_class,
static av_cold int init(AVFilterContext *ctx)
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
@ AV_SAMPLE_FMT_FLTP
float, planar
A list of supported channel layouts.
#define AV_LOG_WARNING
Something somehow does not look correct.
static av_always_inline double ff_exp10(double x)
Compute 10^x for floating point values.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static enum AVSampleFormat sample_fmts[]
enum MovChannelLayoutTag * layouts
static const char *const var_names[]
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
@ VAR_NB_CONSUMED_SAMPLES
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static av_cold int end(AVCodecContext *avctx)
This structure describes decoded (raw) audio or video data.
int32_t album_gain
Same as track_gain, but for the whole album.
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
#define AV_LOG_VERBOSE
Detailed information.
const char * name
Filter name.
A link between two filters.
static av_cold void uninit(AVFilterContext *ctx)
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.
static av_cold void volume_init(VolumeContext *vol)
static void scale_samples_s32(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 int config_output(AVFilterLink *outlink)
AVFILTER_DEFINE_CLASS(volume)
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
A filter pad used for either input or output.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int query_formats(AVFilterContext *ctx)
static double av_q2d(AVRational a)
Convert an AVRational to a double.
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
static const AVFilterPad outputs[]
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
static int set_volume(AVFilterContext *ctx)
uint32_t track_peak
Peak track amplitude, with 100000 representing full scale (but values may overflow).
static void scale_samples_u8_small(uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
static void scale_samples_u8(uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
void(* vector_fmul_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float.
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
void av_opt_free(void *obj)
Free all allocated objects in obj.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
double var_values[VAR_VARS_NB]
@ AV_FRAME_DATA_REPLAYGAIN
ReplayGain information in the form of the AVReplayGain struct.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
@ AV_SAMPLE_FMT_U8P
unsigned 8 bits, planar
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
static void scale_samples_s16_small(uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
int32_t track_gain
Track replay gain in microbels (divide by 100000 to get the value in dB).
AVFilterContext * src
source filter
static const char *const precision_str[]
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.
void(* scale_samples)(uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
int nb_samples
number of audio samples (per channel) described by this frame
static const AVFilterPad avfilter_af_volume_outputs[]
#define i(width, name, range_min, range_max)
static int set_expr(AVExpr **pexpr, const char *expr, void *log_ctx)
uint8_t ** extended_data
pointers to the data planes/channels.
AVSampleFormat
Audio sample formats.
const char AVS_Value args
@ AV_SAMPLE_FMT_S16
signed 16 bits
const char * name
Pad name.
static const AVOption volume_options[]
void(* vector_dmul_scalar)(double *dst, const double *src, double mul, int len)
Multiply a vector of double by a scalar double.
void ff_volume_init_x86(VolumeContext *vol)
uint32_t album_peak
Same as track_peak, but for the whole album,.
enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt)
Get the packed alternative form of the given sample format.
@ AV_SAMPLE_FMT_DBLP
double, planar
ReplayGain information (see http://wiki.hydrogenaudio.org/index.php?title=ReplayGain_1....
enum AVSampleFormat sample_fmt
Structure to hold side data for an AVFrame.
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
#define flags(name, subs,...)
static const AVFilterPad avfilter_af_volume_inputs[]
@ AV_SAMPLE_FMT_DBL
double
@ AV_SAMPLE_FMT_S32
signed 32 bits