aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2021-08-21 21:44:18 +0200
committerPaul B Mahol <onemda@gmail.com>2021-08-21 22:05:08 +0200
commit5b258c27702c3a58b9be2b23b074ad4c4355bdac (patch)
treea46caf75d0111290ced54b4654e785f339920d8a
parent99ccad843f51e2fc16a8dada225a14928bd46fa6 (diff)
downloadffmpeg-5b258c27702c3a58b9be2b23b074ad4c4355bdac.tar.gz
avfilter/af_astats: remove invalid 5x factor in window size calculation
Also allow smaller window sizes, and change histogram for noise floor calculation to uint64_t type.
-rw-r--r--doc/filters.texi2
-rw-r--r--libavfilter/af_astats.c6
2 files changed, 4 insertions, 4 deletions
diff --git a/doc/filters.texi b/doc/filters.texi
index a5752c4d6e..c84202cf85 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -2647,7 +2647,7 @@ It accepts the following option:
@table @option
@item length
Short window length in seconds, used for peak and trough RMS measurement.
-Default is @code{0.05} (50 milliseconds). Allowed range is @code{[0.01 - 10]}.
+Default is @code{0.05} (50 milliseconds). Allowed range is @code{[0 - 10]}.
@item metadata
diff --git a/libavfilter/af_astats.c b/libavfilter/af_astats.c
index c8fbe44f69..9577468c81 100644
--- a/libavfilter/af_astats.c
+++ b/libavfilter/af_astats.c
@@ -82,7 +82,7 @@ typedef struct ChannelStats {
uint64_t nb_infs;
uint64_t nb_denormals;
double *win_samples;
- unsigned histogram[HISTOGRAM_SIZE];
+ uint64_t histogram[HISTOGRAM_SIZE];
int win_pos;
int max_index;
double noise_floor;
@@ -109,7 +109,7 @@ typedef struct AudioStatsContext {
#define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
static const AVOption astats_options[] = {
- { "length", "set the window length", OFFSET(time_constant), AV_OPT_TYPE_DOUBLE, {.dbl=.05}, .01, 10, FLAGS },
+ { "length", "set the window length", OFFSET(time_constant), AV_OPT_TYPE_DOUBLE, {.dbl=.05}, 0, 10, FLAGS },
{ "metadata", "inject metadata in the filtergraph", OFFSET(metadata), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS },
{ "reset", "recalculate stats after this many frames", OFFSET(reset_count), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
{ "measure_perchannel", "only measure_perchannel these per-channel statistics", OFFSET(measure_perchannel), AV_OPT_TYPE_FLAGS, {.i64=MEASURE_ALL}, 0, UINT_MAX, FLAGS, "measure" },
@@ -213,7 +213,7 @@ static int config_output(AVFilterLink *outlink)
if (!s->chstats)
return AVERROR(ENOMEM);
- s->tc_samples = 5 * s->time_constant * outlink->sample_rate + .5;
+ s->tc_samples = FFMAX(s->time_constant * outlink->sample_rate + .5, 1);
s->nb_channels = outlink->channels;
for (int i = 0; i < s->nb_channels; i++) {