[FFmpeg-cvslog] avfilter/aevalsrc: switch to activate

Paul B Mahol git at videolan.org
Sat Aug 21 17:46:02 EEST 2021


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sat Aug 21 16:37:20 2021 +0200| [99ccad843f51e2fc16a8dada225a14928bd46fa6] | committer: Paul B Mahol

avfilter/aevalsrc: switch to activate

Allow to set the EOF timestamp.

FATE test is updated, as last 2 frames were duplicated.

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

 libavfilter/aeval.c                        | 15 +++++++++++----
 tests/ref/fate/ffmpeg-filter_complex_audio |  2 --
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/libavfilter/aeval.c b/libavfilter/aeval.c
index 7cb05d206a..5f0f25dd59 100644
--- a/libavfilter/aeval.c
+++ b/libavfilter/aeval.c
@@ -30,6 +30,7 @@
 #include "libavutil/parseutils.h"
 #include "avfilter.h"
 #include "audio.h"
+#include "filters.h"
 #include "internal.h"
 
 static const char * const var_names[] = {
@@ -259,21 +260,27 @@ static int query_formats(AVFilterContext *ctx)
     return ff_set_common_samplerates_from_list(ctx, sample_rates);
 }
 
-static int request_frame(AVFilterLink *outlink)
+static int activate(AVFilterContext *ctx)
 {
+    AVFilterLink *outlink = ctx->outputs[0];
     EvalContext *eval = outlink->src->priv;
     AVFrame *samplesref;
     int i, j;
     int64_t t = av_rescale(eval->n, AV_TIME_BASE, eval->sample_rate);
     int nb_samples;
 
+    if (!ff_outlink_frame_wanted(outlink))
+        return FFERROR_NOT_READY;
+
     if (eval->duration >= 0 && t >= eval->duration)
         return AVERROR_EOF;
 
     if (eval->duration >= 0) {
         nb_samples = FFMIN(eval->nb_samples, av_rescale(eval->duration, eval->sample_rate, AV_TIME_BASE) - eval->pts);
-        if (!nb_samples)
-            return AVERROR_EOF;
+        if (!nb_samples) {
+            ff_outlink_set_status(outlink, AVERROR_EOF, eval->pts);
+            return 0;
+        }
     } else {
         nb_samples = eval->nb_samples;
     }
@@ -305,7 +312,6 @@ static const AVFilterPad aevalsrc_outputs[] = {
         .name          = "default",
         .type          = AVMEDIA_TYPE_AUDIO,
         .config_props  = config_props,
-        .request_frame = request_frame,
     },
 };
 
@@ -315,6 +321,7 @@ const AVFilter ff_asrc_aevalsrc = {
     .query_formats = query_formats,
     .init          = init,
     .uninit        = uninit,
+    .activate      = activate,
     .priv_size     = sizeof(EvalContext),
     .inputs        = NULL,
     FILTER_OUTPUTS(aevalsrc_outputs),
diff --git a/tests/ref/fate/ffmpeg-filter_complex_audio b/tests/ref/fate/ffmpeg-filter_complex_audio
index c424675061..649f0def43 100644
--- a/tests/ref/fate/ffmpeg-filter_complex_audio
+++ b/tests/ref/fate/ffmpeg-filter_complex_audio
@@ -6,5 +6,3 @@
 #channel_layout_name 0: mono
 0,       -256,       -256,     1536,      416, 0x3001fb2d
 0,       1280,       1280,     1536,      418, 0xba72fc16
-0,       2816,       2816,     1536,      418, 0xba72fc16
-0,       4352,       4352,     1536,      418, 0xba72fc16



More information about the ffmpeg-cvslog mailing list