Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2017-07-19 21:44:14 +0300
committerPaul B Mahol <onemda@gmail.com>2017-07-19 22:07:45 +0300
commit12791ec5b0d3653ad2a453d20368229f53df65c4 (patch)
tree957090ecf3d7a1dd447f11e7b3a7ab6d75d5cda6 /libavfilter
parentcb13f4483183fc280857dcba22049ded047184d1 (diff)
avfilter/af_astats: measure dynamic range
Signed-off-by: Paul B Mahol <onemda@gmail.com>
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/af_astats.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavfilter/af_astats.c b/libavfilter/af_astats.c
index 41fec156a3..2922da9f44 100644
--- a/libavfilter/af_astats.c
+++ b/libavfilter/af_astats.c
@@ -28,6 +28,7 @@
typedef struct ChannelStats {
double last;
+ double min_non_zero;
double sigma_x, sigma_x2;
double avg_sigma_x2, min_sigma_x2, max_sigma_x2;
double min, max;
@@ -110,6 +111,7 @@ static void reset_stats(AudioStatsContext *s)
p->min = p->nmin = p->min_sigma_x2 = DBL_MAX;
p->max = p->nmax = p->max_sigma_x2 = DBL_MIN;
+ p->min_non_zero = DBL_MAX;
p->min_diff = DBL_MAX;
p->max_diff = DBL_MIN;
p->sigma_x = 0;
@@ -178,6 +180,9 @@ static inline void update_stat(AudioStatsContext *s, ChannelStats *p, double d,
p->min_runs += p->min_run * p->min_run;
}
+ if (d != 0 && FFABS(d) < p->min_non_zero)
+ p->min_non_zero = FFABS(d);
+
if (d > p->max) {
p->max = d;
p->nmax = nd;
@@ -286,6 +291,7 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata)
bit_depth(s, p->mask, p->imask, &depth);
set_meta(metadata, c + 1, "Bit_depth", "%f", depth.num);
set_meta(metadata, c + 1, "Bit_depth2", "%f", depth.den);
+ set_meta(metadata, c + 1, "Dynamic_range", "%f", LINEAR_TO_DB(2 * FFMAX(FFABS(p->min), FFABS(p->max))/ p->min_non_zero));
}
set_meta(metadata, 0, "Overall.DC_offset", "%f", max_sigma_x / (nb_samples / s->nb_channels));
@@ -479,6 +485,7 @@ static void print_stats(AVFilterContext *ctx)
av_log(ctx, AV_LOG_INFO, "Peak count: %"PRId64"\n", p->min_count + p->max_count);
bit_depth(s, p->mask, p->imask, &depth);
av_log(ctx, AV_LOG_INFO, "Bit depth: %u/%u\n", depth.num, depth.den);
+ av_log(ctx, AV_LOG_INFO, "Dynamic range: %f\n", LINEAR_TO_DB(2 * FFMAX(FFABS(p->min), FFABS(p->max))/ p->min_non_zero));
}
av_log(ctx, AV_LOG_INFO, "Overall\n");