Re: [FFmpeg-devel] [PATCH] avfilter: add Dynamic Audio Normalizer filter

2015-07-17 Thread Paul B Mahol
On 7/9/15, Paul B Mahol one...@gmail.com wrote:
 From: LoRd_MuldeR muld...@gmx.de


 Signed-off-by: Paul B Mahol one...@gmail.com
 ---
  doc/filters.texi| 158 ++
  libavfilter/Makefile|   1 +
  libavfilter/af_dynaudnorm.c | 739
 
  libavfilter/allfilters.c|   1 +
  4 files changed, 899 insertions(+)
  create mode 100644 libavfilter/af_dynaudnorm.c


If nobody is against, I will apply this soon.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add Dynamic Audio Normalizer filter

2015-07-17 Thread Paul B Mahol
On 7/17/15, James Darnley james.darn...@gmail.com wrote:
 On 2015-07-09 18:55, Paul B Mahol wrote:
 +{ n, enable channels coupling, OFFSET(channels_coupled),
 AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, FLAGS },

 This should be enable channel coupling

Fixed


 +static const double s_pi =
 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679;

 Why not use the standard M_PI define?

Its too short. And I try hard to produce exact same output as
reference implementation as possible, even if doubles are used.


 +static void init_gaussian_filter(DynamicAudioNormalizerContext *s)
 +{
 +double total_weight = 0.0;
 +const double sigma = (((s-filter_size / 2.0) - 1.0) / 3.0) + (1.0 /
 3.0);
 +double adjust;
 +int i;
 +
 +// Pre-computer constants

 Pre-compute constants

Fixed.




___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add Dynamic Audio Normalizer filter

2015-07-17 Thread James Darnley
On 2015-07-09 18:55, Paul B Mahol wrote:
 +{ n, enable channels coupling, OFFSET(channels_coupled), 
 AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, FLAGS },

This should be enable channel coupling

 +static const double s_pi = 
 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679;

Why not use the standard M_PI define?

 +static void init_gaussian_filter(DynamicAudioNormalizerContext *s)
 +{
 +double total_weight = 0.0;
 +const double sigma = (((s-filter_size / 2.0) - 1.0) / 3.0) + (1.0 / 
 3.0);
 +double adjust;
 +int i;
 +
 +// Pre-computer constants

Pre-compute constants




signature.asc
Description: OpenPGP digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add Dynamic Audio Normalizer filter

2015-07-17 Thread James Darnley
On 2015-07-09 18:55, Paul B Mahol wrote:
 diff --git a/doc/filters.texi b/doc/filters.texi
 index 3fce874..74c408a 100644
 --- a/doc/filters.texi
 +++ b/doc/filters.texi
 @@ -1520,6 +1520,164 @@ Optional. It should have a value much less than 1 
 (e.g. 0.05 or 0.02) and is
  used to prevent clipping.
  @end table
  
 +@section dynaudnorm
 +Dynamic Audio Normalizer.
 +
 +This filter applies a certain amount of gain to the input audion in order
 ^^
audio

 +to bring its peak magnitude to a target level (e.g. 0 dBFS). However, in
 +contrast to more simple normalization algorithms, the Dynamic Audio
 +Normalizer *dynamically* re-adjusts the gain factor to the input audio.
 +This allows for applying extra gain to the quiet sections of the audio
 +while avoiding distortions or clipping the loud sections. In other words:
 +The Dynamic Audio Normalizer will even out the volume of quiet and loud
 +sections, in the sense that the volume of each section is brought to the
 +same target level. Note, however, that the Dynamic Audio Normalizer achieves
 +this goal *without* applying dynamic range compressing. It will retain 100%
 +of the dynamic range *within* each section of the audio file.
 +
 +@table @option
 +@item f
 +Set the frame length in milliseconds. In range from 10 to 8000 milliseconds.
 +Default is 500 milliseconds.
 +The Dynamic Audio Normalizer processes the input audio in small chunks,
 +referred to as frames. This is required, because a peak magnitude has no
 +meaning for just a single sample value. Instead, we need to determine the
 +peak magnitude for a contiguous sequence of sample values. While a standard
 +normalizer would simply use the peak magnitude of the complete file, the
 +Dynamic Audio Normalizer determines the peak magnitude individually for each
 +frame. The length of a frame is specified in milliseconds. By default, the
 +Dynamic Audio Normalizer uses a frame length of 500 milliseconds, which has
 +been found to give good results with most files.
 +Note that the exact frame length, in number of samples, will be determined
 +automatically, based on the sampling rate of the individual input audio file.
 +
 +@item g
 +Set the Gaussian filter window size. In range from 3 to 301, must be odd
 +number. Default is 31.
 +Probably the most important parameter of the Dynamic Audio Normalizer is the
 +@code{window size} of the Gaussian smoothing filter. The filter's window size
 +is specified in frames, centered around the current frame. For the sake of
 +simplicity, this must be an odd number. Consequently, the default value of 31
 +takes into account the current frame, as well as the 15 preceding frames and
 +the 15 subsequent frames. Using a larger window results in a stronger
 +smoothing effect and thus in less gain variation, i.e. slower gain
 +adaptation. Conversely, using a smaller window results in a weaker smoothing
 +effect and thus in more gain variation, i.e. faster gain adaptation.
 +In other words, the more you increase this value, the more the Dynamic Audio
 +Normalizer will behave like a traditional normalization filter. On the
 +contrary, the more you decrease this value, the more the Dynamic Audio
 +Normalizer will behave like a dynamic range compressor.
 +
 +@item p
 +Set the target peak value. This specifies the highest permissible magnitude
 +level for the normalized audio input. This filter will try to approach the
 +target peak magnitude as closely as possible, but at the same time it also
 +makes sure that the normalized signal will never exceed the peak magnitude.
 +A frame's maximum local gain factor is imposed directly by the target peak
 +magnitude. The default value is 0.95 and thus leaves a headroom of 5%*.
 +It is not recommended to go above this value.
 +
 +@item m
 +Set the maximum gain factor. In range from 1.0 to 100.0. Default is 10.0.
 +The Dynamic Audio Normalizer determines the maximum possible (local) gain
 +factor for each input frame, i.e. the maximum gain factor that does not
 +result in clipping or distortion. The maximum gain factor is determined by
 +the frame's highest magnitude sample. However, the Dynamic Audio Normalizer
 +additionally bounds the frame's maximum gain factor by a predetermined
 +(global) maximum gain factor. This is done in order to avoid excessive gain
 +factors in silent or almost silent frames. By default, the maximum gain
 +factor is 10.0, For most inputs the default value should be sufficient and
 +it usually is not recommended to increase this value. Though, for input
 +with an extremely low overall volume level, it may be necessary to allow even
 +higher gain factors. Note, however, that the Dynamic Audio Normalizer does
 +not simply apply a hard threshold (i.e. cut off values above the 
 threshold).
 +Instead, a sigmoid threshold function will be applied. This way, the
 +gainfactors will smoothly approach the threshold value, but never exceed that
   ^^^

Re: [FFmpeg-devel] [PATCH] avfilter: add Dynamic Audio Normalizer filter

2015-07-17 Thread Paul B Mahol
On 7/17/15, James Darnley james.darn...@gmail.com wrote:
 On 2015-07-09 18:55, Paul B Mahol wrote:
 diff --git a/doc/filters.texi b/doc/filters.texi
 index 3fce874..74c408a 100644
 --- a/doc/filters.texi
 +++ b/doc/filters.texi
 @@ -1520,6 +1520,164 @@ Optional. It should have a value much less than 1
 (e.g. 0.05 or 0.02) and is
  used to prevent clipping.
  @end table

 +@section dynaudnorm
 +Dynamic Audio Normalizer.
 +
 +This filter applies a certain amount of gain to the input audion in
 order
  ^^
 audio

 +to bring its peak magnitude to a target level (e.g. 0 dBFS). However, in
 +contrast to more simple normalization algorithms, the Dynamic Audio
 +Normalizer *dynamically* re-adjusts the gain factor to the input audio.
 +This allows for applying extra gain to the quiet sections of the audio
 +while avoiding distortions or clipping the loud sections. In other
 words:
 +The Dynamic Audio Normalizer will even out the volume of quiet and
 loud
 +sections, in the sense that the volume of each section is brought to the
 +same target level. Note, however, that the Dynamic Audio Normalizer
 achieves
 +this goal *without* applying dynamic range compressing. It will retain
 100%
 +of the dynamic range *within* each section of the audio file.
 +
 +@table @option
 +@item f
 +Set the frame length in milliseconds. In range from 10 to 8000
 milliseconds.
 +Default is 500 milliseconds.
 +The Dynamic Audio Normalizer processes the input audio in small chunks,
 +referred to as frames. This is required, because a peak magnitude has no
 +meaning for just a single sample value. Instead, we need to determine
 the
 +peak magnitude for a contiguous sequence of sample values. While a
 standard
 +normalizer would simply use the peak magnitude of the complete file, the
 +Dynamic Audio Normalizer determines the peak magnitude individually for
 each
 +frame. The length of a frame is specified in milliseconds. By default,
 the
 +Dynamic Audio Normalizer uses a frame length of 500 milliseconds, which
 has
 +been found to give good results with most files.
 +Note that the exact frame length, in number of samples, will be
 determined
 +automatically, based on the sampling rate of the individual input audio
 file.
 +
 +@item g
 +Set the Gaussian filter window size. In range from 3 to 301, must be odd
 +number. Default is 31.
 +Probably the most important parameter of the Dynamic Audio Normalizer is
 the
 +@code{window size} of the Gaussian smoothing filter. The filter's window
 size
 +is specified in frames, centered around the current frame. For the sake
 of
 +simplicity, this must be an odd number. Consequently, the default value
 of 31
 +takes into account the current frame, as well as the 15 preceding frames
 and
 +the 15 subsequent frames. Using a larger window results in a stronger
 +smoothing effect and thus in less gain variation, i.e. slower gain
 +adaptation. Conversely, using a smaller window results in a weaker
 smoothing
 +effect and thus in more gain variation, i.e. faster gain adaptation.
 +In other words, the more you increase this value, the more the Dynamic
 Audio
 +Normalizer will behave like a traditional normalization filter. On the
 +contrary, the more you decrease this value, the more the Dynamic Audio
 +Normalizer will behave like a dynamic range compressor.
 +
 +@item p
 +Set the target peak value. This specifies the highest permissible
 magnitude
 +level for the normalized audio input. This filter will try to approach
 the
 +target peak magnitude as closely as possible, but at the same time it
 also
 +makes sure that the normalized signal will never exceed the peak
 magnitude.
 +A frame's maximum local gain factor is imposed directly by the target
 peak
 +magnitude. The default value is 0.95 and thus leaves a headroom of 5%*.
 +It is not recommended to go above this value.
 +
 +@item m
 +Set the maximum gain factor. In range from 1.0 to 100.0. Default is
 10.0.
 +The Dynamic Audio Normalizer determines the maximum possible (local)
 gain
 +factor for each input frame, i.e. the maximum gain factor that does not
 +result in clipping or distortion. The maximum gain factor is determined
 by
 +the frame's highest magnitude sample. However, the Dynamic Audio
 Normalizer
 +additionally bounds the frame's maximum gain factor by a predetermined
 +(global) maximum gain factor. This is done in order to avoid excessive
 gain
 +factors in silent or almost silent frames. By default, the maximum
 gain
 +factor is 10.0, For most inputs the default value should be sufficient
 and
 +it usually is not recommended to increase this value. Though, for input
 +with an extremely low overall volume level, it may be necessary to allow
 even
 +higher gain factors. Note, however, that the Dynamic Audio Normalizer
 does
 +not simply apply a hard threshold (i.e. cut off values above the
 threshold).
 +Instead, a sigmoid threshold function will be applied. This way, the
 

Re: [FFmpeg-devel] [PATCH] avfilter: add Dynamic Audio Normalizer filter

2015-07-17 Thread James Darnley
On 2015-07-17 12:55, Paul B Mahol wrote:
 On 7/17/15, James Darnley james.darn...@gmail.com wrote:
 On 2015-07-09 18:55, Paul B Mahol wrote:
 +{ n, enable channels coupling, OFFSET(channels_coupled),
 AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, FLAGS },

 This should be enable channel coupling
 
 Fixed
 

 +static const double s_pi =
 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679;

 Why not use the standard M_PI define?
 
 Its too short. And I try hard to produce exact same output as
 reference implementation as possible, even if doubles are used.

I would have expected it to be long enough to be as precise as double
can be, or an exact hex define.  Colour me surprised.

I don't object then.




signature.asc
Description: OpenPGP digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add Dynamic Audio Normalizer filter

2015-07-10 Thread compn
On Thu,  9 Jul 2015 16:55:48 +
Paul B Mahol one...@gmail.com wrote:

 From: LoRd_MuldeR muld...@gmx.de
 
 
 Signed-off-by: Paul B Mahol one...@gmail.com
 ---
  doc/filters.texi| 158 ++
  libavfilter/Makefile|   1 +
  libavfilter/af_dynaudnorm.c | 739

i think i prefer af dnormalize or so.

we know its audio, so we dont need the aud part.
make it a little easier to type and remember and search for.

-compn
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avfilter: add Dynamic Audio Normalizer filter

2015-07-10 Thread Paul B Mahol
On 7/10/15, compn te...@mi.rr.com wrote:
 On Thu,  9 Jul 2015 16:55:48 +
 Paul B Mahol one...@gmail.com wrote:

 From: LoRd_MuldeR muld...@gmx.de


 Signed-off-by: Paul B Mahol one...@gmail.com
 ---
  doc/filters.texi| 158 ++
  libavfilter/Makefile|   1 +
  libavfilter/af_dynaudnorm.c | 739

 i think i prefer af dnormalize or so.

 we know its audio, so we dont need the aud part.
 make it a little easier to type and remember and search for.


This is how effect is called as sox plugin.
And I would rather not rename it.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel