From patchwork Thu Jan 20 03:25:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 33704 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp5432218iog; Wed, 19 Jan 2022 19:26:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwxLRLMGsJv0I1p5nSE6H7LXria2a3V9oOzw0nZaydDN+8iUIJd8nu4swfNTYhiOSe5Zn7u X-Received: by 2002:a17:906:b6d1:: with SMTP id ec17mr27304252ejb.21.1642649208321; Wed, 19 Jan 2022 19:26:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642649208; cv=none; d=google.com; s=arc-20160816; b=P9VF//yJzVskkwgX4mraBg4OOqX2YGBOZM1M1Gwwl4BDr7fnZ2+5I+iLGdlDdtQobf 6oqCsARr3zfUrCvDocqoDyfvjQvaP5bOCYHDQlZhjJ5khBrrokggw9LiWmpiZ3FdCpLn UNgVhV8nr9eDN6BoiJAGxMGJGdXtKsbsqYiVcTUj8sWf1RMV0/9nD32BmZ8PoRKHpOVL 3CuD+Bzee6f3cTUHsqJaPZhWdFfRXWwLaJNgIuU7Qx01/CwqWIKZXmG5nq+2Pp1P2so3 5A5LT4NIjr/JdHfoXfdA+8E8w8C/q4b4PPRe0ACkBqmFe6EmYXxs4/Rkc5lf+JIahg4N CMyA== 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=XEb/HW0mm7zbsuiKGRJcy276324L8Iuykvi3GEFrlVADZwpA+fwxTADBYH8uwMKCAs CMZcrZCQNlbirEUWnSr7i+79CyGyDhnblaw1y9HkwDFvK+keU+4uzE/YT/as1L1qmgxq BrC6Ipi+PdBsEKVOUFwQwL7rwjE1l/UrypWtxSpKWupJGUEiY4boj4+HrbbOCd56Aw7Z FXGD8aV4ZUcQ5ihwV/Jwr/qza7g5GjV8iAe3aDl3sERCT/8oLzlI1nvrl2AQk/zc8LqE urmH/QZIBTSAEePtvIcGRJwhOsAfKw4K8gvaHOBL+TqyFueOGPgm/nEvrvvVLd1R82e+ hvKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=njXKQ8DC; 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 n21si1053887eda.533.2022.01.19.19.26.47; Wed, 19 Jan 2022 19:26:48 -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=njXKQ8DC; 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 994D668B2B9; Thu, 20 Jan 2022 05:25:53 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B1F3F68B26C for ; Thu, 20 Jan 2022 05:25:47 +0200 (EET) Received: by mail-pj1-f53.google.com with SMTP id s61-20020a17090a69c300b001b4d0427ea2so8362847pjj.4 for ; Wed, 19 Jan 2022 19:25:47 -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=njXKQ8DCobkmPReqzvLJJXdnKiwzLepIm0c/GzCm5MwBhb4wpdqGdfgz9+Ktttrqbm OMtrxJoKh5FAx+lUYF15xNSABFZ27bK30pIG+aryt+Ahdz0oORG6wFPhxo3g3IegGjPe Cks3aiApAZ96Cpad9m4M5R1PAdBw9/b+W04/A42yp3wPKJ6CVp3Qvr7/YBYCKe4aA5b3 hLbILqhUSliIXaMXr5mxSsHds/alqm3EfJrtTRk8M/WMyNGbJDOx3Va6z5GJ5VFqq9SL HZKCKGXlXnoWO3bsU+N/D16yVUzuq7rSPM4gWhagIhizX06JXu3TBspVlexjpICyL/lw nxXA== 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=B7XPDjn++FSjLGUz8owsQCDCed8OsCNAVg/D4mxQjDJaRVvv1vuyM3WkkQ/c3iQpVG Ag7OxlbC2yt4k3YAb06aTKN+288dAvosRtNZKdvfFs7SjYQ5AnNsxkkzRU/OR1xb6FrS 3/rd+ETlg6HZP32HPI0Ct+BNq/BueRPOTDZuPCGy2MvPpRyebwoPvvx5l+O4pjFqxJBX tw/m8OZdUp+veQymhinvbLPDV7KPFyft2u7Cj1i5Wh3GSeD3smLTr9bTJ860V+rD3k28 30fyeUtYpfV5yt8LGMltDtGGtKoOiEgZ62jxQPKKvYcK88zvB0M1h1l4SjrCO6HysDGF nt9g== X-Gm-Message-State: AOAM5327FtnquOmQAVpKkuUTGJE4Ph4MsXuTKKxpRhfbG1C4sRe/JPgO +QjpWMhsjcFkKl6eK9i+VmIYSPgC8qM= X-Received: by 2002:a17:90b:1a91:: with SMTP id ng17mr8229330pjb.55.1642649145952; Wed, 19 Jan 2022 19:25:45 -0800 (PST) Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50]) by smtp.gmail.com with ESMTPSA id p12sm6851350pjj.55.2022.01.19.19.25.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jan 2022 19:25:45 -0800 (PST) Message-Id: In-Reply-To: References: From: ffmpegagent Date: Thu, 20 Jan 2022 03:25:18 +0000 Fcc: Sent MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v3 10/26] 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 , Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 4Z4V4OehNCh5 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;