55 #define OFFSET(x) offsetof(AudioStatsContext, x)
56 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
130 unsigned result = 64;
132 for (; result && !(mask & 1); --result, mask >>= 1);
144 }
else if (d == p->
min) {
147 }
else if (p->
last == p->
min) {
156 }
else if (d == p->
max) {
159 }
else if (p->
last == p->
max) {
180 const char *
fmt,
double val)
185 snprintf(value,
sizeof(value), fmt, val);
187 snprintf(key2,
sizeof(key2),
"lavfi.astats.%d.%s", chan, key);
189 snprintf(key2,
sizeof(key2),
"lavfi.astats.%s", key);
193 #define LINEAR_TO_DB(x) (log10(x) * 20)
197 uint64_t
mask = 0, min_count = 0, max_count = 0, nb_samples = 0;
198 double min_runs = 0, max_runs = 0,
199 min = DBL_MAX, max = DBL_MIN, min_diff = DBL_MAX, max_diff = 0,
204 min_sigma_x2 = DBL_MAX,
205 max_sigma_x2 = DBL_MIN;
229 if (fabs(p->
sigma_x) > fabs(max_sigma_x))
233 set_meta(metadata, c + 1,
"Min_level",
"%f", p->
min);
234 set_meta(metadata, c + 1,
"Max_level",
"%f", p->
max);
248 set_meta(metadata, 0,
"Overall.DC_offset",
"%f", max_sigma_x / (nb_samples / s->
nb_channels));
249 set_meta(metadata, 0,
"Overall.Min_level",
"%f",
min);
250 set_meta(metadata, 0,
"Overall.Max_level",
"%f", max);
251 set_meta(metadata, 0,
"Overall.Min_difference",
"%f", min_diff);
252 set_meta(metadata, 0,
"Overall.Max_difference",
"%f", max_diff);
253 set_meta(metadata, 0,
"Overall.Mean_difference",
"%f", diff1_sum / (nb_samples - s->
nb_channels));
258 set_meta(metadata, 0,
"Overall.Flat_factor",
"%f",
LINEAR_TO_DB((min_runs + max_runs) / (min_count + max_count)));
259 set_meta(metadata, 0,
"Overall.Peak_count",
"%f", (
float)(min_count + max_count) / (
double)s->
nb_channels);
274 for (c = 0; c < channels; c++) {
286 for (c = 0; c < channels; c++, src++)
309 uint64_t
mask = 0, min_count = 0, max_count = 0, nb_samples = 0;
310 double min_runs = 0, max_runs = 0,
311 min = DBL_MAX, max = DBL_MIN, min_diff = DBL_MAX, max_diff = 0,
316 min_sigma_x2 = DBL_MAX,
317 max_sigma_x2 = DBL_MIN;
341 if (fabs(p->
sigma_x) > fabs(max_sigma_x))
372 if (min_sigma_x2 != 1)
412 .priv_class = &astats_class,
const char const char void * val
This structure describes decoded (raw) audio or video data.
static int query_formats(AVFilterContext *ctx)
static void update_stat(AudioStatsContext *s, ChannelStats *p, double d)
Main libavfilter public API header.
static enum AVSampleFormat formats[]
const char * name
Pad name.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
static const AVFilterPad astats_inputs[]
A filter pad used for either input or output.
A link between two filters.
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
static av_cold void uninit(AVFilterContext *ctx)
int sample_rate
samples per second
static const uint16_t mask[17]
#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
AVFILTER_DEFINE_CLASS(astats)
static void print_stats(AVFilterContext *ctx)
GLsizei GLboolean const GLfloat * value
static int config_output(AVFilterLink *outlink)
static void reset_stats(AudioStatsContext *s)
AVFilterContext * src
source filter
static const AVFilterPad outputs[]
int format
agreed upon media format
A list of supported channel layouts.
static const AVOption astats_options[]
#define AV_LOG_INFO
Standard information.
static const AVFilterPad inputs[]
AVSampleFormat
Audio sample formats.
AVDictionary ** avpriv_frame_get_metadatap(AVFrame *frame)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Describe the class of an AVClass context structure.
const char * name
Filter name.
AVFilterLink ** outputs
array of pointers to output links
enum MovChannelLayoutTag * layouts
void * av_calloc(size_t nmemb, size_t size)
Allocate a block of nmemb * size bytes with alignment suitable for all memory accesses (including vec...
static unsigned bit_depth(uint64_t mask)
static void set_meta(AVDictionary **metadata, int chan, const char *key, const char *fmt, double val)
int channels
Number of channels.
AVFilterContext * dst
dest filter
static const AVFilterPad astats_outputs[]
static enum AVSampleFormat sample_fmts[]
uint8_t ** extended_data
pointers to the data planes/channels.
int nb_samples
number of audio samples (per channel) described by this frame
static void set_metadata(AudioStatsContext *s, AVDictionary **metadata)