Re: [FFmpeg-devel] [PATCH] avfilter: add firequalizer filter

2016-02-22 Thread Muhammad Faiz
On Fri, Feb 19, 2016 at 11:52 PM, Muhammad Faiz  wrote:
> On Fri, Feb 19, 2016 at 3:52 AM, Paul B Mahol  wrote:
>>> +center = s->fir_len / 2;
>>> +
>>> +for (k = 0; k <= center; k++) {
>>> +double u = k * (M_PI/center);
>>> +double win;
>>> +switch (s->wfunc) {
>>> +case WFUNC_RECTANGULAR:
>>> +win = 1.0;
>>> +break;
>>> +case WFUNC_HANN:
>>> +win = 0.5 + 0.5 * cos(u);
>>> +break;
>>> +case WFUNC_HAMMING:
>>> +win = 0.53836 + 0.46164 * cos(u);
>>> +break;
>>> +case WFUNC_BLACKMAN:
>>> +win = 0.48 + 0.5 * cos(u) + 0.02 * cos(2*u);
>>> +break;
>>> +case WFUNC_NUTTALL3:
>>> +win = 0.40897 + 0.5 * cos(u) + 0.09103 * cos(2*u);
>>> +break;
>>> +case WFUNC_MNUTTALL3:
>>> +win = 0.4243801 + 0.4973406 * cos(u) + 0.0782793 * 
>>> cos(2*u);
>>> +break;
>>> +case WFUNC_NUTTALL:
>>> +win = 0.355768 + 0.487396 * cos(u) + 0.144232 * cos(2*u) + 
>>> 0.012604 * cos(3*u);
>>> +break;
>>> +case WFUNC_BNUTTALL:
>>> +win = 0.3635819 + 0.4891775 * cos(u) + 0.1365995 * 
>>> cos(2*u) + 0.0106411 * cos(3*u);
>>> +break;
>>> +case WFUNC_BHARRIS:
>>> +win = 0.35875 + 0.48829 * cos(u) + 0.14128 * cos(2*u) + 
>>> 0.01168 * cos(3*u);
>>> +break;
>>
>> What about using libavfilter/window_func.c ?
>
> My version calculate half-length zero centered window. Incompatible
> with ff_generate_window_func()
>
>>
>> Still LGTM.

Pushed

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


Re: [FFmpeg-devel] [PATCH] avfilter: add firequalizer filter

2016-02-19 Thread Muhammad Faiz
On Fri, Feb 19, 2016 at 3:52 AM, Paul B Mahol  wrote:
>> +center = s->fir_len / 2;
>> +
>> +for (k = 0; k <= center; k++) {
>> +double u = k * (M_PI/center);
>> +double win;
>> +switch (s->wfunc) {
>> +case WFUNC_RECTANGULAR:
>> +win = 1.0;
>> +break;
>> +case WFUNC_HANN:
>> +win = 0.5 + 0.5 * cos(u);
>> +break;
>> +case WFUNC_HAMMING:
>> +win = 0.53836 + 0.46164 * cos(u);
>> +break;
>> +case WFUNC_BLACKMAN:
>> +win = 0.48 + 0.5 * cos(u) + 0.02 * cos(2*u);
>> +break;
>> +case WFUNC_NUTTALL3:
>> +win = 0.40897 + 0.5 * cos(u) + 0.09103 * cos(2*u);
>> +break;
>> +case WFUNC_MNUTTALL3:
>> +win = 0.4243801 + 0.4973406 * cos(u) + 0.0782793 * cos(2*u);
>> +break;
>> +case WFUNC_NUTTALL:
>> +win = 0.355768 + 0.487396 * cos(u) + 0.144232 * cos(2*u) + 
>> 0.012604 * cos(3*u);
>> +break;
>> +case WFUNC_BNUTTALL:
>> +win = 0.3635819 + 0.4891775 * cos(u) + 0.1365995 * cos(2*u) 
>> + 0.0106411 * cos(3*u);
>> +break;
>> +case WFUNC_BHARRIS:
>> +win = 0.35875 + 0.48829 * cos(u) + 0.14128 * cos(2*u) + 
>> 0.01168 * cos(3*u);
>> +break;
>
> What about using libavfilter/window_func.c ?

My version calculate half-length zero centered window. Incompatible
with ff_generate_window_func()

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


Re: [FFmpeg-devel] [PATCH] avfilter: add firequalizer filter

2016-02-18 Thread Paul B Mahol
> +center = s->fir_len / 2;
> +
> +for (k = 0; k <= center; k++) {
> +double u = k * (M_PI/center);
> +double win;
> +switch (s->wfunc) {
> +case WFUNC_RECTANGULAR:
> +win = 1.0;
> +break;
> +case WFUNC_HANN:
> +win = 0.5 + 0.5 * cos(u);
> +break;
> +case WFUNC_HAMMING:
> +win = 0.53836 + 0.46164 * cos(u);
> +break;
> +case WFUNC_BLACKMAN:
> +win = 0.48 + 0.5 * cos(u) + 0.02 * cos(2*u);
> +break;
> +case WFUNC_NUTTALL3:
> +win = 0.40897 + 0.5 * cos(u) + 0.09103 * cos(2*u);
> +break;
> +case WFUNC_MNUTTALL3:
> +win = 0.4243801 + 0.4973406 * cos(u) + 0.0782793 * cos(2*u);
> +break;
> +case WFUNC_NUTTALL:
> +win = 0.355768 + 0.487396 * cos(u) + 0.144232 * cos(2*u) + 
> 0.012604 * cos(3*u);
> +break;
> +case WFUNC_BNUTTALL:
> +win = 0.3635819 + 0.4891775 * cos(u) + 0.1365995 * cos(2*u) 
> + 0.0106411 * cos(3*u);
> +break;
> +case WFUNC_BHARRIS:
> +win = 0.35875 + 0.48829 * cos(u) + 0.14128 * cos(2*u) + 
> 0.01168 * cos(3*u);
> +break;

What about using libavfilter/window_func.c ?

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


Re: [FFmpeg-devel] [PATCH] avfilter: add firequalizer filter

2016-02-16 Thread Muhammad Faiz
On Tue, Feb 16, 2016 at 6:48 PM, Paul B Mahol  wrote:
> On 2/16/16, Muhammad Faiz  wrote:
>> patch attached
>>
>> thank's
>>
>>
>> ---
>>  Changelog |   1 +
>>  MAINTAINERS   |   1 +
>>  configure |   2 +
>>  doc/filters.texi  | 109 
>>  libavfilter/Makefile  |   1 +
>>  libavfilter/af_firequalizer.c | 592 
>> ++
>>  libavfilter/allfilters.c  |   1 +
>>  libavfilter/version.h |   2 +-
>>  8 files changed, 708 insertions(+), 1 deletion(-)
>>  create mode 100644 libavfilter/af_firequalizer.c
>>
>> diff --git a/Changelog b/Changelog
>> index 96a9955..1794164 100644
>> --- a/Changelog
>> +++ b/Changelog
>> @@ -2,6 +2,7 @@ Entries are sorted chronologically from oldest to youngest 
>> within each release,
>>  releases are sorted from youngest to oldest.
>>
>>  version :
>> +- firequalizer filter
>>
>
> Interesting.
>
>>
>>  version 3.0:
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index e57150d..9f7baf0 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -353,6 +353,7 @@ Filters:
>>af_biquads.c  Paul B Mahol
>>af_chorus.c   Paul B Mahol
>>af_compand.c  Paul B Mahol
>> +  af_firequalizer.c Muhammad Faiz
>>af_ladspa.c   Paul B Mahol
>>af_pan.c  Nicolas George
>>af_sidechaincompress.cPaul B Mahol
>> diff --git a/configure b/configure
>> index 2148f11..b775cb9 100755
>> --- a/configure
>> +++ b/configure
>> @@ -2857,6 +2857,8 @@ eq_filter_deps="gpl"
>>  fftfilt_filter_deps="avcodec"
>>  fftfilt_filter_select="rdft"
>>  find_rect_filter_deps="avcodec avformat gpl"
>> +firequalizer_filter_deps="avcodec"
>> +firequalizer_filter_select="rdft"
>>  flite_filter_deps="libflite"
>>  frei0r_filter_deps="frei0r dlopen"
>>  frei0r_src_filter_deps="frei0r dlopen"
>> diff --git a/doc/filters.texi b/doc/filters.texi
>> index 68f54f1..67506dc 100644
>> --- a/doc/filters.texi
>> +++ b/doc/filters.texi
>> @@ -2366,6 +2366,115 @@ Sets the difference coefficient (default: 2.5). 0.0 
>> means mono sound
>>  Enable clipping. By default is enabled.
>>  @end table
>>
>> +@section firequalizer
>> +Apply FIR Equalization using arbitrary frequency response.
>> +
>> +The filter accepts the following option:
>> +
>> +@table @option
>> +@item gain
>> +Set gain curve equation (in dB). The expression can contain variables:
>> +@table @option
>> +@item f
>> +the evaluated frequency
>> +@item sr
>> +sample rate
>> +@item ch
>> +channel number, set to 0 when multichannels evaluation is disabled
>> +@item chid
>> +channel id, see libavutil/channel_layout.h, set to the first channel id when
>> +multichannels evaluation is disabled
>> +@item chs
>> +number of channels
>> +@item chlayout
>> +channel_layout, see libavutil/channel_layout.h
>> +
>> +@end table
>> +and functions:
>> +@table @option
>> +@item gain_interpolate(f)
>> +interpote gain on frequency f based on gain_entry
>> +@end table
>> +This option is also available as command. Default is 
>> @code{gain_interpolate(f)}.
>> +
>> +@item gain_entry
>> +Set gain entry for gain_interpolate function. The expression can
>> +contain functions:
>> +@table @option
>> +@item entry(f, g)
>> +store gain entry at frequency f with value g
>> +@end table
>> +This option is also available as command.
>> +
>> +@item delay
>> +Set filter delay in seconds. Higher value means more accurate.
>> +Default is @code{0.01}.
>> +
>> +@item accuracy
>> +Set filter accuracy in Hz. Lower value means more accurate.
>> +Default is @code{5}.
>> +
>> +@item wfunc
>> +Set window function. Acceptable values are:
>> +@table @option
>> +@item rectangular
>> +rectangular window, useful when gain curve is already smooth
>> +@item hann
>> +hann window (default)
>> +@item hamming
>> +hamming window
>> +@item blackman
>> +blackman window
>> +@item nuttall3
>> +3-terms continuous 1st derivative nuttall window
>> +@item mnuttall3
>> +minimum 3-terms discontinuous nuttall window
>> +@item nuttall
>> +4-terms continuous 1st derivative nuttall window
>> +@item bnuttall
>> +minimum 4-terms discontinuous nuttall (blackman-nuttall) window
>> +@item bharris
>> +blackman-harris window
>> +@end table
>> +
>> +@item fixed
>> +If enabled, use fixed number of audio samples. This improves speed when
>> +filtering with large delay. Default is disabled.
>> +
>> +@item multi
>> +Enable multichannels evaluation on gain. Default is disabled.
>> +@end table
>> +
>> +@subsection Examples
>> +@itemize
>> +@item
>> +lowpass at 1000 Hz:
>> +@example
>> +firequalizer=gain='if(lt(f,1000), 0, -INF)'
>> +@end example
>> +@item
>> +lowpass at 1000 Hz with gain_entry:
>> +@example
>> +firequalizer=gain_entry='entry(1000,0); entry(1001, -INF)'
>> +@end example
>> +@item
>> +custom equalization:
>> +@example
>> 

Re: [FFmpeg-devel] [PATCH] avfilter: add firequalizer filter

2016-02-16 Thread Paul B Mahol
On 2/16/16, Muhammad Faiz  wrote:
> patch attached
>
> thank's
>
>
> ---
>  Changelog |   1 +
>  MAINTAINERS   |   1 +
>  configure |   2 +
>  doc/filters.texi  | 109 
>  libavfilter/Makefile  |   1 +
>  libavfilter/af_firequalizer.c | 592 
> ++
>  libavfilter/allfilters.c  |   1 +
>  libavfilter/version.h |   2 +-
>  8 files changed, 708 insertions(+), 1 deletion(-)
>  create mode 100644 libavfilter/af_firequalizer.c
>
> diff --git a/Changelog b/Changelog
> index 96a9955..1794164 100644
> --- a/Changelog
> +++ b/Changelog
> @@ -2,6 +2,7 @@ Entries are sorted chronologically from oldest to youngest 
> within each release,
>  releases are sorted from youngest to oldest.
>
>  version :
> +- firequalizer filter
>

Interesting.

>
>  version 3.0:
> diff --git a/MAINTAINERS b/MAINTAINERS
> index e57150d..9f7baf0 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -353,6 +353,7 @@ Filters:
>af_biquads.c  Paul B Mahol
>af_chorus.c   Paul B Mahol
>af_compand.c  Paul B Mahol
> +  af_firequalizer.c Muhammad Faiz
>af_ladspa.c   Paul B Mahol
>af_pan.c  Nicolas George
>af_sidechaincompress.cPaul B Mahol
> diff --git a/configure b/configure
> index 2148f11..b775cb9 100755
> --- a/configure
> +++ b/configure
> @@ -2857,6 +2857,8 @@ eq_filter_deps="gpl"
>  fftfilt_filter_deps="avcodec"
>  fftfilt_filter_select="rdft"
>  find_rect_filter_deps="avcodec avformat gpl"
> +firequalizer_filter_deps="avcodec"
> +firequalizer_filter_select="rdft"
>  flite_filter_deps="libflite"
>  frei0r_filter_deps="frei0r dlopen"
>  frei0r_src_filter_deps="frei0r dlopen"
> diff --git a/doc/filters.texi b/doc/filters.texi
> index 68f54f1..67506dc 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -2366,6 +2366,115 @@ Sets the difference coefficient (default: 2.5). 0.0 
> means mono sound
>  Enable clipping. By default is enabled.
>  @end table
>
> +@section firequalizer
> +Apply FIR Equalization using arbitrary frequency response.
> +
> +The filter accepts the following option:
> +
> +@table @option
> +@item gain
> +Set gain curve equation (in dB). The expression can contain variables:
> +@table @option
> +@item f
> +the evaluated frequency
> +@item sr
> +sample rate
> +@item ch
> +channel number, set to 0 when multichannels evaluation is disabled
> +@item chid
> +channel id, see libavutil/channel_layout.h, set to the first channel id when
> +multichannels evaluation is disabled
> +@item chs
> +number of channels
> +@item chlayout
> +channel_layout, see libavutil/channel_layout.h
> +
> +@end table
> +and functions:
> +@table @option
> +@item gain_interpolate(f)
> +interpote gain on frequency f based on gain_entry
> +@end table
> +This option is also available as command. Default is 
> @code{gain_interpolate(f)}.
> +
> +@item gain_entry
> +Set gain entry for gain_interpolate function. The expression can
> +contain functions:
> +@table @option
> +@item entry(f, g)
> +store gain entry at frequency f with value g
> +@end table
> +This option is also available as command.
> +
> +@item delay
> +Set filter delay in seconds. Higher value means more accurate.
> +Default is @code{0.01}.
> +
> +@item accuracy
> +Set filter accuracy in Hz. Lower value means more accurate.
> +Default is @code{5}.
> +
> +@item wfunc
> +Set window function. Acceptable values are:
> +@table @option
> +@item rectangular
> +rectangular window, useful when gain curve is already smooth
> +@item hann
> +hann window (default)
> +@item hamming
> +hamming window
> +@item blackman
> +blackman window
> +@item nuttall3
> +3-terms continuous 1st derivative nuttall window
> +@item mnuttall3
> +minimum 3-terms discontinuous nuttall window
> +@item nuttall
> +4-terms continuous 1st derivative nuttall window
> +@item bnuttall
> +minimum 4-terms discontinuous nuttall (blackman-nuttall) window
> +@item bharris
> +blackman-harris window
> +@end table
> +
> +@item fixed
> +If enabled, use fixed number of audio samples. This improves speed when
> +filtering with large delay. Default is disabled.
> +
> +@item multi
> +Enable multichannels evaluation on gain. Default is disabled.
> +@end table
> +
> +@subsection Examples
> +@itemize
> +@item
> +lowpass at 1000 Hz:
> +@example
> +firequalizer=gain='if(lt(f,1000), 0, -INF)'
> +@end example
> +@item
> +lowpass at 1000 Hz with gain_entry:
> +@example
> +firequalizer=gain_entry='entry(1000,0); entry(1001, -INF)'
> +@end example
> +@item
> +custom equalization:
> +@example
> +firequalizer=gain_entry='entry(100,0); entry(400, -4); entry(1000, -6); 
> entry(2000, 0)'
> +@end example
> +@item
> +higher delay:
> +@example
> +firequalizer=delay=0.1:fixed=on
> +@end example
> +@item
> +lowpass on left channel, highpass 

[FFmpeg-devel] [PATCH] avfilter: add firequalizer filter

2016-02-16 Thread Muhammad Faiz
patch attached

thank's
From 5ec5d798e974f690d881787b7272ed23b7d4bdbc Mon Sep 17 00:00:00 2001
From: Muhammad Faiz 
Date: Tue, 16 Feb 2016 17:03:08 +0700
Subject: [PATCH] avfilter: add firequalizer filter

---
 Changelog |   1 +
 MAINTAINERS   |   1 +
 configure |   2 +
 doc/filters.texi  | 109 
 libavfilter/Makefile  |   1 +
 libavfilter/af_firequalizer.c | 592 ++
 libavfilter/allfilters.c  |   1 +
 libavfilter/version.h |   2 +-
 8 files changed, 708 insertions(+), 1 deletion(-)
 create mode 100644 libavfilter/af_firequalizer.c

diff --git a/Changelog b/Changelog
index 96a9955..1794164 100644
--- a/Changelog
+++ b/Changelog
@@ -2,6 +2,7 @@ Entries are sorted chronologically from oldest to youngest within each release,
 releases are sorted from youngest to oldest.
 
 version :
+- firequalizer filter
 
 
 version 3.0:
diff --git a/MAINTAINERS b/MAINTAINERS
index e57150d..9f7baf0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -353,6 +353,7 @@ Filters:
   af_biquads.c  Paul B Mahol
   af_chorus.c   Paul B Mahol
   af_compand.c  Paul B Mahol
+  af_firequalizer.c Muhammad Faiz
   af_ladspa.c   Paul B Mahol
   af_pan.c  Nicolas George
   af_sidechaincompress.cPaul B Mahol
diff --git a/configure b/configure
index 2148f11..b775cb9 100755
--- a/configure
+++ b/configure
@@ -2857,6 +2857,8 @@ eq_filter_deps="gpl"
 fftfilt_filter_deps="avcodec"
 fftfilt_filter_select="rdft"
 find_rect_filter_deps="avcodec avformat gpl"
+firequalizer_filter_deps="avcodec"
+firequalizer_filter_select="rdft"
 flite_filter_deps="libflite"
 frei0r_filter_deps="frei0r dlopen"
 frei0r_src_filter_deps="frei0r dlopen"
diff --git a/doc/filters.texi b/doc/filters.texi
index 68f54f1..67506dc 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -2366,6 +2366,115 @@ Sets the difference coefficient (default: 2.5). 0.0 means mono sound
 Enable clipping. By default is enabled.
 @end table
 
+@section firequalizer
+Apply FIR Equalization using arbitrary frequency response.
+
+The filter accepts the following option:
+
+@table @option
+@item gain
+Set gain curve equation (in dB). The expression can contain variables:
+@table @option
+@item f
+the evaluated frequency
+@item sr
+sample rate
+@item ch
+channel number, set to 0 when multichannels evaluation is disabled
+@item chid
+channel id, see libavutil/channel_layout.h, set to the first channel id when
+multichannels evaluation is disabled
+@item chs
+number of channels
+@item chlayout
+channel_layout, see libavutil/channel_layout.h
+
+@end table
+and functions:
+@table @option
+@item gain_interpolate(f)
+interpote gain on frequency f based on gain_entry
+@end table
+This option is also available as command. Default is @code{gain_interpolate(f)}.
+
+@item gain_entry
+Set gain entry for gain_interpolate function. The expression can
+contain functions:
+@table @option
+@item entry(f, g)
+store gain entry at frequency f with value g
+@end table
+This option is also available as command.
+
+@item delay
+Set filter delay in seconds. Higher value means more accurate.
+Default is @code{0.01}.
+
+@item accuracy
+Set filter accuracy in Hz. Lower value means more accurate.
+Default is @code{5}.
+
+@item wfunc
+Set window function. Acceptable values are:
+@table @option
+@item rectangular
+rectangular window, useful when gain curve is already smooth
+@item hann
+hann window (default)
+@item hamming
+hamming window
+@item blackman
+blackman window
+@item nuttall3
+3-terms continuous 1st derivative nuttall window
+@item mnuttall3
+minimum 3-terms discontinuous nuttall window
+@item nuttall
+4-terms continuous 1st derivative nuttall window
+@item bnuttall
+minimum 4-terms discontinuous nuttall (blackman-nuttall) window
+@item bharris
+blackman-harris window
+@end table
+
+@item fixed
+If enabled, use fixed number of audio samples. This improves speed when
+filtering with large delay. Default is disabled.
+
+@item multi
+Enable multichannels evaluation on gain. Default is disabled.
+@end table
+
+@subsection Examples
+@itemize
+@item
+lowpass at 1000 Hz:
+@example
+firequalizer=gain='if(lt(f,1000), 0, -INF)'
+@end example
+@item
+lowpass at 1000 Hz with gain_entry:
+@example
+firequalizer=gain_entry='entry(1000,0); entry(1001, -INF)'
+@end example
+@item
+custom equalization:
+@example
+firequalizer=gain_entry='entry(100,0); entry(400, -4); entry(1000, -6); entry(2000, 0)'
+@end example
+@item
+higher delay:
+@example
+firequalizer=delay=0.1:fixed=on
+@end example
+@item
+lowpass on left channel, highpass on right channel:
+@example
+firequalizer=gain='if(eq(chid,1), gain_interpolate(f), if(eq(chid,2), gain_interpolate(1e6+f), 0))'
+:gain_entry='entry(1000, 0); entry(1001,-INF);