74 for (plane = 0; plane < nb_planes; plane++) {
76 for (
i = 0;
i < nb_samples;
i++)
85 static inline double logdb(uint64_t v)
87 double d = v / (double)(0x8000 * 0x8000);
90 return -log10(d) * 10;
97 uint64_t nb_samples = 0, power = 0, nb_samples_shift = 0, sum = 0;
98 uint64_t histdb[
MAX_DB + 1] = { 0 };
100 for (
i = 0;
i < 0x10000;
i++)
111 for (
i = 0;
i < 0x10000;
i++) {
115 if (!nb_samples_shift)
117 power = (power + nb_samples_shift / 2) / nb_samples_shift;
122 while (max_volume > 0 && !vd->
histogram[0x8000 + max_volume] &&
127 for (
i = 0;
i < 0x10000;
i++)
130 for (;
i <=
MAX_DB && sum < nb_samples / 1000;
i++) {
159 .
name =
"volumedetect",
static enum AVSampleFormat sample_fmts[]
static const AVFilterPad inputs[]
static const AVFilterPad outputs[]
static const AVFilterPad volumedetect_inputs[]
static int query_formats(AVFilterContext *ctx)
static void print_stats(AVFilterContext *ctx)
static double logdb(uint64_t v)
static av_cold void uninit(AVFilterContext *ctx)
static const AVFilterPad volumedetect_outputs[]
AVFilter ff_af_volumedetect
static int filter_frame(AVFilterLink *inlink, AVFrame *samples)
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Main libavfilter public API header.
audio channel layout utility functions
#define AV_LOG_INFO
Standard information.
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
@ AV_SAMPLE_FMT_S16
signed 16 bits
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
enum MovChannelLayoutTag * layouts
static int shift(int a, int b)
A list of supported channel layouts.
AVFilterLink ** outputs
array of pointers to output links
A link between two filters.
AVFilterContext * dst
dest filter
A filter pad used for either input or output.
const char * name
Pad name.
const char * name
Filter name.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
int channels
number of audio channels, only used for audio.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
uint8_t ** extended_data
pointers to the data planes/channels.
uint64_t histogram[0x10001]
Number of samples at each PCM value.