From patchwork Fri Jan 14 01:13:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 33570 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp985628iog; Thu, 13 Jan 2022 17:15:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJzvfaQ5lkW3/RImrQzDObAM3j79/OBIH8jBM6n49Ulj47glU+safN6mmC6icZzbH8j0DGFQ X-Received: by 2002:a17:907:1c1f:: with SMTP id nc31mr5709866ejc.624.1642122912735; Thu, 13 Jan 2022 17:15:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642122912; cv=none; d=google.com; s=arc-20160816; b=CEFV/nFY7unFaw+ALby7DGzajEZo7UQ5Q18mBsgtHNNBSOqjvB9fOqfev2gPWNK47M cWvXbaxoThPl2LoxJltDC2b+k7r4iLMOLja0SMOem1EdpCRBn83E/jM5zadApcpHGmxS E397C2wYlmqpOYa6G6Q7IFgB1Amh+s6u5Q/+q/sX19R2xBXrgQF5kjagu09E/xV3n4nY o90YUnJfbrFVM0In7qoV3nWU4Aey+erw8I54R6iaHwovFgO6mUnmbGvLAqiKpkZ9zAXv VBUdAIHUOinJqd3OT2MFZaxAtBR2GTvbcoJmUQ688iUUqaS+Z/X4dOhNY2YgUmVKsQcE I3Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:to:mime-version:fcc:date:from:references :in-reply-to:message-id:dkim-signature:delivered-to; bh=DMORk3iCvLf5j+sjlnx5ZV2v9mtRZ96F5CuJJ7deRQU=; b=aHcroDNsPxo7tojVRafMaK3p3A3MfaYHPYqKe2M9SXGH7oyjz9dsHfnpeTI3op+Aob dHlrjSwtWaWWsbp8DnPgNndliFJq0PIgWi3eJsZx98KzbSan4qc0ui50j4SB9JwS6gnq FtLQ2qYQHDxIV3/zvtFUTfZT2n66aNyHgfd5Ra4DVP9oNcQ/AJBhTNsXGgQjpUy+0mIa R5nxsWwGtGJSMOlxtJYh58LejP2AF1SX2jtcGEO3ZuwZXPNYM4kX395YxVtdF0pR7Zip KzacPf+/WCGYVtJWEJ7XX9CZCEvn3FryRHHIMS+9Zgii/TXAPoBL6GGse3Y8nOGkciG3 bC4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=iEKsSZfS; 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=QUARANTINE 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 t21si2171139ejj.855.2022.01.13.17.15.11; Thu, 13 Jan 2022 17:15:12 -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=@gmail.com header.s=20210112 header.b=iEKsSZfS; 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=QUARANTINE 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 D269A68B5D0; Fri, 14 Jan 2022 03:13:54 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C848D68B59D for ; Fri, 14 Jan 2022 03:13:48 +0200 (EET) Received: by mail-pg1-f174.google.com with SMTP id v25so1433467pge.2 for ; Thu, 13 Jan 2022 17:13:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=QPt1g4d++6eqMGF272qoYSTMz7/wEE7bKAIBuuhcHL8=; b=iEKsSZfSrYmu4sBcD7jFUhRezS8eViAd83HYDxrkW7LneWjWTcEeudlL+VVwhIbzpf Dy4sdjAeKpGQgaUtiONHRKtvqWzeMGNI0GimHfJ6pRmnFkj9ShrLsJgpZwMroZy7kxSO 9Zt5mO12YIVKLJLck3ZGmne3t6WcPeHHKwHJV0PaOIdQmjCle8PJiwuJ5iiTLQfhmOEV mqQ5fZKNm778flr6dbs0Efue9XD0AgnhDfPjagAOjS1koG8j4aW8y+x+YNGlRJPLJI+F kVfrKHYVLiwQQ+hYxWyXH7JFPGAAXRlctafszTBZqOxCvKcaizTqupp+UwwgkPi50lBs VP2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=QPt1g4d++6eqMGF272qoYSTMz7/wEE7bKAIBuuhcHL8=; b=2l+P9MCeahegBeRRiJ7BFIQ+tR2Sa3cOyXbH8X9i8l4iGw9k8kloeok0jOdgZGp5Dq R5cUkoFmwtRZ1XxjztOpypD98cT+wg0AEnKSm5zTcOStSkBdgdrXhWDhK8pQQGRgnfcu ORy0MzuOdAm1CldEP623D9eYooOWuHYJXTm6+5gsrSy9gsF7OXJETNAjS0p5o0a8xh1v avtWxTFdH4KptmvRG90QnGv6bMgO1rb4sC/QpIjAucqAepe/yLsRpRIVIMwK6jV8zX/m y6JPgB0/OKItcJK45HgXtLLzqqPncXfETAjw6+XXKBLQmDBSTbIh1433FhmhRg/n8pK8 LmyQ== X-Gm-Message-State: AOAM530Ybx3yEaShoQjbvlPZiZOBLjvhckaXu6d+Kn3zIUu9/mxDSuKS abkr1TNhQzUgL713lvooOJuG7x0cFJ2lWw== X-Received: by 2002:aa7:8658:0:b0:4c1:3a5c:3df6 with SMTP id a24-20020aa78658000000b004c13a5c3df6mr6662353pfo.58.1642122827023; Thu, 13 Jan 2022 17:13:47 -0800 (PST) Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50]) by smtp.gmail.com with ESMTPSA id z16sm3205008pgi.89.2022.01.13.17.13.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jan 2022 17:13:46 -0800 (PST) Message-Id: <76a236404899811b17b09d8905b5cb586c6409ff.1642122814.git.ffmpegagent@gmail.com> In-Reply-To: References: From: ffmpegagent Date: Fri, 14 Jan 2022 01:13:20 +0000 Fcc: Sent MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 11/24] avfilter/avfilter: Fix hardcoded input index X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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: softworkz Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: PLsrTWLVGgpS From: softworkz This fix targets (rare) cases where multiple input pads have a .filter_frame function. ff_request_frame_to_filter needs to call ff_request_frame with the correct input pad instead of the hardcoded first one. Signed-off-by: softworkz --- libavfilter/avfilter.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 75d5e86539..aa9aa71f53 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -463,7 +463,7 @@ static int64_t guess_status_pts(AVFilterContext *ctx, int status, AVRational lin return AV_NOPTS_VALUE; } -static int ff_request_frame_to_filter(AVFilterLink *link) +static int ff_request_frame_to_filter(AVFilterLink *link, int input_index) { int ret = -1; @@ -472,8 +472,8 @@ static int ff_request_frame_to_filter(AVFilterLink *link) link->frame_blocked_in = 1; if (link->srcpad->request_frame) ret = link->srcpad->request_frame(link); - else if (link->src->inputs[0]) - ret = ff_request_frame(link->src->inputs[0]); + else if (link->src->inputs[input_index]) + ret = ff_request_frame(link->src->inputs[input_index]); if (ret < 0) { if (ret != AVERROR(EAGAIN) && ret != link->status_in) ff_avfilter_link_set_in_status(link, ret, guess_status_pts(link->src, ret, link->time_base)); @@ -1172,6 +1172,14 @@ static int forward_status_change(AVFilterContext *filter, AVFilterLink *in) { unsigned out = 0, progress = 0; int ret; + int input_index = 0; + + for (int i = 0; i < in->dst->nb_inputs; i++) { + if (&in->dst->input_pads[i] == in->dstpad) { + input_index = i; + break; + } + } av_assert0(!in->status_out); if (!filter->nb_outputs) { @@ -1181,7 +1189,7 @@ static int forward_status_change(AVFilterContext *filter, AVFilterLink *in) while (!in->status_out) { if (!filter->outputs[out]->status_in) { progress++; - ret = ff_request_frame_to_filter(filter->outputs[out]); + ret = ff_request_frame_to_filter(filter->outputs[out], input_index); if (ret < 0) return ret; } @@ -1218,7 +1226,7 @@ static int ff_filter_activate_default(AVFilterContext *filter) for (i = 0; i < filter->nb_outputs; i++) { if (filter->outputs[i]->frame_wanted_out && !filter->outputs[i]->frame_blocked_in) { - return ff_request_frame_to_filter(filter->outputs[i]); + return ff_request_frame_to_filter(filter->outputs[i], 0); } } return FFERROR_NOT_READY;