42 int nb_planes = nb_channels;
47 nb_samples *= nb_channels;
50 for (plane = 0; plane < nb_planes; plane++) {
52 for (
i = 0;
i < nb_samples;
i++)
61static inline double logdb(uint64_t v)
63 double d = v / (
double)(0x8000 * 0x8000);
66 return -log10(d) * 10;
73 uint64_t nb_samples = 0,
power = 0, nb_samples_shift = 0, sum = 0;
74 uint64_t histdb[
MAX_DB + 1] = { 0 };
76 for (
i = 0;
i < 0x10000;
i++)
87 for (
i = 0;
i < 0x10000;
i++) {
91 if (!nb_samples_shift)
93 power = (
power + nb_samples_shift / 2) / nb_samples_shift;
98 while (max_volume > 0 && !vd->
histogram[0x8000 + max_volume] &&
103 for (
i = 0;
i < 0x10000;
i++)
106 for (;
i <=
MAX_DB && sum < nb_samples / 1000;
i++) {
126 .p.name =
"volumedetect",
static const AVFilterPad volumedetect_inputs[]
const FFFilter ff_af_volumedetect
static double logdb(uint64_t v)
static av_cold void uninit(AVFilterContext *ctx)
static int filter_frame(AVFilterLink *inlink, AVFrame *samples)
static AVFormatContext * ctx
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
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.
#define i(width, name, range_min, range_max)
Public libavutil channel layout APIs header.
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
#define AVFILTER_FLAG_METADATA_ONLY
The filter is a "metadata" filter - it does not modify the frame data in any way.
#define AV_LOG_INFO
Standard information.
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
@ AV_SAMPLE_FMT_S16
signed 16 bits
static av_cold void uninit(AVBitStreamFilterContext *ctx)
static int shift(int a, int b)
#define FILTER_INPUTS(array)
#define FILTER_OUTPUTS(array)
#define FILTER_SAMPLEFMTS(...)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static float power(float r, float g, float b, float max)
int nb_channels
Number of channels in this layout.
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.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
AVChannelLayout ch_layout
Channel layout of the audio data.
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.