43 "fixed",
"float",
"double"
49 "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
64#define T AV_OPT_FLAG_RUNTIME_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);
166 int nb_samples,
int volume)
169 for (
i = 0;
i < nb_samples;
i++)
174 int nb_samples,
int volume)
177 for (
i = 0;
i < nb_samples;
i++)
182 int nb_samples,
int volume)
185 int16_t *smp_dst = (int16_t *)
dst;
186 const int16_t *smp_src = (
const int16_t *)
src;
187 for (
i = 0;
i < nb_samples;
i++)
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++)
202 int nb_samples,
int volume)
207 for (
i = 0;
i < nb_samples;
i++)
239#if ARCH_X86 && HAVE_X86ASM
308 char *res,
int res_len,
int flags)
313 if (!strcmp(cmd,
"volume")) {
338 uint32_t peak = 100000;
347 }
else if (replaygain->
album_gain != INT32_MIN) {
354 "values are unknown.\n");
356 g = gain / 100000.0f;
357 p = peak / 100000.0f;
360 "Using gain %f dB from replaygain side data.\n",
g);
407 int p, plane_samples;
415 for (p = 0; p < vol->
planes; p++) {
421 for (p = 0; p < vol->
planes; p++) {
424 vol->
volume, plane_samples);
427 for (p = 0; p < vol->
planes; p++) {
430 vol->
volume, plane_samples);
462 .p.priv_class = &volume_class,
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
static enum AVSampleFormat sample_fmts[]
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static void scale_samples_s32(uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
static int set_volume(AVFilterContext *ctx)
static void scale_samples_s16(uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
static av_cold void volume_init(VolumeContext *vol)
const FFFilter ff_af_volume
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
static void scale_samples_s16_small(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 const AVFilterPad avfilter_af_volume_inputs[]
static const AVOption volume_options[]
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static av_cold void uninit(AVFilterContext *ctx)
static int config_output(AVFilterLink *outlink)
static void scale_samples_u8(uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
static const char *const precision_str[]
static int set_expr(AVExpr **pexpr, const char *expr, void *log_ctx)
static const AVFilterPad avfilter_af_volume_outputs[]
@ VAR_NB_CONSUMED_SAMPLES
void ff_volume_init_x86(VolumeContext *vol)
static AVFormatContext * ctx
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
common internal and external API header
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
int(* init)(AVBSFContext *ctx)
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
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.
simple arithmetic expression evaluator
internal math functions header
static av_always_inline double ff_exp10(double x)
Compute 10^x for floating point values.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_DOUBLE
Underlying C type is double.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type)
Remove and free all side data instances of the given type.
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
@ AV_FRAME_DATA_REPLAYGAIN
ReplayGain information in the form of the AVReplayGain struct.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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.
enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt)
Get the packed alternative form of the given sample format.
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_FLTP
float, planar
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
@ AV_SAMPLE_FMT_U8P
unsigned 8 bits, planar
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
@ AV_SAMPLE_FMT_S32
signed 32 bits
@ AV_SAMPLE_FMT_U8
unsigned 8 bits
@ AV_SAMPLE_FMT_DBLP
double, planar
@ AV_SAMPLE_FMT_DBL
double
@ AV_SAMPLE_FMT_S16
signed 16 bits
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int config_output(AVBitStreamFilterLink *outlink)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
static FilterLink * ff_filter_link(AVFilterLink *link)
#define AVFILTER_DEFINE_CLASS(fname)
#define FILTER_QUERY_FUNC2(func)
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Memory handling functions.
static const char *const var_names[]
int nb_channels
Number of channels in this layout.
void * priv
private data for use by the filter
AVFilterLink ** outputs
array of pointers to output links
A link between two filters.
AVFilterContext * src
source filter
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
int sample_rate
samples per second
AVChannelLayout ch_layout
channel layout of current buffer (see libavutil/channel_layout.h)
AVFilterContext * dst
dest filter
int format
agreed upon media format
A filter pad used for either input or output.
void(* vector_dmul_scalar)(double *dst, const double *src, double mul, int len)
Multiply a vector of double by a scalar double.
void(* vector_fmul_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float.
Structure to hold side data for an AVFrame.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
uint8_t ** extended_data
pointers to the data planes/channels.
ReplayGain information (see http://wiki.hydrogenaudio.org/index.php?title=ReplayGain_1....
uint32_t track_peak
Peak track amplitude, with 100000 representing full scale (but values may overflow).
uint32_t album_peak
Same as track_peak, but for the whole album,.
int32_t track_gain
Track replay gain in microbels (divide by 100000 to get the value in dB).
int32_t album_gain
Same as track_gain, but for the whole album.
Link properties exposed to filter code, but not external callers.
enum AVSampleFormat sample_fmt
double var_values[VAR_VARS_NB]
void(* scale_samples)(uint8_t *dst, const uint8_t *src, int nb_samples, int volume)