27 #include "libavutil/channel_layout.h"
28 #include "libavutil/common.h"
29 #include "libavutil/eval.h"
31 #include "libavutil/opt.h"
39 "fixed",
"float",
"double"
42 #define OFFSET(x) offsetof(VolumeContext, x)
43 #define A AV_OPT_FLAG_AUDIO_PARAM
44 #define F AV_OPT_FLAG_FILTERING_PARAM
47 {
"volume",
"set volume adjustment",
49 {
"precision",
"select mathematical precision",
123 int nb_samples,
int volume)
126 for (i = 0; i < nb_samples; i++)
127 dst[i] = av_clip_uint8(((((int64_t)src[i] - 128) * volume + 128) >> 8) + 128);
131 int nb_samples,
int volume)
134 for (i = 0; i < nb_samples; i++)
135 dst[i] = av_clip_uint8((((src[i] - 128) * volume + 128) >> 8) + 128);
139 int nb_samples,
int volume)
142 int16_t *smp_dst = (int16_t *)dst;
143 const int16_t *smp_src = (
const int16_t *)src;
144 for (i = 0; i < nb_samples; i++)
145 smp_dst[i] = av_clip_int16(((int64_t)smp_src[i] * volume + 128) >> 8);
149 int nb_samples,
int volume)
152 int16_t *smp_dst = (int16_t *)dst;
153 const int16_t *smp_src = (
const int16_t *)src;
154 for (i = 0; i < nb_samples; i++)
155 smp_dst[i] = av_clip_int16((smp_src[i] * volume + 128) >> 8);
159 int nb_samples,
int volume)
164 for (i = 0; i < nb_samples; i++)
165 smp_dst[i] = av_clipl_int32((((int64_t)smp_src[i] * volume + 128) >> 8));
238 int p, plane_samples;
246 for (p = 0; p < vol->
planes; p++) {
252 for (p = 0; p < vol->
planes; p++) {
255 vol->
volume, plane_samples);
258 for (p = 0; p < vol->
planes; p++) {
261 vol->
volume, plane_samples);
295 .priv_class = &volume_class,
297 .
inputs = avfilter_af_volume_inputs,
298 .
outputs = avfilter_af_volume_outputs,
This structure describes decoded (raw) audio or video data.
const char * name
Filter name.
void * priv
private data for use by the filter
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[]
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
#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.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
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)
#define AV_LOG_VERBOSE
Detailed information.
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.
#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
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
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)
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[]
static void scale_samples_u8(uint8_t *dst, const uint8_t *src, int nb_samples, int volume)
int format
agreed upon media format
A list of supported channel layouts.
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.
enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt)
Get the packed alternative form of the given sample format.
static const AVFilterPad inputs[]
AVFilterLink ** inputs
array of pointers to input links
AVFilterContext * dst
dest filter
static const AVOption volume_options[]
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[]
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
#define AVFILTER_DEFINE_CLASS(fname)
static enum AVSampleFormat sample_fmts[]
int nb_samples
number of audio samples (per channel) described by this frame
AVFilter avfilter_af_volume
static int config_output(AVFilterLink *outlink)