From patchwork Fri Feb 10 12:35:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wm4 X-Patchwork-Id: 2475 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp473936vsb; Fri, 10 Feb 2017 04:36:37 -0800 (PST) X-Received: by 10.28.132.9 with SMTP id g9mr7834338wmd.28.1486730197185; Fri, 10 Feb 2017 04:36:37 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i133si1064608wme.31.2017.02.10.04.36.36; Fri, 10 Feb 2017 04:36:37 -0800 (PST) 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=@googlemail.com; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=googlemail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0E4F8689DE0; Fri, 10 Feb 2017 14:35:58 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6CEC0689DD3 for ; Fri, 10 Feb 2017 14:35:56 +0200 (EET) Received: by mail-wm0-f68.google.com with SMTP id u63so7183986wmu.2 for ; Fri, 10 Feb 2017 04:36:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IiPcvkDG2fyrdUypn0Mc8xkDotdREvNdRpl6GK9muRc=; b=PTxN/vNyQS0oK6g80VFgCyE08oni012oEn3QRVF/hgV5Pao35JiFJBH6pEnQ676xqw rzjsLPNZX6h3XbJuGlR8ptl2mBkRMBZqBx7F/lurTKUPUHbT9xvjKLZjSwzBcGFUdDzZ DyXHiiWQQE5PDt6PxenK3UgRhtxYXFTWxsS62nHr8+x4eL17OOhTjfy9JBd6PDABxU8c oT5YL2nVWeO+qqsr2VGmt36OCzlAtTxQyZnr6XK/MbQplzgPKMZTewYPEUM+HYADgNJI EhWJrTZE63Jy+LjMev3ygCNKMxX3FxaXXZYspc6KHZYqrXp3hxDNRQA64bsXBmlXzF1q e+Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IiPcvkDG2fyrdUypn0Mc8xkDotdREvNdRpl6GK9muRc=; b=FvguMzZicv5vKFG1UGHkkf2MbeNUdeOWKeQQdRm8yVcCwUB4gDM0XXK1dNbRBn8TQ0 BfNpw5wiS1Ov7/cchz3i696rif630VK80vegEDG2Zcf/EwWnwIlmR0O51sx8xqpPT3Hj EY0mnKL7wyCnvoLsCFGsscAikfhRwBibYrIOXbg6+5nT+kp7fx3gfcx71p1Q1cm8udDj 8tLdrRVn+nO+lax9oiPLvJnarn/D1DMACuOI1Msekm94P/KRquMbgr2x7caudcKngBN0 yBSv/9CLkw3lMcjeUDP/jMxWD6lW6IUvmKDJu0NzMb7/oVAgOsEQDfChmn7lQKhFU1D7 AyrA== X-Gm-Message-State: AMke39m3BijfXxmruVB68gIoqwoLvdqGIgSWevh2a12enGStHEIv+LqB506cxaziqJqicQ== X-Received: by 10.28.153.139 with SMTP id b133mr6873990wme.93.1486730159734; Fri, 10 Feb 2017 04:35:59 -0800 (PST) Received: from localhost.localdomain (p4FF029FA.dip0.t-ipconnect.de. [79.240.41.250]) by smtp.googlemail.com with ESMTPSA id s18sm1413656wmb.18.2017.02.10.04.35.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Feb 2017 04:35:59 -0800 (PST) From: wm4 To: ffmpeg-devel@ffmpeg.org Date: Fri, 10 Feb 2017 13:35:38 +0100 Message-Id: <20170210123541.32375-7-nfxjfg@googlemail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170210123541.32375-1-nfxjfg@googlemail.com> References: <20170210123541.32375-1-nfxjfg@googlemail.com> Subject: [FFmpeg-devel] [PATCH 6/9] ffmpeg: restructure sending EOF to filters 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 Cc: wm4 , Anton Khirnov MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Anton Khirnov Be more careful when an input stream encounters EOF when its filtergraph has not been configured yet. The current code would immediately mark the corresponding output streams as finished, while there may still be buffered frames waiting for frames to appear on other filtergraph inputs. This should fix the random FATE failures for complex filtergraph tests after a3a0230a9870b9018dc7415ae5872784d524cfe5 This merges Libav commit 94ebf55. It was previously skipped. This is the last filter init related Libav commit that was skipped, so this also removes the commits from doc/libav-merge.txt. Signed-off-by: wm4 --- doc/libav-merge.txt | 1 - ffmpeg.c | 43 ++++++++++++++++++++++++++++++++----------- ffmpeg.h | 2 ++ ffmpeg_filter.c | 9 +++++++++ 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/doc/libav-merge.txt b/doc/libav-merge.txt index 23b48d1e2b..39d846f8fc 100644 --- a/doc/libav-merge.txt +++ b/doc/libav-merge.txt @@ -95,7 +95,6 @@ Stuff that didn't reach the codebase: - 0cef06df0 checkasm: add HEVC MC tests - e7078e842 hevcdsp: add x86 SIMD for MC - QSV scaling filter (62c58c5) -- ffmpeg.c filter init decoupling (3e265ca,a3a0230,d2e56cf,94ebf55) Collateral damage that needs work locally: ------------------------------------------ diff --git a/ffmpeg.c b/ffmpeg.c index f816808489..97d0946b6b 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2148,6 +2148,34 @@ static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame) return 0; } +static int ifilter_send_eof(InputFilter *ifilter) +{ + int i, j, ret; + + ifilter->eof = 1; + + if (ifilter->filter) { + ret = av_buffersrc_add_frame(ifilter->filter, NULL); + if (ret < 0) + return ret; + } else { + // the filtergraph was never configured + FilterGraph *fg = ifilter->graph; + for (i = 0; i < fg->nb_inputs; i++) + if (!fg->inputs[i]->eof) + break; + if (i == fg->nb_inputs) { + // All the input streams have finished without the filtergraph + // ever being configured. + // Mark the output streams as finished. + for (j = 0; j < fg->nb_outputs; j++) + finish_output_stream(fg->outputs[j]->ost); + } + } + + return 0; +} + // This does not quite work like avcodec_decode_audio4/avcodec_decode_video2. // There is the following difference: if you got a frame, you must call // it again with pkt=NULL. pkt==NULL is treated differently from pkt.size==0 @@ -2449,18 +2477,11 @@ out: static int send_filter_eof(InputStream *ist) { - int i, j, ret; + int i, ret; for (i = 0; i < ist->nb_filters; i++) { - if (ist->filters[i]->filter) { - ret = av_buffersrc_add_frame(ist->filters[i]->filter, NULL); - if (ret < 0) - return ret; - } else { - // the filtergraph was never configured - FilterGraph *fg = ist->filters[i]->graph; - for (j = 0; j < fg->nb_outputs; j++) - finish_output_stream(fg->outputs[j]->ost); - } + ret = ifilter_send_eof(ist->filters[i]); + if (ret < 0) + return ret; } return 0; } diff --git a/ffmpeg.h b/ffmpeg.h index 11ad15b04e..7a807e1ab9 100644 --- a/ffmpeg.h +++ b/ffmpeg.h @@ -248,6 +248,8 @@ typedef struct InputFilter { uint64_t channel_layout; AVBufferRef *hw_frames_ctx; + + int eof; } InputFilter; typedef struct OutputFilter { diff --git a/ffmpeg_filter.c b/ffmpeg_filter.c index 4d9a4e2eb8..816c906c7e 100644 --- a/ffmpeg_filter.c +++ b/ffmpeg_filter.c @@ -1128,6 +1128,15 @@ int configure_filtergraph(FilterGraph *fg) } } + /* send the EOFs for the finished inputs */ + for (i = 0; i < fg->nb_inputs; i++) { + if (fg->inputs[i]->eof) { + ret = av_buffersrc_add_frame(fg->inputs[i]->filter, NULL); + if (ret < 0) + return ret; + } + } + return 0; }