[FFmpeg-cvslog] avfilter/af_afir: kill useless code which increases latency for no reason

Paul B Mahol git at videolan.org
Fri Nov 9 12:41:39 EET 2018


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Nov  9 10:40:16 2018 +0100| [16d91b7e99cd65ddb098de7b38f2f51277c97083] | committer: Paul B Mahol

avfilter/af_afir: kill useless code which increases latency for no reason

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

 libavfilter/af_afir.c | 41 +++++++++--------------------------------
 libavfilter/af_afir.h |  2 --
 2 files changed, 9 insertions(+), 34 deletions(-)

diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c
index f12049f7ba..efdd6bb883 100644
--- a/libavfilter/af_afir.c
+++ b/libavfilter/af_afir.c
@@ -120,16 +120,13 @@ static int fir_frame(AudioFIRContext *s, AVFrame *in, AVFilterLink *outlink)
 {
     AVFilterContext *ctx = outlink->src;
     AVFrame *out = NULL;
-    int ret;
 
     s->nb_samples = in->nb_samples;
 
-    if (!s->want_skip) {
-        out = ff_get_audio_buffer(outlink, s->nb_samples);
-        if (!out) {
-            av_frame_free(&in);
-            return AVERROR(ENOMEM);
-        }
+    out = ff_get_audio_buffer(outlink, s->nb_samples);
+    if (!out) {
+        av_frame_free(&in);
+        return AVERROR(ENOMEM);
     }
 
     if (s->pts == AV_NOPTS_VALUE)
@@ -139,11 +136,9 @@ static int fir_frame(AudioFIRContext *s, AVFrame *in, AVFilterLink *outlink)
 
     s->part_index = (s->part_index + 1) % s->nb_partitions;
 
-    if (!s->want_skip) {
-        out->pts = s->pts;
-        if (s->pts != AV_NOPTS_VALUE)
-            s->pts += av_rescale_q(out->nb_samples, (AVRational){1, outlink->sample_rate}, outlink->time_base);
-    }
+    out->pts = s->pts;
+    if (s->pts != AV_NOPTS_VALUE)
+        s->pts += av_rescale_q(out->nb_samples, (AVRational){1, outlink->sample_rate}, outlink->time_base);
 
     s->index++;
     if (s->index == 3)
@@ -152,14 +147,7 @@ static int fir_frame(AudioFIRContext *s, AVFrame *in, AVFilterLink *outlink)
     av_frame_free(&in);
     s->in[0] = NULL;
 
-    if (s->want_skip == 1) {
-        s->want_skip = 0;
-        ret = 0;
-    } else {
-        ret = ff_filter_frame(outlink, out);
-    }
-
-    return ret;
+    return ff_filter_frame(outlink, out);
 }
 
 static void drawtext(AVFrame *pic, int x, int y, const char *txt, uint32_t color)
@@ -496,16 +484,7 @@ static int activate(AVFilterContext *ctx)
             return ret;
     }
 
-    if (s->need_padding) {
-        in = ff_get_audio_buffer(outlink, s->part_size);
-        if (!in)
-            return AVERROR(ENOMEM);
-        s->need_padding = 0;
-        ret = 1;
-    } else {
-        ret = ff_inlink_consume_samples(ctx->inputs[0], s->part_size, s->part_size, &in);
-    }
-
+    ret = ff_inlink_consume_samples(ctx->inputs[0], s->part_size, s->part_size, &in);
     if (ret > 0)
         ret = fir_frame(s, in, outlink);
 
@@ -626,8 +605,6 @@ static int config_output(AVFilterLink *outlink)
 
     s->nb_channels = outlink->channels;
     s->nb_coef_channels = ctx->inputs[1]->channels;
-    s->want_skip = 1;
-    s->need_padding = 1;
     s->pts = AV_NOPTS_VALUE;
 
     return 0;
diff --git a/libavfilter/af_afir.h b/libavfilter/af_afir.h
index f6727edf0e..13f7c98d72 100644
--- a/libavfilter/af_afir.h
+++ b/libavfilter/af_afir.h
@@ -66,8 +66,6 @@ typedef struct AudioFIRContext {
     int nb_coef_channels;
     int one2many;
     int nb_samples;
-    int want_skip;
-    int need_padding;
 
     RDFTContext **rdft, **irdft;
     float **sum;



More information about the ffmpeg-cvslog mailing list