From patchwork Sun Jun 26 16:35:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 36463 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:8b27:b0:88:1bbf:7fd2 with SMTP id l39csp1540050pzh; Sun, 26 Jun 2022 09:37:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1scZgCbzJjnDgyzXI7jgxXtODo/Yhc+6zDHwV1ZdBs/jPOvc6/xDieYxMThBDPoonOB/WDt X-Received: by 2002:a17:906:848b:b0:718:c04a:5131 with SMTP id m11-20020a170906848b00b00718c04a5131mr8882923ejx.70.1656261422313; Sun, 26 Jun 2022 09:37:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656261422; cv=none; d=google.com; s=arc-20160816; b=M7O5rlGMcuM12fUBhtlEaFrMZQyaAlxtH4MqccB1TEIZdhCVS5Q9VMV1n1hfL/3vXj jwfQwgpVkZMsRQr9UPcIUkEE8q9Qh4MTVS08X4DbcQEKrHLAi5ZNUb+VpMHEmEaCGhZL APG8U+9urK828WmMFxo6AQmvKGdGevahR6dRn8XWys477r0+HAAn3ky7xhcFIT4iG0BU WGEaqHeb6UvlQyQEIZQdcXiERX55bV/3otCJfnslhO5aAHASe7NUcT+Hx/us9a0gHqyF S1tCvhC5n7rlWPm6iC6E/qaE5L85cBoQ4LZe+HqvFckpbApdYyo4cvTal4u6pXLuoqdb DNjg== 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:references :in-reply-to:message-id:from:dkim-signature:delivered-to; bh=4g61yKRBfTasaoOxMZCYhItZRj7VzC7+x39f2rAXY2s=; b=RW04+yxDXE5qEHx2C2qlhPA+LXD3KFYbOpt2INhXSCKk2RQc8A+UM7u89CBCbuN2jS eydrIO5fYDQwjVsMFE989KcmURFDv3lDKPv75dmMR6sVVqg+LXh87+5VaeDqM8OWZesy nBtO/MpHo7YME7NStRxyCblKUA3gWz2c4hL7leGOFRHEoP8yZfQ8AnhjN/2lHiE4FEKK bh/9THSmnbzpYVr8SYaDdtqvHCqR+JpzTPuQksuJo44z50jPxg5kcSX9MUWABKLoUMUH XjHaHJ3RKjEs8a6UN/joO4FUc2Acp6/2XsdKKaV8wHZYex4XpXDcQYXTU4hdyo6zOYnn GsYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=VlnMynnL; 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 bp16-20020a170907919000b006ff278107bbsi8512604ejb.597.2022.06.26.09.37.00; Sun, 26 Jun 2022 09:37:02 -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.s=20210112 header.b=VlnMynnL; 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 383A568B86B; Sun, 26 Jun 2022 19:35:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f181.google.com (mail-pg1-f181.google.com [209.85.215.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E637768B808 for ; Sun, 26 Jun 2022 19:35:36 +0300 (EEST) Received: by mail-pg1-f181.google.com with SMTP id e63so6955349pgc.5 for ; Sun, 26 Jun 2022 09:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:message-id:in-reply-to:references:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=MNcLRSLBqO7OXbNGwb+5j+sSx1ajfXoLKzl6ro5TTMI=; b=VlnMynnL1UIUfd/I3J3xG6PdBiPbRZmhVDf/VFiW7DLFQf2/FXTBq8hPTeEuPlhnI5 N43Ey7DMVZ/+QZMf9Gif+yohwuaWn2BiUoqIwM4gUFY2yEdjN16ikvHaD6g/6ZqmlRvA pSYWcIfWAbKs4ZGng2aS3Bok1hGh4cSwgIdYCD+7OsPKEDf+wIly9tsuBZhTwTy5yUEz HcJBB3iduC7WF5Eo60pMRIMN7XTrUDhzs+ac7M5s7FDIg6L2Bu98j71KhKyRZ0+UM+ne md3+HmY61M9peBgWpuz4P2Tf7y8bzGhfe5KYW6jemrolD+9P4ETo65XKdZu+Gfea+rwU +xrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:message-id:in-reply-to:references:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=MNcLRSLBqO7OXbNGwb+5j+sSx1ajfXoLKzl6ro5TTMI=; b=4+3+Fj2RTBXk5gl4aCFKQBu2T7XEZchP3qnMjxktJCs5Pq2OUq/cH0oMxrGAdwDaUW 7BCDF+0lVIz/rSM0V1jQAeSbXs2uzrzcVjFpSI0iHR4nTRC7DZKcNkdY5yPLQm4z3itP rZtwe3tpPKaZNsyK4HRFfcrEUkOGgWqUJ5kHgQDnGDtV+Lgtj/vKgFnRE2p39pRFgZwF IFm+iWW0kxpUkX9LDVvaU7I/BTfy0J+NmKd98mNhgvkiUC2nDEbfuAeUJQUSrEgg+skD H5tGTHsEf5w0EabNyXtPKlLS+8+gRYTHj9qr91Ejn75Hj5mYd0TyEAUhBmSJL06jpH+F K5AQ== X-Gm-Message-State: AJIora80Vn4hDaPhFdbT8C3T7GSICyjXO7pMhRnPN8WDnPyz3b81tidP QjfwH5eVGnmMw/7RsyU5/fn817zCF5M/uQ== X-Received: by 2002:a63:1b26:0:b0:3fd:8db8:9602 with SMTP id b38-20020a631b26000000b003fd8db89602mr8712956pgb.239.1656261335037; Sun, 26 Jun 2022 09:35:35 -0700 (PDT) Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50]) by smtp.gmail.com with ESMTPSA id n17-20020a170903405100b0016a25ba1f46sm5350531pla.256.2022.06.26.09.35.34 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Jun 2022 09:35:34 -0700 (PDT) From: softworkz X-Google-Original-From: softworkz Message-Id: In-Reply-To: References: Date: Sun, 26 Jun 2022 16:35:08 +0000 Fcc: Sent MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v6 11/25] 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: Michael Niedermayer , softworkz , Andriy Gelman , Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: r7mM0wtLxvhu 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 853e2b967f..e6217b60d6 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -451,7 +451,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; @@ -460,8 +460,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)); @@ -1161,6 +1161,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) { @@ -1170,7 +1178,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; } @@ -1207,7 +1215,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;