39 "fixed",
"float",
"double"
42 #define OFFSET(x) offsetof(VolumeContext, x)
43 #define A AV_OPT_FLAG_AUDIO_PARAM
46 {
"volume",
"Volume adjustment.",
48 {
"precision",
"Mathematical precision.",
130 int nb_samples,
int volume)
133 for (i = 0; i < nb_samples; i++)
134 dst[i] = av_clip_uint8(((((int64_t)src[i] - 128) * volume + 128) >> 8) + 128);
138 int nb_samples,
int volume)
141 for (i = 0; i < nb_samples; i++)
142 dst[i] = av_clip_uint8((((src[i] - 128) * volume + 128) >> 8) + 128);
146 int nb_samples,
int volume)
149 int16_t *smp_dst = (int16_t *)dst;
150 const int16_t *smp_src = (
const int16_t *)src;
151 for (i = 0; i < nb_samples; i++)
152 smp_dst[i] = av_clip_int16(((int64_t)smp_src[i] * volume + 128) >> 8);
156 int nb_samples,
int volume)
159 int16_t *smp_dst = (int16_t *)dst;
160 const int16_t *smp_src = (
const int16_t *)src;
161 for (i = 0; i < nb_samples; i++)
162 smp_dst[i] = av_clip_int16((smp_src[i] * volume + 128) >> 8);
166 int nb_samples,
int volume)
171 for (i = 0; i < nb_samples; i++)
172 smp_dst[i] = av_clipl_int32((((int64_t)smp_src[i] * volume + 128) >> 8));
253 int p, plane_samples;
261 for (p = 0; p < vol->
planes; p++) {
267 for (p = 0; p < vol->
planes; p++) {
270 vol->
volume, plane_samples);
273 for (p = 0; p < vol->
planes; p++) {
276 vol->
volume, plane_samples);
312 .priv_class = &volume_class,
314 .
inputs = avfilter_af_volume_inputs,
315 .
outputs = avfilter_af_volume_outputs,
This structure describes decoded (raw) audio or video data.
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[]
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[]
static const AVClass volume_class
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)
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)
enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt)
Get the packed alternative form of the given sample format.
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
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
enum AVSampleFormat sample_fmt
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Describe the class of an AVClass context structure.
static const AVFilterPad inputs[]
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
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
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
AVSampleFormat
Audio Sample Formats.
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
AVFilterContext * dst
dest filter
uint8_t ** extended_data
pointers to the data planes/channels.
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)