From patchwork Tue Jun 2 18:35:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 20129 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 70F6044B1DA for ; Tue, 2 Jun 2020 21:35:17 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5EF1D68AA35; Tue, 2 Jun 2020 21:35:17 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 58F8B681866 for ; Tue, 2 Jun 2020 21:35:10 +0300 (EEST) X-ENS-nef-client: 129.199.129.80 Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef.ens.fr (8.14.4/1.01.28121999) with ESMTP id 052IZ9mo023810 for ; Tue, 2 Jun 2020 20:35:09 +0200 Received: by phare.normalesup.org (Postfix, from userid 1001) id 6947FE977F; Tue, 2 Jun 2020 20:35:09 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Tue, 2 Jun 2020 20:35:05 +0200 Message-Id: <20200602183506.491783-2-george@nsup.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200602183506.491783-1-george@nsup.org> References: <20200602183506.491783-1-george@nsup.org> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Tue, 02 Jun 2020 20:35:09 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 2/3] lavfi/sine: switch to activate. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Allow to set the EOF timestamp. Signed-off-by: Nicolas George --- libavfilter/asrc_sine.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libavfilter/asrc_sine.c b/libavfilter/asrc_sine.c index 8fff1dda8b..947bc9a288 100644 --- a/libavfilter/asrc_sine.c +++ b/libavfilter/asrc_sine.c @@ -26,6 +26,7 @@ #include "libavutil/opt.h" #include "audio.h" #include "avfilter.h" +#include "filters.h" #include "internal.h" #include "intsine.h" @@ -171,9 +172,10 @@ static av_cold int config_props(AVFilterLink *outlink) return 0; } -static int request_frame(AVFilterLink *outlink) +static int activate(AVFilterContext *ctx) { - SineContext *sine = outlink->src->priv; + AVFilterLink *outlink = ctx->outputs[0]; + SineContext *sine = ctx->priv; AVFrame *frame; double values[VAR_VARS_NB] = { [VAR_N] = outlink->frame_count_in, @@ -184,6 +186,8 @@ static int request_frame(AVFilterLink *outlink) int i, nb_samples = lrint(av_expr_eval(sine->samples_per_frame_expr, values, sine)); int16_t *samples; + if (!ff_outlink_frame_wanted(outlink)) + return FFERROR_NOT_READY; if (nb_samples <= 0) { av_log(sine, AV_LOG_WARNING, "nb samples expression evaluated to %d, " "defaulting to 1024\n", nb_samples); @@ -193,8 +197,10 @@ static int request_frame(AVFilterLink *outlink) if (sine->duration) { nb_samples = FFMIN(nb_samples, sine->duration - sine->pts); av_assert1(nb_samples >= 0); - if (!nb_samples) - return AVERROR_EOF; + if (!nb_samples) { + ff_outlink_set_status(outlink, AVERROR_EOF, sine->pts); + return 0; + } } if (!(frame = ff_get_audio_buffer(outlink, nb_samples))) return AVERROR(ENOMEM); @@ -220,7 +226,6 @@ static const AVFilterPad sine_outputs[] = { { .name = "default", .type = AVMEDIA_TYPE_AUDIO, - .request_frame = request_frame, .config_props = config_props, }, { NULL } @@ -232,6 +237,7 @@ AVFilter ff_asrc_sine = { .query_formats = query_formats, .init = init, .uninit = uninit, + .activate = activate, .priv_size = sizeof(SineContext), .inputs = NULL, .outputs = sine_outputs,