Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
24db9372
Commit
24db9372
authored
Apr 17, 2020
by
Paul B Mahol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avfilter/af_astats: add noise floor count stat
parent
715da295
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
4 deletions
+30
-4
filters.texi
doc/filters.texi
+6
-0
af_astats.c
libavfilter/af_astats.c
+24
-4
No files found.
doc/filters.texi
View file @
24db9372
...
@@ -2330,6 +2330,7 @@ Crest_factor
...
@@ -2330,6 +2330,7 @@ Crest_factor
Flat_factor
Flat_factor
Peak_count
Peak_count
Noise_floor
Noise_floor
Noise_floor_count
Bit_depth
Bit_depth
Dynamic_range
Dynamic_range
Zero_crossings
Zero_crossings
...
@@ -2353,6 +2354,7 @@ RMS_trough
...
@@ -2353,6 +2354,7 @@ RMS_trough
Flat_factor
Flat_factor
Peak_count
Peak_count
Noise_floor
Noise_floor
Noise_floor_count
Bit_depth
Bit_depth
Number_of_samples
Number_of_samples
Number_of_NaNs
Number_of_NaNs
...
@@ -2427,6 +2429,10 @@ Number of occasions (not the number of samples) that the signal attained either
...
@@ -2427,6 +2429,10 @@ Number of occasions (not the number of samples) that the signal attained either
@item Noise floor dB
@item Noise floor dB
Minimum local peak measured in dBFS over a short window.
Minimum local peak measured in dBFS over a short window.
@item Noise floor count
Number of occasions (not the number of samples) that the signal attained
@var{Noise floor}.
@item Bit depth
@item Bit depth
Overall bit depth of audio. Number of bits used for each sample.
Overall bit depth of audio. Number of bits used for each sample.
...
...
libavfilter/af_astats.c
View file @
24db9372
...
@@ -56,6 +56,7 @@
...
@@ -56,6 +56,7 @@
#define MEASURE_NUMBER_OF_INFS (1 << 20)
#define MEASURE_NUMBER_OF_INFS (1 << 20)
#define MEASURE_NUMBER_OF_DENORMALS (1 << 21)
#define MEASURE_NUMBER_OF_DENORMALS (1 << 21)
#define MEASURE_NOISE_FLOOR (1 << 22)
#define MEASURE_NOISE_FLOOR (1 << 22)
#define MEASURE_NOISE_FLOOR_COUNT (1 << 23)
#define MEASURE_MINMAXPEAK (MEASURE_MIN_LEVEL | MEASURE_MAX_LEVEL | MEASURE_PEAK_LEVEL)
#define MEASURE_MINMAXPEAK (MEASURE_MIN_LEVEL | MEASURE_MAX_LEVEL | MEASURE_PEAK_LEVEL)
...
@@ -74,6 +75,7 @@ typedef struct ChannelStats {
...
@@ -74,6 +75,7 @@ typedef struct ChannelStats {
double
diff1_sum_x2
;
double
diff1_sum_x2
;
uint64_t
mask
,
imask
;
uint64_t
mask
,
imask
;
uint64_t
min_count
,
max_count
;
uint64_t
min_count
,
max_count
;
uint64_t
noise_floor_count
;
uint64_t
zero_runs
;
uint64_t
zero_runs
;
uint64_t
nb_samples
;
uint64_t
nb_samples
;
uint64_t
nb_nans
;
uint64_t
nb_nans
;
...
@@ -132,6 +134,7 @@ static const AVOption astats_options[] = {
...
@@ -132,6 +134,7 @@ static const AVOption astats_options[] = {
{
"Zero_crossings"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
MEASURE_ZERO_CROSSINGS
},
0
,
0
,
FLAGS
,
"measure"
},
{
"Zero_crossings"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
MEASURE_ZERO_CROSSINGS
},
0
,
0
,
FLAGS
,
"measure"
},
{
"Zero_crossings_rate"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
MEASURE_ZERO_CROSSINGS_RATE
},
0
,
0
,
FLAGS
,
"measure"
},
{
"Zero_crossings_rate"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
MEASURE_ZERO_CROSSINGS_RATE
},
0
,
0
,
FLAGS
,
"measure"
},
{
"Noise_floor"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
MEASURE_NOISE_FLOOR
},
0
,
0
,
FLAGS
,
"measure"
},
{
"Noise_floor"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
MEASURE_NOISE_FLOOR
},
0
,
0
,
FLAGS
,
"measure"
},
{
"Noise_floor_count"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
MEASURE_NOISE_FLOOR_COUNT
},
0
,
0
,
FLAGS
,
"measure"
},
{
"Number_of_samples"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
MEASURE_NUMBER_OF_SAMPLES
},
0
,
0
,
FLAGS
,
"measure"
},
{
"Number_of_samples"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
MEASURE_NUMBER_OF_SAMPLES
},
0
,
0
,
FLAGS
,
"measure"
},
{
"Number_of_NaNs"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
MEASURE_NUMBER_OF_NANS
},
0
,
0
,
FLAGS
,
"measure"
},
{
"Number_of_NaNs"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
MEASURE_NUMBER_OF_NANS
},
0
,
0
,
FLAGS
,
"measure"
},
{
"Number_of_Infs"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
MEASURE_NUMBER_OF_INFS
},
0
,
0
,
FLAGS
,
"measure"
},
{
"Number_of_Infs"
,
""
,
0
,
AV_OPT_TYPE_CONST
,
{.
i64
=
MEASURE_NUMBER_OF_INFS
},
0
,
0
,
FLAGS
,
"measure"
},
...
@@ -208,6 +211,7 @@ static void reset_stats(AudioStatsContext *s)
...
@@ -208,6 +211,7 @@ static void reset_stats(AudioStatsContext *s)
p
->
nb_denormals
=
0
;
p
->
nb_denormals
=
0
;
p
->
last
=
NAN
;
p
->
last
=
NAN
;
p
->
noise_floor
=
NAN
;
p
->
noise_floor
=
NAN
;
p
->
noise_floor_count
=
0
;
p
->
win_pos
=
0
;
p
->
win_pos
=
0
;
memset
(
p
->
win_samples
,
0
,
s
->
tc_samples
*
sizeof
(
*
p
->
win_samples
));
memset
(
p
->
win_samples
,
0
,
s
->
tc_samples
*
sizeof
(
*
p
->
win_samples
));
memset
(
p
->
histogram
,
0
,
sizeof
(
p
->
histogram
));
memset
(
p
->
histogram
,
0
,
sizeof
(
p
->
histogram
));
...
@@ -346,8 +350,14 @@ static inline void update_stat(AudioStatsContext *s, ChannelStats *p, double d,
...
@@ -346,8 +350,14 @@ static inline void update_stat(AudioStatsContext *s, ChannelStats *p, double d,
if
(
isnan
(
p
->
noise_floor
))
{
if
(
isnan
(
p
->
noise_floor
))
{
p
->
noise_floor
=
noise_floor
;
p
->
noise_floor
=
noise_floor
;
p
->
noise_floor_count
=
1
;
}
else
{
}
else
{
p
->
noise_floor
=
FFMIN
(
noise_floor
,
p
->
noise_floor
);
if
(
noise_floor
<
p
->
noise_floor
)
{
p
->
noise_floor
=
noise_floor
;
p
->
noise_floor_count
=
1
;
}
else
if
(
noise_floor
==
p
->
noise_floor
)
{
p
->
noise_floor_count
++
;
}
}
}
}
}
...
@@ -398,7 +408,7 @@ static void set_meta(AVDictionary **metadata, int chan, const char *key,
...
@@ -398,7 +408,7 @@ static void set_meta(AVDictionary **metadata, int chan, const char *key,
static
void
set_metadata
(
AudioStatsContext
*
s
,
AVDictionary
**
metadata
)
static
void
set_metadata
(
AudioStatsContext
*
s
,
AVDictionary
**
metadata
)
{
{
uint64_t
mask
=
0
,
imask
=
0xFFFFFFFFFFFFFFFF
,
min_count
=
0
,
max_count
=
0
,
nb_samples
=
0
;
uint64_t
mask
=
0
,
imask
=
0xFFFFFFFFFFFFFFFF
,
min_count
=
0
,
max_count
=
0
,
nb_samples
=
0
,
noise_floor_count
=
0
;
uint64_t
nb_nans
=
0
,
nb_infs
=
0
,
nb_denormals
=
0
;
uint64_t
nb_nans
=
0
,
nb_infs
=
0
,
nb_denormals
=
0
;
double
min_runs
=
0
,
max_runs
=
0
,
double
min_runs
=
0
,
max_runs
=
0
,
min
=
DBL_MAX
,
max
=-
DBL_MAX
,
min_diff
=
DBL_MAX
,
max_diff
=
0
,
min
=
DBL_MAX
,
max
=-
DBL_MAX
,
min_diff
=
DBL_MAX
,
max_diff
=
0
,
...
@@ -433,6 +443,7 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata)
...
@@ -433,6 +443,7 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata)
sigma_x
+=
p
->
sigma_x
;
sigma_x
+=
p
->
sigma_x
;
sigma_x2
+=
p
->
sigma_x2
;
sigma_x2
+=
p
->
sigma_x2
;
noise_floor
=
FFMAX
(
noise_floor
,
p
->
noise_floor
);
noise_floor
=
FFMAX
(
noise_floor
,
p
->
noise_floor
);
noise_floor_count
+=
p
->
noise_floor_count
;
min_count
+=
p
->
min_count
;
min_count
+=
p
->
min_count
;
max_count
+=
p
->
max_count
;
max_count
+=
p
->
max_count
;
min_runs
+=
p
->
min_runs
;
min_runs
+=
p
->
min_runs
;
...
@@ -475,7 +486,9 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata)
...
@@ -475,7 +486,9 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata)
if
(
s
->
measure_perchannel
&
MEASURE_PEAK_COUNT
)
if
(
s
->
measure_perchannel
&
MEASURE_PEAK_COUNT
)
set_meta
(
metadata
,
c
+
1
,
"Peak_count"
,
"%f"
,
(
float
)(
p
->
min_count
+
p
->
max_count
));
set_meta
(
metadata
,
c
+
1
,
"Peak_count"
,
"%f"
,
(
float
)(
p
->
min_count
+
p
->
max_count
));
if
(
s
->
measure_perchannel
&
MEASURE_NOISE_FLOOR
)
if
(
s
->
measure_perchannel
&
MEASURE_NOISE_FLOOR
)
set_meta
(
metadata
,
c
+
1
,
"Noise_floor"
,
" %f"
,
LINEAR_TO_DB
(
p
->
noise_floor
));
set_meta
(
metadata
,
c
+
1
,
"Noise_floor"
,
"%f"
,
LINEAR_TO_DB
(
p
->
noise_floor
));
if
(
s
->
measure_perchannel
&
MEASURE_NOISE_FLOOR_COUNT
)
set_meta
(
metadata
,
c
+
1
,
"Noise_floor_count"
,
"%f"
,
p
->
noise_floor_count
);
if
(
s
->
measure_perchannel
&
MEASURE_BIT_DEPTH
)
{
if
(
s
->
measure_perchannel
&
MEASURE_BIT_DEPTH
)
{
bit_depth
(
s
,
p
->
mask
,
p
->
imask
,
&
depth
);
bit_depth
(
s
,
p
->
mask
,
p
->
imask
,
&
depth
);
set_meta
(
metadata
,
c
+
1
,
"Bit_depth"
,
"%f"
,
depth
.
num
);
set_meta
(
metadata
,
c
+
1
,
"Bit_depth"
,
"%f"
,
depth
.
num
);
...
@@ -523,6 +536,8 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata)
...
@@ -523,6 +536,8 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata)
set_meta
(
metadata
,
0
,
"Overall.Peak_count"
,
"%f"
,
(
float
)(
min_count
+
max_count
)
/
(
double
)
s
->
nb_channels
);
set_meta
(
metadata
,
0
,
"Overall.Peak_count"
,
"%f"
,
(
float
)(
min_count
+
max_count
)
/
(
double
)
s
->
nb_channels
);
if
(
s
->
measure_overall
&
MEASURE_NOISE_FLOOR
)
if
(
s
->
measure_overall
&
MEASURE_NOISE_FLOOR
)
set_meta
(
metadata
,
0
,
"Overall.Noise_floor"
,
"%f"
,
LINEAR_TO_DB
(
noise_floor
));
set_meta
(
metadata
,
0
,
"Overall.Noise_floor"
,
"%f"
,
LINEAR_TO_DB
(
noise_floor
));
if
(
s
->
measure_overall
&
MEASURE_NOISE_FLOOR_COUNT
)
set_meta
(
metadata
,
0
,
"Overall.Noise_floor_count"
,
"%f"
,
noise_floor_count
/
(
double
)
s
->
nb_channels
);
if
(
s
->
measure_overall
&
MEASURE_BIT_DEPTH
)
{
if
(
s
->
measure_overall
&
MEASURE_BIT_DEPTH
)
{
bit_depth
(
s
,
mask
,
imask
,
&
depth
);
bit_depth
(
s
,
mask
,
imask
,
&
depth
);
set_meta
(
metadata
,
0
,
"Overall.Bit_depth"
,
"%f"
,
depth
.
num
);
set_meta
(
metadata
,
0
,
"Overall.Bit_depth"
,
"%f"
,
depth
.
num
);
...
@@ -641,7 +656,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
...
@@ -641,7 +656,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
static
void
print_stats
(
AVFilterContext
*
ctx
)
static
void
print_stats
(
AVFilterContext
*
ctx
)
{
{
AudioStatsContext
*
s
=
ctx
->
priv
;
AudioStatsContext
*
s
=
ctx
->
priv
;
uint64_t
mask
=
0
,
imask
=
0xFFFFFFFFFFFFFFFF
,
min_count
=
0
,
max_count
=
0
,
nb_samples
=
0
;
uint64_t
mask
=
0
,
imask
=
0xFFFFFFFFFFFFFFFF
,
min_count
=
0
,
max_count
=
0
,
nb_samples
=
0
,
noise_floor_count
=
0
;
uint64_t
nb_nans
=
0
,
nb_infs
=
0
,
nb_denormals
=
0
;
uint64_t
nb_nans
=
0
,
nb_infs
=
0
,
nb_denormals
=
0
;
double
min_runs
=
0
,
max_runs
=
0
,
double
min_runs
=
0
,
max_runs
=
0
,
min
=
DBL_MAX
,
max
=-
DBL_MAX
,
min_diff
=
DBL_MAX
,
max_diff
=
0
,
min
=
DBL_MAX
,
max
=-
DBL_MAX
,
min_diff
=
DBL_MAX
,
max_diff
=
0
,
...
@@ -678,6 +693,7 @@ static void print_stats(AVFilterContext *ctx)
...
@@ -678,6 +693,7 @@ static void print_stats(AVFilterContext *ctx)
noise_floor
=
FFMAX
(
noise_floor
,
p
->
noise_floor
);
noise_floor
=
FFMAX
(
noise_floor
,
p
->
noise_floor
);
min_count
+=
p
->
min_count
;
min_count
+=
p
->
min_count
;
max_count
+=
p
->
max_count
;
max_count
+=
p
->
max_count
;
noise_floor_count
+=
p
->
noise_floor_count
;
min_runs
+=
p
->
min_runs
;
min_runs
+=
p
->
min_runs
;
max_runs
+=
p
->
max_runs
;
max_runs
+=
p
->
max_runs
;
mask
|=
p
->
mask
;
mask
|=
p
->
mask
;
...
@@ -721,6 +737,8 @@ static void print_stats(AVFilterContext *ctx)
...
@@ -721,6 +737,8 @@ static void print_stats(AVFilterContext *ctx)
av_log
(
ctx
,
AV_LOG_INFO
,
"Peak count: %"
PRId64
"
\n
"
,
p
->
min_count
+
p
->
max_count
);
av_log
(
ctx
,
AV_LOG_INFO
,
"Peak count: %"
PRId64
"
\n
"
,
p
->
min_count
+
p
->
max_count
);
if
(
s
->
measure_perchannel
&
MEASURE_NOISE_FLOOR
)
if
(
s
->
measure_perchannel
&
MEASURE_NOISE_FLOOR
)
av_log
(
ctx
,
AV_LOG_INFO
,
"Noise floor dB: %f
\n
"
,
LINEAR_TO_DB
(
p
->
noise_floor
));
av_log
(
ctx
,
AV_LOG_INFO
,
"Noise floor dB: %f
\n
"
,
LINEAR_TO_DB
(
p
->
noise_floor
));
if
(
s
->
measure_perchannel
&
MEASURE_NOISE_FLOOR_COUNT
)
av_log
(
ctx
,
AV_LOG_INFO
,
"Noise floor count: %"
PRId64
"
\n
"
,
p
->
noise_floor_count
);
if
(
s
->
measure_perchannel
&
MEASURE_BIT_DEPTH
)
{
if
(
s
->
measure_perchannel
&
MEASURE_BIT_DEPTH
)
{
bit_depth
(
s
,
p
->
mask
,
p
->
imask
,
&
depth
);
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
,
"Bit depth: %u/%u
\n
"
,
depth
.
num
,
depth
.
den
);
...
@@ -769,6 +787,8 @@ static void print_stats(AVFilterContext *ctx)
...
@@ -769,6 +787,8 @@ static void print_stats(AVFilterContext *ctx)
av_log
(
ctx
,
AV_LOG_INFO
,
"Peak count: %f
\n
"
,
(
min_count
+
max_count
)
/
(
double
)
s
->
nb_channels
);
av_log
(
ctx
,
AV_LOG_INFO
,
"Peak count: %f
\n
"
,
(
min_count
+
max_count
)
/
(
double
)
s
->
nb_channels
);
if
(
s
->
measure_overall
&
MEASURE_NOISE_FLOOR
)
if
(
s
->
measure_overall
&
MEASURE_NOISE_FLOOR
)
av_log
(
ctx
,
AV_LOG_INFO
,
"Noise floor dB: %f
\n
"
,
LINEAR_TO_DB
(
noise_floor
));
av_log
(
ctx
,
AV_LOG_INFO
,
"Noise floor dB: %f
\n
"
,
LINEAR_TO_DB
(
noise_floor
));
if
(
s
->
measure_overall
&
MEASURE_NOISE_FLOOR_COUNT
)
av_log
(
ctx
,
AV_LOG_INFO
,
"Noise floor count: %f
\n
"
,
noise_floor_count
/
(
double
)
s
->
nb_channels
);
if
(
s
->
measure_overall
&
MEASURE_BIT_DEPTH
)
{
if
(
s
->
measure_overall
&
MEASURE_BIT_DEPTH
)
{
bit_depth
(
s
,
mask
,
imask
,
&
depth
);
bit_depth
(
s
,
mask
,
imask
,
&
depth
);
av_log
(
ctx
,
AV_LOG_INFO
,
"Bit depth: %u/%u
\n
"
,
depth
.
num
,
depth
.
den
);
av_log
(
ctx
,
AV_LOG_INFO
,
"Bit depth: %u/%u
\n
"
,
depth
.
num
,
depth
.
den
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment