From patchwork Wed Aug 12 17:25:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 21610 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 BB87F44B8F5 for ; Wed, 12 Aug 2020 20:26:11 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A83D568B56C; Wed, 12 Aug 2020 20:26:11 +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 78B1568B51C for ; Wed, 12 Aug 2020 20:26:04 +0300 (EEST) X-ENS-nef-client: 129.199.129.80 ( name = phare.normalesup.org ) 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 07CHQ3Rd007293 for ; Wed, 12 Aug 2020 19:26:04 +0200 Received: by phare.normalesup.org (Postfix, from userid 1001) id 918B8E8C4D; Wed, 12 Aug 2020 19:26:03 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Aug 2020 19:25:58 +0200 Message-Id: <20200812172558.262021-4-george@nsup.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200812172558.262021-1-george@nsup.org> References: <20200812172558.262021-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]); Wed, 12 Aug 2020 19:26:04 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 4/4] lavfi: remove request_samples. 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" Filters can use min_samples/max_samples if the number is constant or activate and ff_inlink_consume_samples(). Signed-off-by: Nicolas George --- libavfilter/avfilter.h | 8 ---- libavfilter/fifo.c | 99 ++---------------------------------------- 2 files changed, 3 insertions(+), 104 deletions(-) diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index fcab450f47..6acceb2a18 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -490,14 +490,6 @@ struct AVFilterLink { struct AVFilterChannelLayouts *in_channel_layouts; struct AVFilterChannelLayouts *out_channel_layouts; - /** - * Audio only, the destination filter sets this to a non-zero value to - * request that buffers with the given number of samples should be sent to - * it. - * Last buffer before EOF will be padded with silence. - */ - int request_samples; - /** stage of the initialization of the link properties (dimensions, etc) */ enum { AVLINK_UNINIT = 0, ///< not started diff --git a/libavfilter/fifo.c b/libavfilter/fifo.c index f5587df62a..70f4876a50 100644 --- a/libavfilter/fifo.c +++ b/libavfilter/fifo.c @@ -143,112 +143,19 @@ static int calc_ptr_alignment(AVFrame *frame) return min_align; } -static int return_audio_frame(AVFilterContext *ctx) -{ - AVFilterLink *link = ctx->outputs[0]; - FifoContext *s = ctx->priv; - AVFrame *head = s->root.next ? s->root.next->frame : NULL; - AVFrame *out; - int ret; - - /* if head is NULL then we're flushing the remaining samples in out */ - if (!head && !s->out) - return AVERROR_EOF; - - if (!s->out && - head->nb_samples >= link->request_samples && - calc_ptr_alignment(head) >= 32) { - if (head->nb_samples == link->request_samples) { - out = head; - queue_pop(s); - } else { - out = av_frame_clone(head); - if (!out) - return AVERROR(ENOMEM); - - out->nb_samples = link->request_samples; - buffer_offset(link, head, link->request_samples); - } - } else { - int nb_channels = link->channels; - - if (!s->out) { - s->out = ff_get_audio_buffer(link, link->request_samples); - if (!s->out) - return AVERROR(ENOMEM); - - s->out->nb_samples = 0; - s->out->pts = head->pts; - s->allocated_samples = link->request_samples; - } else if (link->request_samples != s->allocated_samples) { - av_log(ctx, AV_LOG_ERROR, "request_samples changed before the " - "buffer was returned.\n"); - return AVERROR(EINVAL); - } - - while (s->out->nb_samples < s->allocated_samples) { - int len; - - if (!s->root.next) { - ret = ff_request_frame(ctx->inputs[0]); - if (ret == AVERROR_EOF) { - av_samples_set_silence(s->out->extended_data, - s->out->nb_samples, - s->allocated_samples - - s->out->nb_samples, - nb_channels, link->format); - s->out->nb_samples = s->allocated_samples; - break; - } else if (ret < 0) - return ret; - if (!s->root.next) - return 0; - } - head = s->root.next->frame; - - len = FFMIN(s->allocated_samples - s->out->nb_samples, - head->nb_samples); - - av_samples_copy(s->out->extended_data, head->extended_data, - s->out->nb_samples, 0, len, nb_channels, - link->format); - s->out->nb_samples += len; - - if (len == head->nb_samples) { - av_frame_free(&head); - queue_pop(s); - } else { - buffer_offset(link, head, len); - } - } - out = s->out; - s->out = NULL; - } - return ff_filter_frame(link, out); -} - static int request_frame(AVFilterLink *outlink) { FifoContext *s = outlink->src->priv; int ret = 0; if (!s->root.next) { - if ((ret = ff_request_frame(outlink->src->inputs[0])) < 0) { - if (ret == AVERROR_EOF && outlink->request_samples) - return return_audio_frame(outlink->src); + if ((ret = ff_request_frame(outlink->src->inputs[0])) < 0) return ret; - } if (!s->root.next) return 0; } - - if (outlink->request_samples) { - return return_audio_frame(outlink->src); - } else { - ret = ff_filter_frame(outlink, s->root.next->frame); - queue_pop(s); - } - + ret = ff_filter_frame(outlink, s->root.next->frame); + queue_pop(s); return ret; }