[FFmpeg-devel] [PATCH] astats filter
Paul B Mahol
onemda at gmail.com
Sat Apr 27 01:01:23 CEST 2013
On 4/24/13, Stefano Sabatini <stefasab at gmail.com> wrote:
> On date Tuesday 2013-04-23 12:59:08 +0000, Paul B Mahol encoded:
>> Signed-off-by: Paul B Mahol <onemda at gmail.com>
>> ---
>> doc/filters.texi | 44 ++++++++
>> libavfilter/Makefile | 1 +
>> libavfilter/af_astats.c | 287
>> +++++++++++++++++++++++++++++++++++++++++++++++
>> libavfilter/allfilters.c | 1 +
>> 4 files changed, 333 insertions(+)
>> create mode 100644 libavfilter/af_astats.c
>>
>> diff --git a/doc/filters.texi b/doc/filters.texi
>> index d5fda03..1e2363d 100644
>> --- a/doc/filters.texi
>> +++ b/doc/filters.texi
>> @@ -990,6 +990,50 @@ the data is treated as if all the planes were
>> concatenated.
>> A list of Adler-32 checksums for each data plane.
>> @end table
>>
>> + at section astats
>> +
>> +Display time domain statistical information about the audio channels.
>> +Statistics are calculated and displayed for each audio channel and,
>> +where applicable, an overall figure is also given.
>> +
>> +The filter accepts the following option:
>> + at table @option
>> + at item length
>> +Short window length. Default is 50ms.
>
> nit: specify the unit (I think it is seconds), and range.
>
> Also it is not clear what this "short window" refers to.
Done.
>
>> + at end table
>> +
>> +A description of each shown parameter follows:
>> +
>> + at table @option
>> + at item DC offset
>> +Mean amplitude displacement from zero.
>> +
>> + at item Min level
>> +Minimal sample level.
>> +
>> + at item Max level
>> +Maximal sample level.
>> +
>> + at item Peak level dB
>> + at item RMS level dB
>> +Standard peak and RMS level measured in dBFS.
>> +
>> + at item RMS peak dB
>
>> + at item RMS through dB
>> +Peak and trough values for RMS level measured over a short window.
>
> trough or through?
>
Fixed.
>> +
>> + at item Crest factor
>> +Standard ratio of peak to RMS level (note: not in dB).
>> +
>> + at item Flat factor
>> +Flatness (i.e. consecutive samples with the same value) of the signal at
>> its peak levels
>> +(i.e. either @var{Min level} or @var{Max level}).
>> +
>> + at item Peak count
>> +Number of occasions (not the number of samples) that the signal attained
>> either
>> + at var{Min level} or @var{Max level}.
>> + at end table
>> +
>> @section astreamsync
>>
>> Forward two audio streams and control the order the buffers are
>> forwarded.
>> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
>> index 4fce503..2b2adcb 100644
>> --- a/libavfilter/Makefile
>> +++ b/libavfilter/Makefile
>> @@ -69,6 +69,7 @@ OBJS-$(CONFIG_ASETRATE_FILTER) +=
>> af_asetrate.o
>> OBJS-$(CONFIG_ASETTB_FILTER) += f_settb.o
>> OBJS-$(CONFIG_ASHOWINFO_FILTER) += af_ashowinfo.o
>> OBJS-$(CONFIG_ASPLIT_FILTER) += split.o
>> +OBJS-$(CONFIG_ASTATS_FILTER) += af_astats.o
>> OBJS-$(CONFIG_ASTREAMSYNC_FILTER) += af_astreamsync.o
>> OBJS-$(CONFIG_ASYNCTS_FILTER) += af_asyncts.o
>> OBJS-$(CONFIG_ATEMPO_FILTER) += af_atempo.o
>> diff --git a/libavfilter/af_astats.c b/libavfilter/af_astats.c
>> new file mode 100644
>> index 0000000..547cfc2
>> --- /dev/null
>> +++ b/libavfilter/af_astats.c
[...]
>> + stat(s, p, *src);
>> + }
>> + break;
>> + case AV_SAMPLE_FMT_DBL: {
>> + const double *src = (const double *)buf->extended_data[0];
>> +
>> + for (i = 0; i < buf->nb_samples; i++) {
>> + for (c = 0; c < channels; c++, src++) {
>> + ChannelStats *p = &s->chstats[c];
>> +
>> + stat(s, p, *src);
>
> you can directly use s->chstats[c]
>
Done.
>> + }
>> + }
>> + break; }
>> + }
>> +
>> + return ff_filter_frame(inlink->dst->outputs[0], buf);
>> +}
>> +
>> +#define LINEAR_TO_DB(x) (log10(x) * 20)
>> +
[..]
Fixed other bugs, will apply soon.
More information about the ffmpeg-devel
mailing list