42 "fixed",
"float",
"double"
45 #define OFFSET(x) offsetof(VolumeContext, x)
46 #define A AV_OPT_FLAG_AUDIO_PARAM
49 {
"volume",
"Volume adjustment.",
51 {
"precision",
"Mathematical precision.",
56 {
"replaygain",
"Apply replaygain side data when present",
62 {
"replaygain_preamp",
"Apply replaygain pre-amplification",
64 {
"replaygain_noclip",
"Apply replaygain clipping prevention",
143 int nb_samples,
int volume)
146 for (i = 0; i < nb_samples; i++)
147 dst[i] = av_clip_uint8(((((int64_t)src[i] - 128) * volume + 128) >> 8) + 128);
151 int nb_samples,
int volume)
154 for (i = 0; i < nb_samples; i++)
155 dst[i] = av_clip_uint8((((src[i] - 128) * volume + 128) >> 8) + 128);
159 int nb_samples,
int volume)
162 int16_t *smp_dst = (int16_t *)dst;
163 const int16_t *smp_src = (
const int16_t *)src;
164 for (i = 0; i < nb_samples; i++)
165 smp_dst[i] = av_clip_int16(((int64_t)smp_src[i] * volume + 128) >> 8);
169 int nb_samples,
int volume)
172 int16_t *smp_dst = (int16_t *)dst;
173 const int16_t *smp_src = (
const int16_t *)src;
174 for (i = 0; i < nb_samples; i++)
175 smp_dst[i] = av_clip_int16((smp_src[i] * volume + 128) >> 8);
179 int nb_samples,
int volume)
184 for (i = 0; i < nb_samples; i++)
185 smp_dst[i] = av_clipl_int32((((int64_t)smp_src[i] * volume + 128) >> 8));
252 uint32_t peak = 100000;
261 }
else if (replaygain->
album_gain != INT32_MIN) {
268 "values are unknown.\n");
270 g = gain / 100000.0f;
271 p = peak / 100000.0f;
274 "Using gain %f dB from replaygain side data.\n", g);
305 int p, plane_samples;
313 for (p = 0; p < vol->
planes; p++) {
319 for (p = 0; p < vol->
planes; p++) {
322 vol->
volume, plane_samples);
325 for (p = 0; p < vol->
planes; p++) {
328 vol->
volume, plane_samples);
364 .priv_class = &volume_class,
366 .
inputs = avfilter_af_volume_inputs,
367 .
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.
enum PrecisionType precision
static av_cold void volume_init(VolumeContext *vol)
static av_cold int init(AVFilterContext *ctx)
static enum AVSampleFormat formats[]
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)
const char * name
Pad name.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
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.
void(* scale_samples)(uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
#define AV_LOG_VERBOSE
Detailed information.
static const AVOption options[]
int32_t album_gain
Same as track_gain, but for the whole album.
static const AVClass volume_class
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.
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
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
void av_log(void *avcl, int level, const char *fmt,...)
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)
enum ReplayGainType replaygain
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
if(ac->has_optimized_func)
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.
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...
Describe the class of an AVClass context structure.
static const AVFilterPad inputs[]
const char * name
Filter name.
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)
static const char * precision_str[]
av_cold void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact)
Initialize a float DSP context.
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)
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
uint32_t album_peak
Same as track_peak, but for the whole album,.
AVFilterContext * dst
dest filter
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
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)