27 #include "libavutil/channel_layout.h"
28 #include "libavutil/common.h"
29 #include "libavutil/eval.h"
31 #include "libavutil/intreadwrite.h"
32 #include "libavutil/opt.h"
33 #include "libavutil/replaygain.h"
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,
This structure describes decoded (raw) audio or video data.
const char * name
Filter name.
void * priv
private data for use by the filter
#define AV_LOG_WARNING
Something somehow does not look correct.
static const AVFilterPad outputs[]
enum PrecisionType precision
static av_cold void volume_init(VolumeContext *vol)
uint8_t ** extended_data
pointers to the data planes/channels.
static av_cold int init(AVFilterContext *ctx)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
static enum AVSampleFormat formats[]
uint32_t track_peak
Peak track amplitude, with 100000 representing full scale (but values may overflow).
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#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 link between two filters.
void(* vector_dmul_scalar)(double *dst, const double *src, double mul, int len)
Multiply a vector of double by a scalar double.
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. ...
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
AVFilterContext * src
source filter
static int query_formats(AVFilterContext *ctx)
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
enum ReplayGainType replaygain
static void scale_samples_s16(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_outputs[]
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)
Main libavfilter public API header.
AVFilterLink ** outputs
array of pointers to output links
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[]
AVFilterLink ** inputs
array of pointers to input links
void(* vector_fmul_scalar)(float *dst, const float *src, float mul, int len)
Multiply a vector of floats by a scalar float.
AVFilterContext * dst
dest filter
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[]
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)
struct AVFilterPad AVFilterPad
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).
av_default_item_name
Return the context name.
ReplayGain information in the form of the AVReplayGain struct.
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.
void(* scale_samples)(uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
static int config_output(AVFilterLink *outlink)