From patchwork Sat May 28 13:25:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 35963 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6914:b0:82:6b11:2509 with SMTP id q20csp1366211pzj; Sat, 28 May 2022 06:26:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxT/KK59InAD+6Zy9ZUhYE337VsC6z0dApbxPhp4NYJWoKO/EBqyEn4e+ToFfjN/9drq6g1 X-Received: by 2002:a05:6402:1150:b0:42a:9dbf:8860 with SMTP id g16-20020a056402115000b0042a9dbf8860mr49558769edw.350.1653744418490; Sat, 28 May 2022 06:26:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653744418; cv=none; d=google.com; s=arc-20160816; b=WstZYLhyd080WII0mTBGuZrv08sq4uPXehriClwIvjE9aJ1uavOY4IKMKIfezFqd+U 9eAj3rNKvq4LyVUh/K0z/EkHSHMj19ZMAFm5nQugxboi8JseZXQErI4fPoWz4e0ftCCC 0yZNpbHEpDe1UEuc00szaKxW9FxG33Hvoduygza733OjWvy0TLAgA8VCRKOK/p3H+u/m 6mi76uVJpLI4ZYnBUVE1FJUVEguTXMkC7J0HWsEQyxrsaCRC2IAt13OcO7rSU8YQK7GY nHdQQj5Fed68S0ZbE06oA2yyFc2aqYlUv051HyxGhqOa/k9A5yiCrc8UfVJiHefTib87 5apg== 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=UtqzexoT4Ezmtfi57f7x4tIuzPiZzyGh8hkddPuZOVE=; b=Jsv1mAFsWEILKUtLwx5oFVINtFA5fV09B0ZWlGLUFzJ9eDnpWZELmSaEwAZwOiGpAB /UCvm89/EX0cHCFuG1OpJSem2Cz6vsLva7Ib1l6xO9O1fkwvTkm+ezlheRo1/xfzQxSw S2fR4vmuC9eI4l84qN8EQqmy/M3WbR2sMDgQZP89RdaZO0uOvunUnvO04sHzeXMkkPTb JcpUnR5Y9rx7DB2xDUle0e5m8efHi55p4HBkxnHaGqwJci7jW3w6YM0x5SRah62wYtKF 2N9LlQG/NjAg7NwDCF9WBul1Bvd9uzSqb+iWMYUDvxiyRe15Hh6RjyT0NuDVQFl0YAjB QmqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=G6TJNm47; 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 qk32-20020a1709077fa000b006fe58b19736si6883559ejc.510.2022.05.28.06.26.58; Sat, 28 May 2022 06:26:58 -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=G6TJNm47; 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 54D5568B5D4; Sat, 28 May 2022 16:25:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C8FC668B56B for ; Sat, 28 May 2022 16:25:38 +0300 (EEST) Received: by mail-pl1-f176.google.com with SMTP id n8so6473020plh.1 for ; Sat, 28 May 2022 06:25:38 -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=HvaSrUNkdYU7ZKtqQZac5tap7Ome60MMPRJc94yc6OY=; b=G6TJNm47Pco2JGKBYdmE+WMZw1jzmW+tzko4xPB8TXZfA9QGYwR+atu3cZny6K3Slq zLHRRhtqSWobwvNtvTIUMBYotkJOrZKy8JFxWhpXsyyjdHKxfOENUbwLduL1gssVdVdx wp8cmmI5d2ksISl2D0S/K29FzQ+HPxoF+1QHt51esvpB54/HN4BGmCji0rm0nH7NPF4/ PywwC1Y4Hv8grjXDnnecamdi8+PLgcUGhg+gQEIueKQJ8MK62cHRfK6gaVK8EpHbM1JD z/vBYJmKnOJVoZWz3UaV2W14OW/RGcpUDYuMShSZvyahVCQ0OjNbL/ID7REBSNNE2XZb CagA== 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=HvaSrUNkdYU7ZKtqQZac5tap7Ome60MMPRJc94yc6OY=; b=jqXcdKTYxUw6TAJe7A/0TGOi9zbPH7rffjKdtv3hxBk+s0lxMJ8vl3mauXZdA6ue4w TxmqGio6ejKkdvD7LrnrMhRtzz5sdn+rUS91t4uJaCDBrNmEap8Xd6M1DeY37X6wRsmI +RBKHN29a2MvUL2LEGY/wo4iUDUeAhFR/YeifabjxwfW8oar1n96H04ga4BlAvGB2XRG vc3r+Uvqs+LhKicA14iKtVOE12dhfCgdb0sYS7ttAiI4kDed5G4tjaJWOVXngBOT+4s9 sc/Od6sPdnaoNi+JIeORS0U8s5qkJzWiBvPAE3fjw+lZEH2KNgfq8A8E2j7C3K1pnZhL 81vA== X-Gm-Message-State: AOAM533jAJHJ71hKp1nEv/ofQ6NAJDQ8kiBglKsz5UHTLeO8fbmE/EAM wVAk6h80ohFIEGh/px0O4HZxcR1yLOzGvA== X-Received: by 2002:a17:90b:1a88:b0:1dc:e4a1:a81e with SMTP id ng8-20020a17090b1a8800b001dce4a1a81emr13504549pjb.96.1653744337313; Sat, 28 May 2022 06:25:37 -0700 (PDT) Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50]) by smtp.gmail.com with ESMTPSA id n15-20020a170902968f00b001617ffc6d25sm3993106plp.19.2022.05.28.06.25.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 May 2022 06:25:36 -0700 (PDT) From: softworkz X-Google-Original-From: softworkz Message-Id: In-Reply-To: References: Date: Sat, 28 May 2022 13:25:11 +0000 Fcc: Sent MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v4 11/23] 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: f0dsTSk1BBiO 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 30745f41cb..6cbfc54a85 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -443,7 +443,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; @@ -452,8 +452,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)); @@ -1153,6 +1153,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) { @@ -1162,7 +1170,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; } @@ -1199,7 +1207,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;