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",
102 "Error when evaluating the volume expression '%s'\n", expr);
179 int nb_samples,
int volume)
182 for (i = 0; i < nb_samples; i++)
183 dst[i] = av_clip_uint8(((((int64_t)src[i] - 128) * volume + 128) >> 8) + 128);
187 int nb_samples,
int volume)
190 for (i = 0; i < nb_samples; i++)
191 dst[i] = av_clip_uint8((((src[i] - 128) * volume + 128) >> 8) + 128);
195 int nb_samples,
int volume)
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);
205 int nb_samples,
int volume)
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);
215 int nb_samples,
int volume)
220 for (i = 0; i < nb_samples; i++)
221 smp_dst[i] = av_clipl_int32((((int64_t)smp_src[i] * volume + 128) >> 8));
321 char *res,
int res_len,
int flags)
326 if (!strcmp(cmd,
"volume")) {
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))
355 uint32_t peak = 100000;
364 }
else if (replaygain->
album_gain != INT32_MIN) {
371 "values are unknown.\n");
373 g = gain / 100000.0f;
374 p = peak / 100000.0f;
377 "Using gain %f dB from replaygain side data.\n", g);
424 int p, plane_samples;
432 for (p = 0; p < vol->
planes; p++) {
438 for (p = 0; p < vol->
planes; p++) {
441 vol->
volume, plane_samples);
444 for (p = 0; p < vol->
planes; p++) {
447 vol->
volume, plane_samples);
485 .priv_class = &volume_class,
488 .
inputs = avfilter_af_volume_inputs,
489 .
outputs = avfilter_af_volume_outputs,
This structure describes decoded (raw) audio or video data.
#define AV_LOG_WARNING
Something somehow does not look correct.
static const AVFilterPad outputs[]
Main libavfilter public API header.
static av_cold void uninit(AVFilterContext *ctx)
static const char *const var_names[]
static av_cold void volume_init(VolumeContext *vol)
static av_cold int init(AVFilterContext *ctx)
static int set_volume(AVFilterContext *ctx)
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.
double var_values[VAR_VARS_NB]
uint32_t track_peak
Peak track amplitude, with 100000 representing full scale (but values may overflow).
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static av_always_inline av_const int isnan(float x)
static av_cold int end(AVCodecContext *avctx)
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Structure to hold side data for an AVFrame.
static double av_q2d(AVRational a)
Convert rational to double.
void(* scale_samples)(uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
#define AV_LOG_VERBOSE
Detailed information.
int32_t album_gain
Same as track_gain, but for the whole album.
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
static void scale_samples_s32(uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
A filter pad used for either input or output.
A link between two filters.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int sample_rate
samples per second
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
AVFILTER_DEFINE_CLASS(volume)
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
void(* vector_dmul_scalar)(double *dst, const double *src, double mul, int len)
Multiply a vector of double by a scalar double.
static int query_formats(AVFilterContext *ctx)
static void scale_samples_s16(uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
audio channel layout utility functions
static void scale_samples_u8_small(uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
void(* vector_fmul_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float.
static const AVFilterPad avfilter_af_volume_outputs[]
AVFilterContext * src
source filter
static void scale_samples_u8(uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
int format
agreed upon media format
static const char *const precision_str[]
A list of supported channel layouts.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
enum AVSampleFormat sample_fmt
AVSampleFormat
Audio sample formats.
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
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...
static const AVFilterPad inputs[]
const char * name
Filter name.
av_cold AVFloatDSPContext * avpriv_float_dsp_alloc(int bit_exact)
Allocate a float DSP context.
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static const AVOption volume_options[]
AVFilterLink ** outputs
array of pointers to output links
enum MovChannelLayoutTag * layouts
static void scale_samples_s16_small(uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
void av_opt_free(void *obj)
Free all allocated objects in obj.
void ff_volume_init_x86(VolumeContext *vol)
static const AVFilterPad avfilter_af_volume_inputs[]
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.
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
int channels
Number of channels.
static int set_expr(AVExpr **pexpr, const char *expr, void *log_ctx)
uint32_t album_peak
Same as track_peak, but for the whole album,.
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
AVFilterContext * dst
dest filter
int64_t av_frame_get_pkt_pos(const AVFrame *frame)
static enum AVSampleFormat sample_fmts[]
int32_t track_gain
Track replay gain in microbels (divide by 100000 to get the value in dB).
ReplayGain information in the form of the AVReplayGain struct.
uint8_t ** extended_data
pointers to the data planes/channels.
ReplayGain information (see http://wiki.hydrogenaudio.org/index.php?title=ReplayGain_1.0_specification).
int nb_samples
number of audio samples (per channel) described by this frame
int64_t frame_count
Number of past frames sent through the link.
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
simple arithmetic expression evaluator
static int config_output(AVFilterLink *outlink)