[FFmpeg-devel] avfilter/showvolume : add new options and minor clean

Michael Niedermayer michael at niedermayer.cc
Wed Apr 11 01:13:14 EEST 2018


On Sat, Mar 31, 2018 at 04:21:36PM +0200, Martin Vignali wrote:
> Hello,
> 
> In attach new patchs for showvolume filter
> 
> 001 : Move the clear picture part to a new func, and use it if fade option
> == 0.
> (no need to calculate it in float)
> 
> 002/003 : Move "height" condition for draw volume at the start of the loop
> and indent
> 
> 004 : add a new option for choosing the display scale
> currently, the filter use linear display,
> most audio meter use some kind of log display
> 
> 
> 005 : WIP :
> The idea is to add an option to draw a line for the max level for a given
> duration.
> Several audio meter have this kind of display, and its help user, to check
> peak level (even
> if the "peak" happen during a very short time.
> 
> I'm not entirely sure, this is the best way to add this.
> 
> For now, i store the max value for each channel, update it, if a new peak
> is bigger than the store value
> And count the number of frame for display. If a given display duration is
> exceed, update the max value to the current max value.
> 
> Missing docs and probably code reorganization to reduce code duplication.
> 
> I also have had very few inspiration for option naming and variable naming
> (and i don't know the "official name" of this little line in audio meter).
> So i'm open to better naming suggestion.
> 
> This display need to be enable using dm=1
> and the duration during the max value is still display can be set with
> dm_duration (in seconds)
[...]

>  doc/filters.texi             |    4 ++++
>  libavfilter/avf_showvolume.c |   22 +++++++++++++++++++---
>  2 files changed, 23 insertions(+), 3 deletions(-)
> 727228fe3128595cad5a00f9370b63c1c3c06273  0004-avfilter-showvolume-add-display-scale-option.patch
> From 06b19cff28558885b8c4a987d27f56a3a90528f7 Mon Sep 17 00:00:00 2001
> From: Martin Vignali <martin.vignali at gmail.com>
> Date: Sat, 31 Mar 2018 15:52:20 +0200
> Subject: [PATCH 4/5] avfilter/showvolume : add display scale option
> 
> linear (current behaviour) or log display (more close to classic audio meter)
> ---
>  doc/filters.texi             |  4 ++++
>  libavfilter/avf_showvolume.c | 22 +++++++++++++++++++---
>  2 files changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/doc/filters.texi b/doc/filters.texi
> index bf2b94e240..764abd4be7 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -19974,6 +19974,10 @@ Set background opacity, allowed range is [0, 1]. Default is 0.
>  @item m
>  Set metering mode, can be peak: @code{p} or rms: @code{r},
>  default is @code{p}.
> +
> + at item ds
> +Set display scale, can be linear: @code{lin} or log: @code{log},
> +default is @code{lin}.
>  @end table
>  
>  @section showwaves
> diff --git a/libavfilter/avf_showvolume.c b/libavfilter/avf_showvolume.c
> index 7fe3916855..50ff80e022 100644
> --- a/libavfilter/avf_showvolume.c
> +++ b/libavfilter/avf_showvolume.c
> @@ -54,6 +54,7 @@ typedef struct ShowVolumeContext {
>      uint32_t *color_lut;
>      float *max;
>      float rms_factor;

> +    int display_scale; /* 0 for linear, 1 for log */

please use #define or values from a enum.
self explanatory code is better than comments.

also leave the type of display_scale int dont change it to enum if you
use a enum, (generic code like AVOptions cannot support arbitrary enum types)

i like the idea of this patch though


[...]
>  avf_showvolume.c |   63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 63 insertions(+)
> e256cdd9a6d44f721f19aab6eedba48be089ad03  0005-avfilter-showvolume-add-persistent-max-display.patch
> From 1cac1a13e5142b0eff4acd17aecaac596ae359d4 Mon Sep 17 00:00:00 2001
> From: Martin Vignali <martin.vignali at gmail.com>
> Date: Sat, 31 Mar 2018 15:53:04 +0200
> Subject: [PATCH 5/5] avfilter/showvolume : add persistent max display
> 
> WIP
> ---
>  libavfilter/avf_showvolume.c | 63 ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 63 insertions(+)

didnt review as its still WIP but i think the idea is good as well

you could combine the dm and dm_duration options though making the interface
simpler

thx
[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Asymptotically faster algorithms should always be preferred if you have
asymptotical amounts of data
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180411/d6b204ad/attachment.sig>


More information about the ffmpeg-devel mailing list