[FFmpeg-cvslog] avfilter/af_firequalizer: add zero_phase option

Muhammad Faiz git at videolan.org
Tue Jun 7 03:01:35 CEST 2016


ffmpeg | branch: master | Muhammad Faiz <mfcc64 at gmail.com> | Mon Jun  6 06:28:09 2016 +0700| [77d4dfbec69f6697ba8931ffa8833bf9bda96ce6] | committer: Muhammad Faiz

avfilter/af_firequalizer: add zero_phase option

simply by substracting pts to compensate delay
also handle AV_NOPTS_VALUE

Signed-off-by: Muhammad Faiz <mfcc64 at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=77d4dfbec69f6697ba8931ffa8833bf9bda96ce6
---

 doc/filters.texi              |    8 ++++++--
 libavfilter/af_firequalizer.c |    9 ++++++++-
 libavfilter/version.h         |    2 +-
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 707fb04..d9330e3 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -2443,6 +2443,10 @@ filtering with large delay. Default is disabled.
 
 @item multi
 Enable multichannels evaluation on gain. Default is disabled.
+
+ at item zero_phase
+Enable zero phase mode by substracting timestamp to compensate delay.
+Default is disabled.
 @end table
 
 @subsection Examples
@@ -2463,9 +2467,9 @@ custom equalization:
 firequalizer=gain_entry='entry(100,0); entry(400, -4); entry(1000, -6); entry(2000, 0)'
 @end example
 @item
-higher delay:
+higher delay with zero phase to compensate delay:
 @example
-firequalizer=delay=0.1:fixed=on
+firequalizer=delay=0.1:fixed=on:zero_phase=on
 @end example
 @item
 lowpass on left channel, highpass on right channel:
diff --git a/libavfilter/af_firequalizer.c b/libavfilter/af_firequalizer.c
index a5c3550..6a9c641 100644
--- a/libavfilter/af_firequalizer.c
+++ b/libavfilter/af_firequalizer.c
@@ -83,6 +83,7 @@ typedef struct {
     int           wfunc;
     int           fixed;
     int           multi;
+    int           zero_phase;
 
     int           nb_gain_entry;
     int           gain_entry_err;
@@ -109,6 +110,7 @@ static const AVOption firequalizer_options[] = {
         { "bharris", "blackman-harris window", 0, AV_OPT_TYPE_CONST, { .i64 = WFUNC_BHARRIS }, 0, 0, FLAGS, "wfunc" },
     { "fixed", "set fixed frame samples", OFFSET(fixed), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
     { "multi", "set multi channels mode", OFFSET(multi), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
+    { "zero_phase", "set zero phase mode", OFFSET(zero_phase), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
     { NULL }
 };
 
@@ -493,7 +495,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
                        (float *) frame->extended_data[ch], frame->nb_samples);
     }
 
-    s->next_pts = frame->pts + av_rescale_q(frame->nb_samples, av_make_q(1, inlink->sample_rate), inlink->time_base);
+    s->next_pts = AV_NOPTS_VALUE;
+    if (frame->pts != AV_NOPTS_VALUE) {
+        s->next_pts = frame->pts + av_rescale_q(frame->nb_samples, av_make_q(1, inlink->sample_rate), inlink->time_base);
+        if (s->zero_phase)
+            frame->pts -= av_rescale_q(s->fir_len/2, av_make_q(1, inlink->sample_rate), inlink->time_base);
+    }
     s->frame_nsamples_max = FFMAX(s->frame_nsamples_max, frame->nb_samples);
     return ff_filter_frame(ctx->outputs[0], frame);
 }
diff --git a/libavfilter/version.h b/libavfilter/version.h
index d693d6d..cb9b092 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,7 +31,7 @@
 
 #define LIBAVFILTER_VERSION_MAJOR   6
 #define LIBAVFILTER_VERSION_MINOR  46
-#define LIBAVFILTER_VERSION_MICRO 100
+#define LIBAVFILTER_VERSION_MICRO 101
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
                                                LIBAVFILTER_VERSION_MINOR, \



More information about the ffmpeg-cvslog mailing list