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.
This commit is contained in:
Paul B Mahol 2021-08-21 21:44:18 +02:00
parent 99ccad843f
commit 5b258c2770
2 changed files with 4 additions and 4 deletions

View File

@ -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

View File

@ -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++) {