From patchwork Tue Jul 11 19:12:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul B Mahol X-Patchwork-Id: 4298 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.1.76 with SMTP id 73csp5438667vsb; Tue, 11 Jul 2017 12:12:18 -0700 (PDT) X-Received: by 10.28.65.66 with SMTP id o63mr3751004wma.71.1499800338075; Tue, 11 Jul 2017 12:12:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499800338; cv=none; d=google.com; s=arc-20160816; b=UfMnK2SBX2Qs+YofTLFpNXatg8JUCNohE1X3v6+2gP7DG2cZfGJPW00+xNJZcMezIB LNXPMO4XZVgoQKpr+L19bFtDeuaALFM22h2tzNpxkZHaX8yRbvx4NqJyFqj7+MtwcJvM jYVRaO/J0A04USaA9iWr1omGoY+SDdtEM8BfJZ1W7L/TgfpqZLXXu6tLS/V1tXSDwpaF kjOtVgAVRnP8EuZ4CR/S1fLCNkSZZTrwBgcEacwZvl9QJvJ2JFl5TR20ffE1o3VM4xot eZ3nzbJlX8mOW/x9NjQF0V/46dXW9ypgaTtORAHdMQE+DzZgq9hTw/UQceLIZvyY3bj6 HJdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:delivered-to:arc-authentication-results; bh=MpYaYPSXMeipBuV25S0sqopKuP/xppNYFRGBYsuep+4=; b=dmfQzqj779IACIsgeyek1o29l2Y9jJ9phPNOuvMxy1ZMYutbKn4UE20MbZxwxgyXzj AXTI6i0Osoy8phCUkLIzCMO1uSaPDUtWWsG3oonWA90opF3K/dj9nFPv8dXW0baX8usO f1QSdWbUCzX/JVtWiNtMeHjiTyx9YlS/3N88vYuUmTTNpMqVPuOzQOyBeBZ99PiipUVv k+4qMSxZoIgQza1UUmAu+kI9g22DATa+U5TLsoX9jn6AzlOPAe+NS8SUxK0wGmOpIk46 85tNLExzHmYELsGzO4t6fmx9i93gq3HdYAgq466F7JE5HLgIfFOm0vaBoRy7Ft9R0ZK6 3ItA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.b=b2ZTecXY; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 191si97617wmw.153.2017.07.11.12.12.17; Tue, 11 Jul 2017 12:12:18 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.b=b2ZTecXY; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C5485689721; Tue, 11 Jul 2017 22:12:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f180.google.com (mail-wr0-f180.google.com [209.85.128.180]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E786D68920C for ; Tue, 11 Jul 2017 22:12:03 +0300 (EEST) Received: by mail-wr0-f180.google.com with SMTP id k67so2039872wrc.2 for ; Tue, 11 Jul 2017 12:12:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=yjoTP7aLuR0/onqmWuP0f6c0/YcMu+pOv4SPyDgHzkY=; b=b2ZTecXYYs12wvCm1qrOrJKLvx3u9jp4wlpWgdQAQ+tjn+kVtmI9H4Z/YU5+2IGKy7 yuvJT3524bo+6meulB0OHHDbAiW+ZVHQ2cuOsarX8pCdGivBwbcQLtxjoihw7qDrw2rA qPHuw06j+yJwwCnd8OzP35tMnysNokFKr3bicYD3D0fZhFBcEp5zQ+GCRnpoD0gMgaNB RvpaswCDtdRVYLtguJ0rU25oC4IplygFXvDQjU8+MeGimJhP0mZPnoxmP+xEe0E+tX3s Jc2N/9nHBO2oMTFYx9Ty8vbwej+n1kWfn1bPaHBBt5N1L3AG/0a09GAGRcpM6WvAqqZl sdQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=yjoTP7aLuR0/onqmWuP0f6c0/YcMu+pOv4SPyDgHzkY=; b=f2S2fcY+jDZ17D+bEb2aQ1c+5ynbzjBq+Isvt92pknarSKuqhjcLWrmhF8OVTLBoST wEKgTtXHB4lFZEDiQsZvuy0kNCCaiQ2nyk42qFRZKoklA6cuWoNc5VmVXJSAoeZjl/tj DuQf0Xce+ve1p6TiMQkGagQKOYTPmWaDKcLl8sbiKjaJDX82I160SoEI9nCT+nBNOqLg B7VhqMuc1ene7I+kBUEMcma9ZYM0bDxiAaf5HI0rjO7ir/5Y481hyAonLsdHtg3NRrdM XNC40t8NMHgBlcfsKsfvYh2P388Arfz8DP1KJV9n14O3tcwdhQBMJ3Z7+pu5rVAHYegd t5AQ== X-Gm-Message-State: AIVw113q+Iu7sII5KR0/ygL0rhoOUD+/2lYjggI5Uwjrj0tm+uEaPUUp jC3R2t6miGSClNPH+3lE94tL1RD/Ng== X-Received: by 10.28.139.204 with SMTP id n195mr3802601wmd.14.1499800327783; Tue, 11 Jul 2017 12:12:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.38.5 with HTTP; Tue, 11 Jul 2017 12:12:06 -0700 (PDT) In-Reply-To: <20170711174709.GA2872818@phare.normalesup.org> References: <20170624150641.GY4727@nb4> <20170624153734.GA1628447@phare.normalesup.org> <20170711153730.GA2723657@phare.normalesup.org> <20170711174709.GA2872818@phare.normalesup.org> From: Paul B Mahol Date: Tue, 11 Jul 2017 21:12:06 +0200 Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH] lavfi/buffersrc: push the frame deeper if requested. 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" On 7/11/17, Nicolas George wrote: > Le tridi 23 messidor, an CCXXV, Paul B Mahol a ecrit : >> Nothing can get rid of that issue, except tootal lavfi rewrite. > > Why do you say that? My plan gets rid of them quite easily, since now > all links have a dynamically-sized FIFO built-in. > >> I tried this and it did not work at all. And I even contacted Nicolas >> privately and never got reply. > > I found your mail in my inbox, and I vaguely remember reading them at > the time, but no more. It was a very busy week. Sorry for missing them. > > Unfortunately, you neglected to include your code, so I cannot tell why > it did not work. You never asked for one. Here it is attached just for you. From 20d00cead1e47b2e389fde99a3c0f9c36b6587ec Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Tue, 20 Jun 2017 19:44:54 +0200 Subject: [PATCH] shit Signed-off-by: Paul B Mahol --- libavfilter/framesync.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ libavfilter/framesync.h | 4 ++++ libavfilter/vf_stack.c | 9 ++++----- 3 files changed, 55 insertions(+), 5 deletions(-) diff --git a/libavfilter/framesync.c b/libavfilter/framesync.c index eb05d66..f2a4450 100644 --- a/libavfilter/framesync.c +++ b/libavfilter/framesync.c @@ -23,6 +23,7 @@ #include "libavutil/avassert.h" #include "avfilter.h" +#include "filters.h" #include "bufferqueue.h" #include "framesync.h" #include "internal.h" @@ -224,6 +225,22 @@ void ff_framesync_next(FFFrameSync *fs) framesync_advance(fs); } +void ff_framesync_next2(FFFrameSync *fs) +{ + AVFilterContext *ctx = fs->parent; + unsigned i; + + av_assert0(!fs->frame_ready); + for (i = 0; i < fs->nb_in; i++) + if (!fs->in[i].have_next && ff_framequeue_queued_frames(&ctx->inputs[i]->fifo)) { + framesync_inject_frame(fs, i, ff_framequeue_take(&ctx->inputs[i]->fifo)); + ctx->inputs[i]->frame_wanted_out = 1; + ff_filter_set_ready(ctx->inputs[i]->src, 100); + } + fs->frame_ready = 0; + framesync_advance(fs); +} + void ff_framesync_drop(FFFrameSync *fs) { fs->frame_ready = 0; @@ -300,6 +317,27 @@ int ff_framesync_process_frame(FFFrameSync *fs, unsigned all) return count; } +int ff_framesync_process_frame2(FFFrameSync *fs, unsigned all) +{ + int ret, count = 0; + + av_assert0(fs->on_event); + while (1) { + ff_framesync_next2(fs); + if (fs->eof || !fs->frame_ready) + break; + if ((ret = fs->on_event(fs)) < 0) + return ret; + ff_framesync_drop(fs); + count++; + if (!all) + break; + } + if (!count && fs->eof) + return AVERROR_EOF; + return count; +} + int ff_framesync_filter_frame(FFFrameSync *fs, AVFilterLink *inlink, AVFrame *in) { @@ -314,6 +352,15 @@ int ff_framesync_filter_frame(FFFrameSync *fs, AVFilterLink *inlink, return 0; } +int ff_framesync_activate(FFFrameSync *fs, AVFilterContext *ctx) +{ + int ret; + + if ((ret = ff_framesync_process_frame2(fs, 1)) < 0) + return ret; + return 0; +} + int ff_framesync_request_frame(FFFrameSync *fs, AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; diff --git a/libavfilter/framesync.h b/libavfilter/framesync.h index 7ba99d5..0f381e3 100644 --- a/libavfilter/framesync.h +++ b/libavfilter/framesync.h @@ -250,6 +250,7 @@ int ff_framesync_add_frame(FFFrameSync *fs, unsigned in, AVFrame *frame); * The status of the operation can be found in fs->frame_ready and fs->eof. */ void ff_framesync_next(FFFrameSync *fs); +void ff_framesync_next2(FFFrameSync *fs); /** * Drop the current frame event. @@ -275,6 +276,7 @@ int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, * @return number of frames processed or negative error code */ int ff_framesync_process_frame(FFFrameSync *fs, unsigned all); +int ff_framesync_process_frame2(FFFrameSync *fs, unsigned all); /** @@ -286,6 +288,8 @@ int ff_framesync_process_frame(FFFrameSync *fs, unsigned all); int ff_framesync_filter_frame(FFFrameSync *fs, AVFilterLink *inlink, AVFrame *in); +int ff_framesync_activate(FFFrameSync *fs, AVFilterContext *ctx); + /** * Request a frame on the filter output. * diff --git a/libavfilter/vf_stack.c b/libavfilter/vf_stack.c index 03643b6..0e45952 100644 --- a/libavfilter/vf_stack.c +++ b/libavfilter/vf_stack.c @@ -58,10 +58,10 @@ static int query_formats(AVFilterContext *ctx) return ff_set_common_formats(ctx, pix_fmts); } -static int filter_frame(AVFilterLink *inlink, AVFrame *in) +static int activate(AVFilterContext *ctx) { - StackContext *s = inlink->dst->priv; - return ff_framesync_filter_frame(&s->fs, inlink, in); + StackContext *s = ctx->priv; + return ff_framesync_activate(&s->fs, ctx); } static av_cold int init(AVFilterContext *ctx) @@ -83,7 +83,6 @@ static av_cold int init(AVFilterContext *ctx) pad.name = av_asprintf("input%d", i); if (!pad.name) return AVERROR(ENOMEM); - pad.filter_frame = filter_frame; if ((ret = ff_insert_inpad(ctx, i, &pad)) < 0) { av_freep(&pad.name); @@ -237,7 +236,6 @@ static const AVFilterPad outputs[] = { .name = "default", .type = AVMEDIA_TYPE_VIDEO, .config_props = config_output, - .request_frame = request_frame, }, { NULL } }; @@ -274,6 +272,7 @@ AVFilter ff_vf_vstack = { .query_formats = query_formats, .outputs = outputs, .init = init, + .activate = activate, .uninit = uninit, .flags = AVFILTER_FLAG_DYNAMIC_INPUTS, }; -- 2.9.3