From patchwork Tue Oct 25 09:13:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 38985 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4a86:b0:9d:28a3:170e with SMTP id fn6csp2685191pzb; Tue, 25 Oct 2022 02:15:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7bJzgL5HcEgZKpNfHijJe2VhK+sfubo9NNMgyNlUZ5bjEA/GWRL0W269BfWZZIX0g7/yMO X-Received: by 2002:a17:907:9688:b0:7a5:74eb:d12b with SMTP id hd8-20020a170907968800b007a574ebd12bmr10054257ejc.60.1666689325413; Tue, 25 Oct 2022 02:15:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666689325; cv=none; d=google.com; s=arc-20160816; b=ecJtL1rs6A3RWt/oTo46j6M4t1gHw4N9GrMmEqp2h0wFdxXRL3Oc4y1lxZXiOLHHDh EkeQiLYAtjeHbmDdn0rAHbWqs49zqd9OSM6mgv7Hp8BKgl+gfVD8DhRDZlaZYzChz6wo bBb5dJuSxZDUWb3PRTMKc7Qc2xgWF873CThv6bBPCDn4E1JE4HMJ8cRgB1y1nCGT1WPy 8ivl/vLX+DmqQd9aAQwELecOgjsmxExmiqQ55PEnc1Sb7WSFdpVNB5WQZ7pMsx30YI7a S57Sc5ArRg8j6rbkiuRR8lcs/QaVmo9KTyBioIdgeRgYnWF1RmBsOBLZ8mwMi6ADjfGq lGMQ== 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=7jXbtK8pNlI4iUuNJ4K9ovkspvfEF3MSbxh4YG/3Byo=; b=xplfKXZyMrH+XqPTsNJ+Q3tkN7xWWlZ6c6V8Pv0yo+CcUf8kT2sRZMvnEC4JlS5Tfm oSE18O0QqxbNMeJWUBzVoqAVSJpE1i12XEUDqAxWZNCADmAfALoC/wsD8/tvEx2CG7kc tVyrQES4Mk8XQxyqocnuATQk93MWZQGKPaOEplFFJM4nQYVrTdyNvWMMIMivrCvgZQwY Wwgb78JqsvYyr+ycrHuI6/0KMUGSNDaKpXCZ854BhPPNJ6haNDnQRCaMY3bdWG9UhfOk 8YyOlxkDi9A/aHmdc7Yl1oF4Fy+VL+jYaXiIniAuQWWRj9Jj3r33ZMInJL+cH4RIjKLx MWGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=cq3CVStu; 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 ji20-20020a170907981400b00783698dd8b4si2437267ejc.722.2022.10.25.02.15.24; Tue, 25 Oct 2022 02:15:25 -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=cq3CVStu; 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 0E36B68BA9D; Tue, 25 Oct 2022 12:14:09 +0300 (EEST) 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 36E9B68B85C for ; Tue, 25 Oct 2022 12:14:03 +0300 (EEST) Received: by mail-pg1-f174.google.com with SMTP id 128so10946308pga.1 for ; Tue, 25 Oct 2022 02:14:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date :references:in-reply-to:message-id:from:from:to:cc:subject:date :message-id:reply-to; bh=YfKPiEDxU7JWTn0qHJlasal2N9e2SU9ex1lyvaxrkuY=; b=cq3CVStunSJWfZj+4RJbJ5bkB1AQwsCBDvNQPqjuYKRw2qiTph03/2nekgoCyzTJol np/aGbFXi8W7Tte1yRY8op/pbN9Ysx7Htihtyn9VvhjCSp6Gmqz0pLVnjgXX0k8SfJBf WEScSkfj6nX+31CZPvByB9/FhFn8q4AKt06UHrJMFhKX6j6QiYdl906FagzCJLLQURCc qOEWfxvCP1q2vMmEVuCoKQBxHkJqV9eN2jAoRto759nLxMdUiFYHwUt92PGeSsGVrxAP 88glKcR8oduc7IFhBuIYCIG6mc8FeRgXRrcp2cOUxx3UvFqbTzKJMvhhc2O1x69e+cg4 eIXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date :references:in-reply-to:message-id:from:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=YfKPiEDxU7JWTn0qHJlasal2N9e2SU9ex1lyvaxrkuY=; b=FDkU2BGeJXFF/f9zHsC0rq5Kv0rbXpBHuKSRwqcZ0zuxXAqjmKSuUEp4XHHvQeEfoP Y9TaQYgUr+bc/Cy1tAxhgBjVi2POePz/lBfRAPNz0JndRDSFmEe6fz4a831h4z/GWA15 tvK5OxMYQbLpmu2CMiCV5zyiNFpkXmbFaqJgmGxdzwHSwhPC6g6vID6K5K3mbE/DoGTV lk7mmfgWvfYZ7QPkR2Z2BDokfRprH4GlOiK2osH915JTh/rGiCO4j4I9RxrQRXZ/MWh+ w0QX/FmX1MSoQ6CZQO2zgfxk40naprg/PcDxUPsxZHKmmL+mB3xQcu3TVci50K3X/pYP JMwg== X-Gm-Message-State: ACrzQf2rqzuBaIonRThzhk8hbXRFwAxsXy9W+vAnpV+UXn06EwcmOaWu RmWs1cxll04iYGlixbF6pssHUGD4qvQ= X-Received: by 2002:a63:2b41:0:b0:46e:9364:eb07 with SMTP id r62-20020a632b41000000b0046e9364eb07mr23822317pgr.46.1666689242328; Tue, 25 Oct 2022 02:14:02 -0700 (PDT) Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50]) by smtp.gmail.com with ESMTPSA id a13-20020a17090ae20d00b0020a821e97fbsm1054038pjz.13.2022.10.25.02.14.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Oct 2022 02:14:01 -0700 (PDT) From: softworkz X-Google-Original-From: softworkz Message-Id: <0b31d698845594ba7e660f5e5cd288fff62ca03b.1666689226.git.ffmpegagent@gmail.com> In-Reply-To: References: Date: Tue, 25 Oct 2022 09:13:32 +0000 Fcc: Sent MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v9 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: softworkz Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: DnIkqbz5dWKx 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 b40a2fc7cd..6cd83ae34a 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -461,7 +461,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; @@ -470,8 +470,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)); @@ -1171,6 +1171,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) { @@ -1180,7 +1188,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; } @@ -1217,7 +1225,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;