From patchwork Wed Aug 12 17:25:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 21607 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 731E044B8F5 for ; Wed, 12 Aug 2020 20:26:08 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 43E8F68B527; Wed, 12 Aug 2020 20:26:08 +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 A95DB68B307 for ; Wed, 12 Aug 2020 20:26:01 +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 07CHQ0QR007278 for ; Wed, 12 Aug 2020 19:26:01 +0200 Received: by phare.normalesup.org (Postfix, from userid 1001) id A3120E8C4D; Wed, 12 Aug 2020 19:26:00 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Aug 2020 19:25:55 +0200 Message-Id: <20200812172558.262021-1-george@nsup.org> X-Mailer: git-send-email 2.28.0 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:01 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 1/4] lavfi/vf_overlay_qsv: remove needs_fifo. 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" It is not relevant when using activate and framesync. Signed-off-by: Nicolas George --- libavfilter/vf_overlay_qsv.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavfilter/vf_overlay_qsv.c b/libavfilter/vf_overlay_qsv.c index 2a4dc5cb58..11f5fc2242 100644 --- a/libavfilter/vf_overlay_qsv.c +++ b/libavfilter/vf_overlay_qsv.c @@ -398,13 +398,11 @@ static const AVFilterPad overlay_qsv_inputs[] = { .name = "main", .type = AVMEDIA_TYPE_VIDEO, .config_props = config_main_input, - .needs_fifo = 1, }, { .name = "overlay", .type = AVMEDIA_TYPE_VIDEO, .config_props = config_overlay_input, - .needs_fifo = 1, }, { NULL } }; From patchwork Wed Aug 12 17:25:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 21608 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 9CE6E44B8F5 for ; Wed, 12 Aug 2020 20:26:09 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 80E4668B3D0; Wed, 12 Aug 2020 20:26:09 +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 5E50168B3D0 for ; Wed, 12 Aug 2020 20:26:02 +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 07CHQ1K6007282 for ; Wed, 12 Aug 2020 19:26:01 +0200 Received: by phare.normalesup.org (Postfix, from userid 1001) id 82CFBE8C4D; Wed, 12 Aug 2020 19:26:01 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Aug 2020 19:25:56 +0200 Message-Id: <20200812172558.262021-2-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:01 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 2/4] lavfi/vaf_spectrumsynth: 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" Preserve the original workings, that does not use frames timestamps and therefore is very fragile. Allow to remove needs_fifo. Signed-off-by: Nicolas George --- libavfilter/vaf_spectrumsynth.c | 69 ++++++++++++++++----------------- 1 file changed, 34 insertions(+), 35 deletions(-) Tested with the example in the doc. diff --git a/libavfilter/vaf_spectrumsynth.c b/libavfilter/vaf_spectrumsynth.c index fed2cbba03..6a0c45450d 100644 --- a/libavfilter/vaf_spectrumsynth.c +++ b/libavfilter/vaf_spectrumsynth.c @@ -34,6 +34,7 @@ #include "formats.h" #include "audio.h" #include "video.h" +#include "filters.h" #include "internal.h" #include "window_func.h" @@ -222,25 +223,6 @@ static int config_output(AVFilterLink *outlink) return 0; } -static int request_frame(AVFilterLink *outlink) -{ - AVFilterContext *ctx = outlink->src; - SpectrumSynthContext *s = ctx->priv; - int ret; - - if (!s->magnitude) { - ret = ff_request_frame(ctx->inputs[0]); - if (ret < 0) - return ret; - } - if (!s->phase) { - ret = ff_request_frame(ctx->inputs[1]); - if (ret < 0) - return ret; - } - return 0; -} - static void read16_fft_bin(SpectrumSynthContext *s, int x, int y, int f, int ch) { @@ -470,22 +452,43 @@ static int try_push_frames(AVFilterContext *ctx) return ret; } -static int filter_frame_magnitude(AVFilterLink *inlink, AVFrame *magnitude) +static int activate(AVFilterContext *ctx) { - AVFilterContext *ctx = inlink->dst; SpectrumSynthContext *s = ctx->priv; + AVFrame **staging[2] = { &s->magnitude, &s->phase }; + int64_t pts; + int i, ret; - s->magnitude = magnitude; - return try_push_frames(ctx); -} + FF_FILTER_FORWARD_STATUS_BACK_ALL(ctx->outputs[0], ctx); -static int filter_frame_phase(AVFilterLink *inlink, AVFrame *phase) -{ - AVFilterContext *ctx = inlink->dst; - SpectrumSynthContext *s = ctx->priv; + for (i = 0; i < 2; i++) { + if (*staging[i]) + continue; + ret = ff_inlink_consume_frame(ctx->inputs[i], staging[i]); + if (ret < 0) + return ret; + if (ret) { + ff_filter_set_ready(ctx, 10); + return try_push_frames(ctx); + } + } + + for (i = 0; i < 2; i++) { + if (ff_inlink_acknowledge_status(ctx->inputs[i], &ret, &pts)) { + ff_outlink_set_status(ctx->outputs[0], ret, pts); + ff_inlink_set_status(ctx->inputs[1 - i], ret); + return 0; + } + } + + if (ff_outlink_frame_wanted(ctx->outputs[0])) { + for (i = 0; i < 2; i++) { + if (!*staging[i]) + ff_inlink_request_frame(ctx->inputs[i]); + } + } - s->phase = phase; - return try_push_frames(ctx); + return FFERROR_NOT_READY; } static av_cold void uninit(AVFilterContext *ctx) @@ -509,14 +512,10 @@ static const AVFilterPad spectrumsynth_inputs[] = { { .name = "magnitude", .type = AVMEDIA_TYPE_VIDEO, - .filter_frame = filter_frame_magnitude, - .needs_fifo = 1, }, { .name = "phase", .type = AVMEDIA_TYPE_VIDEO, - .filter_frame = filter_frame_phase, - .needs_fifo = 1, }, { NULL } }; @@ -526,7 +525,6 @@ static const AVFilterPad spectrumsynth_outputs[] = { .name = "default", .type = AVMEDIA_TYPE_AUDIO, .config_props = config_output, - .request_frame = request_frame, }, { NULL } }; @@ -536,6 +534,7 @@ AVFilter ff_vaf_spectrumsynth = { .description = NULL_IF_CONFIG_SMALL("Convert input spectrum videos to audio output."), .uninit = uninit, .query_formats = query_formats, + .activate = activate, .priv_size = sizeof(SpectrumSynthContext), .inputs = spectrumsynth_inputs, .outputs = spectrumsynth_outputs, From patchwork Wed Aug 12 17:25:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 21609 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 AC0ED44B8F5 for ; Wed, 12 Aug 2020 20:26:10 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9659768B571; Wed, 12 Aug 2020 20:26:10 +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 5C37368B4BD for ; Wed, 12 Aug 2020 20:26:03 +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 07CHQ2G2007287 for ; Wed, 12 Aug 2020 19:26:02 +0200 Received: by phare.normalesup.org (Postfix, from userid 1001) id 77565E8C4D; Wed, 12 Aug 2020 19:26:02 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Wed, 12 Aug 2020 19:25:57 +0200 Message-Id: <20200812172558.262021-3-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:02 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH 3/4] lavfi: remove needs_fifo. 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" Signed-off-by: Nicolas George --- libavfilter/avfilter.h | 3 +-- libavfilter/avfiltergraph.c | 40 ------------------------------------- libavfilter/internal.h | 8 -------- 3 files changed, 1 insertion(+), 50 deletions(-) diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 49b4f7a939..fcab450f47 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -493,8 +493,7 @@ struct AVFilterLink { /** * 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. AVFilterPad.needs_fifo must also be set on the corresponding input - * pad. + * it. * Last buffer before EOF will be padded with silence. */ int request_samples; diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 2fe4f0b0f9..c62750d654 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -1228,52 +1228,12 @@ static int graph_config_pointers(AVFilterGraph *graph, return 0; } -static int graph_insert_fifos(AVFilterGraph *graph, AVClass *log_ctx) -{ - AVFilterContext *f; - int i, j, ret; - int fifo_count = 0; - - for (i = 0; i < graph->nb_filters; i++) { - f = graph->filters[i]; - - for (j = 0; j < f->nb_inputs; j++) { - AVFilterLink *link = f->inputs[j]; - AVFilterContext *fifo_ctx; - const AVFilter *fifo; - char name[32]; - - if (!link->dstpad->needs_fifo) - continue; - - fifo = f->inputs[j]->type == AVMEDIA_TYPE_VIDEO ? - avfilter_get_by_name("fifo") : - avfilter_get_by_name("afifo"); - - snprintf(name, sizeof(name), "auto_fifo_%d", fifo_count++); - - ret = avfilter_graph_create_filter(&fifo_ctx, fifo, name, NULL, - NULL, graph); - if (ret < 0) - return ret; - - ret = avfilter_insert_filter(link, fifo_ctx, 0, 0); - if (ret < 0) - return ret; - } - } - - return 0; -} - int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx) { int ret; if ((ret = graph_check_validity(graphctx, log_ctx))) return ret; - if ((ret = graph_insert_fifos(graphctx, log_ctx)) < 0) - return ret; if ((ret = graph_config_formats(graphctx, log_ctx))) return ret; if ((ret = graph_config_links(graphctx, log_ctx))) diff --git a/libavfilter/internal.h b/libavfilter/internal.h index 6cb601f36f..cc208f8e3a 100644 --- a/libavfilter/internal.h +++ b/libavfilter/internal.h @@ -117,14 +117,6 @@ struct AVFilterPad { */ int (*config_props)(AVFilterLink *link); - /** - * The filter expects a fifo to be inserted on its input link, - * typically because it has a delay. - * - * input pads only. - */ - int needs_fifo; - /** * The filter expects writable frames from its input link, * duplicating data buffers if needed. 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; }