|
|
|
@ -36,6 +36,7 @@ typedef struct ChannelStats { |
|
|
|
|
double min_runs, max_runs; |
|
|
|
|
double min_diff, max_diff; |
|
|
|
|
double diff1_sum; |
|
|
|
|
double diff1_sum_x2; |
|
|
|
|
uint64_t mask, imask; |
|
|
|
|
uint64_t min_count, max_count; |
|
|
|
|
uint64_t nb_samples; |
|
|
|
@ -121,6 +122,7 @@ static void reset_stats(AudioStatsContext *s) |
|
|
|
|
p->min_runs = 0; |
|
|
|
|
p->max_runs = 0; |
|
|
|
|
p->diff1_sum = 0; |
|
|
|
|
p->diff1_sum_x2 = 0; |
|
|
|
|
p->mask = 0; |
|
|
|
|
p->imask = 0xFFFFFFFFFFFFFFFF; |
|
|
|
|
p->min_count = 0; |
|
|
|
@ -197,6 +199,7 @@ static inline void update_stat(AudioStatsContext *s, ChannelStats *p, double d, |
|
|
|
|
p->min_diff = FFMIN(p->min_diff, fabs(d - p->last)); |
|
|
|
|
p->max_diff = FFMAX(p->max_diff, fabs(d - p->last)); |
|
|
|
|
p->diff1_sum += fabs(d - p->last); |
|
|
|
|
p->diff1_sum_x2 += (d - p->last) * (d - p->last); |
|
|
|
|
p->last = d; |
|
|
|
|
p->mask |= i; |
|
|
|
|
p->imask &= i; |
|
|
|
@ -232,6 +235,7 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata) |
|
|
|
|
nmin = DBL_MAX, nmax = DBL_MIN, |
|
|
|
|
max_sigma_x = 0, |
|
|
|
|
diff1_sum = 0, |
|
|
|
|
diff1_sum_x2 = 0, |
|
|
|
|
sigma_x = 0, |
|
|
|
|
sigma_x2 = 0, |
|
|
|
|
min_sigma_x2 = DBL_MAX, |
|
|
|
@ -251,7 +255,8 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata) |
|
|
|
|
nmax = FFMAX(nmax, p->nmax); |
|
|
|
|
min_diff = FFMIN(min_diff, p->min_diff); |
|
|
|
|
max_diff = FFMAX(max_diff, p->max_diff); |
|
|
|
|
diff1_sum += p->diff1_sum, |
|
|
|
|
diff1_sum += p->diff1_sum; |
|
|
|
|
diff1_sum_x2 += p->diff1_sum_x2; |
|
|
|
|
min_sigma_x2 = FFMIN(min_sigma_x2, p->min_sigma_x2); |
|
|
|
|
max_sigma_x2 = FFMAX(max_sigma_x2, p->max_sigma_x2); |
|
|
|
|
sigma_x += p->sigma_x; |
|
|
|
@ -272,6 +277,7 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata) |
|
|
|
|
set_meta(metadata, c + 1, "Min_difference", "%f", p->min_diff); |
|
|
|
|
set_meta(metadata, c + 1, "Max_difference", "%f", p->max_diff); |
|
|
|
|
set_meta(metadata, c + 1, "Mean_difference", "%f", p->diff1_sum / (p->nb_samples - 1)); |
|
|
|
|
set_meta(metadata, c + 1, "RMS_difference", "%f", sqrt(p->diff1_sum_x2 / (p->nb_samples - 1))); |
|
|
|
|
set_meta(metadata, c + 1, "Peak_level", "%f", LINEAR_TO_DB(FFMAX(-p->nmin, p->nmax))); |
|
|
|
|
set_meta(metadata, c + 1, "RMS_level", "%f", LINEAR_TO_DB(sqrt(p->sigma_x2 / p->nb_samples))); |
|
|
|
|
set_meta(metadata, c + 1, "RMS_peak", "%f", LINEAR_TO_DB(sqrt(p->max_sigma_x2))); |
|
|
|
@ -290,6 +296,7 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata) |
|
|
|
|
set_meta(metadata, 0, "Overall.Min_difference", "%f", min_diff); |
|
|
|
|
set_meta(metadata, 0, "Overall.Max_difference", "%f", max_diff); |
|
|
|
|
set_meta(metadata, 0, "Overall.Mean_difference", "%f", diff1_sum / (nb_samples - s->nb_channels)); |
|
|
|
|
set_meta(metadata, 0, "Overall.RMS_difference", "%f", sqrt(diff1_sum_x2 / (nb_samples - s->nb_channels))); |
|
|
|
|
set_meta(metadata, 0, "Overall.Peak_level", "%f", LINEAR_TO_DB(FFMAX(-nmin, nmax))); |
|
|
|
|
set_meta(metadata, 0, "Overall.RMS_level", "%f", LINEAR_TO_DB(sqrt(sigma_x2 / nb_samples))); |
|
|
|
|
set_meta(metadata, 0, "Overall.RMS_peak", "%f", LINEAR_TO_DB(sqrt(max_sigma_x2))); |
|
|
|
@ -419,6 +426,7 @@ static void print_stats(AVFilterContext *ctx) |
|
|
|
|
min = DBL_MAX, max = DBL_MIN, min_diff = DBL_MAX, max_diff = 0, |
|
|
|
|
nmin = DBL_MAX, nmax = DBL_MIN, |
|
|
|
|
max_sigma_x = 0, |
|
|
|
|
diff1_sum_x2 = 0, |
|
|
|
|
diff1_sum = 0, |
|
|
|
|
sigma_x = 0, |
|
|
|
|
sigma_x2 = 0, |
|
|
|
@ -439,7 +447,8 @@ static void print_stats(AVFilterContext *ctx) |
|
|
|
|
nmax = FFMAX(nmax, p->nmax); |
|
|
|
|
min_diff = FFMIN(min_diff, p->min_diff); |
|
|
|
|
max_diff = FFMAX(max_diff, p->max_diff); |
|
|
|
|
diff1_sum += p->diff1_sum, |
|
|
|
|
diff1_sum_x2 += p->diff1_sum_x2; |
|
|
|
|
diff1_sum += p->diff1_sum; |
|
|
|
|
min_sigma_x2 = FFMIN(min_sigma_x2, p->min_sigma_x2); |
|
|
|
|
max_sigma_x2 = FFMAX(max_sigma_x2, p->max_sigma_x2); |
|
|
|
|
sigma_x += p->sigma_x; |
|
|
|
@ -461,6 +470,7 @@ static void print_stats(AVFilterContext *ctx) |
|
|
|
|
av_log(ctx, AV_LOG_INFO, "Min difference: %f\n", p->min_diff); |
|
|
|
|
av_log(ctx, AV_LOG_INFO, "Max difference: %f\n", p->max_diff); |
|
|
|
|
av_log(ctx, AV_LOG_INFO, "Mean difference: %f\n", p->diff1_sum / (p->nb_samples - 1)); |
|
|
|
|
av_log(ctx, AV_LOG_INFO, "RMS difference: %f\n", sqrt(p->diff1_sum_x2 / (p->nb_samples - 1))); |
|
|
|
|
av_log(ctx, AV_LOG_INFO, "Peak level dB: %f\n", LINEAR_TO_DB(FFMAX(-p->nmin, p->nmax))); |
|
|
|
|
av_log(ctx, AV_LOG_INFO, "RMS level dB: %f\n", LINEAR_TO_DB(sqrt(p->sigma_x2 / p->nb_samples))); |
|
|
|
|
av_log(ctx, AV_LOG_INFO, "RMS peak dB: %f\n", LINEAR_TO_DB(sqrt(p->max_sigma_x2))); |
|
|
|
@ -480,6 +490,7 @@ static void print_stats(AVFilterContext *ctx) |
|
|
|
|
av_log(ctx, AV_LOG_INFO, "Min difference: %f\n", min_diff); |
|
|
|
|
av_log(ctx, AV_LOG_INFO, "Max difference: %f\n", max_diff); |
|
|
|
|
av_log(ctx, AV_LOG_INFO, "Mean difference: %f\n", diff1_sum / (nb_samples - s->nb_channels)); |
|
|
|
|
av_log(ctx, AV_LOG_INFO, "RMS difference: %f\n", sqrt(diff1_sum_x2 / (nb_samples - s->nb_channels))); |
|
|
|
|
av_log(ctx, AV_LOG_INFO, "Peak level dB: %f\n", LINEAR_TO_DB(FFMAX(-nmin, nmax))); |
|
|
|
|
av_log(ctx, AV_LOG_INFO, "RMS level dB: %f\n", LINEAR_TO_DB(sqrt(sigma_x2 / nb_samples))); |
|
|
|
|
av_log(ctx, AV_LOG_INFO, "RMS peak dB: %f\n", LINEAR_TO_DB(sqrt(max_sigma_x2))); |
|
|
|
|